Skip to content

Commit

Permalink
Add settings table keys check to canUserChangeCell
Browse files Browse the repository at this point in the history
  • Loading branch information
hermann-p committed Jan 16, 2024
1 parent dadd605 commit 7b87e65
Showing 1 changed file with 15 additions and 2 deletions.
17 changes: 15 additions & 2 deletions src/app/helpers/accessManagementHelper.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
import f from "lodash/fp";

import { Langtags, ImmutableColumnKinds } from "../constants/TableauxConstants";
import {
Langtags,
ImmutableColumnKinds,
TableType
} from "../constants/TableauxConstants";
import { memoizeWith, unless } from "./functools";
import { noAuthNeeded } from "./authenticate";
import store from "../redux/store";
Expand Down Expand Up @@ -63,6 +67,11 @@ const getPermission = pathToPermission =>
lookUpPermissions
);

const isSettingsTable = table => table.type === TableType.settings;
const isSettingsKey = cell =>
isSettingsTable(cell.table) &&
(cell.column.name === "key" || cell.column.name === "displayKey");

// (cell | {tableId: number, columnId: number}) -> (langtag | nil) -> boolean
export const canUserChangeCell = f.curry((cellInfo, langtag) => {
const { kind } = cellInfo;
Expand All @@ -72,7 +81,11 @@ export const canUserChangeCell = f.curry((cellInfo, langtag) => {
? editCellValue
: f.isPlainObject(editCellValue) && editCellValue[langtag];

return !f.contains(kind, ImmutableColumnKinds) && (allowed || noAuthNeeded()); // this special case is not caught by ALLOW_ANYTHING
return (
!isSettingsKey(cellInfo) &&
!f.contains(kind, ImmutableColumnKinds) &&
(allowed || noAuthNeeded())
); // this special case is not caught by ALLOW_ANYTHING
});

export const canUserChangeAnyCountryTypeCell = cellInfo => {
Expand Down

0 comments on commit 7b87e65

Please sign in to comment.