mirror of
https://github.com/lensapp/lens.git
synced 2025-05-20 05:10:56 +00:00
Fix using default hotbars (#3196)
Signed-off-by: Pavel Ashevskii <pashevskii@mirantis.com>
This commit is contained in:
parent
aa86e5a41e
commit
52828a4385
@ -26,6 +26,7 @@ import * as uuid from "uuid";
|
|||||||
import isNull from "lodash/isNull";
|
import isNull from "lodash/isNull";
|
||||||
import { toJS } from "./utils";
|
import { toJS } from "./utils";
|
||||||
import { CatalogEntity } from "./catalog";
|
import { CatalogEntity } from "./catalog";
|
||||||
|
import { catalogEntity } from "../main/catalog-sources/general";
|
||||||
|
|
||||||
export interface HotbarItem {
|
export interface HotbarItem {
|
||||||
entity: {
|
entity: {
|
||||||
@ -94,7 +95,15 @@ export class HotbarStore extends BaseStore<HotbarStoreModel> {
|
|||||||
|
|
||||||
@action
|
@action
|
||||||
protected async fromStore(data: Partial<HotbarStoreModel> = {}) {
|
protected async fromStore(data: Partial<HotbarStoreModel> = {}) {
|
||||||
|
if (!data.hotbars || !data.hotbars.length) {
|
||||||
|
this.hotbars = [{
|
||||||
|
id: uuid.v4(),
|
||||||
|
name: "Default",
|
||||||
|
items: this.defaultHotbarInitialItems,
|
||||||
|
}];
|
||||||
|
} else {
|
||||||
this.hotbars = data.hotbars;
|
this.hotbars = data.hotbars;
|
||||||
|
}
|
||||||
|
|
||||||
if (data.activeHotbarId) {
|
if (data.activeHotbarId) {
|
||||||
if (this.getById(data.activeHotbarId)) {
|
if (this.getById(data.activeHotbarId)) {
|
||||||
@ -107,6 +116,16 @@ export class HotbarStore extends BaseStore<HotbarStoreModel> {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
get defaultHotbarInitialItems() {
|
||||||
|
const { metadata: { uid, name, source } } = catalogEntity;
|
||||||
|
const initialItem = { entity: { uid, name, source }};
|
||||||
|
|
||||||
|
return [
|
||||||
|
initialItem,
|
||||||
|
...Array.from(Array(defaultHotbarCells - 1).fill(null))
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
||||||
getActive() {
|
getActive() {
|
||||||
return this.getById(this.activeHotbarId);
|
return this.getById(this.activeHotbarId);
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user