mirror of
https://github.com/lensapp/lens.git
synced 2025-05-20 05:10:56 +00:00
Add eslint rule padding-line-between-statements (#1593)
Signed-off-by: Panu Horsmalahti <phorsmalahti@mirantis.com>
This commit is contained in:
1 parent
7b77f18376
commit
dcf253e7d5
401 files changed
+2018
-40
No files matched your search
@@ -80,6 +80,7 @@ export class AddRoleBindingDialog extends React.Component<Props> {
|
||||
rolesStore,
|
||||
serviceAccountsStore,
|
||||
];
|
||||
|
||||
this.isLoading = true;
|
||||
await Promise.all(stores.map(store => store.loadAll()));
|
||||
this.isLoading = false;
|
||||
@@ -91,6 +92,7 @@ export class AddRoleBindingDialog extends React.Component<Props> {
|
||||
if (this.roleBinding) {
|
||||
const { name, kind } = this.roleBinding.roleRef;
|
||||
const role = rolesStore.items.find(role => role.kind === kind && role.getName() === name);
|
||||
|
||||
if (role) {
|
||||
this.selectedRoleId = role.getId();
|
||||
this.bindContext = role.getNs() || "";
|
||||
@@ -107,6 +109,7 @@ export class AddRoleBindingDialog extends React.Component<Props> {
|
||||
onBindContextChange = (namespace: string) => {
|
||||
this.bindContext = namespace;
|
||||
const roleContext = this.selectedRole && this.selectedRole.getNs() || "";
|
||||
|
||||
if (this.bindContext && this.bindContext !== roleContext) {
|
||||
this.selectedRoleId = ""; // reset previously selected role for specific context
|
||||
}
|
||||
@@ -123,11 +126,13 @@ export class AddRoleBindingDialog extends React.Component<Props> {
|
||||
namespace: item.getNs(),
|
||||
};
|
||||
}
|
||||
|
||||
return item;
|
||||
});
|
||||
|
||||
try {
|
||||
let roleBinding: RoleBinding;
|
||||
|
||||
if (this.isEditing) {
|
||||
roleBinding = await roleBindingsStore.updateSubjects({
|
||||
roleBinding: this.roleBinding,
|
||||
@@ -136,6 +141,7 @@ export class AddRoleBindingDialog extends React.Component<Props> {
|
||||
}
|
||||
else {
|
||||
const name = useRoleForBindingName ? selectedRole.getName() : bindingName;
|
||||
|
||||
roleBinding = await roleBindingsStore.create({ name, namespace }, {
|
||||
subjects,
|
||||
roleRef: {
|
||||
@@ -153,13 +159,16 @@ export class AddRoleBindingDialog extends React.Component<Props> {
|
||||
|
||||
@computed get roleOptions(): BindingSelectOption[] {
|
||||
let roles = rolesStore.items as Role[];
|
||||
|
||||
if (this.bindContext) {
|
||||
// show only cluster-roles or roles for selected context namespace
|
||||
roles = roles.filter(role => !role.getNs() || role.getNs() === this.bindContext);
|
||||
}
|
||||
|
||||
return roles.map(role => {
|
||||
const name = role.getName();
|
||||
const namespace = role.getNs();
|
||||
|
||||
return {
|
||||
value: role.getId(),
|
||||
label: name + (namespace ? ` (${namespace})` : "")
|
||||
@@ -171,6 +180,7 @@ export class AddRoleBindingDialog extends React.Component<Props> {
|
||||
return serviceAccountsStore.items.map(account => {
|
||||
const name = account.getName();
|
||||
const namespace = account.getNs();
|
||||
|
||||
return {
|
||||
item: account,
|
||||
value: name,
|
||||
@@ -181,6 +191,7 @@ export class AddRoleBindingDialog extends React.Component<Props> {
|
||||
|
||||
renderContents() {
|
||||
const unwrapBindings = (options: BindingSelectOption[]) => options.map(option => option.item || option.subject);
|
||||
|
||||
return (
|
||||
<>
|
||||
<SubTitle title={<Trans>Context</Trans>}/>
|
||||
@@ -257,6 +268,7 @@ export class AddRoleBindingDialog extends React.Component<Props> {
|
||||
);
|
||||
const disableNext = this.isLoading || !selectedRole || !selectedBindings.length;
|
||||
const nextLabel = isEditing ? <Trans>Update</Trans> : <Trans>Create</Trans>;
|
||||
|
||||
return (
|
||||
<Dialog
|
||||
{...dialogProps}
|
||||
|
||||
@@ -36,6 +36,7 @@ export class RoleBindingDetails extends React.Component<Props> {
|
||||
selectSubject(subject: IRoleBindingSubject) {
|
||||
const { selectedSubjects } = this;
|
||||
const isSelected = selectedSubjects.includes(subject);
|
||||
|
||||
selectedSubjects.replace(
|
||||
isSelected
|
||||
? selectedSubjects.filter(sub => sub !== subject) // unselect
|
||||
@@ -47,6 +48,7 @@ export class RoleBindingDetails extends React.Component<Props> {
|
||||
removeSelectedSubjects() {
|
||||
const { object: roleBinding } = this.props;
|
||||
const { selectedSubjects } = this;
|
||||
|
||||
ConfirmDialog.open({
|
||||
ok: () => roleBindingsStore.updateSubjects({ roleBinding, removeSubjects: selectedSubjects }),
|
||||
labelOk: _i18n._(t`Remove`),
|
||||
@@ -59,12 +61,14 @@ export class RoleBindingDetails extends React.Component<Props> {
|
||||
render() {
|
||||
const { selectedSubjects } = this;
|
||||
const { object: roleBinding } = this.props;
|
||||
|
||||
if (!roleBinding) {
|
||||
return null;
|
||||
}
|
||||
const name = roleBinding.getName();
|
||||
const { roleRef } = roleBinding;
|
||||
const subjects = roleBinding.getSubjects();
|
||||
|
||||
return (
|
||||
<div className="RoleBindingDetails">
|
||||
<KubeObjectMeta object={roleBinding}/>
|
||||
@@ -96,6 +100,7 @@ export class RoleBindingDetails extends React.Component<Props> {
|
||||
subjects.map((subject, i) => {
|
||||
const { kind, name, namespace } = subject;
|
||||
const isSelected = selectedSubjects.includes(subject);
|
||||
|
||||
return (
|
||||
<TableRow
|
||||
key={i} selected={isSelected}
|
||||
|
||||
@@ -22,6 +22,7 @@ export class RoleBindingsStore extends KubeObjectStore<RoleBinding> {
|
||||
|
||||
protected loadItem(params: { name: string; namespace?: string }) {
|
||||
if (params.namespace) return roleBindingApi.get(params);
|
||||
|
||||
return clusterRoleBindingApi.get(params);
|
||||
}
|
||||
|
||||
@@ -52,6 +53,7 @@ export class RoleBindingsStore extends KubeObjectStore<RoleBinding> {
|
||||
const { roleBinding, addSubjects, removeSubjects } = params;
|
||||
const currentSubjects = roleBinding.getSubjects();
|
||||
let newSubjects = currentSubjects;
|
||||
|
||||
if (addSubjects) {
|
||||
newSubjects = uniqBy(currentSubjects.concat(addSubjects), ({ kind, name, namespace }) => {
|
||||
return [kind, name, namespace].join("-");
|
||||
@@ -59,6 +61,7 @@ export class RoleBindingsStore extends KubeObjectStore<RoleBinding> {
|
||||
} else if (removeSubjects) {
|
||||
newSubjects = difference(currentSubjects, removeSubjects);
|
||||
}
|
||||
|
||||
return this.update(roleBinding, {
|
||||
roleRef: roleBinding.roleRef,
|
||||
subjects: newSubjects
|
||||
|
||||
Reference in new issue
Block a user