Merge remote-tracking branch 'origin/master' into mobx-6.2

This commit is contained in:
Roman committed 2021-04-23 16:25:32 +03:00
commit 671e7c26ca
22 files changed
+179 -75

No files matched your search

@@ -45,6 +45,15 @@ export class CatalogEntityItem implements ItemObject {
return this.entity.metadata.source || "unknown";
}
get searchFields() {
return [
this.name,
this.id,
this.phase,
...this.labels.map((value, key) => `${key}=${value}`)
];
}
onRun(ctx: CatalogEntityActionContext) {
this.entity.onRun(ctx);
}
+4 -1
View File
@@ -168,9 +168,12 @@ export class Catalog extends React.Component {
[sortBy.source]: (item: CatalogEntityItem) => item.source,
[sortBy.status]: (item: CatalogEntityItem) => item.phase,
}}
searchFilters={[
(entity: CatalogEntityItem) => entity.searchFields,
]}
renderTableHeader={[
{ title: "Name", className: "name", sortBy: sortBy.name },
{ title: "Source", className: "source" },
{ title: "Source", className: "source", sortBy: sortBy.source },
{ title: "Labels", className: "labels" },
{ title: "Status", className: "status", sortBy: sortBy.status },
]}
@@ -84,7 +84,7 @@ export class AddHelmRepoDialog extends React.Component<Props> {
async addCustomRepo() {
try {
await HelmRepoManager.getInstance().addСustomRepo(this.helmRepo);
await HelmRepoManager.addСustomRepo(this.helmRepo);
Notifications.ok(<>Helm repository <b>{this.helmRepo.name}</b> has added</>);
this.props.onAddRepo();
this.close();
@@ -39,7 +39,7 @@ export class HelmCharts extends React.Component {
try {
if (!this.repos.length) {
this.repos = await HelmRepoManager.getInstance().loadAvailableRepos(); // via https://helm.sh
this.repos = await HelmRepoManager.loadAvailableRepos();
}
const repos = await HelmRepoManager.getInstance().repositories(); // via helm-cli
@@ -54,7 +54,7 @@ export class HelmCharts extends React.Component {
async addRepo(repo: HelmRepo) {
try {
await HelmRepoManager.getInstance().addRepo(repo);
await HelmRepoManager.addRepo(repo);
this.addedRepos.set(repo.name, repo);
} catch (err) {
Notifications.error(<>Adding helm branch <b>{repo.name}</b> has failed: {String(err)}</>);
@@ -63,7 +63,7 @@ export class HelmCharts extends React.Component {
async removeRepo(repo: HelmRepo) {
try {
await HelmRepoManager.getInstance().removeRepo(repo);
await HelmRepoManager.removeRepo(repo);
this.addedRepos.delete(repo.name);
} catch (err) {
Notifications.error(
@@ -38,6 +38,22 @@
}
}
.badge {
color: $textColorAccent;
position: absolute;
right: 0;
bottom: 0;
margin: -$padding;
font-size: $font-size-small;
background: $clusterMenuBackground;
color: white;
padding: 0px;
border-radius: 50%;
svg {
width: 13px;
}
}
img {
width: var(--size);
height: var(--size);
@@ -12,6 +12,7 @@ import { observable, makeObservable } from "mobx";
import { navigate } from "../../navigation";
import { HotbarStore } from "../../../common/hotbar-store";
import { ConfirmDialog } from "../confirm-dialog";
import { catalogCategoryRegistry } from "../../api/catalog-category-registry";
interface Props extends DOMAttributes<HTMLElement> {
entity: CatalogEntity;
@@ -60,6 +61,21 @@ export class HotbarIcon extends React.Component<Props> {
}
}
get badgeIcon() {
const className = "badge";
const category = catalogCategoryRegistry.getCategoryForEntity(this.props.entity);
if (!category) {
return <Icon material="bug_report" className={className} />;
}
if (category.metadata.icon.includes("<svg")) {
return <Icon svg={category.metadata.icon} className={className} />;
} else {
return <Icon material={category.metadata.icon} className={className} />;
}
}
toggleMenu() {
this.menuOpen = !this.menuOpen;
}
@@ -111,6 +127,7 @@ export class HotbarIcon extends React.Component<Props> {
<div className={className}>
<Tooltip targetId={entityIconId}>{entity.metadata.name}</Tooltip>
<Avatar {...elemProps} id={entityIconId} variant="square" className={isActive ? "active" : "default"}>{this.iconString}</Avatar>
{ this.badgeIcon }
<Menu
usePortal={false}
htmlFor={entityIconId}
+1 -1
View File
@@ -94,7 +94,7 @@ export class Icon extends React.PureComponent<IconProps> {
// render as inline svg-icon
if (svg) {
const svgIconText = require(`!!raw-loader!./${svg}.svg`).default;
const svgIconText = svg.includes("<svg") ? svg : require(`!!raw-loader!./${svg}.svg`).default;
iconContent = <span className="icon" dangerouslySetInnerHTML={{ __html: svgIconText }}/>;
}