1
0
mirror of https://github.com/lensapp/lens.git synced 2025-05-20 05:10:56 +00:00
lens/src/migrations/hotbar-store/5.0.0-alpha.0.ts
Alex Andreev 3a2b8eb4b8 Migration for adding extra data to hotbar items
Signed-off-by: Alex Andreev <alex.andreev.email@gmail.com>
2021-05-07 14:19:39 +03:00

33 lines
811 B
TypeScript

// Cleans up a store that had the state related data stored
import { Hotbar } from "../../common/hotbar-store";
import { ClusterStore } from "../../common/cluster-store";
import { migration } from "../migration-wrapper";
import { v4 as uuid } from "uuid";
export default migration({
version: "5.0.0-alpha.0",
run(store) {
const hotbars: Hotbar[] = [];
ClusterStore.getInstance().clustersList.forEach((cluster: any) => {
const name = cluster.workspace;
if (!name) return;
let hotbar = hotbars.find((h) => h.name === name);
if (!hotbar) {
hotbar = { id: uuid(), name, items: [] };
hotbars.push(hotbar);
}
hotbar.items.push({
entity: { uid: cluster.id },
params: {}
});
});
store.set("hotbars", hotbars);
}
});