mirror of
https://git.mirrors.martin98.com/https://github.com/SigNoz/signoz
synced 2025-08-15 06:55:58 +08:00
fix: updating dashboard variables is not allowed for viewer role (#2910)
Co-authored-by: Prashant Shahi <prashant@signoz.io>
This commit is contained in:
parent
86c6c43f95
commit
9aa8148269
@ -10,6 +10,7 @@ import { UpdateDashboardVariables } from 'store/actions/dashboard/updatedDashboa
|
|||||||
import { AppState } from 'store/reducers';
|
import { AppState } from 'store/reducers';
|
||||||
import AppActions from 'types/actions';
|
import AppActions from 'types/actions';
|
||||||
import { IDashboardVariable } from 'types/api/dashboard/getAll';
|
import { IDashboardVariable } from 'types/api/dashboard/getAll';
|
||||||
|
import AppReducer from 'types/reducer/app';
|
||||||
import DashboardReducer from 'types/reducer/dashboards';
|
import DashboardReducer from 'types/reducer/dashboards';
|
||||||
|
|
||||||
import VariableItem from './VariableItem';
|
import VariableItem from './VariableItem';
|
||||||
@ -29,6 +30,8 @@ function DashboardVariableSelection({
|
|||||||
const [lastUpdatedVar, setLastUpdatedVar] = useState<string>('');
|
const [lastUpdatedVar, setLastUpdatedVar] = useState<string>('');
|
||||||
const { notifications } = useNotifications();
|
const { notifications } = useNotifications();
|
||||||
|
|
||||||
|
const { role } = useSelector<AppState, AppReducer>((state) => state.app);
|
||||||
|
|
||||||
const onVarChanged = (name: string): void => {
|
const onVarChanged = (name: string): void => {
|
||||||
setLastUpdatedVar(name);
|
setLastUpdatedVar(name);
|
||||||
setUpdate(!update);
|
setUpdate(!update);
|
||||||
@ -36,19 +39,15 @@ function DashboardVariableSelection({
|
|||||||
|
|
||||||
const onValueUpdate = (
|
const onValueUpdate = (
|
||||||
name: string,
|
name: string,
|
||||||
value:
|
value: IDashboardVariable['selectedValue'],
|
||||||
| string
|
|
||||||
| string[]
|
|
||||||
| number
|
|
||||||
| number[]
|
|
||||||
| boolean
|
|
||||||
| boolean[]
|
|
||||||
| null
|
|
||||||
| undefined,
|
|
||||||
): void => {
|
): void => {
|
||||||
const updatedVariablesData = { ...variables };
|
const updatedVariablesData = { ...variables };
|
||||||
updatedVariablesData[name].selectedValue = value;
|
updatedVariablesData[name].selectedValue = value;
|
||||||
|
|
||||||
|
if (role !== 'VIEWER') {
|
||||||
updateDashboardVariables(updatedVariablesData, notifications);
|
updateDashboardVariables(updatedVariablesData, notifications);
|
||||||
|
}
|
||||||
|
|
||||||
onVarChanged(name);
|
onVarChanged(name);
|
||||||
};
|
};
|
||||||
const onAllSelectedUpdate = (
|
const onAllSelectedUpdate = (
|
||||||
@ -57,7 +56,10 @@ function DashboardVariableSelection({
|
|||||||
): void => {
|
): void => {
|
||||||
const updatedVariablesData = { ...variables };
|
const updatedVariablesData = { ...variables };
|
||||||
updatedVariablesData[name].allSelected = value;
|
updatedVariablesData[name].allSelected = value;
|
||||||
|
|
||||||
|
if (role !== 'VIEWER') {
|
||||||
updateDashboardVariables(updatedVariablesData, notifications);
|
updateDashboardVariables(updatedVariablesData, notifications);
|
||||||
|
}
|
||||||
onVarChanged(name);
|
onVarChanged(name);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -1,6 +1,8 @@
|
|||||||
|
import { IDashboardVariable } from '../getAll';
|
||||||
|
|
||||||
export type PayloadVariables = Record<
|
export type PayloadVariables = Record<
|
||||||
string,
|
string,
|
||||||
undefined | null | string | number | boolean | (string | number | boolean)[]
|
IDashboardVariable['selectedValue']
|
||||||
>;
|
>;
|
||||||
|
|
||||||
export type Props = {
|
export type Props = {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user