Skip to content

Commit

Permalink
add: convert showing all environment images including uninstalled one…
Browse files Browse the repository at this point in the history
…s by config
  • Loading branch information
lizable committed Sep 9, 2024
1 parent 612b54c commit 31f1b3b
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 4 deletions.
1 change: 1 addition & 0 deletions config.toml.sample
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,7 @@ allowNonAuthTCP = false # Expose TCP apps to be executable in web br
#allowlist = "" # Comma-separated image name. Image name should contain the repository (registry path and image name) part of the full image URL, excluding the protocol and tag
# e.g. cr.backend.ai/stable/python
# You should pick default_environment in general section too.
showAllEnvironmentImages = false # Show all environment images regardless of installation

[server]
webServerURL = "[Web server website URL. App will use the site instead of local app.]"
Expand Down
9 changes: 5 additions & 4 deletions react/src/components/ImageEnvironmentSelectFormItems.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,10 @@ const ImageEnvironmentSelectFormItems: React.FC<

const envSelectRef = useRef<RefSelectProps>(null);
const versionSelectRef = useRef<RefSelectProps>(null);

const ImageEnvironmentSelectFormItemsVariables = baiClient?._config
?.showAllEnvironmentImages
? {}
: { installed: true };
const { images } = useLazyLoadQuery<ImageEnvironmentSelectFormItemsQuery>(
graphql`
query ImageEnvironmentSelectFormItemsQuery($installed: Boolean) {
Expand All @@ -117,9 +120,7 @@ const ImageEnvironmentSelectFormItems: React.FC<
}
}
`,
{
installed: true,
},
ImageEnvironmentSelectFormItemsVariables,
{
fetchPolicy: 'store-and-network',
},
Expand Down
1 change: 1 addition & 0 deletions react/src/hooks/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -383,5 +383,6 @@ type BackendAIConfig = {
allowSignout: boolean;
allowNonAuthTCP: boolean;
enableExtendLoginSession: boolean;
showAllEnvironmentImages: boolean;
[key: string]: any;
};
13 changes: 13 additions & 0 deletions src/components/backend-ai-login.ts
Original file line number Diff line number Diff line change
Expand Up @@ -142,6 +142,7 @@ export default class BackendAILogin extends BackendAIPage {
@property({ type: Boolean }) enableModelStore = false;
@property({ type: Boolean }) enableLLMPlayground = false;
@property({ type: Boolean }) enableExtendLoginSession = false;
@property({ type: Boolean }) showAllEnvironmentImages = false;
@property({ type: String }) eduAppNamePrefix;
@property({ type: String }) pluginPages;
@property({ type: Array }) blockList = [] as string[];
Expand Down Expand Up @@ -1038,6 +1039,16 @@ export default class BackendAILogin extends BackendAIPage {
? environmentsConfig?.allowlist.split(',').map((el) => el.trim())
: [],
} as ConfigValueObject) as string[];

// Enable show all images when creating session/service
this.showAllEnvironmentImages = this._getConfigValueByExists(
environmentsConfig,
{
valueType: 'boolean',
defaultValue: false,
value: environmentsConfig?.showAllEnvironmentImages,
} as ConfigValueObject,
) as boolean;
}

/**
Expand Down Expand Up @@ -1846,6 +1857,8 @@ export default class BackendAILogin extends BackendAIPage {
this.maxFileUploadSize;
globalThis.backendaiclient._config.allow_image_list =
this.allow_image_list;
globalThis.backendaiclient._config.showAllEnvironmentImages =
this.showAllEnvironmentImages;
globalThis.backendaiclient._config.maskUserInfo = this.maskUserInfo;
globalThis.backendaiclient._config.singleSignOnVendors =
this.singleSignOnVendors;
Expand Down

0 comments on commit 31f1b3b

Please sign in to comment.