mirror of
https://github.com/lensapp/lens.git
synced 2025-05-20 05:10:56 +00:00
Refactored to use observable field
Signed-off-by: Steve Richards <srichards@mirantis.com>
This commit is contained in:
parent
d8f972a02e
commit
8adf683056
@ -146,9 +146,8 @@ export class AddCluster extends React.Component {
|
||||
clusterStore.addCluster(...newClusters);
|
||||
if (newClusters.length === 1) {
|
||||
const clusterId = newClusters[0].id;
|
||||
const wsId = workspaceStore.currentWorkspace.id;
|
||||
clusterStore.setActive(clusterId);
|
||||
workspaceStore.setLastActiveClusterId(wsId, clusterStore.activeClusterId);
|
||||
workspaceStore.setLastActiveClusterId(workspaceStore.currentWorkspaceId, clusterStore.activeClusterId);
|
||||
navigate(clusterViewURL({ params: { clusterId } }));
|
||||
} else {
|
||||
Notifications.ok(
|
||||
|
||||
@ -20,7 +20,7 @@ export class WorkspaceMenu extends React.Component<Props> {
|
||||
|
||||
activateWorkspace = (id: WorkspaceId) => {
|
||||
if (clusterStore.activeClusterId) {
|
||||
workspaceStore.setLastActiveClusterId(workspaceStore.currentWorkspace.id, clusterStore.activeClusterId);
|
||||
workspaceStore.setLastActiveClusterId(workspaceStore.currentWorkspaceId, clusterStore.activeClusterId);
|
||||
}
|
||||
workspaceStore.setActive(id);
|
||||
}
|
||||
|
||||
@ -29,9 +29,8 @@ interface Props {
|
||||
@observer
|
||||
export class ClustersMenu extends React.Component<Props> {
|
||||
showCluster = (clusterId: ClusterId) => {
|
||||
const wsId = workspaceStore.currentWorkspace.id;
|
||||
if(clusterId) {
|
||||
workspaceStore.setLastActiveClusterId(wsId, clusterId);
|
||||
workspaceStore.setLastActiveClusterId(workspaceStore.currentWorkspaceId, clusterId);
|
||||
}
|
||||
clusterStore.setActive(clusterId);
|
||||
navigate(clusterViewURL({ params: { clusterId } }));
|
||||
@ -61,11 +60,10 @@ export class ClustersMenu extends React.Component<Props> {
|
||||
menu.append(new MenuItem({
|
||||
label: _i18n._(t`Disconnect`),
|
||||
click: async () => {
|
||||
const wsId = workspaceStore.currentWorkspace.id;
|
||||
const wsLastActiveClusterId = workspaceStore.currentWorkspace.lastActiveClusterId
|
||||
if (clusterStore.isActive(cluster.id)) {
|
||||
if (wsLastActiveClusterId === cluster.id) {
|
||||
workspaceStore.setLastActiveClusterId(wsId, "");
|
||||
workspaceStore.setLastActiveClusterId(workspaceStore.currentWorkspaceId, "");
|
||||
}
|
||||
navigate(landingURL());
|
||||
clusterStore.setActive(null);
|
||||
@ -84,11 +82,10 @@ export class ClustersMenu extends React.Component<Props> {
|
||||
label: _i18n._(t`Remove`),
|
||||
},
|
||||
ok: () => {
|
||||
const wsId = workspaceStore.currentWorkspace.id;
|
||||
const wsLastActiveClusterId = workspaceStore.currentWorkspace.lastActiveClusterId
|
||||
|
||||
if (wsLastActiveClusterId === cluster.id) {
|
||||
workspaceStore.setLastActiveClusterId(wsId, "");
|
||||
workspaceStore.setLastActiveClusterId(workspaceStore.currentWorkspaceId, "");
|
||||
}
|
||||
if (clusterStore.activeClusterId === cluster.id) {
|
||||
navigate(landingURL());
|
||||
|
||||
Loading…
Reference in New Issue
Block a user