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);
|
clusterStore.addCluster(...newClusters);
|
||||||
if (newClusters.length === 1) {
|
if (newClusters.length === 1) {
|
||||||
const clusterId = newClusters[0].id;
|
const clusterId = newClusters[0].id;
|
||||||
const wsId = workspaceStore.currentWorkspace.id;
|
|
||||||
clusterStore.setActive(clusterId);
|
clusterStore.setActive(clusterId);
|
||||||
workspaceStore.setLastActiveClusterId(wsId, clusterStore.activeClusterId);
|
workspaceStore.setLastActiveClusterId(workspaceStore.currentWorkspaceId, clusterStore.activeClusterId);
|
||||||
navigate(clusterViewURL({ params: { clusterId } }));
|
navigate(clusterViewURL({ params: { clusterId } }));
|
||||||
} else {
|
} else {
|
||||||
Notifications.ok(
|
Notifications.ok(
|
||||||
|
|||||||
@ -20,7 +20,7 @@ export class WorkspaceMenu extends React.Component<Props> {
|
|||||||
|
|
||||||
activateWorkspace = (id: WorkspaceId) => {
|
activateWorkspace = (id: WorkspaceId) => {
|
||||||
if (clusterStore.activeClusterId) {
|
if (clusterStore.activeClusterId) {
|
||||||
workspaceStore.setLastActiveClusterId(workspaceStore.currentWorkspace.id, clusterStore.activeClusterId);
|
workspaceStore.setLastActiveClusterId(workspaceStore.currentWorkspaceId, clusterStore.activeClusterId);
|
||||||
}
|
}
|
||||||
workspaceStore.setActive(id);
|
workspaceStore.setActive(id);
|
||||||
}
|
}
|
||||||
|
|||||||
@ -29,9 +29,8 @@ interface Props {
|
|||||||
@observer
|
@observer
|
||||||
export class ClustersMenu extends React.Component<Props> {
|
export class ClustersMenu extends React.Component<Props> {
|
||||||
showCluster = (clusterId: ClusterId) => {
|
showCluster = (clusterId: ClusterId) => {
|
||||||
const wsId = workspaceStore.currentWorkspace.id;
|
|
||||||
if(clusterId) {
|
if(clusterId) {
|
||||||
workspaceStore.setLastActiveClusterId(wsId, clusterId);
|
workspaceStore.setLastActiveClusterId(workspaceStore.currentWorkspaceId, clusterId);
|
||||||
}
|
}
|
||||||
clusterStore.setActive(clusterId);
|
clusterStore.setActive(clusterId);
|
||||||
navigate(clusterViewURL({ params: { clusterId } }));
|
navigate(clusterViewURL({ params: { clusterId } }));
|
||||||
@ -61,11 +60,10 @@ export class ClustersMenu extends React.Component<Props> {
|
|||||||
menu.append(new MenuItem({
|
menu.append(new MenuItem({
|
||||||
label: _i18n._(t`Disconnect`),
|
label: _i18n._(t`Disconnect`),
|
||||||
click: async () => {
|
click: async () => {
|
||||||
const wsId = workspaceStore.currentWorkspace.id;
|
|
||||||
const wsLastActiveClusterId = workspaceStore.currentWorkspace.lastActiveClusterId
|
const wsLastActiveClusterId = workspaceStore.currentWorkspace.lastActiveClusterId
|
||||||
if (clusterStore.isActive(cluster.id)) {
|
if (clusterStore.isActive(cluster.id)) {
|
||||||
if (wsLastActiveClusterId === cluster.id) {
|
if (wsLastActiveClusterId === cluster.id) {
|
||||||
workspaceStore.setLastActiveClusterId(wsId, "");
|
workspaceStore.setLastActiveClusterId(workspaceStore.currentWorkspaceId, "");
|
||||||
}
|
}
|
||||||
navigate(landingURL());
|
navigate(landingURL());
|
||||||
clusterStore.setActive(null);
|
clusterStore.setActive(null);
|
||||||
@ -84,11 +82,10 @@ export class ClustersMenu extends React.Component<Props> {
|
|||||||
label: _i18n._(t`Remove`),
|
label: _i18n._(t`Remove`),
|
||||||
},
|
},
|
||||||
ok: () => {
|
ok: () => {
|
||||||
const wsId = workspaceStore.currentWorkspace.id;
|
|
||||||
const wsLastActiveClusterId = workspaceStore.currentWorkspace.lastActiveClusterId
|
const wsLastActiveClusterId = workspaceStore.currentWorkspace.lastActiveClusterId
|
||||||
|
|
||||||
if (wsLastActiveClusterId === cluster.id) {
|
if (wsLastActiveClusterId === cluster.id) {
|
||||||
workspaceStore.setLastActiveClusterId(wsId, "");
|
workspaceStore.setLastActiveClusterId(workspaceStore.currentWorkspaceId, "");
|
||||||
}
|
}
|
||||||
if (clusterStore.activeClusterId === cluster.id) {
|
if (clusterStore.activeClusterId === cluster.id) {
|
||||||
navigate(landingURL());
|
navigate(landingURL());
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user