@@ -432,23 +432,12 @@ const _switchToNewWorkspace = function () {
432
432
} ;
433
433
434
434
/**
435
- * Switch to the specified cluster.
436
- * @param {string } clusterId ID of the cluster in Lens.
437
- * @param {string } [workspaceId] Optional ID of the workspace that contains the
438
- * cluster. If specified, this workspace will be activated before the cluster
439
- * is activated.
435
+ * [ASYNC] Switch to the specified cluster (and associated workspace).
436
+ * @param {string } clusterId ID of the cluster in Lens. Can be in any workspace,
437
+ * even if it's not the active one.
440
438
*/
441
- const _switchToCluster = function ( clusterId , workspaceId ) {
442
- if ( workspaceId ) {
443
- Store . workspaceStore . setActive ( workspaceId ) ;
444
- }
445
-
446
- Store . clusterStore . activeClusterId = clusterId ;
447
- // TODO: doesn't __always__ work; bug in Lens somewhere, and feels like clusterStore
448
- // should have setActive(clusterId) like workspaceStore.setActive() and have it do
449
- // the navigation in a consistent way.
450
- // TRACKING: https://github.com/Mirantis/lens-extension-cc/issues/26
451
- extension . navigate ( `/cluster/${ clusterId } ` ) ;
439
+ const _switchToCluster = async function ( clusterId ) {
440
+ await Store . workspaceStore . setActiveCluster ( clusterId ) ;
452
441
} ;
453
442
454
443
/**
@@ -796,6 +785,7 @@ const _addKubeCluster = async function ({
796
785
_switchToNewWorkspace ( ) ;
797
786
}
798
787
788
+ // NOTE: this is async but we don't need to wait on it
799
789
_switchToCluster ( clusterId ) ;
800
790
}
801
791
}
@@ -820,6 +810,7 @@ const _activateCluster = function ({ namespace, clusterName, clusterId }) {
820
810
const lensCluster = _getLensCluster ( clusterId ) ;
821
811
822
812
if ( lensCluster ) {
813
+ // NOTE: this is async but we don't need to wait on it
823
814
_switchToCluster ( clusterId , lensCluster . workspace ) ;
824
815
} else {
825
816
pr . error = strings . clusterActionsProvider . error . clusterNotFound (
@@ -1003,10 +994,8 @@ export const useClusterActions = function () {
1003
994
} ;
1004
995
1005
996
export const ClusterActionsProvider = function ( {
1006
- extension : lensExtension ,
1007
997
...props
1008
998
} ) {
1009
- extension = lensExtension ;
1010
999
1011
1000
// NOTE: since the state is passed directly (by reference) into the context
1012
1001
// returned by the provider, even the initial state should be a clone of the
0 commit comments