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 CLP modal #632

Merged
merged 1 commit into from
Oct 10, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
62 changes: 38 additions & 24 deletions src/components/PermissionsDialog/PermissionsDialog.react.js
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ function resolvePermission(perms, rowId, column) {
};
}

function resolvePointerPermission(perms, pointerPerms, rowId, column, parseVersion) {
function resolvePointerPermission(perms, pointerPerms, rowId, column, isDeletedColumn) {
const publicAccess = perms.get(column) && perms.get(column).get('*');
const auth = perms.get(column).get('requiresAuthentication');

Expand All @@ -73,7 +73,7 @@ function resolvePointerPermission(perms, pointerPerms, rowId, column, parseVersi
// - Public row: always
// - Authn row: always
// - Entry row: when requires auth OR not Public
const editable = !forceChecked;
const editable = isDeletedColumn ? false : !forceChecked;

return {
checked,
Expand Down Expand Up @@ -301,14 +301,14 @@ function renderSimpleCheckboxes(rowId, perms, onChange) {
];
}

function renderPointerCheckboxes(rowId, perms, pointerPerms, advanced, onChange) {
const get = resolvePointerPermission(perms, pointerPerms, rowId, 'get');
const find = resolvePointerPermission(perms, pointerPerms, rowId, 'find');
const count = resolvePointerPermission(perms, pointerPerms, rowId, 'count');
const create = resolvePointerPermission(perms, pointerPerms, rowId, 'create');
const update = resolvePointerPermission(perms, pointerPerms, rowId, 'update');
const del = resolvePointerPermission(perms, pointerPerms, rowId, 'delete');
const addField = resolvePointerPermission(perms, pointerPerms, rowId, 'addField');
function renderPointerCheckboxes(rowId, perms, pointerPerms, advanced, onChange, isDeletedColumn) {
const get = resolvePointerPermission(perms, pointerPerms, rowId, 'get', isDeletedColumn);
const find = resolvePointerPermission(perms, pointerPerms, rowId, 'find', isDeletedColumn);
const count = resolvePointerPermission(perms, pointerPerms, rowId, 'count', isDeletedColumn);
const create = resolvePointerPermission(perms, pointerPerms, rowId, 'create', isDeletedColumn);
const update = resolvePointerPermission(perms, pointerPerms, rowId, 'update', isDeletedColumn);
const del = resolvePointerPermission(perms, pointerPerms, rowId, 'delete', isDeletedColumn);
const addField = resolvePointerPermission(perms, pointerPerms, rowId, 'addField', isDeletedColumn);

// whether this field is listed under readUserFields[]
const readUserFields = pointerPerms.get('read');
Expand Down Expand Up @@ -1006,6 +1006,7 @@ export default class PermissionsDialog extends React.Component {
</a>
</span>
);
let isDeletedColumn = false;

if (type.user) {
label = (
Expand Down Expand Up @@ -1055,19 +1056,31 @@ export default class PermissionsDialog extends React.Component {
);
} else if (pointer) {
// get class info from schema
const { type, targetClass } = columns[key];

const pillText = type + (targetClass ? `<${targetClass}>` : '');

label = (
<span>
<p>
{key}
{pill(pillText)}
</p>
<p className={styles.hint}>Only users pointed to by this field</p>
</span>
);
const selectedColumn = columns.find(col => col.name === key);
const isColumnTypeChanged = selectedColumn && selectedColumn.type !== 'Pointer';
if (selectedColumn && selectedColumn.type === 'Pointer') {
const { type, targetClass } = selectedColumn;
const pillText = type + (targetClass ? `<${targetClass}>` : '');
label = (
<span>
<p>
{key}
{pill(pillText)}
</p>
<p className={styles.hint}>Only users pointed to by this field</p>
</span>
);
} else {
isDeletedColumn = true;
label = (
<span>
<p>
{key}
</p>
<p className={styles.hint}>{isColumnTypeChanged ? 'The column type has been changed' : 'The column has been deleted'}</p>
</span>
);
}
}

let content = null;
Expand All @@ -1078,7 +1091,8 @@ export default class PermissionsDialog extends React.Component {
this.state.perms,
this.state.pointerPerms.get(key),
this.state.level === 'Advanced',
this.togglePointer.bind(this)
this.togglePointer.bind(this),
isDeletedColumn
);
} else if (this.props.advanced) {
content = renderAdvancedCheckboxes(
Expand Down
Loading