1
0
mirror of https://github.com/lensapp/lens.git synced 2025-05-20 05:10:56 +00:00

Migration for adding extra data to hotbar items

Signed-off-by: Alex Andreev <alex.andreev.email@gmail.com>
This commit is contained in:
Alex Andreev 2021-05-07 14:19:39 +03:00
parent c679a88ff1
commit 3a2b8eb4b8
2 changed files with 31 additions and 5 deletions

View File

@ -22,11 +22,7 @@ export default migration({
}
hotbar.items.push({
entity: {
uid: cluster.id,
name: cluster.name,
source: cluster.source
},
entity: { uid: cluster.id },
params: {}
});
});

View File

@ -0,0 +1,30 @@
import { Hotbar } from "../../common/hotbar-store";
import { migration } from "../migration-wrapper";
import { catalogEntityRegistry } from "../../renderer/api/catalog-entity-registry";
export default migration({
version: "5.0.0-beta.4",
run(store) {
const hotbars: Hotbar[] = store.get("hotbars");
hotbars.forEach((hotbar, hotbarIndex) => {
hotbar.items.forEach((item, itemIndex) => {
const entity = catalogEntityRegistry.items.find((entity) => entity.metadata.uid === item?.entity.uid);
if (!entity) {
// Clear disabled item
hotbars[hotbarIndex].items[itemIndex] = null;
} else {
// Save additional data
hotbars[hotbarIndex].items[itemIndex].entity = {
...item.entity,
name: entity.metadata.name,
source: entity.metadata.source
};
}
});
});
store.set("hotbars", hotbars);
}
});