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 { navigation } from "../../navigation";
|
||||
import { searchUrlParam } from "../input";
|
||||
import { makeCss } from "../../../common/utils/makeCss";
|
||||
import { KubeObject } from "../../../common/k8s-api/kube-object";
|
||||
import type { CatalogEntityRegistry } from "../../api/catalog-entity-registry";
|
||||
|
||||
const css = makeCss(styles);
|
||||
|
||||
export class CatalogEntityItem<T extends CatalogEntity> implements ItemObject {
|
||||
constructor(public entity: T, private registry: CatalogEntityRegistry) {
|
||||
if (!(entity instanceof CatalogEntity)) {
|
||||
@ -79,7 +76,7 @@ export class CatalogEntityItem<T extends CatalogEntity> implements ItemObject {
|
||||
return this.labels
|
||||
.map(label => (
|
||||
<Badge
|
||||
className={css.badge}
|
||||
className={styles.badge}
|
||||
key={label}
|
||||
label={label}
|
||||
title={label}
|
||||
|
||||
@ -19,59 +19,77 @@
|
||||
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
*/
|
||||
|
||||
.list :global(.TableRow) {
|
||||
.entityName {
|
||||
position: relative;
|
||||
width: min-content;
|
||||
max-width: 100%;
|
||||
.Catalog {
|
||||
: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;
|
||||
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;
|
||||
text-overflow: ellipsis;
|
||||
padding-right: 24px;
|
||||
padding-left: var(--padding);
|
||||
}
|
||||
|
||||
.pinIcon {
|
||||
position: absolute;
|
||||
right: 0;
|
||||
opacity: 0;
|
||||
transition: none;
|
||||
:global(.HotbarIcon){
|
||||
align-self: center;
|
||||
|
||||
&:hover {
|
||||
/* Drop styles defined for <Icon/> */
|
||||
background-color: transparent;
|
||||
box-shadow: none;
|
||||
}
|
||||
div {
|
||||
/* icons with plain text */
|
||||
font-size: var(--unit);
|
||||
}
|
||||
|
||||
.Icon {
|
||||
/* icons with font-icon */
|
||||
font-size: var(--small-size);
|
||||
}
|
||||
}
|
||||
|
||||
&:hover .pinIcon {
|
||||
opacity: 1;
|
||||
.pinIcon {
|
||||
position: absolute;
|
||||
right: 0;
|
||||
transition: none;
|
||||
display: none;
|
||||
|
||||
&:hover {
|
||||
/* Drop styles defined for <Icon/> */
|
||||
background-color: transparent;
|
||||
box-shadow: none;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
.iconCell {
|
||||
@apply flex items-center max-w-[40px];
|
||||
}
|
||||
|
||||
.iconCell > div * {
|
||||
font-size: var(--unit);
|
||||
}
|
||||
|
||||
.nameCell {
|
||||
}
|
||||
|
||||
.sourceCell {
|
||||
max-width: 100px;
|
||||
}
|
||||
|
||||
.statusCell {
|
||||
max-width: 100px;
|
||||
}
|
||||
|
||||
.connected, .available {
|
||||
color: var(--colorSuccess);
|
||||
}
|
||||
:global {
|
||||
.connected, .available {
|
||||
color: var(--colorSuccess);
|
||||
}
|
||||
|
||||
.disconnected, .deleting, .unavailable {
|
||||
color: var(--halfGray);
|
||||
.disconnected, .deleting, .unavailable {
|
||||
color: var(--halfGray);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
.labelsCell {
|
||||
|
||||
@ -37,8 +37,7 @@ import { CatalogAddButton } from "./catalog-add-button";
|
||||
import type { RouteComponentProps } from "react-router";
|
||||
import { Notifications } from "../notifications";
|
||||
import { MainLayout } from "../layout/main-layout";
|
||||
import { createStorage, cssNames, prevDefault } from "../../utils";
|
||||
import { makeCss } from "../../../common/utils/makeCss";
|
||||
import { createStorage, prevDefault } from "../../utils";
|
||||
import { CatalogEntityDetails } from "./catalog-entity-details";
|
||||
import { browseCatalogTab, catalogURL, CatalogViewRouteParam } from "../../../common/routes";
|
||||
import { CatalogMenu } from "./catalog-menu";
|
||||
@ -56,8 +55,6 @@ enum sortBy {
|
||||
status = "status",
|
||||
}
|
||||
|
||||
const css = makeCss(styles);
|
||||
|
||||
interface Props extends RouteComponentProps<CatalogViewRouteParam> {
|
||||
catalogEntityStore?: CatalogEntityStore;
|
||||
}
|
||||
@ -73,6 +70,7 @@ export class Catalog extends React.Component<Props> {
|
||||
makeObservable(this);
|
||||
this.catalogEntityStore = props.catalogEntityStore;
|
||||
}
|
||||
|
||||
static defaultProps = {
|
||||
catalogEntityStore: new CatalogEntityStore(),
|
||||
};
|
||||
@ -105,7 +103,7 @@ export class Catalog extends React.Component<Props> {
|
||||
this.activeTab = routeTab;
|
||||
this.catalogEntityStore.activeCategory = item;
|
||||
});
|
||||
} catch(error) {
|
||||
} catch (error) {
|
||||
console.error(error);
|
||||
Notifications.error(<p>Unknown category: {routeTab}</p>);
|
||||
}
|
||||
@ -177,7 +175,7 @@ export class Catalog extends React.Component<Props> {
|
||||
|
||||
renderNavigation() {
|
||||
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);
|
||||
|
||||
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
|
||||
uid={`catalog-icon-${item.getId()}`}
|
||||
title={item.getName()}
|
||||
@ -240,7 +222,16 @@ export class Catalog extends React.Component<Props> {
|
||||
background={item.entity.spec.icon?.background}
|
||||
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 (
|
||||
<ItemListLayout
|
||||
className={styles.Catalog}
|
||||
tableId={tableId}
|
||||
renderHeaderTitle={activeCategory?.metadata.name || "Browse All"}
|
||||
isSelectable={false}
|
||||
isConfigurable={true}
|
||||
className={styles.list}
|
||||
store={this.catalogEntityStore}
|
||||
sortingCallbacks={{
|
||||
[sortBy.name]: item => item.name,
|
||||
@ -270,23 +261,21 @@ export class Catalog extends React.Component<Props> {
|
||||
entity => entity.searchFields,
|
||||
]}
|
||||
renderTableHeader={[
|
||||
{ title: "", className: css.iconCell, id: "icon" },
|
||||
{ title: "Name", className: css.nameCell, sortBy: sortBy.name, id: "name" },
|
||||
!activeCategory && { title: "Kind", className: css.kindCell, sortBy: sortBy.kind, id: "kind" },
|
||||
{ title: "Source", className: css.sourceCell, sortBy: sortBy.source, id: "source" },
|
||||
{ title: "Labels", className: css.labelsCell, id: "labels" },
|
||||
{ title: "Status", className: css.statusCell, sortBy: sortBy.status, id: "status" },
|
||||
{ title: "Name", className: styles.entityName, sortBy: sortBy.name, id: "name" },
|
||||
!activeCategory && { title: "Kind", sortBy: sortBy.kind, id: "kind" },
|
||||
{ title: "Source", className: styles.sourceCell, sortBy: sortBy.source, id: "source" },
|
||||
{ title: "Labels", className: styles.labelsCell, id: "labels" },
|
||||
{ title: "Status", className: styles.statusCell, sortBy: sortBy.status, id: "status" },
|
||||
].filter(Boolean)}
|
||||
customizeTableRowProps={item => ({
|
||||
disabled: !item.enabled,
|
||||
})}
|
||||
renderTableContents={item => [
|
||||
this.renderIcon(item),
|
||||
this.renderName(item),
|
||||
!activeCategory && item.kind,
|
||||
item.source,
|
||||
item.getLabelBadges(),
|
||||
{ title: item.phase, className: cssNames(css[item.phase]) },
|
||||
<span key="phase" className={item.phase}>{item.phase}</span>,
|
||||
].filter(Boolean)}
|
||||
onDetails={this.onDetails}
|
||||
renderItemMenu={this.renderItemMenu}
|
||||
@ -302,7 +291,7 @@ export class Catalog extends React.Component<Props> {
|
||||
return (
|
||||
<MainLayout sidebar={this.renderNavigation()}>
|
||||
<div className="p-6 h-full">
|
||||
{ this.renderList() }
|
||||
{this.renderList()}
|
||||
</div>
|
||||
{
|
||||
this.catalogEntityStore.selectedItem
|
||||
|
||||
|
Before Width: | Height: | Size: 959 B After Width: | Height: | Size: 959 B |
Loading…
Reference in New Issue
Block a user