Skip to content

Commit 0463c2a

Browse files
committed
Revert "app/vmui: properly show tenant info if AccountID and ProjectID headers are set by proxy or remove it completely (#664)"
This reverts commit 97ffbff. Reason for revert: this functionality depends on the commit 2d4b343 , which is going to be reverted. The reason for reverting the 2d4b343 is that it mixes multiple unrelated features in a single commit. This functionality must be implemented in a distinct pull request dedicated solely for this functionality at both VictoriaLogs server side and VictoriaLogs web UI. Updates #664 Updates #5 Updates #656
1 parent 88e9e3c commit 0463c2a

File tree

17 files changed

+156
-245
lines changed

17 files changed

+156
-245
lines changed

app/vmui/packages/vmui/src/components/Configurators/GlobalSettings/TenantsConfiguration/TenantsFields.tsx

Lines changed: 90 additions & 119 deletions
Original file line numberDiff line numberDiff line change
@@ -13,17 +13,15 @@ import TextField from "../../../Main/TextField/TextField";
1313
import useBoolean from "../../../../hooks/useBoolean";
1414
import useStateSearchParams from "../../../../hooks/useStateSearchParams";
1515
import { useSearchParams } from "react-router-dom";
16-
import { useAppState } from "../../../../state/common/StateContext";
1716

