mirror of
https://github.com/lensapp/lens.git
synced 2025-05-20 05:10:56 +00:00
Move Hotbar types to seperate file (#3532)
This commit is contained in:
1 parent
77077ef72c
commit
3fe8014f11
8 files changed
+82
-73
No files matched your search
@@ -20,20 +20,14 @@
|
||||
*/
|
||||
|
||||
// Cleans up a store that had the state related data stored
|
||||
import { Hotbar, HotbarStore } from "../../common/hotbar-store";
|
||||
import * as uuid from "uuid";
|
||||
import type { MigrationDeclaration } from "../helpers";
|
||||
import { catalogEntity } from "../../main/catalog-sources/general";
|
||||
import { getEmptyHotbar } from "../../common/hotbar-types";
|
||||
|
||||
export default {
|
||||
version: "5.0.0-alpha.0",
|
||||
run(store) {
|
||||
const hotbar: Hotbar = {
|
||||
id: uuid.v4(),
|
||||
name: "default",
|
||||
items: HotbarStore.getInitialItems(),
|
||||
};
|
||||
|
||||
const hotbar = getEmptyHotbar("default");
|
||||
const { metadata: { uid, name, source } } = catalogEntity;
|
||||
|
||||
hotbar.items[0] = { entity: { uid, name, source } };
|
||||
|
||||
@@ -20,7 +20,7 @@
|
||||
*/
|
||||
|
||||
// Cleans up a store that had the state related data stored
|
||||
import type { Hotbar } from "../../common/hotbar-store";
|
||||
import type { Hotbar } from "../../common/hotbar-types";
|
||||
import * as uuid from "uuid";
|
||||
import type { MigrationDeclaration } from "../helpers";
|
||||
|
||||
|
||||
@@ -25,7 +25,7 @@ import { isNull } from "lodash";
|
||||
import path from "path";
|
||||
import * as uuid from "uuid";
|
||||
import type { ClusterStoreModel } from "../../common/cluster-store";
|
||||
import { defaultHotbarCells, Hotbar, HotbarStore } from "../../common/hotbar-store";
|
||||
import { defaultHotbarCells, getEmptyHotbar, Hotbar, HotbarItem } from "../../common/hotbar-types";
|
||||
import { catalogEntity } from "../../main/catalog-sources/general";
|
||||
import { MigrationDeclaration, migrationLog } from "../helpers";
|
||||
import { generateNewIdFor } from "../utils";
|
||||
@@ -37,6 +37,12 @@ interface Pre500WorkspaceStoreModel {
|
||||
}[];
|
||||
}
|
||||
|
||||
interface PartialHotbar {
|
||||
id: string;
|
||||
name: string;
|
||||
items: (null | HotbarItem)[];
|
||||
}
|
||||
|
||||
export default {
|
||||
version: "5.0.0-beta.10",
|
||||
run(store) {
|
||||
@@ -46,7 +52,7 @@ export default {
|
||||
try {
|
||||
const workspaceStoreData: Pre500WorkspaceStoreModel = fse.readJsonSync(path.join(userDataPath, "lens-workspace-store.json"));
|
||||
const { clusters }: ClusterStoreModel = fse.readJSONSync(path.join(userDataPath, "lens-cluster-store.json"));
|
||||
const workspaceHotbars = new Map<string, Hotbar>(); // mapping from WorkspaceId to HotBar
|
||||
const workspaceHotbars = new Map<string, PartialHotbar>(); // mapping from WorkspaceId to HotBar
|
||||
|
||||
for (const { id, name } of workspaceStoreData.workspaces) {
|
||||
migrationLog(`Creating new hotbar for ${name}`);
|
||||
@@ -103,7 +109,7 @@ export default {
|
||||
hotbar.items.push(null);
|
||||
}
|
||||
|
||||
hotbars.push(hotbar);
|
||||
hotbars.push(hotbar as Hotbar);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -123,11 +129,7 @@ export default {
|
||||
if (freeIndex === -1) {
|
||||
// making a new hotbar is less destructive if the first hotbar
|
||||
// called "default" is full than overriding a hotbar item
|
||||
const hotbar = {
|
||||
id: uuid.v4(),
|
||||
name: "initial",
|
||||
items: HotbarStore.getInitialItems(),
|
||||
};
|
||||
const hotbar = getEmptyHotbar("initial");
|
||||
|
||||
hotbar.items[0] = { entity: { uid, name, source } };
|
||||
hotbars.unshift(hotbar);
|
||||
@@ -135,11 +137,7 @@ export default {
|
||||
defaultHotbar.items[freeIndex] = { entity: { uid, name, source } };
|
||||
}
|
||||
} else {
|
||||
const hotbar = {
|
||||
id: uuid.v4(),
|
||||
name: "default",
|
||||
items: HotbarStore.getInitialItems(),
|
||||
};
|
||||
const hotbar = getEmptyHotbar("default");
|
||||
|
||||
hotbar.items[0] = { entity: { uid, name, source } };
|
||||
hotbars.unshift(hotbar);
|
||||
|
||||
@@ -19,7 +19,7 @@
|
||||
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
*/
|
||||
|
||||
import type { Hotbar } from "../../common/hotbar-store";
|
||||
import type { Hotbar } from "../../common/hotbar-types";
|
||||
import { catalogEntityRegistry } from "../../main/catalog";
|
||||
import type { MigrationDeclaration } from "../helpers";
|
||||
|
||||
|
||||
Reference in new issue
Block a user