mirror of
https://github.com/harvester/harvester-ui-extension.git
synced 2026-10-03 20:56:06 +08:00
Add pkg/harvester components + shell portings - 1
Signed-off-by: Francesco Torchia <francesco.torchia@suse.com>
This commit is contained in:
@@ -0,0 +1,69 @@
|
||||
import SteveModel from '@shell/plugins/steve/steve-class';
|
||||
import { PRODUCT_NAME as HARVESTER_PRODUCT } from '../config/harvester';
|
||||
import { VIEW_IN_API, DEV } from '@shell/store/prefs';
|
||||
|
||||
export default class HarvesterResource extends SteveModel {
|
||||
get listLocation() {
|
||||
const name = this.harvesterResourcesInExplorer ? 'c-cluster-product-resource' : `${ HARVESTER_PRODUCT }-c-cluster-resource`;
|
||||
|
||||
return this.$rootGetters['type-map/optionsFor'](this.type).customRoute || {
|
||||
name,
|
||||
params: {
|
||||
product: this.$rootGetters['productId'],
|
||||
cluster: this.$rootGetters['clusterId'],
|
||||
resource: this.type,
|
||||
},
|
||||
};
|
||||
}
|
||||
|
||||
get parentLocationOverride() {
|
||||
return this.listLocation;
|
||||
}
|
||||
|
||||
get doneRoute() {
|
||||
return this.listLocation.name;
|
||||
}
|
||||
|
||||
get doneOverride() {
|
||||
return this.listLocation;
|
||||
}
|
||||
|
||||
get harvesterResourcesInExplorer() {
|
||||
return this.$rootGetters['productId'] !== HARVESTER_PRODUCT;
|
||||
}
|
||||
|
||||
get _detailLocation() {
|
||||
const schema = this.$getters['schemaFor'](this.type);
|
||||
const id = this.id?.replace(/.*\//, '');
|
||||
const name = this.harvesterResourcesInExplorer ? `c-cluster-product-resource${ schema?.attributes?.namespaced ? '-namespace' : '' }-id` : `${ HARVESTER_PRODUCT }-c-cluster-resource${ schema?.attributes?.namespaced ? '-namespace' : '' }-id`;
|
||||
|
||||
const out = {
|
||||
name,
|
||||
params: {
|
||||
product: this.$rootGetters['productId'],
|
||||
cluster: this.$rootGetters['clusterId'],
|
||||
resource: this.type,
|
||||
namespace: this.metadata?.namespace,
|
||||
id,
|
||||
},
|
||||
};
|
||||
|
||||
if (this.harvesterResourcesInExplorer) {
|
||||
out.query = { as: 'yaml' };
|
||||
}
|
||||
|
||||
return out;
|
||||
}
|
||||
|
||||
get forceYaml() {
|
||||
return this.harvesterResourcesInExplorer;
|
||||
}
|
||||
|
||||
get canViewInApi() {
|
||||
try {
|
||||
return this.hasLink('self') && this.$rootGetters['prefs/get'](VIEW_IN_API);
|
||||
} catch {
|
||||
return this.hasLink('self') && this.$rootGetters['prefs/get'](DEV);
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user