Skip to content

Commit

Permalink
Merge branch 'v3' into PMM-12776-re-enable-RBAC
Browse files Browse the repository at this point in the history
  • Loading branch information
matejkubinec committed Jun 19, 2024
2 parents 4d861be + 5ea2ec4 commit f1b8d5b
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import React from 'react';
import { GrafanaTheme2 } from '@grafana/data';
import { selectors } from '@grafana/e2e-selectors';
import { Icon, Link, useTheme2 } from '@grafana/ui';
import { useLinkWithVariables } from 'app/percona/shared/helpers/navigation';

export interface Props {
children: React.ReactNode;
Expand All @@ -17,6 +18,8 @@ export function MegaMenuItemText({ children, isActive, onClick, target, url }: P
const theme = useTheme2();
const styles = getStyles(theme, isActive);
const LinkComponent = !target && url.startsWith('/') ? Link : 'a';
// @PERCONA
const urlWithVariables = useLinkWithVariables(url);

const linkContent = (
<div className={styles.linkContent}>
Expand All @@ -35,7 +38,7 @@ export function MegaMenuItemText({ children, isActive, onClick, target, url }: P
className={cx(styles.container, {
[styles.containerActive]: isActive,
})}
href={url}
href={urlWithVariables}
target={target}
onClick={onClick}
>
Expand Down
2 changes: 1 addition & 1 deletion public/app/percona/inventory/Inventory.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ export const InventoryService = {
return api.post<NodeListDBPayload, object>(`/v1/management/Node/List`, body, false, token);
},
removeNode(body: RemoveNodeBody, token?: CancelToken) {
return api.post<void, RemoveNodeBody>(`${BASE_URL}/Nodes/Remove`, body, false, token);
return api.post<void, RemoveNodeBody>(`/v1/management/Node/Unregister`, body, false, token);
},
getService(serviceId: string, token?: CancelToken) {
return api.post<any, any>(`${BASE_URL}/Services/Get`, { service_id: serviceId }, false, token);
Expand Down
21 changes: 21 additions & 0 deletions public/app/percona/shared/helpers/navigation.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
import { getLinkSrv } from 'app/features/panel/panellinks/link_srv';

export const useLinkWithVariables = (url?: string) => {
if (url?.match('/d/')) {
return getLinkSrv().getLinkUrl({
url: url,
keepTime: true,
// Check if the DB type matches the current one used
includeVars: checkDbType(url),
});
} else {
return url ? url : '#';
}
};

const checkDbType = (url: string): boolean => {
const currentDB = window.location.pathname.split('/')[3].split('-')[0];
const urlDB = url.split('/')[3].split('-')[0];

return currentDB === urlDB;
};

0 comments on commit f1b8d5b

Please sign in to comment.