mirror of
https://github.com/lensapp/lens.git
synced 2025-05-20 05:10:56 +00:00
Clean up unneded changes
Signed-off-by: Alex Andreev <alex.andreev.email@gmail.com>
This commit is contained in:
parent
e4b6541727
commit
79c0da5dae
@ -1,28 +0,0 @@
|
|||||||
/**
|
|
||||||
* Copyright (c) OpenLens Authors. All rights reserved.
|
|
||||||
* Licensed under MIT License. See LICENSE in root directory for more information.
|
|
||||||
*/
|
|
||||||
|
|
||||||
import { getInjectable } from "@ogre-tools/injectable";
|
|
||||||
import type { Namespace } from "../../../common/k8s-api/endpoints";
|
|
||||||
import removeSubnamespaceInjectable from "./remove-subnamespace.injectable";
|
|
||||||
import namespaceStoreInjectable from "./store.injectable";
|
|
||||||
|
|
||||||
const deleteNamespaceInjectable = getInjectable({
|
|
||||||
id: "delete-namespace",
|
|
||||||
|
|
||||||
instantiate: (di) => {
|
|
||||||
const namespaceStore = di.inject(namespaceStoreInjectable);
|
|
||||||
const removeSubnamespace = di.inject(removeSubnamespaceInjectable);
|
|
||||||
|
|
||||||
return async (namespace: Namespace) => {
|
|
||||||
if (namespace.isSubnamespace()) {
|
|
||||||
return await removeSubnamespace(namespace.getName());
|
|
||||||
}
|
|
||||||
|
|
||||||
return await namespaceStore.remove(namespace);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
export default deleteNamespaceInjectable;
|
|
||||||
@ -1,73 +0,0 @@
|
|||||||
/**
|
|
||||||
* Copyright (c) OpenLens Authors. All rights reserved.
|
|
||||||
* Licensed under MIT License. See LICENSE in root directory for more information.
|
|
||||||
*/
|
|
||||||
|
|
||||||
import { withInjectables } from "@ogre-tools/injectable-react";
|
|
||||||
import React from "react";
|
|
||||||
import type { Namespace } from "../../../common/k8s-api/endpoints";
|
|
||||||
import type { KubeObject } from "../../../common/k8s-api/kube-object";
|
|
||||||
import withConfirmationInjectable, { WithConfirmation } from "../confirm-dialog/with-confirm.injectable";
|
|
||||||
import createEditResourceTabInjectable from "../dock/edit-resource/edit-resource-tab.injectable";
|
|
||||||
import { Icon } from "../icon";
|
|
||||||
import { MenuItem } from "../menu";
|
|
||||||
import type { MenuActionsProps } from "../menu/menu-actions";
|
|
||||||
import { MenuActions } from "../menu/menu-actions";
|
|
||||||
import deleteNamespaceInjectable from "./delete-namespace.injectable";
|
|
||||||
import type { NamespaceStore } from "./store";
|
|
||||||
import namespaceStoreInjectable from "./store.injectable";
|
|
||||||
|
|
||||||
export interface NamespaceMenuProps extends MenuActionsProps {
|
|
||||||
namespace: Namespace;
|
|
||||||
}
|
|
||||||
|
|
||||||
interface Dependencies {
|
|
||||||
readonly namespaceStore: NamespaceStore;
|
|
||||||
readonly createEditResourceTab: (kubeObject: KubeObject) => void;
|
|
||||||
readonly withConfirmation: WithConfirmation;
|
|
||||||
readonly deleteNamespace: (namespace: Namespace) => Promise<void>;
|
|
||||||
}
|
|
||||||
|
|
||||||
function NonInjectedNamespaceMenu(props: NamespaceMenuProps & Dependencies) {
|
|
||||||
const { namespace, namespaceStore, deleteNamespace, createEditResourceTab, withConfirmation } = props;
|
|
||||||
|
|
||||||
const remove = async () => {
|
|
||||||
deleteNamespace(namespace);
|
|
||||||
namespaceStore.clearSelected();
|
|
||||||
};
|
|
||||||
|
|
||||||
const renderRemoveMessage = (object: KubeObject) => {
|
|
||||||
return (
|
|
||||||
<p>
|
|
||||||
Remove <b>{object.getName()}</b>?
|
|
||||||
</p>
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
return (
|
|
||||||
<MenuActions {...props}>
|
|
||||||
<MenuItem onClick={() => createEditResourceTab(namespace)}>
|
|
||||||
<Icon material="edit" interactive={false} tooltip="Edit" />
|
|
||||||
<span className="title">Edit</span>
|
|
||||||
</MenuItem>
|
|
||||||
<MenuItem onClick={withConfirmation({
|
|
||||||
message: renderRemoveMessage(namespace),
|
|
||||||
labelOk: "Remove",
|
|
||||||
ok: remove,
|
|
||||||
})}>
|
|
||||||
<Icon material="delete" interactive={false} tooltip="Delete" />
|
|
||||||
<span className="title">Delete</span>
|
|
||||||
</MenuItem>
|
|
||||||
</MenuActions>
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
export const NamespaceMenu = withInjectables<Dependencies, NamespaceMenuProps>(NonInjectedNamespaceMenu, {
|
|
||||||
getProps: (di, props) => ({
|
|
||||||
...props,
|
|
||||||
namespaceStore: di.inject(namespaceStoreInjectable),
|
|
||||||
createEditResourceTab: di.inject(createEditResourceTabInjectable),
|
|
||||||
withConfirmation: di.inject(withConfirmationInjectable),
|
|
||||||
deleteNamespace: di.inject(deleteNamespaceInjectable),
|
|
||||||
}),
|
|
||||||
});
|
|
||||||
@ -17,12 +17,6 @@ import namespaceStoreInjectable from "./store.injectable";
|
|||||||
import { KubeObjectAge } from "../kube-object/age";
|
import { KubeObjectAge } from "../kube-object/age";
|
||||||
import openAddNamepaceDialogInjectable from "./add-dialog/open.injectable";
|
import openAddNamepaceDialogInjectable from "./add-dialog/open.injectable";
|
||||||
import { SubnamespaceBadge } from "./subnamespace-badge";
|
import { SubnamespaceBadge } from "./subnamespace-badge";
|
||||||
import { NamespaceMenu } from "./namespace-menu";
|
|
||||||
import type { OpenConfirmDialog } from "../confirm-dialog/open.injectable";
|
|
||||||
import openConfirmDialogInjectable from "../confirm-dialog/open.injectable";
|
|
||||||
import type { Namespace } from "../../../common/k8s-api/endpoints";
|
|
||||||
import deleteNamespaceInjectable from "./delete-namespace.injectable";
|
|
||||||
import { observer } from "mobx-react";
|
|
||||||
|
|
||||||
enum columnId {
|
enum columnId {
|
||||||
name = "name",
|
name = "name",
|
||||||
@ -34,41 +28,9 @@ enum columnId {
|
|||||||
interface Dependencies {
|
interface Dependencies {
|
||||||
namespaceStore: NamespaceStore;
|
namespaceStore: NamespaceStore;
|
||||||
openAddNamespaceDialog: () => void;
|
openAddNamespaceDialog: () => void;
|
||||||
openConfirmDialog: OpenConfirmDialog;
|
|
||||||
deleteNamespace: (namespace: Namespace) => Promise<void>;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
const NonInjectedNamespacesRoute = observer(({ namespaceStore, openAddNamespaceDialog, openConfirmDialog, deleteNamespace }: Dependencies) => {
|
const NonInjectedNamespacesRoute = ({ namespaceStore, openAddNamespaceDialog }: Dependencies) => (
|
||||||
function onConfirm() {
|
|
||||||
const namespaces = namespaceStore.selectedItems;
|
|
||||||
|
|
||||||
namespaces.forEach(deleteNamespace);
|
|
||||||
}
|
|
||||||
|
|
||||||
const openRemoveNamespaceDialog = () => {
|
|
||||||
const namespaces = namespaceStore.selectedItems;
|
|
||||||
const message = (
|
|
||||||
<div>
|
|
||||||
<>
|
|
||||||
Remove following namespaces?
|
|
||||||
{" "}
|
|
||||||
<div className="confirm-dialog-scrollable-content">
|
|
||||||
{namespaces.map(namespace => (
|
|
||||||
<li key={namespace.getId()}>{namespace.getName()}</li>
|
|
||||||
))}
|
|
||||||
</div>
|
|
||||||
</>
|
|
||||||
</div>
|
|
||||||
);
|
|
||||||
|
|
||||||
openConfirmDialog({
|
|
||||||
ok: onConfirm,
|
|
||||||
labelOk: "Remove",
|
|
||||||
message,
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
return (
|
|
||||||
<TabLayout>
|
<TabLayout>
|
||||||
<KubeObjectListLayout
|
<KubeObjectListLayout
|
||||||
isConfigurable
|
isConfigurable
|
||||||
@ -114,25 +76,16 @@ const NonInjectedNamespacesRoute = observer(({ namespaceStore, openAddNamespaceD
|
|||||||
addRemoveButtons={{
|
addRemoveButtons={{
|
||||||
addTooltip: "Add Namespace",
|
addTooltip: "Add Namespace",
|
||||||
onAdd: openAddNamespaceDialog,
|
onAdd: openAddNamespaceDialog,
|
||||||
onRemove: namespaceStore.selectedItems.length > 0 ? openRemoveNamespaceDialog : undefined,
|
|
||||||
}}
|
}}
|
||||||
renderItemMenu={namespace => (
|
|
||||||
<NamespaceMenu
|
|
||||||
namespace={namespace}
|
|
||||||
/>
|
|
||||||
)}
|
|
||||||
/>
|
/>
|
||||||
<AddNamespaceDialog/>
|
<AddNamespaceDialog/>
|
||||||
</TabLayout>
|
</TabLayout>
|
||||||
);
|
);
|
||||||
});
|
|
||||||
|
|
||||||
|
|
||||||
export const NamespacesRoute = withInjectables<Dependencies>(NonInjectedNamespacesRoute, {
|
export const NamespacesRoute = withInjectables<Dependencies>(NonInjectedNamespacesRoute, {
|
||||||
getProps: (di) => ({
|
getProps: (di) => ({
|
||||||
namespaceStore: di.inject(namespaceStoreInjectable),
|
namespaceStore: di.inject(namespaceStoreInjectable),
|
||||||
openAddNamespaceDialog: di.inject(openAddNamepaceDialogInjectable),
|
openAddNamespaceDialog: di.inject(openAddNamepaceDialogInjectable),
|
||||||
openConfirmDialog: di.inject(openConfirmDialogInjectable),
|
|
||||||
deleteNamespace: di.inject(deleteNamespaceInjectable),
|
|
||||||
}),
|
}),
|
||||||
});
|
});
|
||||||
@ -41,11 +41,6 @@
|
|||||||
font-size: small;
|
font-size: small;
|
||||||
margin-top: $margin;
|
margin-top: $margin;
|
||||||
}
|
}
|
||||||
|
|
||||||
.confirm-dialog-scrollable-content {
|
|
||||||
overflow: auto;
|
|
||||||
max-height: 200px;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
.confirm-buttons {
|
.confirm-buttons {
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user