diff --git a/src/common/catalog-entities/general.ts b/src/common/catalog-entities/general.ts index 589e7acad9..d7afb24df2 100644 --- a/src/common/catalog-entities/general.ts +++ b/src/common/catalog-entities/general.ts @@ -25,7 +25,6 @@ import { catalogCategoryRegistry } from "../catalog/catalog-category-registry"; type GeneralEntitySpec = { path: string; - materialIcon?: string; } & CatalogEntitySpec; export class GeneralEntity extends CatalogEntity { diff --git a/src/common/catalog-entities/kubernetes-cluster.ts b/src/common/catalog-entities/kubernetes-cluster.ts index 82582d2bc5..3956f3abdf 100644 --- a/src/common/catalog-entities/kubernetes-cluster.ts +++ b/src/common/catalog-entities/kubernetes-cluster.ts @@ -28,6 +28,7 @@ import { productName } from "../vars"; import { CatalogCategory, CatalogCategorySpec } from "../catalog"; import { addClusterURL } from "../routes"; import { app } from "electron"; +import type { CatalogEntitySpec } from "../catalog/catalog-entity"; export type KubernetesClusterPrometheusMetrics = { address?: { @@ -42,12 +43,11 @@ export type KubernetesClusterPrometheusMetrics = { export type KubernetesClusterSpec = { kubeconfigPath: string; kubeconfigContext: string; - iconData?: string; metrics?: { source: string; prometheus?: KubernetesClusterPrometheusMetrics; } -}; +} & CatalogEntitySpec; export interface KubernetesClusterStatus extends CatalogEntityStatus { phase: "connected" | "disconnected"; diff --git a/src/common/catalog/catalog-entity.ts b/src/common/catalog/catalog-entity.ts index 9acc2a47c9..6181801558 100644 --- a/src/common/catalog/catalog-entity.ts +++ b/src/common/catalog/catalog-entity.ts @@ -142,7 +142,13 @@ export interface CatalogEntityAddMenuContext { menuItems: CatalogEntityAddMenu[]; } -export type CatalogEntitySpec = Record; +export type CatalogEntitySpec = { + icon?: { + src?: string; + material?: string; + background?: string; + } +} & Record; export interface CatalogEntityData< Metadata extends CatalogEntityMetadata = CatalogEntityMetadata, diff --git a/src/main/catalog-sources/general.ts b/src/main/catalog-sources/general.ts index 4b5d2e3178..1f42e69ac9 100644 --- a/src/main/catalog-sources/general.ts +++ b/src/main/catalog-sources/general.ts @@ -34,7 +34,10 @@ const generalEntities = observable([ }, spec: { path: catalogURL(), - materialIcon: "view_list", + icon: { + material: "view_list", + background: "#3d90ce" + } }, status: { phase: "active", @@ -49,7 +52,10 @@ const generalEntities = observable([ }, spec: { path: preferencesURL(), - materialIcon: "settings" + icon: { + material: "settings", + background: "#3d90ce" + } }, status: { phase: "active", diff --git a/src/main/cluster-manager.ts b/src/main/cluster-manager.ts index 4075c81e36..29b5f0e757 100644 --- a/src/main/cluster-manager.ts +++ b/src/main/cluster-manager.ts @@ -110,7 +110,7 @@ export class ClusterManager extends Singleton { entity.spec.metrics.prometheus = prometheus; } - entity.spec.iconData = cluster.preferences.icon; + entity.spec.icon.src = cluster.preferences.icon; catalogEntityRegistry.items.splice(index, 1, entity); } @@ -204,7 +204,8 @@ export function catalogEntityFromCluster(cluster: Cluster) { }, spec: { kubeconfigPath: cluster.kubeConfigPath, - kubeconfigContext: cluster.contextName + kubeconfigContext: cluster.contextName, + icon: {} }, status: { phase: cluster.disconnected ? "disconnected" : "connected", diff --git a/src/renderer/components/+catalog/catalog-entity-details.tsx b/src/renderer/components/+catalog/catalog-entity-details.tsx index 0a918466c6..9560b57f22 100644 --- a/src/renderer/components/+catalog/catalog-entity-details.tsx +++ b/src/renderer/components/+catalog/catalog-entity-details.tsx @@ -79,8 +79,9 @@ export class CatalogEntityDetails extends Component { uid={entity.metadata.uid} title={entity.metadata.name} source={entity.metadata.source} - src={entity.spec.iconData} - materialIcon={entity.spec.materialIcon} + src={entity.spec.icon?.src} + material={entity.spec.icon?.material} + background={entity.spec.icon?.background} onClick={() => this.openEntity()} size={128} />
diff --git a/src/renderer/components/+catalog/catalog.tsx b/src/renderer/components/+catalog/catalog.tsx index 06f1f9f9bf..0ed484eb9f 100644 --- a/src/renderer/components/+catalog/catalog.tsx +++ b/src/renderer/components/+catalog/catalog.tsx @@ -173,10 +173,12 @@ export class Catalog extends React.Component { uid={item.getId()} title={item.getName()} source={item.source} - src={item.entity.spec.iconData} - materialIcon={item.entity.spec.materialIcon} + src={item.entity.spec.icon?.src} + material={item.entity.spec.icon?.material} + background={item.entity.spec.icon?.background} onClick={() => this.onDetails(item)} - size={24} /> + size={24} + /> ); } diff --git a/src/renderer/components/avatar/avatar.tsx b/src/renderer/components/avatar/avatar.tsx index 43cdb31603..cd27497bbb 100644 --- a/src/renderer/components/avatar/avatar.tsx +++ b/src/renderer/components/avatar/avatar.tsx @@ -32,6 +32,7 @@ interface Props extends DOMAttributes, Partial { height?: number; src?: string; className?: string; + background?: string; } function getNameParts(name: string): string[] { @@ -69,11 +70,11 @@ function getIconString(title: string) { } export function Avatar(props: Props) { - const { title, width = 32, height = 32, colorHash, children, ...settings } = props; + const { title, width = 32, height = 32, colorHash, children, background, ...settings } = props; const generateAvatarStyle = (): React.CSSProperties => { return { - backgroundColor: settings.src ? "transparent" : randomColor({ seed: colorHash, luminosity: "dark" }), + backgroundColor: background || randomColor({ seed: colorHash, luminosity: "dark" }), width, height, textTransform: "uppercase" diff --git a/src/renderer/components/cluster-settings/components/cluster-icon-settings.tsx b/src/renderer/components/cluster-settings/components/cluster-icon-settings.tsx index f14d1479ab..148395872b 100644 --- a/src/renderer/components/cluster-settings/components/cluster-icon-settings.tsx +++ b/src/renderer/components/cluster-settings/components/cluster-icon-settings.tsx @@ -86,7 +86,7 @@ export class ClusterIconSetting extends React.Component { uid={entity.metadata.uid} title={entity.metadata.name} source={entity.metadata.source} - src={entity.spec.iconData} + src={entity.spec.icon?.src} /> Browse for new icon... diff --git a/src/renderer/components/hotbar/hotbar-entity-icon.tsx b/src/renderer/components/hotbar/hotbar-entity-icon.tsx index 779cc72c06..675627ab3e 100644 --- a/src/renderer/components/hotbar/hotbar-entity-icon.tsx +++ b/src/renderer/components/hotbar/hotbar-entity-icon.tsx @@ -129,8 +129,9 @@ export class HotbarEntityIcon extends React.Component { uid={entity.metadata.uid} title={entity.metadata.name} source={entity.metadata.source} - src={entity.spec.iconData} - materialIcon={entity.spec.materialIcon} + src={entity.spec.icon?.src} + material={entity.spec.icon?.material} + background={entity.spec.icon?.background} className={className} active={isActive} onMenuOpen={onOpen} diff --git a/src/renderer/components/hotbar/hotbar-icon.scss b/src/renderer/components/hotbar/hotbar-icon.scss index 9e3451ab94..e7bc4d04ba 100644 --- a/src/renderer/components/hotbar/hotbar-icon.scss +++ b/src/renderer/components/hotbar/hotbar-icon.scss @@ -20,7 +20,6 @@ */ .HotbarMenu { - .HotbarIconMenu { left: 30px; min-width: 250px; @@ -126,4 +125,10 @@ } } } + + .materialIcon { + margin-left: 1px; + margin-top: 1px; + text-shadow: none; + } } diff --git a/src/renderer/components/hotbar/hotbar-icon.tsx b/src/renderer/components/hotbar/hotbar-icon.tsx index b1d6e2e99f..93cb48005d 100644 --- a/src/renderer/components/hotbar/hotbar-icon.tsx +++ b/src/renderer/components/hotbar/hotbar-icon.tsx @@ -37,13 +37,14 @@ export interface HotbarIconProps extends DOMAttributes { title: string; source: string; src?: string; - materialIcon?: string; + material?: string; onMenuOpen?: () => void; className?: IClassName; active?: boolean; menuItems?: CatalogEntityContextMenu[]; disabled?: boolean; size?: number; + background?: string; } function onMenuItemClick(menuItem: CatalogEntityContextMenu) { @@ -64,7 +65,7 @@ function onMenuItemClick(menuItem: CatalogEntityContextMenu) { } export const HotbarIcon = observer(({menuItems = [], size = 40, ...props}: HotbarIconProps) => { - const { uid, title, src, materialIcon, active, className, source, disabled, onMenuOpen, children, ...rest } = props; + const { uid, title, src, material, active, className, source, disabled, onMenuOpen, children, ...rest } = props; const id = `hotbarIcon-${uid}`; const [menuOpen, setMenuOpen] = useState(false); @@ -83,7 +84,7 @@ export const HotbarIcon = observer(({menuItems = [], size = 40, ...props}: Hotba height={size} src={src} > - {materialIcon && } + {material && } ); };