1817
const TenantsFields: FC = () => {
19-
const { tenantId } = useAppState();
2018
const appModeEnable = getAppModeEnable();
2119
const { isMobile } = useDeviceDetect();
2220
const timeDispatch = useTimeDispatch();
2321

2422
const [searchParams, setSearchParams] = useSearchParams();
25-
const [accountID, setAccountID] = useStateSearchParams(tenantId?.accountID || "0", "accountID");
26-
const [projectID, setProjectID] = useStateSearchParams(tenantId?.projectID || "0", "projectID");
23+
const [accountID, setAccountID] = useStateSearchParams("0", "accountID");
24+
const [projectID, setProjectID] = useStateSearchParams("0", "projectID");
2725
const formattedTenant = `${accountID}:${projectID}`;
2826

2927
const buttonRef = useRef<HTMLDivElement>(null);
@@ -43,134 +41,107 @@ const TenantsFields: FC = () => {
4341
};
4442

4543
const handleReset = () => {
46-
setAccountID(searchParams.get("accountID") || tenantId?.accountID || "0");
47-
setProjectID(searchParams.get("projectID") || tenantId?.projectID || "0");
44+
setAccountID(searchParams.get("accountID") || "0");
45+
setProjectID(searchParams.get("projectID") || "0");
4846
};
4947

5048
useEffect(() => {
5149
if (openPopup) return;
5250
handleReset();
5351
}, [openPopup]);
5452

55-
const isTenantStatic = !!(tenantId?.accountID || tenantId?.projectID);
56-
const tooltipMessage = isTenantStatic ? "Static tenant for a current user" : "Define Tenant ID if you need request to another storage";
57-
58-
const getTenantLabel = () => {
59-
return (
60-
<div ref={buttonRef}>
61-
<div
62-
className="vm-mobile-option"
63-
onClick={isTenantStatic ? undefined : toggleOpenPopup}
64-
>
65-
<span className="vm-mobile-option__icon"><StorageIcon/></span>
66-
<div className="vm-mobile-option-text">
67-
{isMobile && (
68-
<span className="vm-mobile-option-text__label">Tenant ID</span>
69-
)}
70-
<span className="vm-mobile-option-text__value">{formattedTenant}</span>
71-
</div>
72-
{!isTenantStatic && (
73-
<span className="vm-mobile-option__arrow"><ArrowDownIcon/></span>
74-
)}
75-
</div>
76-
</div>
77-
);
78-
};
79-
8053
return (
81-
<div
82-
className={classNames({
83-
"vm-tenant-input": true,
84-
"vm-tenant-input_disabled": isTenantStatic,
85-
"vm-tenant-input_mobile": isMobile,
86-
})}
87-
>
88-
{isMobile ? (
89-
getTenantLabel()
90-
) : (
91-
<Tooltip title={tooltipMessage}>
92-
{isTenantStatic ? (
93-
getTenantLabel()
94-
) : (
95-
<div ref={buttonRef}>
96-
<Button
97-
className={appModeEnable ? "" : "vm-header-button"}
98-
variant="contained"
99-
color="primary"
100-
fullWidth
101-
startIcon={<StorageIcon/>}
102-
endIcon={(
103-
<div
104-
className={classNames({
105-
"vm-execution-controls-buttons__arrow": true,
106-
"vm-execution-controls-buttons__arrow_open": openPopup,
107-
})}
108-
>
109-
<ArrowDownIcon/>
110-
</div>
111-
)}
112-
onClick={toggleOpenPopup}
113-
>
114-
{formattedTenant}
115-
</Button>
54+
<div className="vm-tenant-input">
55+
<Tooltip title="Define Tenant ID if you need request to another storage">
56+
<div ref={buttonRef}>
57+
{isMobile ? (
58+
<div
59+
className="vm-mobile-option"
60+
onClick={toggleOpenPopup}
61+
>
62+
<span className="vm-mobile-option__icon"><StorageIcon/></span>
63+
<div className="vm-mobile-option-text">
64+
<span className="vm-mobile-option-text__label">Tenant ID</span>
65+
<span className="vm-mobile-option-text__value">{formattedTenant}</span>
66+
</div>
67+
<span className="vm-mobile-option__arrow"><ArrowDownIcon/></span>
11668
</div>
69+
) : (
70+
<Button
71+
className={appModeEnable ? "" : "vm-header-button"}
72+
variant="contained"
73+
color="primary"
74+
fullWidth
75+
startIcon={<StorageIcon/>}
76+
endIcon={(
77+
<div
78+
className={classNames({
79+
"vm-execution-controls-buttons__arrow": true,
80+
"vm-execution-controls-buttons__arrow_open": openPopup,
81+
})}
82+
>
83+
<ArrowDownIcon/>
84+
</div>
85+
)}
86+
onClick={toggleOpenPopup}
87+
>
88+
{formattedTenant}
89+
</Button>
11790
)}
118-
</Tooltip>
119-
)}
120-
{!isTenantStatic && (
121-
<Popper
122-
open={openPopup}
123-
placement="bottom-right"
124-
onClose={handleClosePopup}
125-
buttonRef={buttonRef}
126-
title={isMobile ? "Define Tenant ID" : undefined}
91+
</div>
92+
</Tooltip>
93+
<Popper
94+
open={openPopup}
95+
placement="bottom-right"
96+
onClose={handleClosePopup}
97+
buttonRef={buttonRef}
98+
title={isMobile ? "Define Tenant ID" : undefined}
99+
>
100+
<div
101+
className={classNames({
102+
"vm-list vm-tenant-input-list": true,
103+
"vm-list vm-tenant-input-list_mobile": isMobile,
104+
"vm-tenant-input-list_inline": true,
105+
})}
127106
>
128-
<div
129-
className={classNames({
130-
"vm-list vm-tenant-input-list": true,
131-
"vm-list vm-tenant-input-list_mobile": isMobile,
132-
"vm-tenant-input-list_inline": true,
133-
})}
134-
>
135-
<TextField
136-
autofocus
137-
label="accountID"
138-
value={accountID}
139-
onChange={setAccountID}
140-
type="number"
141-
/>
142-
<TextField
143-
autofocus
144-
label="projectID"
145-
value={projectID}
146-
onChange={setProjectID}
147-
type="number"
148-
/>
149-
<div className="vm-tenant-input-list__buttons">
150-
<Tooltip title="Multitenancy in VictoriaLogs documentation">
151-
<a
152-
href="https://docs.victoriametrics.com/victorialogs/#multitenancy"
153-
target="_blank"
154-
rel="help noreferrer"
155-
>
156-
<Button
157-
variant="text"
158-
color="gray"
159-
startIcon={<QuestionIcon/>}
160-
/>
161-
</a>
162-
</Tooltip>
163-
<Button
164-
variant="contained"
165-
color="primary"
166-
onClick={applyChanges}
107+
<TextField
108+
autofocus
109+
label="accountID"
110+
value={accountID}
111+
onChange={setAccountID}
112+
type="number"
113+
/>
114+
<TextField
115+
autofocus
116+
label="projectID"
117+
value={projectID}
118+
onChange={setProjectID}
119+
type="number"
120+
/>
121+
<div className="vm-tenant-input-list__buttons">
122+
<Tooltip title="Multitenancy in VictoriaLogs documentation">
123+
<a
124+
href="https://docs.victoriametrics.com/victorialogs/#multitenancy"
125+
target="_blank"
126+
rel="help noreferrer"
167127
>
168-
Apply
169-
</Button>
170-
</div>
128+
<Button
129+
variant="text"
130+
color="gray"
131+
startIcon={<QuestionIcon/>}
132+
/>
133+
</a>
134+
</Tooltip>
135+
<Button
136+
variant="contained"
137+
color="primary"
138+
onClick={applyChanges}
139+
>
140+
Apply
141+
</Button>
171142
</div>
172-
</Popper>
173-
)}
143+
</div>
144+
</Popper>
174145
</div>
175146
);
176147
};

app/vmui/packages/vmui/src/components/Configurators/GlobalSettings/TenantsConfiguration/style.scss

Lines changed: 0 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -3,31 +3,6 @@
33
.vm-tenant-input {
44
position: relative;
55

6-
&_disabled:not(&_mobile) {
7-
.vm-mobile-option {
8-
&__icon {
9-
color: #fff;
10-
}
11-
&-text {
12-
color: #fff;
13-
&__value {
14-
color: #fff;
15-
}
16-
}
17-
}
18-
}
19-
20-
&_disabled:is(&_mobile) {
21-
.vm-mobile-option {
22-
&__icon {
23-
color: $color-text-disabled;
24-
}
25-
&-text {
26-
color: $color-text-disabled;
27-
}
28-
}
29-
}
30-
316
&-list {
327
max-height: 300px;
338
overflow: auto;

app/vmui/packages/vmui/src/components/Views/JsonView/JsonView.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ export const JsonView: FC<Props> = ({ data }) => {
1212
return s;
1313
}
1414
return JSON.stringify(a);
15-
}).join("\n");
15+
}).join("\n")
1616
}, [data]);
1717
return (
1818
<pre style="line-height: 1.2em">{jsonStr}</pre>

app/vmui/packages/vmui/src/hooks/useFetchAppConfig.ts

Lines changed: 3 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,8 @@
1-
import { useAppDispatch, useAppState } from "../state/common/StateContext";
1+
import { useAppDispatch } from "../state/common/StateContext";
22
import { useEffect, useState } from "preact/compat";
33
import { ErrorTypes } from "../types";
44

55
const useFetchFlags = () => {
6-
const { serverUrl } = useAppState();
76
const dispatch = useAppDispatch();
87

98
const [isLoading, setIsLoading] = useState(false);
@@ -15,23 +14,17 @@ const useFetchFlags = () => {
1514
setIsLoading(true);
1615

1716
try {
18-
const data = await fetch(`${serverUrl}/select/vmui/config.json`);
17+
const data = await fetch("./config.json");
1918
const config = await data.json();
2019
dispatch({ type: "SET_APP_CONFIG", payload: config || {} });
21-
const tenant = {
22-
accountID: data.headers.get("AccountID") || "",
23-
projectID: data.headers.get("ProjectID") || "",
24-
disableTenantInfo: data.headers.get("VL-Disable-Tenant-Controls") == "true",
25-
};
26-
dispatch({ type: "SET_TENANT_ID", payload: tenant });
2720
} catch (e) {
2821
setIsLoading(false);
2922
if (e instanceof Error) setError(`${e.name}: ${e.message}`);
3023
}
3124
};
3225

3326
fetchAppConfig();
34-
}, [serverUrl]);
27+
}, []);
3528

