mirror of
https://github.com/harvester/harvester-ui-extension.git
synced 2026-10-04 21:26:08 +08:00
fix: some actions should be hidden for read-only user (#855)
* fix: some actions limited for virt-viewer Signed-off-by: Andy Lee <andy.lee@suse.com> * refactor: based on schema collectionMethods Signed-off-by: Andy Lee <andy.lee@suse.com> * fix: conditionally add migrate action to available actions * fix: update collectionMethods check to use find for case-insensitive matching * fix: update canEditClusterMembers method to use schema for collectionMethods * fix: update canCreateImage check to use case-insensitive matching --------- Signed-off-by: Andy Lee <andy.lee@suse.com>
This commit is contained in:
@@ -123,5 +123,26 @@ export default {
|
||||
const clusterId = currentCluster.id;
|
||||
|
||||
return projectsInAllClusters.filter((project: any) => project.spec.clusterName === clusterId && project.nameDisplay !== 'System');
|
||||
}
|
||||
},
|
||||
|
||||
// Few harvester resources name and REAL resource are different. E.g. HCI.NETWORK_ATTACHMENT page resource is NETWORK_ATTACHMENT.
|
||||
// Check in config/harvester-cluster.js for more details.
|
||||
// We need to look up the schema by resource name, and fallback to find using real resource name
|
||||
schemaFor: (state, getters, rootState, rootGetters) => (type, _fuzzy = false, _allowThrow = true) => {
|
||||
// follow the same logic as type-map/schemaFor in /dashboard/shell/plugins/dashboard-store/getters.js
|
||||
const normalizedType = getters.normalizeType(type);
|
||||
const schemas = state.types['schema'];
|
||||
const out = schemas?.map?.get(normalizedType);
|
||||
|
||||
if (out) return out;
|
||||
|
||||
// if not found, use the resource mapping in configureType for a second try
|
||||
const resourceType = rootGetters['type-map/optionsFor'](type)?.resource;
|
||||
if (resourceType && resourceType !== type) {
|
||||
const normalizedResource = getters.normalizeType(resourceType);
|
||||
return schemas?.map?.get(normalizedResource) || null;
|
||||
}
|
||||
|
||||
return null;
|
||||
},
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user