mirror of
https://github.com/lensapp/lens.git
synced 2025-05-20 05:10:56 +00:00
Lens app source code (#119)
Signed-off-by: Jari Kolehmainen <jari.kolehmainen@gmail.com>
This commit is contained in:
1 parent
936cbd53d4
commit
1d0815abd2
797 files changed
+73714
-215
No files matched your search
@@ -0,0 +1,93 @@
|
||||
import "./role-bindings.scss"
|
||||
|
||||
import * as React from "react";
|
||||
import { observer } from "mobx-react";
|
||||
import { Trans } from "@lingui/macro";
|
||||
import { RouteComponentProps } from "react-router";
|
||||
import { Icon } from "../icon";
|
||||
import { IRoleBindingsRouteParams } from "../+user-management/user-management.routes";
|
||||
import { KubeObjectMenu, KubeObjectMenuProps } from "../kube-object/kube-object-menu";
|
||||
import { clusterRoleBindingApi, RoleBinding, roleBindingApi } from "../../api/endpoints";
|
||||
import { roleBindingsStore } from "./role-bindings.store";
|
||||
import { KubeObjectListLayout } from "../kube-object";
|
||||
import { AddRoleBindingDialog } from "./add-role-binding-dialog";
|
||||
import { KubeObject } from "../../api/kube-object";
|
||||
import { apiManager } from "../../api/api-manager";
|
||||
|
||||
enum sortBy {
|
||||
name = "name",
|
||||
namespace = "namespace",
|
||||
bindings = "bindings",
|
||||
age = "age",
|
||||
}
|
||||
|
||||
interface Props extends RouteComponentProps<IRoleBindingsRouteParams> {
|
||||
}
|
||||
|
||||
@observer
|
||||
export class RoleBindings extends React.Component<Props> {
|
||||
render() {
|
||||
return (
|
||||
<KubeObjectListLayout
|
||||
className="RoleBindings"
|
||||
store={roleBindingsStore}
|
||||
sortingCallbacks={{
|
||||
[sortBy.name]: (binding: RoleBinding) => binding.getName(),
|
||||
[sortBy.namespace]: (binding: RoleBinding) => binding.getNs(),
|
||||
[sortBy.bindings]: (binding: RoleBinding) => binding.getSubjectNames(),
|
||||
[sortBy.age]: (binding: RoleBinding) => binding.getAge(false),
|
||||
}}
|
||||
searchFilters={[
|
||||
(binding: RoleBinding) => binding.getSearchFields(),
|
||||
(binding: RoleBinding) => binding.getSubjectNames(),
|
||||
]}
|
||||
renderHeaderTitle={<Trans>Role Bindings</Trans>}
|
||||
filterItems={[
|
||||
(items: RoleBinding[]) => items.filter(KubeObject.isNonSystem),
|
||||
]}
|
||||
customizeHeader={({ info }) => ({
|
||||
info: (
|
||||
<>
|
||||
{info}
|
||||
<Icon
|
||||
small
|
||||
material="help_outline"
|
||||
className="help-icon"
|
||||
tooltip={<Trans>Excluded items with "system:" prefix</Trans>}
|
||||
/>
|
||||
</>
|
||||
)
|
||||
})}
|
||||
renderTableHeader={[
|
||||
{ title: <Trans>Name</Trans>, className: "name", sortBy: sortBy.name },
|
||||
{ title: <Trans>Bindings</Trans>, className: "bindings", sortBy: sortBy.bindings },
|
||||
{ title: <Trans>Namespace</Trans>, className: "namespace", sortBy: sortBy.namespace },
|
||||
{ title: <Trans>Age</Trans>, className: "age", sortBy: sortBy.age },
|
||||
]}
|
||||
renderTableContents={(binding: RoleBinding) => [
|
||||
binding.getName(),
|
||||
binding.getSubjectNames(),
|
||||
binding.getNs() || "-",
|
||||
binding.getAge(),
|
||||
]}
|
||||
renderItemMenu={(item: RoleBinding) => {
|
||||
return <RoleBindingMenu object={item}/>
|
||||
}}
|
||||
addRemoveButtons={{
|
||||
onAdd: () => AddRoleBindingDialog.open(),
|
||||
addTooltip: <Trans>Create new RoleBinding</Trans>,
|
||||
}}
|
||||
/>
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
export function RoleBindingMenu(props: KubeObjectMenuProps<RoleBinding>) {
|
||||
return (
|
||||
<KubeObjectMenu {...props}/>
|
||||
)
|
||||
}
|
||||
|
||||
apiManager.registerViews([roleBindingApi, clusterRoleBindingApi], {
|
||||
Menu: RoleBindingMenu,
|
||||
})
|
||||
Reference in new issue
Block a user