diff --git a/docs/extensibility/statics.md b/docs/extensibility/statics.md index b9f8fef6ad..ae2a602257 100644 --- a/docs/extensibility/statics.md +++ b/docs/extensibility/statics.md @@ -27,6 +27,30 @@ The version is a string value that defines in which version the extension is con The **general** section is not required as static extensions present data that are not connected to any resource. Instead, they may use information from the page they are displayed on via variable `$embedResource`. +### _externalNodes_ + +The **externalNodes** parameter allows you to define optional links to external websites that appear in the navigation menu. + +- **externalNodes** - an optional list of links to external websites. + - **category** - a category name. + - **scope** - either `namespace` or `cluster`. Defaults to `cluster`. + - **icon** - an optional icon. Go to [Icon Explorer](https://sdk.openui5.org/test-resources/sap/m/demokit/iconExplorer/webapp/index.html#/overview) to find the list of the available icons. + - **children** - a list of child Nodes containing details about the links. + - **label** - a displayed label + - **link** - a link to an external website. You can provide a [JSONata](jsonata.md) function. + +### Example + +```yaml +general: + externalNodes: + - category: My Category + icon: course-book + children: + - label: Example Node Label + link: 'https://github.com/kyma-project/busola' +``` + ## _injections_ section -For more information read the [widget injections overview](./70-widget-injection.md). +For more information, read the [widget injections overview](./70-widget-injection.md). diff --git a/src/state/navigation/extensibilityNodesExtSelector.ts b/src/state/navigation/extensibilityNodesExtSelector.ts index 6661b297b6..750f5b3229 100644 --- a/src/state/navigation/extensibilityNodesExtSelector.ts +++ b/src/state/navigation/extensibilityNodesExtSelector.ts @@ -2,7 +2,7 @@ import { RecoilValueReadOnly, selector } from 'recoil'; import { ExtResource, NavNode } from '../types'; import { getFetchFn } from '../utils/getFetchFn'; import { DataSources } from 'components/Extensibility/contexts/DataSources'; -import { extensionsState } from 'state/navigation/extensionsAtom'; +import { extensionsState, staticsState } from 'state/navigation/extensionsAtom'; import { ExtensibilityNodesExt } from 'state/types'; const createExternalNode = ( @@ -68,13 +68,19 @@ export const extensibilityNodesExtSelector: RecoilValueReadOnly< key: 'extensibilityNodesExtSelector', get: async ({ get }) => { const extensions = get(extensionsState) || []; + const statics = get(staticsState) || []; + const fetchFn = getFetchFn(get); if (!fetchFn) { return null; } const extensibilityNodes = getExtensibilityNodesExt(extensions); + const staticsNodes = getExtensibilityNodesExt(statics); + + const filteredExtNodes = [...extensibilityNodes.filter(n => n)]; + const filteresStaticsNodes = [...staticsNodes.filter(n => n)]; - return [...extensibilityNodes.filter(n => n)]; + return [...filteredExtNodes.concat(filteresStaticsNodes)]; }, }); diff --git a/src/state/navigation/extensionsAtom.ts b/src/state/navigation/extensionsAtom.ts index 52741e05c1..54295d51a5 100644 --- a/src/state/navigation/extensionsAtom.ts +++ b/src/state/navigation/extensionsAtom.ts @@ -384,6 +384,7 @@ export const useGetExtensions = () => { const cluster = useRecoilValue(clusterState); const auth = useRecoilValue(authDataState); const setExtensions = useSetRecoilState(extensionsState); + const setStatics = useSetRecoilState(staticsState); const setAllExtensions = useSetRecoilState(allExtensionsState); const setInjections = useSetRecoilState(injectionsState); const setWizard = useSetRecoilState(wizardState); @@ -414,6 +415,7 @@ export const useGetExtensions = () => { const manageExtensions = async () => { if (!cluster) { setExtensions([]); + setStatics([]); setAllExtensions([]); setInjections([]); setWizard([]); @@ -476,6 +478,7 @@ export const useGetExtensions = () => { } if (!filteredConfigs && !statics) { + setStatics([]); setInjections([]); } else { let injectionsConfigs: ExtInjectionConfig[] = []; @@ -500,6 +503,7 @@ export const useGetExtensions = () => { }), ), ); + setStatics(statics); if (isExtensibilityInjectionsEnabled) { setInjections(injectionsConfigs); } @@ -520,6 +524,13 @@ export const extensionsState: RecoilState = atom< default: defaultValue, }); +export const staticsState: RecoilState = atom< + ExtResource[] | null +>({ + key: 'staticsState', + default: defaultValue, +}); + export const allExtensionsState: RecoilState = atom< ExtResource[] | null >({