3629
return { isLoading, error };
3730
};

app/vmui/packages/vmui/src/layouts/Footer/Footer.tsx

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@ import { FC, memo } from "preact/compat";
22
import { LogoShortIcon } from "../../components/Main/Icons";
33
import "./style.scss";
44
import { footerLinksToLogs } from "../../constants/footerLinks";
5-
import { useAppState } from "../../state/common/StateContext";
65

76
interface Props {
87
links?: {
@@ -14,12 +13,10 @@ interface Props {
1413

1514
const Footer: FC<Props> = memo(({ links = footerLinksToLogs }) => {
1615
const copyrightYears = `2019-${new Date().getFullYear()}`;
17-
const { appConfig } = useAppState();
18-
const version = appConfig?.version;
1916

2017
return <footer className="vm-footer">
2118
<a
22-
className="vm-link vm-footer__link"
19+
className="vm-link vm-footer__website"
2320
target="_blank"
2421
href="https://victoriametrics.com/"
2522
rel="me noreferrer"
@@ -40,8 +37,7 @@ const Footer: FC<Props> = memo(({ links = footerLinksToLogs }) => {
4037
</a>
4138
))}
4239
<div className="vm-footer__copyright">
43-
&copy; {copyrightYears} VictoriaMetrics.
44-
{version && <span className="vm-footer__version">&nbsp;Version: {version}</span>}
40+
&copy; {copyrightYears} VictoriaMetrics
4541
</div>
4642
</footer>;
4743
});

app/vmui/packages/vmui/src/layouts/Header/HeaderControls/HeaderControls.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ const HeaderControls: FC<ControlsProps & HeaderProps> = ({
5555
if (isMobile) {
5656
return (
5757
<>
58-
<div className="vm-header-controls">
58+
<div>
5959
<Button
6060
className={classNames({
6161
"vm-header-button": !appModeEnable

0 commit comments

Comments
 (0)