Skip to content

Commit

Permalink
Merge pull request rancher#11971 from rak-phillip/chore/resource-refa…
Browse files Browse the repository at this point in the history
…ctor

Rename `resource` to `resourceType` in `ResourceDetail`
  • Loading branch information
rak-phillip authored Sep 24, 2024
2 parents ec4c5aa + 8d6d46e commit 7c3317d
Showing 1 changed file with 15 additions and 15 deletions.
30 changes: 15 additions & 15 deletions shell/components/ResourceDetail/index.vue
Original file line number Diff line number Diff line change
Expand Up @@ -87,9 +87,9 @@ export default {
const store = this.$store;
const route = this.$route;
const params = route.params;
let resource = this.resourceOverride || params.resource;
let resourceType = this.resourceOverride || params.resource;
const inStore = this.storeOverride || store.getters['currentStore'](resource);
const inStore = this.storeOverride || store.getters['currentStore'](resourceType);
const realMode = this.realMode;
// eslint-disable-next-line prefer-const
Expand All @@ -100,10 +100,10 @@ export default {
// know about: view, edit, create (stage, import and clone become "create")
const mode = ([_CLONE, _IMPORT, _STAGE].includes(realMode) ? _CREATE : realMode);
const getGraphConfig = store.getters['type-map/hasGraph'](resource);
const getGraphConfig = store.getters['type-map/hasGraph'](resourceType);
const hasGraph = !!getGraphConfig;
const hasCustomDetail = store.getters['type-map/hasCustomDetail'](resource, id);
const hasCustomEdit = store.getters['type-map/hasCustomEdit'](resource, id);
const hasCustomDetail = store.getters['type-map/hasCustomDetail'](resourceType, id);
const hasCustomEdit = store.getters['type-map/hasCustomEdit'](resourceType, id);
const schemas = store.getters[`${ inStore }/all`](SCHEMA);
Expand All @@ -124,24 +124,24 @@ export default {
this.as = as;
const options = store.getters[`type-map/optionsFor`](resource);
const options = store.getters[`type-map/optionsFor`](resourceType);
this.showMasthead = [_CREATE, _EDIT].includes(mode) ? options.resourceEditMasthead : true;
const canViewYaml = options.canYaml;
if ( options.resource ) {
resource = options.resource;
resourceType = options.resource;
}
const schema = store.getters[`${ inStore }/schemaFor`](resource);
const schema = store.getters[`${ inStore }/schemaFor`](resourceType);
let model, initialModel, liveModel, yaml;
if ( realMode === _CREATE || realMode === _IMPORT ) {
if ( !namespace ) {
namespace = store.getters['defaultNamespace'];
}
const data = { type: resource };
const data = { type: resourceType };
if ( schema?.attributes?.namespaced ) {
data.metadata = { namespace };
Expand All @@ -162,7 +162,7 @@ export default {
await schema.fetchResourceFields();
}
yaml = createYaml(schemas, resource, data);
yaml = createYaml(schemas, resourceType, data);
}
} else {
if ( as === _GRAPH ) {
Expand Down Expand Up @@ -194,13 +194,13 @@ export default {
try {
liveModel = await store.dispatch(`${ inStore }/find`, {
type: resource,
type: resourceType,
id: fqid,
opt: { watch: true }
});
} catch (e) {
if (e.status === 404 || e.status === 403) {
store.dispatch('loadingError', new Error(this.t('nav.failWhale.resourceIdNotFound', { resource, fqid }, true)));
store.dispatch('loadingError', new Error(this.t('nav.failWhale.resourceIdNotFound', { resource: resourceType, fqid }, true)));
}
liveModel = {};
notFound = fqid;
Expand Down Expand Up @@ -237,7 +237,7 @@ export default {
hasCustomDetail,
hasCustomEdit,
canViewYaml,
resource,
resourceType,
as,
yaml,
initialModel,
Expand All @@ -264,7 +264,7 @@ export default {
hasGraph: null,
hasCustomDetail: null,
hasCustomEdit: null,
resource: null,
resourceType: null,
asYaml: null,
yaml: null,
liveModel: null,
Expand Down Expand Up @@ -381,7 +381,7 @@ export default {
<div v-else>
<Masthead
v-if="showMasthead"
:resource="resource"
:resource="resourceType"
:value="liveModel"
:mode="mode"
:real-mode="realMode"
Expand Down

0 comments on commit 7c3317d

Please sign in to comment.