"Fossies" - the Fresh Open Source Software Archive

Member "lens-6.2.5/src/migrations/hotbar-store/5.0.0-alpha.2.ts" (6 Dec 2022, 679 Bytes) of package /linux/misc/lens-6.2.5.tar.gz:


As a special service "Fossies" has tried to format the requested source page into HTML format using (guessed) TypeScript source code syntax highlighting (style: standard) with prefixed line numbers and code folding option. Alternatively you can here view or download the uninterpreted source code file.

    1 /**
    2  * Copyright (c) OpenLens Authors. All rights reserved.
    3  * Licensed under MIT License. See LICENSE in root directory for more information.
    4  */
    5 
    6 // Cleans up a store that had the state related data stored
    7 import type { Hotbar } from "../../common/hotbars/types";
    8 import * as uuid from "uuid";
    9 import type { MigrationDeclaration } from "../helpers";
   10 
   11 export default {
   12   version: "5.0.0-alpha.2",
   13   run(store) {
   14     const rawHotbars = store.get("hotbars");
   15     const hotbars: Hotbar[] = Array.isArray(rawHotbars) ? rawHotbars : [];
   16 
   17     store.set("hotbars", hotbars.map(({ id, ...rest }) => ({
   18       id: id || uuid.v4(),
   19       ...rest,
   20     })));
   21   },
   22 } as MigrationDeclaration;