Skip to content

Commit adb1ba4

Browse files
committed
Fixing an issue with using show configuration within extensions
Fixes #15658
1 parent b29356d commit adb1ba4

File tree

3 files changed

+23
-10
lines changed

3 files changed

+23
-10
lines changed

shell/components/Resource/Detail/Metadata/composables.ts

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -6,18 +6,19 @@ import { computed, toValue, Ref } from 'vue';
66
import {
77
useLiveDate, useNamespace, useProject, useResourceDetails, useWorkspace
88
} from '@shell/components/Resource/Detail/Metadata/IdentifyingInformation/identifying-fields';
9+
import { useOnShowConfiguration } from '@shell/components/Resource/Detail/composables';
910

1011
export const useBasicMetadata = (resource: any) => {
1112
const labels = useDefaultLabels(resource);
1213
const annotations = useDefaultAnnotations(resource);
13-
const resourceValue = toValue(resource);
14+
const onShowConfiguration = useOnShowConfiguration(resource);
1415

1516
return computed(() => {
1617
return {
17-
resource: toValue(resource),
18-
labels: labels.value,
19-
annotations: annotations.value,
20-
onShowConfiguration: () => resourceValue.showConfiguration()
18+
resource: toValue(resource),
19+
labels: labels.value,
20+
annotations: annotations.value,
21+
onShowConfiguration
2122
};
2223
});
2324
};
@@ -28,15 +29,15 @@ export const useDefaultMetadataProps = (resource: any, additionalIdentifyingInfo
2829

2930
const identifyingInformation = computed(() => [...defaultIdentifyingInformation.value, ...(additionalIdentifyingInformationValue || [])]);
3031
const basicMetaData = useBasicMetadata(resource);
31-
const resourceValue = toValue(resource);
32+
const onShowConfiguration = useOnShowConfiguration(resource);
3233

3334
return computed(() => {
3435
return {
3536
resource: toValue(resource),
3637
identifyingInformation: identifyingInformation.value,
3738
labels: basicMetaData.value.labels,
3839
annotations: basicMetaData.value.annotations,
39-
onShowConfiguration: (returnFocusSelector: string) => resourceValue.showConfiguration(returnFocusSelector)
40+
onShowConfiguration
4041
};
4142
});
4243
};
@@ -47,7 +48,6 @@ export const useDefaultMetadataForLegacyPagesProps = (resource: any) => {
4748
const workspace = useWorkspace(resource);
4849
const namespace = useNamespace(resource);
4950
const liveDate = useLiveDate(resource);
50-
const resourceValue = toValue(resource);
5151

5252
const identifyingInformation = computed((): IdentifyingInformationRow[] => {
5353
const defaultInfo = [
@@ -71,7 +71,7 @@ export const useDefaultMetadataForLegacyPagesProps = (resource: any) => {
7171
identifyingInformation: identifyingInformation.value,
7272
labels: basicMetaData.value.labels,
7373
annotations: basicMetaData.value.annotations,
74-
onShowConfiguration: (returnFocusSelector?: string) => resourceValue.showConfiguration(returnFocusSelector)
74+
onShowConfiguration: basicMetaData.value.onShowConfiguration
7575
};
7676
});
7777
};

shell/components/Resource/Detail/TitleBar/composables.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import { useOnShowConfiguration } from '@shell/components/Resource/Detail/composables';
12
import { TitleBarProps } from '@shell/components/Resource/Detail/TitleBar/index.vue';
23
import { computed, Ref, toValue } from 'vue';
34
import { useRoute } from 'vue-router';
@@ -23,7 +24,7 @@ export const useDefaultTitleBarProps = (resource: any, resourceSubtype?: Ref<str
2324
resource: resourceValue.type
2425
}
2526
};
26-
const onShowConfiguration = resourceValue.disableResourceDetailDrawer ? undefined : (returnFocusSelector: string) => resourceValue.showConfiguration(returnFocusSelector);
27+
const onShowConfiguration = resourceValue.disableResourceDetailDrawer ? undefined : useOnShowConfiguration(resource);
2728

2829
return {
2930
resource: resourceValue,

shell/components/Resource/Detail/composables.ts

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ import { computed, Ref, toValue } from 'vue';
22
import { useStore } from 'vuex';
33
import { Props as BannerProps } from '@components/Banner/Banner.vue';
44
import { useI18n } from '@shell/composables/useI18n';
5+
import ResourceClass from '@shell/plugins/dashboard-store/resource-class';
56

67
export const useResourceDetailBannerProps = (resource: any): Ref<BannerProps | undefined> => {
78
const store = useStore();
@@ -43,3 +44,14 @@ export const useResourceDetailBannerProps = (resource: any): Ref<BannerProps | u
4344
return undefined;
4445
});
4546
};
47+
48+
export const useOnShowConfiguration = (resource: any) => {
49+
return (returnFocusSelector?: string) => {
50+
const resourceValue = toValue(resource);
51+
// Because extensions can make a copy of the resource-class it's possible that an extension will have a resource-class which predates the inclusion of showConfiguration
52+
// to still the rest of shell to consume
53+
const showConfiguration = resourceValue.showConfiguration || ResourceClass.prototype.showConfiguration.bind(resourceValue);
54+
55+
showConfiguration(returnFocusSelector);
56+
};
57+
};

0 commit comments

Comments
 (0)