feat: Support to set defaultLanguage and availableLanguages in new frontend system
Signed-off-by: mario ma <mario.ma.node@gmail.com>
This commit is contained in:
@@ -19,12 +19,25 @@ import { AppLanguageSelector } from '../../../../packages/core-app-api/src/apis/
|
||||
import { appLanguageApiRef } from '@backstage/core-plugin-api/alpha';
|
||||
import { ApiBlueprint } from '@backstage/frontend-plugin-api';
|
||||
|
||||
export const AppLanguageApi = ApiBlueprint.make({
|
||||
export const AppLanguageApi = ApiBlueprint.makeWithOverrides({
|
||||
name: 'app-language',
|
||||
params: defineParams =>
|
||||
defineParams({
|
||||
api: appLanguageApiRef,
|
||||
deps: {},
|
||||
factory: () => AppLanguageSelector.createWithStorage(),
|
||||
}),
|
||||
config: {
|
||||
schema: {
|
||||
defaultLanguage: z => z.string().optional(),
|
||||
availableLanguages: z => z.array(z.string()).optional(),
|
||||
},
|
||||
},
|
||||
factory(originalFactory, { config }) {
|
||||
return originalFactory(defineParams =>
|
||||
defineParams({
|
||||
api: appLanguageApiRef,
|
||||
deps: {},
|
||||
factory: () =>
|
||||
AppLanguageSelector.createWithStorage({
|
||||
defaultLanguage: config.defaultLanguage,
|
||||
availableLanguages: config.availableLanguages,
|
||||
}),
|
||||
}),
|
||||
);
|
||||
},
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user