Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 2 additions & 6 deletions shell/components/Drawer/Chrome.vue
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

All the changes like this are to fix issues I saw in CI.
image

It appears that we have some webpack issues in some extensions which are treated differently in other as well as dashboard.

Original file line number Diff line number Diff line change
@@ -1,13 +1,9 @@
<script lang="ts">
<script setup lang="ts">
import { useI18n } from '@shell/composables/useI18n';
import { useStore } from 'vuex';
import { computed } from 'vue';
export interface Props {
ariaTarget: string;
}
</script>
import { Props } from './types';

<script setup lang="ts">
const props = defineProps<Props>();
const emit = defineEmits(['close']);

Expand Down
12 changes: 3 additions & 9 deletions shell/components/Drawer/ResourceDetailDrawer/ConfigTab.vue
Original file line number Diff line number Diff line change
@@ -1,17 +1,11 @@
<script lang="ts">
<script setup lang="ts">
import { useI18n } from '@shell/composables/useI18n';
import { _VIEW } from '@shell/config/query-params';
import { useStore } from 'vuex';
import Tab from '@shell/components/Tabbed/Tab.vue';
import { ConfigProps } from '@shell/components/Drawer/ResourceDetailDrawer/types';

export interface Props {
resource: any;
component: any;
resourceType: string;
}
</script>
<script setup lang="ts">
const props = defineProps<Props>();
const props = defineProps<ConfigProps>();
const store = useStore();
const i18n = useI18n(store);
</script>
Expand Down
11 changes: 3 additions & 8 deletions shell/components/Drawer/ResourceDetailDrawer/YamlTab.vue
Original file line number Diff line number Diff line change
@@ -1,18 +1,13 @@
<script lang="ts">
<script setup lang="ts">
import { useI18n } from '@shell/composables/useI18n';
import { _VIEW } from '@shell/config/query-params';
import { useStore } from 'vuex';
import Tab from '@shell/components/Tabbed/Tab.vue';
import { useTemplateRef } from 'vue';
import ResourceYaml from '@shell/components/ResourceYaml.vue';
import { YamlProps } from '@shell/components/Drawer/ResourceDetailDrawer/types';

export interface Props {
resource: any;
yaml: string;
}
</script>
<script setup lang="ts">
const props = defineProps<Props>();
const props = defineProps<YamlProps>();
const store = useStore();
const i18n = useI18n(store);
const yamlComponent: any = useTemplateRef('yaml');
Expand Down
7 changes: 3 additions & 4 deletions shell/components/Drawer/ResourceDetailDrawer/composables.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
import { Props as YamlTabProps } from '@shell/components/Drawer/ResourceDetailDrawer/YamlTab.vue';
import { Props as ConfigTabProps } from '@shell/components/Drawer/ResourceDetailDrawer/ConfigTab.vue';
import { useStore } from 'vuex';
import { getYaml } from '@shell/components/Drawer/ResourceDetailDrawer/helpers';
import { ConfigProps, YamlProps } from '@shell/components/Drawer/ResourceDetailDrawer/types';

