* Final phase before the complete cutover * NP migration * lint fix * More NP stuff * Moved Stack Monitoring client plugin outside legacy and fixed all tests * ... * Removed unused files * Fix for main links * Fixed more tests * Fixed redirect when clicking on SM icon again * Code review feedback * Addressed code review feedback * Fixed return value
32 lines
860 B
JavaScript
32 lines
860 B
JavaScript
/*
|
|
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
|
|
* or more contributor license agreements. Licensed under the Elastic License;
|
|
* you may not use this file except in compliance with the Elastic License.
|
|
*/
|
|
|
|
import _ from 'lodash';
|
|
|
|
export function getClusterFromClusters(clusters, globalState) {
|
|
const cluster = (() => {
|
|
const existingCurrent = _.find(clusters, { cluster_uuid: globalState.cluster_uuid });
|
|
if (existingCurrent) {
|
|
return existingCurrent;
|
|
}
|
|
|
|
const firstCluster = _.first(clusters);
|
|
if (firstCluster && firstCluster.cluster_uuid) {
|
|
return firstCluster;
|
|
}
|
|
|
|
return null;
|
|
})();
|
|
|
|
if (cluster && cluster.license) {
|
|
globalState.cluster_uuid = cluster.cluster_uuid;
|
|
globalState.ccs = cluster.ccs;
|
|
globalState.save();
|
|
return cluster;
|
|
}
|
|
|
|
return null;
|
|
}
|