diff --git a/src/components/molecules/ExecutionDetails/TestExecutionDetails/TestExecutionDetailsTabs.tsx b/src/components/molecules/ExecutionDetails/TestExecutionDetails/TestExecutionDetailsTabs.tsx index 110624cb7..e19c467d0 100644 --- a/src/components/molecules/ExecutionDetails/TestExecutionDetails/TestExecutionDetailsTabs.tsx +++ b/src/components/molecules/ExecutionDetails/TestExecutionDetails/TestExecutionDetailsTabs.tsx @@ -102,26 +102,24 @@ const TestExecutionDetailsTabs: React.FC = () => { order: Infinity, }, }, - // TODO: refactor using visibility metadata - whetherToShowArtifactsTab - ? { - value: { - key: 'ArtifactsPane', - label: 'Artifacts', - children: ( - - ), - }, - metadata: { - order: 3, - }, - } - : null, + { + value: { + key: 'ArtifactsPane', + label: 'Artifacts', + children: ( + + ), + }, + metadata: { + order: 3, + visible: () => whetherToShowArtifactsTab, + }, + }, { value: { key: 'CLICommands', @@ -132,19 +130,18 @@ const TestExecutionDetailsTabs: React.FC = () => { order: 2, }, }, - decomposedVars.length - ? { - value: { - key: 'Variables', - label: 'Variables', - children: , - }, - metadata: { - order: 1, - }, - } - : null, - ].filter(Boolean); + { + value: { + key: 'Variables', + label: 'Variables', + children: , + }, + metadata: { + order: 1, + visible: () => decomposedVars.length, + }, + }, + ]; const items = usePluginSlotList('testExecutionTabs', defaultExecutionDetailsTabs); diff --git a/src/components/pages/TestSuites/TestSuitesList/TestSuitesList.tsx b/src/components/pages/TestSuites/TestSuitesList/TestSuitesList.tsx index ae1280844..3a6d80b30 100644 --- a/src/components/pages/TestSuites/TestSuitesList/TestSuitesList.tsx +++ b/src/components/pages/TestSuites/TestSuitesList/TestSuitesList.tsx @@ -69,7 +69,7 @@ const TestSuitesList: FC = () => { onItemAbort={onItemAbort} entity="test-suites" pageTitle="Test Suites" - pageTitleAddon={usePluginSlot('testSuiteTitleIcon')} + pageTitleAddon={usePluginSlot('testSuitesListTitleAddon')} addEntityButtonText="Add a new test suite" pageDescription={PageDescription} emptyDataComponent={EmptyTestSuites} diff --git a/src/plugins/pluginHooks.ts b/src/plugins/pluginHooks.ts index 58fa7eb78..67abf1c47 100644 --- a/src/plugins/pluginHooks.ts +++ b/src/plugins/pluginHooks.ts @@ -14,6 +14,12 @@ export const usePluginSlot = (name: string) => usePluginSlotList(name)[0]; export const usePluginSlotList = (name: string, defaults: any[] = []) => { const {scope} = useContext(PluginsContext); - const elements = useMemo(() => orderArray([...defaults, ...scope.getSlot(name)]), [defaults, scope.getSlot(name)]); + + // by default, all elements are visible, + // unless visibility is configured explicitly in the metadata + const elements = useMemo( + () => orderArray([...defaults, ...scope.getSlot(name)].filter(x => !x.metadata?.visible || x.metadata.visible())), + [defaults, scope.getSlot(name)] + ); return elements; }; diff --git a/src/plugins/types.ts b/src/plugins/types.ts index 859f9916f..b9a52822e 100644 --- a/src/plugins/types.ts +++ b/src/plugins/types.ts @@ -10,6 +10,7 @@ export interface Plugin { export interface SlotMetaData { order?: number; + visible?: () => boolean; } export interface TestExecutionTabsInterface {