Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix breadcrumb link issue for istio config type #6636

Merged
merged 1 commit into from
Sep 19, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
27 changes: 12 additions & 15 deletions frontend/src/components/BreadcrumbView/BreadcrumbView.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,13 +13,13 @@ interface BreadCumbViewProps {
};
}

interface BreadCumbViewState {
namespace: string;
interface BreadcrumbViewState {
cluster?: string;
itemName: string;
istioType?: string;
item: string;
itemName: string;
namespace: string;
pathItem: string;
istioType?: string;
}

const ItemNames = {
Expand All @@ -32,7 +32,7 @@ const ItemNames = {
const IstioName = 'Istio Config';
const namespaceRegex = /namespaces\/([a-z0-9-]+)\/([\w-.]+)\/([\w-.*]+)(\/([\w-.]+))?(\/([\w-.]+))?/;

export class BreadcrumbView extends React.Component<BreadCumbViewProps, BreadCumbViewState> {
export class BreadcrumbView extends React.Component<BreadCumbViewProps, BreadcrumbViewState> {
static capitalize = (str: string) => {
return str.charAt(0).toUpperCase() + str.slice(1);
};
Expand All @@ -47,29 +47,26 @@ export class BreadcrumbView extends React.Component<BreadCumbViewProps, BreadCum
this.state = this.updateItem();
}

updateItem = () => {
let regex = namespaceRegex;
let extension = false;
const match = this.props.location.pathname.match(regex) || [];
updateItem = (): BreadcrumbViewState => {
const match = this.props.location.pathname.match(namespaceRegex) || [];
const ns = match[1];
const page = Paths[match[2].toUpperCase()];
const istioType = match[3];
const urlParams = new URLSearchParams(this.props.location.search);
let itemName = page !== 'istio' ? match[3] : match[5];
return {
namespace: ns,
cluster: HistoryManager.getClusterName(urlParams),
pathItem: page,
istioType: istioType,
item: itemName,
itemName: ItemNames[page],
istioType: istioType,
extension: extension
namespace: ns,
pathItem: page
};
};

componentDidUpdate(
prevProps: Readonly<BreadCumbViewProps>,
_prevState: Readonly<BreadCumbViewState>,
_prevState: Readonly<BreadcrumbViewState>,
_snapshot?: any
): void {
if (prevProps.location !== this.props.location) {
Expand Down Expand Up @@ -120,7 +117,7 @@ export class BreadcrumbView extends React.Component<BreadCumbViewProps, BreadCum
{isIstio && (
<BreadcrumbItem>
<Link
to={`/${pathItem}?namespaces=${namespace}&istiotype=${dicIstioType[this.state.istioType || '']}`}
to={`/${pathItem}?namespaces=${namespace}&type=${dicIstioType[this.state.istioType || '']}`}
onClick={this.cleanFilters}
>
{istioType ? BreadcrumbView.istioType(istioType) : istioType}
Expand Down
4 changes: 2 additions & 2 deletions frontend/src/components/VirtualList/VirtualList.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ class VirtualListComponent<R extends RenderResource> extends React.Component<Vir
if (direction) {
HistoryManager.setParam(URLParam.DIRECTION, direction);
}
HistoryManager.setParam(URLParam.SORT, String(this.state.conf.columns[index].param));
HistoryManager.setParam(URLParam.SORT, String(this.state.columns[index].param));
this.props.sort && this.props.sort(FilterHelper.currentSortField(Sorts.sortFields), direction === 'asc');
};

Expand All @@ -103,7 +103,7 @@ class VirtualListComponent<R extends RenderResource> extends React.Component<Vir
info => !this.props.hiddenColumns || !this.props.hiddenColumns.includes(info.column.toLowerCase())
);
columns = filteredColumns.map(info => {
let config = { title: info.column, renderer: info.renderer };
let config = { param: info.param, title: info.column, renderer: info.renderer };
if (info.transforms) {
config['transforms'] = info.transforms;
}
Expand Down
4 changes: 2 additions & 2 deletions frontend/src/pages/IstioConfigList/FiltersAndSorts.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@ export const sortFields: SortField<IstioConfigItem>[] = [
}
},
{
id: 'istiotype',
title: 'Istio Type',
id: 'type',
title: 'Type',
isNumeric: false,
param: 'it',
compare: (a: IstioConfigItem, b: IstioConfigItem) => {
Expand Down