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:
@@ -0,0 +1,5 @@
|
||||
---
|
||||
'@backstage/plugin-app': patch
|
||||
---
|
||||
|
||||
Support to set defaultLanguage and availableLanguages in new frontend system
|
||||
@@ -21,6 +21,11 @@ app:
|
||||
ownerEntityRefs: [cubic-belugas]
|
||||
|
||||
extensions:
|
||||
# set availableLanguages example
|
||||
- api:app/app-language:
|
||||
config:
|
||||
availableLanguages: ['en', 'es', 'fr', 'de', 'ja']
|
||||
defaultLanguage: 'en'
|
||||
- entity-card:org/members-list:
|
||||
config:
|
||||
showAggregateMembersToggle: true
|
||||
|
||||
@@ -232,12 +232,26 @@ const appPlugin: OverridableFrontendPlugin<
|
||||
) => ExtensionBlueprintParams<AnyApiFactory>;
|
||||
}>;
|
||||
'api:app/app-language': OverridableExtensionDefinition<{
|
||||
config: {
|
||||
defaultLanguage: string | undefined;
|
||||
availableLanguages: string[] | undefined;
|
||||
};
|
||||
configInput: {
|
||||
defaultLanguage?: string | undefined;
|
||||
availableLanguages?: string[] | undefined;
|
||||
};
|
||||
output: ExtensionDataRef<AnyApiFactory, 'core.api.factory', {}>;
|
||||
inputs: {
|
||||
[x: string]: ExtensionInput<
|
||||
ExtensionDataRef,
|
||||
{
|
||||
singleton: boolean;
|
||||
optional: boolean;
|
||||
}
|
||||
>;
|
||||
};
|
||||
kind: 'api';
|
||||
name: 'app-language';
|
||||
config: {};
|
||||
configInput: {};
|
||||
output: ExtensionDataRef<AnyApiFactory, 'core.api.factory', {}>;
|
||||
inputs: {};
|
||||
params: <
|
||||
TApi,
|
||||
TImpl extends TApi,
|
||||
|
||||
@@ -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