1
0
mirror of https://github.com/lensapp/lens.git synced 2025-05-20 05:10:56 +00:00

Second click on list item closes the details view (#3809)

Signed-off-by: Juho Heikka <juho.heikka@gmail.com>
This commit is contained in:
Juho Heikka 2021-09-15 15:48:12 +03:00 committed by GitHub
parent 64fb590377
commit 74f3826235
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
6 changed files with 37 additions and 7 deletions

View File

@ -55,6 +55,14 @@ export class HelmCharts extends Component<Props> {
return helmChartStore.getByName(chartName, repo); return helmChartStore.getByName(chartName, repo);
} }
onDetails = (chart: HelmChart) => {
if (chart === this.selectedChart) {
this.hideDetails();
} else {
this.showDetails(chart);
}
};
showDetails = (chart: HelmChart) => { showDetails = (chart: HelmChart) => {
if (!chart) { if (!chart) {
navigation.push(helmChartsURL()); navigation.push(helmChartsURL());
@ -121,7 +129,7 @@ export class HelmCharts extends Component<Props> {
{ className: "menu" } { className: "menu" }
]} ]}
detailsItem={this.selectedChart} detailsItem={this.selectedChart}
onDetails={this.showDetails} onDetails={this.onDetails}
/> />
{this.selectedChart && ( {this.selectedChart && (
<HelmChartDetails <HelmChartDetails

View File

@ -75,6 +75,14 @@ export class HelmReleases extends Component<Props> {
}); });
} }
onDetails = (item: HelmRelease) => {
if (item === this.selectedRelease) {
this.hideDetails();
} else {
this.showDetails(item);
}
};
showDetails = (item: HelmRelease) => { showDetails = (item: HelmRelease) => {
navigation.push(releaseURL({ navigation.push(releaseURL({
params: { params: {
@ -169,7 +177,7 @@ export class HelmReleases extends Component<Props> {
message: this.renderRemoveDialogMessage(selectedItems) message: this.renderRemoveDialogMessage(selectedItems)
})} })}
detailsItem={this.selectedRelease} detailsItem={this.selectedRelease}
onDetails={this.showDetails} onDetails={this.onDetails}
/> />
<ReleaseDetails <ReleaseDetails
release={this.selectedRelease} release={this.selectedRelease}

View File

@ -122,7 +122,11 @@ export class Catalog extends React.Component<Props> {
} }
onDetails = (item: CatalogEntityItem<CatalogEntity>) => { onDetails = (item: CatalogEntityItem<CatalogEntity>) => {
if (this.catalogEntityStore.selectedItemId === item.getId()) {
this.catalogEntityStore.selectedItemId = null;
} else {
this.catalogEntityStore.selectedItemId = item.getId(); this.catalogEntityStore.selectedItemId = item.getId();
}
}; };
onMenuItemClick(menuItem: CatalogEntityContextMenu) { onMenuItemClick(menuItem: CatalogEntityContextMenu) {

View File

@ -33,7 +33,7 @@ import { boundMethod, cssNames, prevDefault } from "../../utils";
import type { ItemObject } from "../../../common/item.store"; import type { ItemObject } from "../../../common/item.store";
import { Spinner } from "../spinner"; import { Spinner } from "../spinner";
import { ThemeStore } from "../../theme.store"; import { ThemeStore } from "../../theme.store";
import { kubeSelectedUrlParam, showDetails } from "../kube-detail-params"; import { kubeSelectedUrlParam, toggleDetails } from "../kube-detail-params";
import { kubeWatchApi } from "../../../common/k8s-api/kube-watch-api"; import { kubeWatchApi } from "../../../common/k8s-api/kube-watch-api";
import { apiManager } from "../../../common/k8s-api/api-manager"; import { apiManager } from "../../../common/k8s-api/api-manager";
@ -124,7 +124,7 @@ export class ClusterIssues extends React.Component<Props> {
key={getId()} key={getId()}
sortItem={warning} sortItem={warning}
selected={selfLink === kubeSelectedUrlParam.get()} selected={selfLink === kubeSelectedUrlParam.get()}
onClick={prevDefault(() => showDetails(selfLink))} onClick={prevDefault(() => toggleDetails(selfLink))}
> >
<TableCell className="message"> <TableCell className="message">
{message} {message}

View File

@ -41,6 +41,16 @@ export const kubeSelectedUrlParam = createPageParam({
} }
}); });
export function toggleDetails(selfLink: string, resetSelected = true) {
const current = kubeSelectedUrlParam.get() === selfLink;
if (current) {
hideDetails();
} else {
showDetails(selfLink, resetSelected);
}
}
export function showDetails(selfLink = "", resetSelected = true) { export function showDetails(selfLink = "", resetSelected = true) {
const detailsUrl = getDetailsUrl(selfLink, resetSelected); const detailsUrl = getDetailsUrl(selfLink, resetSelected);

View File

@ -31,7 +31,7 @@ import { kubeWatchApi } from "../../../common/k8s-api/kube-watch-api";
import { clusterContext } from "../context"; import { clusterContext } from "../context";
import { NamespaceSelectFilter } from "../+namespaces/namespace-select-filter"; import { NamespaceSelectFilter } from "../+namespaces/namespace-select-filter";
import { ResourceKindMap, ResourceNames } from "../../utils/rbac"; import { ResourceKindMap, ResourceNames } from "../../utils/rbac";
import { kubeSelectedUrlParam, showDetails } from "../kube-detail-params"; import { kubeSelectedUrlParam, toggleDetails } from "../kube-detail-params";
export interface KubeObjectListLayoutProps<K extends KubeObject> extends ItemListLayoutProps<K> { export interface KubeObjectListLayoutProps<K extends KubeObject> extends ItemListLayoutProps<K> {
store: KubeObjectStore<K>; store: KubeObjectStore<K>;
@ -39,7 +39,7 @@ export interface KubeObjectListLayoutProps<K extends KubeObject> extends ItemLis
} }
const defaultProps: Partial<KubeObjectListLayoutProps<KubeObject>> = { const defaultProps: Partial<KubeObjectListLayoutProps<KubeObject>> = {
onDetails: (item: KubeObject) => showDetails(item.selfLink), onDetails: (item: KubeObject) => toggleDetails(item.selfLink),
}; };
@observer @observer