export async function useDefaultYamlTabProps(resource: any): Promise<YamlTabProps> {
export async function useDefaultYamlTabProps(resource: any): Promise<YamlProps> {
const yaml = await getYaml(resource);

return {
Expand All @@ -12,7 +11,7 @@ export async function useDefaultYamlTabProps(resource: any): Promise<YamlTabProp
};
}

export function useDefaultConfigTabProps(resource: any): ConfigTabProps | undefined {
export function useDefaultConfigTabProps(resource: any): ConfigProps | undefined {
const store = useStore();

// You don't want to show the Config tab if there isn't a an edit page to show and you don't want to show it if there isn't
Expand Down
12 changes: 3 additions & 9 deletions shell/components/Drawer/ResourceDetailDrawer/index.vue
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<script lang="ts">
<script setup lang="ts">
import Drawer from '@shell/components/Drawer/Chrome.vue';
import { useI18n } from '@shell/composables/useI18n';
import { useStore } from 'vuex';
Expand All @@ -9,17 +9,11 @@ import ConfigTab from '@shell/components/Drawer/ResourceDetailDrawer/ConfigTab.v
import { computed, ref } from 'vue';
import RcButton from '@components/RcButton/RcButton.vue';
import StateDot from '@shell/components/StateDot/index.vue';
import { ResourceDetailDrawerProps } from '@shell/components/Drawer/ResourceDetailDrawer/types';

export interface Props {
resource: any;

onClose?: () => void;
}
</script>
<script setup lang="ts">
const editBttnDataTestId = 'save-configuration-bttn';
const componentTestid = 'configuration-drawer-tabbed';
const props = defineProps<Props>();
const props = defineProps<ResourceDetailDrawerProps>();
const emit = defineEmits(['close']);
const store = useStore();
const i18n = useI18n(store);
Expand Down
16 changes: 16 additions & 0 deletions shell/components/Drawer/ResourceDetailDrawer/types.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
export interface YamlProps {
resource: any;
yaml: string;
}

export interface ConfigProps {
resource: any;
component: any;
resourceType: string;
}

export interface ResourceDetailDrawerProps {
resource: any;

onClose?: () => void;
}
3 changes: 3 additions & 0 deletions shell/components/Drawer/types.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
export interface Props {
ariaTarget: string;
}
18 changes: 9 additions & 9 deletions shell/components/Resource/Detail/Metadata/composables.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,18 +6,19 @@ import { computed, toValue, Ref } from 'vue';
import {
useLiveDate, useNamespace, useProject, useResourceDetails, useWorkspace
} from '@shell/components/Resource/Detail/Metadata/IdentifyingInformation/identifying-fields';
import { useOnShowConfiguration } from '@shell/components/Resource/Detail/composables';

export const useBasicMetadata = (resource: any) => {
const labels = useDefaultLabels(resource);
const annotations = useDefaultAnnotations(resource);
const resourceValue = toValue(resource);
const onShowConfiguration = useOnShowConfiguration(resource);

return computed(() => {
return {
resource: toValue(resource),
labels: labels.value,
annotations: annotations.value,
onShowConfiguration: () => resourceValue.showConfiguration()
resource: toValue(resource),
labels: labels.value,
annotations: annotations.value,
onShowConfiguration
};
});
};
Expand All @@ -28,15 +29,15 @@ export const useDefaultMetadataProps = (resource: any, additionalIdentifyingInfo

const identifyingInformation = computed(() => [...defaultIdentifyingInformation.value, ...(additionalIdentifyingInformationValue || [])]);
const basicMetaData = useBasicMetadata(resource);
const resourceValue = toValue(resource);
const onShowConfiguration = useOnShowConfiguration(resource);

return computed(() => {
return {
resource: toValue(resource),
identifyingInformation: identifyingInformation.value,
labels: basicMetaData.value.labels,
annotations: basicMetaData.value.annotations,
onShowConfiguration: (returnFocusSelector: string) => resourceValue.showConfiguration(returnFocusSelector)
onShowConfiguration
};
});
};
Expand All @@ -47,7 +48,6 @@ export const useDefaultMetadataForLegacyPagesProps = (resource: any) => {
const workspace = useWorkspace(resource);
const namespace = useNamespace(resource);
const liveDate = useLiveDate(resource);
const resourceValue = toValue(resource);

const identifyingInformation = computed((): IdentifyingInformationRow[] => {
const defaultInfo = [
Expand All @@ -71,7 +71,7 @@ export const useDefaultMetadataForLegacyPagesProps = (resource: any) => {
identifyingInformation: identifyingInformation.value,
labels: basicMetaData.value.labels,
annotations: basicMetaData.value.annotations,
onShowConfiguration: (returnFocusSelector?: string) => resourceValue.showConfiguration(returnFocusSelector)
onShowConfiguration: basicMetaData.value.onShowConfiguration
};
});
};
3 changes: 2 additions & 1 deletion shell/components/Resource/Detail/TitleBar/composables.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import { useOnShowConfiguration } from '@shell/components/Resource/Detail/composables';
import { TitleBarProps } from '@shell/components/Resource/Detail/TitleBar/index.vue';
import { computed, Ref, toValue } from 'vue';
import { useRoute } from 'vue-router';
Expand All @@ -23,7 +24,7 @@ export const useDefaultTitleBarProps = (resource: any, resourceSubtype?: Ref<str
resource: resourceValue.type
}
};
const onShowConfiguration = resourceValue.disableResourceDetailDrawer ? undefined : (returnFocusSelector: string) => resourceValue.showConfiguration(returnFocusSelector);
const onShowConfiguration = resourceValue.disableResourceDetailDrawer ? undefined : useOnShowConfiguration(resource);

return {
resource: resourceValue,
Expand Down
12 changes: 12 additions & 0 deletions shell/components/Resource/Detail/composables.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import { computed, Ref, toValue } from 'vue';
import { useStore } from 'vuex';
import { Props as BannerProps } from '@components/Banner/Banner.vue';
import { useI18n } from '@shell/composables/useI18n';
import ResourceClass from '@shell/plugins/dashboard-store/resource-class';

export const useResourceDetailBannerProps = (resource: any): Ref<BannerProps | undefined> => {
const store = useStore();
Expand Down Expand Up @@ -43,3 +44,14 @@ export const useResourceDetailBannerProps = (resource: any): Ref<BannerProps | u
return undefined;
});
};

export const useOnShowConfiguration = (resource: any) => {
return (returnFocusSelector?: string) => {
const resourceValue = toValue(resource);
// 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
// to still the rest of shell to consume
const showConfiguration = resourceValue.showConfiguration ? resourceValue.showConfiguration.bind(resourceValue) : ResourceClass.prototype.showConfiguration.bind(resourceValue);

showConfiguration(returnFocusSelector);
};
};
4 changes: 4 additions & 0 deletions shell/pkg/dynamic-importer.lib.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,10 @@ export function importDetail(name) {
return () => undefined;
}

export function importDrawer(name) {
return () => undefined;
}

Comment on lines +28 to +31
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This doesn't impact anything in harvester. This is necessary if we want dynamic importing to work in the future.

export function importEdit(name) {
return () => undefined;
}
Expand Down
3 changes: 1 addition & 2 deletions shell/plugins/dashboard-store/resource-class.js
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,6 @@ import { handleConflict } from '@shell/plugins/dashboard-store/normalize';
import { ExtensionPoint, ActionLocation } from '@shell/core/types';
import { getApplicableExtensionEnhancements } from '@shell/core/plugin-helpers';
import { parse } from '@shell/utils/selector';
import { importDrawer } from '@shell/utils/dynamic-importer';

export const DNS_LIKE_TYPES = ['dnsLabel', 'dnsLabelRestricted', 'hostname'];

Expand Down Expand Up @@ -910,7 +909,7 @@ export default class Resource {
const onClose = () => this.$ctx.commit('slideInPanel/close', undefined, { root: true });

this.$ctx.commit('slideInPanel/open', {
component: importDrawer('ResourceDetailDrawer'),
component: require(`@shell/components/Drawer/ResourceDetailDrawer/index.vue`).default,
componentProps: {
resource: this,
onClose,
Expand Down