mirror of
https://github.com/lensapp/lens.git
synced 2025-05-20 05:10:56 +00:00
Add ability to hide KubeObjectMenu Edit and Remove buttons in extensions (#5107)
This commit is contained in:
1 parent
e532b90b72
commit
dbdde19222
51 files changed
+1245
-765
No files matched your search
@@ -12,7 +12,6 @@ import React from "react";
|
||||
import type { ClusterRoleBinding, ClusterRoleBindingSubject } from "../../../../common/k8s-api/endpoints";
|
||||
import { autoBind, ObservableHashSet, prevDefault } from "../../../utils";
|
||||
import { AddRemoveButtons } from "../../add-remove-buttons";
|
||||
import { ConfirmDialog } from "../../confirm-dialog";
|
||||
import { DrawerTitle } from "../../drawer";
|
||||
import type { KubeObjectDetailsProps } from "../../kube-object-details";
|
||||
import { KubeObjectMeta } from "../../kube-object-meta";
|
||||
@@ -20,15 +19,22 @@ import { Table, TableCell, TableHead, TableRow } from "../../table";
|
||||
import { ClusterRoleBindingDialog } from "./dialog";
|
||||
import { clusterRoleBindingsStore } from "./store";
|
||||
import { hashClusterRoleBindingSubject } from "./hashers";
|
||||
import type { OpenConfirmDialog } from "../../confirm-dialog/open.injectable";
|
||||
import { withInjectables } from "@ogre-tools/injectable-react";
|
||||
import openConfirmDialogInjectable from "../../confirm-dialog/open.injectable";
|
||||
|
||||
export interface ClusterRoleBindingDetailsProps extends KubeObjectDetailsProps<ClusterRoleBinding> {
|
||||
}
|
||||
|
||||
interface Dependencies {
|
||||
openConfirmDialog: OpenConfirmDialog;
|
||||
}
|
||||
|
||||
@observer
|
||||
export class ClusterRoleBindingDetails extends React.Component<ClusterRoleBindingDetailsProps> {
|
||||
class NonInjectedClusterRoleBindingDetails extends React.Component<ClusterRoleBindingDetailsProps & Dependencies> {
|
||||
selectedSubjects = new ObservableHashSet<ClusterRoleBindingSubject>([], hashClusterRoleBindingSubject);
|
||||
|
||||
constructor(props: ClusterRoleBindingDetailsProps) {
|
||||
constructor(props: ClusterRoleBindingDetailsProps & Dependencies) {
|
||||
super(props);
|
||||
autoBind(this);
|
||||
}
|
||||
@@ -42,10 +48,10 @@ export class ClusterRoleBindingDetails extends React.Component<ClusterRoleBindin
|
||||
}
|
||||
|
||||
removeSelectedSubjects() {
|
||||
const { object: clusterRoleBinding } = this.props;
|
||||
const { object: clusterRoleBinding, openConfirmDialog } = this.props;
|
||||
const { selectedSubjects } = this;
|
||||
|
||||
ConfirmDialog.open({
|
||||
openConfirmDialog({
|
||||
ok: () => clusterRoleBindingsStore.removeSubjects(clusterRoleBinding, selectedSubjects),
|
||||
labelOk: `Remove`,
|
||||
message: (
|
||||
@@ -123,3 +129,10 @@ export class ClusterRoleBindingDetails extends React.Component<ClusterRoleBindin
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
export const ClusterRoleBindingDetails = withInjectables<Dependencies, ClusterRoleBindingDetailsProps>(NonInjectedClusterRoleBindingDetails, {
|
||||
getProps: (di, props) => ({
|
||||
...props,
|
||||
openConfirmDialog: di.inject(openConfirmDialogInjectable),
|
||||
}),
|
||||
});
|
||||
@@ -11,7 +11,6 @@ import React from "react";
|
||||
import type { RoleBinding, RoleBindingSubject } from "../../../../common/k8s-api/endpoints";
|
||||
import { prevDefault } from "../../../utils";
|
||||
import { AddRemoveButtons } from "../../add-remove-buttons";
|
||||
import { ConfirmDialog } from "../../confirm-dialog";
|
||||
import { DrawerTitle } from "../../drawer";
|
||||
import type { KubeObjectDetailsProps } from "../../kube-object-details";
|
||||
import { KubeObjectMeta } from "../../kube-object-meta";
|
||||
@@ -20,12 +19,19 @@ import { RoleBindingDialog } from "./dialog";
|
||||
import { roleBindingsStore } from "./store";
|
||||
import { ObservableHashSet } from "../../../../common/utils/hash-set";
|
||||
import { hashRoleBindingSubject } from "./hashers";
|
||||
import type { OpenConfirmDialog } from "../../confirm-dialog/open.injectable";
|
||||
import { withInjectables } from "@ogre-tools/injectable-react";
|
||||
import openConfirmDialogInjectable from "../../confirm-dialog/open.injectable";
|
||||
|
||||
export interface RoleBindingDetailsProps extends KubeObjectDetailsProps<RoleBinding> {
|
||||
}
|
||||
|
||||
interface Dependencies {
|
||||
openConfirmDialog: OpenConfirmDialog;
|
||||
}
|
||||
|
||||
@observer
|
||||
export class RoleBindingDetails extends React.Component<RoleBindingDetailsProps> {
|
||||
class NonInjectedRoleBindingDetails extends React.Component<RoleBindingDetailsProps & Dependencies> {
|
||||
selectedSubjects = new ObservableHashSet<RoleBindingSubject>([], hashRoleBindingSubject);
|
||||
|
||||
async componentDidMount() {
|
||||
@@ -37,10 +43,10 @@ export class RoleBindingDetails extends React.Component<RoleBindingDetailsProps>
|
||||
}
|
||||
|
||||
removeSelectedSubjects = () => {
|
||||
const { object: roleBinding } = this.props;
|
||||
const { object: roleBinding, openConfirmDialog } = this.props;
|
||||
const { selectedSubjects } = this;
|
||||
|
||||
ConfirmDialog.open({
|
||||
openConfirmDialog({
|
||||
ok: () => roleBindingsStore.removeSubjects(roleBinding, selectedSubjects.toJSON()),
|
||||
labelOk: `Remove`,
|
||||
message: (
|
||||
@@ -118,3 +124,10 @@ export class RoleBindingDetails extends React.Component<RoleBindingDetailsProps>
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
export const RoleBindingDetails = withInjectables<Dependencies, RoleBindingDetailsProps>(NonInjectedRoleBindingDetails, {
|
||||
getProps: (di, props) => ({
|
||||
...props,
|
||||
openConfirmDialog: di.inject(openConfirmDialogInjectable),
|
||||
}),
|
||||
});
|
||||
Reference in new issue
Block a user