Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Disable the delete button when the selected priorityclass is the system one #104

Merged
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
3 changes: 2 additions & 1 deletion web/components/ResourceBar/ResourceBar.vue
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
editmode = !editmode;
}
"
:enable-delete-btn="selected && !selected.isNew"
:enable-delete-btn="selected && !selected.isNew && selected.isDeletable"
:enable-editmode-switch="selected && !selected.isNew"
/>

Expand Down Expand Up @@ -90,6 +90,7 @@ interface SelectedItem {
isNew: boolean;
item: Resource;
resourceKind: string;
isDeletable: boolean;
}

export default defineComponent({
Expand Down
2 changes: 2 additions & 0 deletions web/store/node.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ type selectedNode = {
isNew: boolean;
item: V1Node;
resourceKind: string;
isDeletable: boolean;
};

export default function nodeStore() {
Expand Down Expand Up @@ -39,6 +40,7 @@ export default function nodeStore() {
isNew: isNew,
item: n,
resourceKind: "Node",
isDeletable: true,
};
}
},
Expand Down
2 changes: 2 additions & 0 deletions web/store/pod.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ export type SelectedPod = {
isNew: boolean;
item: V1Pod;
resourceKind: string;
isDeletable: boolean;
};

export default function podStore() {
Expand Down Expand Up @@ -46,6 +47,7 @@ export default function podStore() {
isNew: isNew,
item: p,
resourceKind: "Pod",
isDeletable: true,
};
}
},
Expand Down
8 changes: 8 additions & 0 deletions web/store/priorityclass.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ type selectedPriorityClass = {
isNew: boolean;
item: V1PriorityClass;
resourceKind: string;
isDeletable: boolean;
};

export default function priorityclassStore() {
Expand All @@ -25,6 +26,12 @@ export default function priorityclassStore() {
priorityclasses: [],
});

// `CheckIsDeletable` returns whether the given PriorityClass can be deleted or not.
// The PriorityClasses that have the name prefixed with `system-` are reserved by the system so can't be deleted.
const checkIsDeletable = (n: V1PriorityClass) => {
return !!n.metadata?.name && !n.metadata?.name?.startsWith("system-");
};

return {
get priorityclasses() {
return state.priorityclasses;
Expand All @@ -44,6 +51,7 @@ export default function priorityclassStore() {
isNew: isNew,
item: n,
resourceKind: "PC",
isDeletable: checkIsDeletable(n),
};
}
},
Expand Down
2 changes: 2 additions & 0 deletions web/store/pv.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ type selectedPersistentVolume = {
isNew: boolean;
item: V1PersistentVolume;
resourceKind: string;
isDeletable: boolean;
};

export default function pvStore() {
Expand Down Expand Up @@ -44,6 +45,7 @@ export default function pvStore() {
isNew: isNew,
item: p,
resourceKind: "PV",
isDeletable: true,
};
}
},
Expand Down
2 changes: 2 additions & 0 deletions web/store/pvc.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ type selectedPersistentVolumeClaim = {
isNew: boolean;
item: V1PersistentVolumeClaim;
resourceKind: string;
isDeletable: boolean;
};

export default function pvcStore() {
Expand Down Expand Up @@ -44,6 +45,7 @@ export default function pvcStore() {
isNew: isNew,
item: n,
resourceKind: "PVC",
isDeletable: true,
};
}
},
Expand Down
2 changes: 2 additions & 0 deletions web/store/schedulerconfiguration.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ type selectedConfig = {
isNew: boolean;
item: SchedulerConfiguration;
resourceKind: string;
isDeletable: boolean;
};

export default function schedulerconfigurationStore() {
Expand Down Expand Up @@ -42,6 +43,7 @@ export default function schedulerconfigurationStore() {
isNew: true,
item: c,
resourceKind: "SchedulerConfiguration",
isDeletable: true,
};
}
},
Expand Down
2 changes: 2 additions & 0 deletions web/store/storageclass.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ type selectedStorageClass = {
isNew: boolean;
item: V1StorageClass;
resourceKind: string;
isDeletable: boolean;
};

export default function storageclassStore() {
Expand Down Expand Up @@ -44,6 +45,7 @@ export default function storageclassStore() {
isNew: isNew,
item: n,
resourceKind: "SC",
isDeletable: true,
};
}
},
Expand Down