mirror of
https://github.com/lensapp/lens.git
synced 2025-05-20 05:10:56 +00:00
Dim disabled pin icon
Signed-off-by: Alex Andreev <alex.andreev.email@gmail.com>
This commit is contained in:
parent
ab38cd32b5
commit
329a1c93c4
@ -324,6 +324,15 @@ describe("HotbarStore", () => {
|
|||||||
console.error = error;
|
console.error = error;
|
||||||
console.warn = warn;
|
console.warn = warn;
|
||||||
});
|
});
|
||||||
|
|
||||||
|
it("checks if entity already pinned to hotbar", () => {
|
||||||
|
const hotbarStore = HotbarStore.getInstance();
|
||||||
|
|
||||||
|
hotbarStore.addToHotbar(testCluster);
|
||||||
|
|
||||||
|
expect(hotbarStore.entityPinnedToHotbar(testCluster)).toBeTruthy();
|
||||||
|
expect(hotbarStore.entityPinnedToHotbar(awsCluster)).toBeFalsy();
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
describe("pre beta-5 migrations", () => {
|
describe("pre beta-5 migrations", () => {
|
||||||
|
|||||||
@ -171,7 +171,7 @@ export class HotbarStore extends BaseStore<HotbarStoreModel> {
|
|||||||
}};
|
}};
|
||||||
|
|
||||||
|
|
||||||
if (hotbar.items.find(i => i?.entity.uid === uid)) {
|
if (this.entityPinnedToHotbar(item)) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -274,6 +274,14 @@ export class HotbarStore extends BaseStore<HotbarStoreModel> {
|
|||||||
|
|
||||||
hotbarStore.activeHotbarId = hotbarStore.hotbars[index].id;
|
hotbarStore.activeHotbarId = hotbarStore.hotbars[index].id;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Checks if entity already pinned to hotbar
|
||||||
|
* @returns boolean
|
||||||
|
*/
|
||||||
|
entityPinnedToHotbar(entity: CatalogEntity) {
|
||||||
|
return !!this.getActive().items.find(item => item?.entity.uid === entity.metadata.uid);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@ -44,6 +44,10 @@
|
|||||||
|
|
||||||
&:hover .pinIcon {
|
&:hover .pinIcon {
|
||||||
opacity: 1;
|
opacity: 1;
|
||||||
|
|
||||||
|
&:global(.disabled) {
|
||||||
|
opacity: 0.3;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -188,10 +188,18 @@ export class Catalog extends React.Component<Props> {
|
|||||||
};
|
};
|
||||||
|
|
||||||
renderName(item: CatalogEntityItem<CatalogEntity>) {
|
renderName(item: CatalogEntityItem<CatalogEntity>) {
|
||||||
|
const disabledIcon = HotbarStore.getInstance().entityPinnedToHotbar(item.entity);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div className={styles.entityName}>
|
<div className={styles.entityName}>
|
||||||
{item.name}
|
{item.name}
|
||||||
<Icon className={styles.pinIcon} material="push_pin" small tooltip="Pin to Hotbar" onClick={(event) => {
|
<Icon
|
||||||
|
small
|
||||||
|
disabled={disabledIcon}
|
||||||
|
className={styles.pinIcon}
|
||||||
|
material="push_pin"
|
||||||
|
tooltip={disabledIcon ? "" : "Pin to Hotbar"}
|
||||||
|
onClick={(event) => {
|
||||||
event.stopPropagation();
|
event.stopPropagation();
|
||||||
this.addToHotbar(item);
|
this.addToHotbar(item);
|
||||||
}}/>
|
}}/>
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user