Pin icon for Catalog list items (#3810)

This commit is contained in:
Alex Andreev authored and GitHub committed 2021-10-18 10:27:53 -04:00
1 parent 5998b4ca84
commit 0eac46530a
10 files changed
+147 -37

No files matched your search

@@ -324,6 +324,15 @@ describe("HotbarStore", () => {
console.error = error;
console.warn = warn;
});
it("checks if entity already pinned to hotbar", () => {
const hotbarStore = HotbarStore.getInstance();
hotbarStore.addToHotbar(testCluster);
expect(hotbarStore.isAddedToActive(testCluster)).toBeTruthy();
expect(hotbarStore.isAddedToActive(awsCluster)).toBeFalsy();
});
});
describe("pre beta-5 migrations", () => {
+9 -1
View File
@@ -171,7 +171,7 @@ export class HotbarStore extends BaseStore<HotbarStoreModel> {
}};
if (hotbar.items.find(i => i?.entity.uid === uid)) {
if (this.isAddedToActive(item)) {
return;
}
@@ -274,6 +274,14 @@ export class HotbarStore extends BaseStore<HotbarStoreModel> {
hotbarStore.activeHotbarId = hotbarStore.hotbars[index].id;
}
/**
* Checks if entity already pinned to hotbar
* @returns boolean
*/
isAddedToActive(entity: CatalogEntity) {
return !!this.getActive().items.find(item => item?.entity.uid === entity.metadata.uid);
}
}
/**