1
0
mirror of https://github.com/lensapp/lens.git synced 2025-05-20 05:10:56 +00:00

auto-enable only objects without ownerRef

Signed-off-by: Jari Kolehmainen <jari.kolehmainen@gmail.com>
This commit is contained in:
Jari Kolehmainen 2020-11-30 20:59:59 +02:00
parent 9271c23dc0
commit 7d805d81a1
3 changed files with 29 additions and 23 deletions

View File

@ -205,7 +205,9 @@ export class ClusterStore extends BaseStore<ClusterStoreModel> {
if (!(model instanceof Cluster)) { if (!(model instanceof Cluster)) {
cluster = new Cluster(model); cluster = new Cluster(model);
} }
cluster.enabled = true; if (!cluster.isManaged) {
cluster.enabled = true;
}
this.clusters.set(model.id, cluster); this.clusters.set(model.id, cluster);
return cluster; return cluster;
} }

View File

@ -94,7 +94,6 @@ export class WorkspaceStore extends BaseStore<WorkspaceStoreModel> {
if (ipcRenderer) { if (ipcRenderer) {
logger.info("[WORKSPACE-STORE] requesting initial state sync"); logger.info("[WORKSPACE-STORE] requesting initial state sync");
const workspaceStates: workspaceStateSync[] = await requestMain(this.stateRequestChannel); const workspaceStates: workspaceStateSync[] = await requestMain(this.stateRequestChannel);
console.log(workspaceStates);
workspaceStates.forEach((workspaceState) => { workspaceStates.forEach((workspaceState) => {
const workspace = this.getById(workspaceState.id); const workspace = this.getById(workspaceState.id);
if (workspace) { if (workspace) {
@ -182,7 +181,10 @@ export class WorkspaceStore extends BaseStore<WorkspaceStoreModel> {
return; return;
} }
this.workspaces.set(id, workspace); this.workspaces.set(id, workspace);
workspace.enabled = true; if (!workspace.isManaged) {
workspace.enabled = true;
}
appEventBus.emit({name: "workspace", action: "add"}); appEventBus.emit({name: "workspace", action: "add"});
return workspace; return workspace;
} }

View File

@ -65,26 +65,28 @@ export class ClustersMenu extends React.Component<Props> {
} }
})); }));
} }
menu.append(new MenuItem({ if (!cluster.isManaged) {
label: _i18n._(t`Remove`), menu.append(new MenuItem({
click: () => { label: _i18n._(t`Remove`),
ConfirmDialog.open({ click: () => {
okButtonProps: { ConfirmDialog.open({
primary: false, okButtonProps: {
accent: true, primary: false,
label: _i18n._(t`Remove`), accent: true,
}, label: _i18n._(t`Remove`),
ok: () => { },
if (clusterStore.activeClusterId === cluster.id) { ok: () => {
navigate(landingURL()); if (clusterStore.activeClusterId === cluster.id) {
clusterStore.setActive(null); navigate(landingURL());
} clusterStore.setActive(null);
clusterStore.removeById(cluster.id); }
}, clusterStore.removeById(cluster.id);
message: <p>Are you sure want to remove cluster <b title={cluster.id}>{cluster.contextName}</b>?</p>, },
}); message: <p>Are you sure want to remove cluster <b title={cluster.id}>{cluster.contextName}</b>?</p>,
} });
})); }
}));
}
menu.popup({ menu.popup({
window: remote.getCurrentWindow() window: remote.getCurrentWindow()
}); });