mirror of
https://github.com/lensapp/lens.git
synced 2025-05-20 05:10:56 +00:00
Fix: Catalog's visibility columns menu -> Empty title for Icon (#4189)
* fix: Catalog -> Columns visibility menu -> Empty title for "Icon" Signed-off-by: Roman <ixrock@gmail.com> * moving entity-icon inside name column / fixes Signed-off-by: Roman <ixrock@gmail.com> * fix lint Signed-off-by: Roman <ixrock@gmail.com> * added vertical alignment for texts in the name column Signed-off-by: Roman <ixrock@gmail.com>
This commit is contained in:
parent
8846b5c96f
commit
38ebbc8b9e
@ -1,30 +0,0 @@
|
|||||||
/**
|
|
||||||
* Copyright (c) 2021 OpenLens Authors
|
|
||||||
*
|
|
||||||
* Permission is hereby granted, free of charge, to any person obtaining a copy of
|
|
||||||
* this software and associated documentation files (the "Software"), to deal in
|
|
||||||
* the Software without restriction, including without limitation the rights to
|
|
||||||
* use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
|
|
||||||
* the Software, and to permit persons to whom the Software is furnished to do so,
|
|
||||||
* subject to the following conditions:
|
|
||||||
*
|
|
||||||
* The above copyright notice and this permission notice shall be included in all
|
|
||||||
* copies or substantial portions of the Software.
|
|
||||||
*
|
|
||||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
||||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
|
|
||||||
* FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
|
|
||||||
* COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
|
|
||||||
* IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
|
|
||||||
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
|
||||||
*/
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Function expands generic CSS Modules literal types and adds dictionary with arbitrary
|
|
||||||
* indexes.
|
|
||||||
* @param styles Styles imported from CSS Module having only literal types
|
|
||||||
* @returns Passed style list with expanded typescript types
|
|
||||||
*/
|
|
||||||
export function makeCss<T>(styles: T) {
|
|
||||||
return styles as typeof styles & { [key: string]: string };
|
|
||||||
}
|
|
||||||
@ -26,12 +26,9 @@ import type { ItemObject } from "../../../common/item.store";
|
|||||||
import { Badge } from "../badge";
|
import { Badge } from "../badge";
|
||||||
import { navigation } from "../../navigation";
|
import { navigation } from "../../navigation";
|
||||||
import { searchUrlParam } from "../input";
|
import { searchUrlParam } from "../input";
|
||||||
import { makeCss } from "../../../common/utils/makeCss";
|
|
||||||
import { KubeObject } from "../../../common/k8s-api/kube-object";
|
import { KubeObject } from "../../../common/k8s-api/kube-object";
|
||||||
import type { CatalogEntityRegistry } from "../../api/catalog-entity-registry";
|
import type { CatalogEntityRegistry } from "../../api/catalog-entity-registry";
|
||||||
|
|
||||||
const css = makeCss(styles);
|
|
||||||
|
|
||||||
export class CatalogEntityItem<T extends CatalogEntity> implements ItemObject {
|
export class CatalogEntityItem<T extends CatalogEntity> implements ItemObject {
|
||||||
constructor(public entity: T, private registry: CatalogEntityRegistry) {
|
constructor(public entity: T, private registry: CatalogEntityRegistry) {
|
||||||
if (!(entity instanceof CatalogEntity)) {
|
if (!(entity instanceof CatalogEntity)) {
|
||||||
@ -79,7 +76,7 @@ export class CatalogEntityItem<T extends CatalogEntity> implements ItemObject {
|
|||||||
return this.labels
|
return this.labels
|
||||||
.map(label => (
|
.map(label => (
|
||||||
<Badge
|
<Badge
|
||||||
className={css.badge}
|
className={styles.badge}
|
||||||
key={label}
|
key={label}
|
||||||
label={label}
|
label={label}
|
||||||
title={label}
|
title={label}
|
||||||
|
|||||||
@ -19,20 +19,52 @@
|
|||||||
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
.list :global(.TableRow) {
|
.Catalog {
|
||||||
.entityName {
|
:global(.TableHead) .entityName {
|
||||||
|
/* offset for icon to align texts in the column */
|
||||||
|
padding-left: calc(21px + var(--padding) * 2.5);
|
||||||
|
}
|
||||||
|
|
||||||
|
:global(.TableRow):hover .pinIcon {
|
||||||
|
display: block;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
.entityName {
|
||||||
position: relative;
|
position: relative;
|
||||||
width: min-content;
|
width: 100%;
|
||||||
max-width: 100%;
|
max-width: 100%;
|
||||||
|
display: flex;
|
||||||
|
align-items: center;
|
||||||
|
padding: 0 var(--padding);
|
||||||
|
padding-bottom: 0;
|
||||||
|
padding-right: 24px; // + reserved space for .pinIcon
|
||||||
|
|
||||||
|
> span {
|
||||||
overflow: hidden;
|
overflow: hidden;
|
||||||
text-overflow: ellipsis;
|
text-overflow: ellipsis;
|
||||||
padding-right: 24px;
|
padding-left: var(--padding);
|
||||||
|
}
|
||||||
|
|
||||||
|
:global(.HotbarIcon){
|
||||||
|
align-self: center;
|
||||||
|
|
||||||
|
div {
|
||||||
|
/* icons with plain text */
|
||||||
|
font-size: var(--unit);
|
||||||
|
}
|
||||||
|
|
||||||
|
.Icon {
|
||||||
|
/* icons with font-icon */
|
||||||
|
font-size: var(--small-size);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
.pinIcon {
|
.pinIcon {
|
||||||
position: absolute;
|
position: absolute;
|
||||||
right: 0;
|
right: 0;
|
||||||
opacity: 0;
|
|
||||||
transition: none;
|
transition: none;
|
||||||
|
display: none;
|
||||||
|
|
||||||
&:hover {
|
&:hover {
|
||||||
/* Drop styles defined for <Icon/> */
|
/* Drop styles defined for <Icon/> */
|
||||||
@ -40,22 +72,6 @@
|
|||||||
box-shadow: none;
|
box-shadow: none;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
&:hover .pinIcon {
|
|
||||||
opacity: 1;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
.iconCell {
|
|
||||||
@apply flex items-center max-w-[40px];
|
|
||||||
}
|
|
||||||
|
|
||||||
.iconCell > div * {
|
|
||||||
font-size: var(--unit);
|
|
||||||
}
|
|
||||||
|
|
||||||
.nameCell {
|
|
||||||
}
|
}
|
||||||
|
|
||||||
.sourceCell {
|
.sourceCell {
|
||||||
@ -64,14 +80,16 @@
|
|||||||
|
|
||||||
.statusCell {
|
.statusCell {
|
||||||
max-width: 100px;
|
max-width: 100px;
|
||||||
}
|
|
||||||
|
|
||||||
.connected, .available {
|
:global {
|
||||||
|
.connected, .available {
|
||||||
color: var(--colorSuccess);
|
color: var(--colorSuccess);
|
||||||
}
|
}
|
||||||
|
|
||||||
.disconnected, .deleting, .unavailable {
|
.disconnected, .deleting, .unavailable {
|
||||||
color: var(--halfGray);
|
color: var(--halfGray);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
.labelsCell {
|
.labelsCell {
|
||||||
|
|||||||
@ -37,8 +37,7 @@ import { CatalogAddButton } from "./catalog-add-button";
|
|||||||
import type { RouteComponentProps } from "react-router";
|
import type { RouteComponentProps } from "react-router";
|
||||||
import { Notifications } from "../notifications";
|
import { Notifications } from "../notifications";
|
||||||
import { MainLayout } from "../layout/main-layout";
|
import { MainLayout } from "../layout/main-layout";
|
||||||
import { createStorage, cssNames, prevDefault } from "../../utils";
|
import { createStorage, prevDefault } from "../../utils";
|
||||||
import { makeCss } from "../../../common/utils/makeCss";
|
|
||||||
import { CatalogEntityDetails } from "./catalog-entity-details";
|
import { CatalogEntityDetails } from "./catalog-entity-details";
|
||||||
import { browseCatalogTab, catalogURL, CatalogViewRouteParam } from "../../../common/routes";
|
import { browseCatalogTab, catalogURL, CatalogViewRouteParam } from "../../../common/routes";
|
||||||
import { CatalogMenu } from "./catalog-menu";
|
import { CatalogMenu } from "./catalog-menu";
|
||||||
@ -56,8 +55,6 @@ enum sortBy {
|
|||||||
status = "status",
|
status = "status",
|
||||||
}
|
}
|
||||||
|
|
||||||
const css = makeCss(styles);
|
|
||||||
|
|
||||||
interface Props extends RouteComponentProps<CatalogViewRouteParam> {
|
interface Props extends RouteComponentProps<CatalogViewRouteParam> {
|
||||||
catalogEntityStore?: CatalogEntityStore;
|
catalogEntityStore?: CatalogEntityStore;
|
||||||
}
|
}
|
||||||
@ -73,6 +70,7 @@ export class Catalog extends React.Component<Props> {
|
|||||||
makeObservable(this);
|
makeObservable(this);
|
||||||
this.catalogEntityStore = props.catalogEntityStore;
|
this.catalogEntityStore = props.catalogEntityStore;
|
||||||
}
|
}
|
||||||
|
|
||||||
static defaultProps = {
|
static defaultProps = {
|
||||||
catalogEntityStore: new CatalogEntityStore(),
|
catalogEntityStore: new CatalogEntityStore(),
|
||||||
};
|
};
|
||||||
@ -105,7 +103,7 @@ export class Catalog extends React.Component<Props> {
|
|||||||
this.activeTab = routeTab;
|
this.activeTab = routeTab;
|
||||||
this.catalogEntityStore.activeCategory = item;
|
this.catalogEntityStore.activeCategory = item;
|
||||||
});
|
});
|
||||||
} catch(error) {
|
} catch (error) {
|
||||||
console.error(error);
|
console.error(error);
|
||||||
Notifications.error(<p>Unknown category: {routeTab}</p>);
|
Notifications.error(<p>Unknown category: {routeTab}</p>);
|
||||||
}
|
}
|
||||||
@ -177,7 +175,7 @@ export class Catalog extends React.Component<Props> {
|
|||||||
|
|
||||||
renderNavigation() {
|
renderNavigation() {
|
||||||
return (
|
return (
|
||||||
<CatalogMenu activeItem={this.activeTab} onItemClick={this.onTabChange}/>
|
<CatalogMenu activeItem={this.activeTab} onItemClick={this.onTabChange} />
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -214,23 +212,7 @@ export class Catalog extends React.Component<Props> {
|
|||||||
const isItemInHotbar = HotbarStore.getInstance().isAddedToActive(item.entity);
|
const isItemInHotbar = HotbarStore.getInstance().isAddedToActive(item.entity);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div className={styles.entityName}>
|
<>
|
||||||
{item.name}
|
|
||||||
<Icon
|
|
||||||
small
|
|
||||||
className={styles.pinIcon}
|
|
||||||
material={!isItemInHotbar && "push_pin"}
|
|
||||||
svg={isItemInHotbar && "push_off"}
|
|
||||||
tooltip={isItemInHotbar ? "Remove from Hotbar" : "Add to Hotbar"}
|
|
||||||
onClick={prevDefault(() => isItemInHotbar ? this.removeFromHotbar(item) : this.addToHotbar(item))}
|
|
||||||
/>
|
|
||||||
</div>
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
renderIcon(item: CatalogEntityItem<CatalogEntity>) {
|
|
||||||
return (
|
|
||||||
<RenderDelay>
|
|
||||||
<HotbarIcon
|
<HotbarIcon
|
||||||
uid={`catalog-icon-${item.getId()}`}
|
uid={`catalog-icon-${item.getId()}`}
|
||||||
title={item.getName()}
|
title={item.getName()}
|
||||||
@ -240,7 +222,16 @@ export class Catalog extends React.Component<Props> {
|
|||||||
background={item.entity.spec.icon?.background}
|
background={item.entity.spec.icon?.background}
|
||||||
size={24}
|
size={24}
|
||||||
/>
|
/>
|
||||||
</RenderDelay>
|
<span>{item.name}</span>
|
||||||
|
<Icon
|
||||||
|
small
|
||||||
|
className={styles.pinIcon}
|
||||||
|
material={!isItemInHotbar && "push_pin"}
|
||||||
|
svg={isItemInHotbar ? "push_off" : "push_pin"}
|
||||||
|
tooltip={isItemInHotbar ? "Remove from Hotbar" : "Add to Hotbar"}
|
||||||
|
onClick={prevDefault(() => isItemInHotbar ? this.removeFromHotbar(item) : this.addToHotbar(item))}
|
||||||
|
/>
|
||||||
|
</>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -254,11 +245,11 @@ export class Catalog extends React.Component<Props> {
|
|||||||
|
|
||||||
return (
|
return (
|
||||||
<ItemListLayout
|
<ItemListLayout
|
||||||
|
className={styles.Catalog}
|
||||||
tableId={tableId}
|
tableId={tableId}
|
||||||
renderHeaderTitle={activeCategory?.metadata.name || "Browse All"}
|
renderHeaderTitle={activeCategory?.metadata.name || "Browse All"}
|
||||||
isSelectable={false}
|
isSelectable={false}
|
||||||
isConfigurable={true}
|
isConfigurable={true}
|
||||||
className={styles.list}
|
|
||||||
store={this.catalogEntityStore}
|
store={this.catalogEntityStore}
|
||||||
sortingCallbacks={{
|
sortingCallbacks={{
|
||||||
[sortBy.name]: item => item.name,
|
[sortBy.name]: item => item.name,
|
||||||
@ -270,23 +261,21 @@ export class Catalog extends React.Component<Props> {
|
|||||||
entity => entity.searchFields,
|
entity => entity.searchFields,
|
||||||
]}
|
]}
|
||||||
renderTableHeader={[
|
renderTableHeader={[
|
||||||
{ title: "", className: css.iconCell, id: "icon" },
|
{ title: "Name", className: styles.entityName, sortBy: sortBy.name, id: "name" },
|
||||||
{ title: "Name", className: css.nameCell, sortBy: sortBy.name, id: "name" },
|
!activeCategory && { title: "Kind", sortBy: sortBy.kind, id: "kind" },
|
||||||
!activeCategory && { title: "Kind", className: css.kindCell, sortBy: sortBy.kind, id: "kind" },
|
{ title: "Source", className: styles.sourceCell, sortBy: sortBy.source, id: "source" },
|
||||||
{ title: "Source", className: css.sourceCell, sortBy: sortBy.source, id: "source" },
|
{ title: "Labels", className: styles.labelsCell, id: "labels" },
|
||||||
{ title: "Labels", className: css.labelsCell, id: "labels" },
|
{ title: "Status", className: styles.statusCell, sortBy: sortBy.status, id: "status" },
|
||||||
{ title: "Status", className: css.statusCell, sortBy: sortBy.status, id: "status" },
|
|
||||||
].filter(Boolean)}
|
].filter(Boolean)}
|
||||||
customizeTableRowProps={item => ({
|
customizeTableRowProps={item => ({
|
||||||
disabled: !item.enabled,
|
disabled: !item.enabled,
|
||||||
})}
|
})}
|
||||||
renderTableContents={item => [
|
renderTableContents={item => [
|
||||||
this.renderIcon(item),
|
|
||||||
this.renderName(item),
|
this.renderName(item),
|
||||||
!activeCategory && item.kind,
|
!activeCategory && item.kind,
|
||||||
item.source,
|
item.source,
|
||||||
item.getLabelBadges(),
|
item.getLabelBadges(),
|
||||||
{ title: item.phase, className: cssNames(css[item.phase]) },
|
<span key="phase" className={item.phase}>{item.phase}</span>,
|
||||||
].filter(Boolean)}
|
].filter(Boolean)}
|
||||||
onDetails={this.onDetails}
|
onDetails={this.onDetails}
|
||||||
renderItemMenu={this.renderItemMenu}
|
renderItemMenu={this.renderItemMenu}
|
||||||
@ -302,7 +291,7 @@ export class Catalog extends React.Component<Props> {
|
|||||||
return (
|
return (
|
||||||
<MainLayout sidebar={this.renderNavigation()}>
|
<MainLayout sidebar={this.renderNavigation()}>
|
||||||
<div className="p-6 h-full">
|
<div className="p-6 h-full">
|
||||||
{ this.renderList() }
|
{this.renderList()}
|
||||||
</div>
|
</div>
|
||||||
{
|
{
|
||||||
this.catalogEntityStore.selectedItem
|
this.catalogEntityStore.selectedItem
|
||||||
|
|||||||
|
Before Width: | Height: | Size: 959 B After Width: | Height: | Size: 959 B |
Loading…
Reference in New Issue
Block a user