这是indexloc提供的服务,不要输入任何密码
Skip to content
Merged
Show file tree
Hide file tree
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
25 changes: 18 additions & 7 deletions console/src/components/Services/Data/TableModify/Modify.scss
Original file line number Diff line number Diff line change
Expand Up @@ -183,9 +183,10 @@ hr
.newRoleTd {
padding-top: 13px;
}
.permissionDelete {
cursor: pointer;
}
//.permissionDelete {
// cursor: pointer;
// margin-left: 10px;
//}

.editPermissionLink {
font-size: 12px;
Expand All @@ -195,10 +196,6 @@ hr
cursor: pointer;
}

.bulkSelect {
margin-right: 10px !important;
}

.clickableCell {
cursor: pointer;
}
Expand All @@ -225,6 +222,20 @@ hr
}
}

.permissionSymbolNA {
color: firebrick;
}

.permissionSymbolFA {
color: green;
}

.permissionSymbolNA,
.permissionSymbolFA,
.permissionSymbolPA {
font-size: 16px;
}

.applyBulkPermissions {
display: inline-block;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -418,9 +418,9 @@ const permRemoveMultipleRoles = tableSchema => {
// Apply migration
const migrationName = 'remove_roles_' + currentSchema + '_table_' + table;

const requestMsg = 'Removing roles...';
const successMsg = 'Roles removed';
const errorMsg = 'Removing roles failed';
const requestMsg = 'Removing permissions...';
const successMsg = 'Permissions removed';
const errorMsg = 'Removing permissions failed';

const customOnSuccess = () => {
// reset new role name
Expand Down
125 changes: 64 additions & 61 deletions console/src/components/Services/Data/TablePermissions/Permissions.js
Original file line number Diff line number Diff line change
Expand Up @@ -315,40 +315,37 @@ class Permissions extends Component {
} else {
const permissions = rolePermissions[role][queryType];

/* eslint-disable no-fallthrough */
if (permissions) {
let checkColumns = false;
let checkColumns;
let filterKey;
switch (queryType) {
case 'select':
case 'update':
checkColumns = true;
case 'delete':
filterKey = 'filter';
case 'insert':
filterKey = filterKey || 'check';

if (JSON.stringify(permissions[filterKey]) === '{}') {
if (
checkColumns &&
!permissions.columns.includes('*') &&
permissions.columns.length !== tableSchema.columns.length
) {
_permission = permissionsSymbols.partialAccess;
} else {
_permission = permissionsSymbols.fullAccess;
}
} else {
_permission = permissionsSymbols.partialAccess;
}
break;
default:
_permission = permissionsSymbols.noAccess;

if (queryType === 'select' || queryType === 'update') {
checkColumns = true;
filterKey = 'filter';
} else if (queryType === 'insert') {
checkColumns = true;
filterKey = 'check';
} else if (queryType === 'delete') {
checkColumns = false;
filterKey = 'filter';
}

if (JSON.stringify(permissions[filterKey]) === '{}') {
if (
checkColumns &&
!permissions.columns.includes('*') &&
permissions.columns.length !== tableSchema.columns.length
) {
_permission = permissionsSymbols.partialAccess;
} else {
_permission = permissionsSymbols.fullAccess;
}
} else {
_permission = permissionsSymbols.partialAccess;
}
} else {
_permission = permissionsSymbols.noAccess;
}
/* eslint-enable no-fallthrough */
}

return _permission;
Expand All @@ -357,13 +354,14 @@ class Permissions extends Component {
const getPermissionsTableRow = (
tableSchema,
role,
roleList,
queryTypes,
permissionsSymbols,
permsState,
isNewPerm
newPermRow
) => {
const dispatchOpenEdit = queryType => () => {
if (isNewPerm && permsState.newRole !== '') {
if (newPermRow && permsState.newRole !== '') {
dispatch(permOpenEdit(tableSchema, permsState.newRole, queryType));
} else if (role !== '') {
const allowInsertPermColumns = semverCheck(
Expand Down Expand Up @@ -393,46 +391,49 @@ class Permissions extends Component {
dispatch(permSetBulkSelect(isChecked, selectedRole));
};

const dispatchDeletePermission = () => {
const isConfirm = window.confirm(
'Are you sure you want to delete the permission for role ' +
role +
'?'
);
if (isConfirm) {
dispatch(permRemoveRole(tableSchema, role));
}
};
// const dispatchDeletePermission = () => {
// const isConfirm = window.confirm(
// 'Are you sure you want to delete the permission for role ' + role + '?'
// );
// if (isConfirm) {
// dispatch(permRemoveRole(tableSchema, role));
// }
// };

const _permissionsRowHtml = [];
if (role === 'admin' || role === '') {
_permissionsRowHtml.push(<td key={-1} />);
} else {
const bulkSelect = permsState.bulkSelect;
const currentInputSelection = (
<input
onChange={dispatchBulkSelect}
checked={bulkSelect.filter(e => e === role).length}
data-role={role}
className={styles.bulkSelect}
type="checkbox"
/>
);

// const deleteIcon = (
// <i
// onClick={dispatchDeletePermission}
// className={styles.permissionDelete + ' fa fa-close'}
// title="Remove all permissions"
// aria-hidden="true"
// />
// );

_permissionsRowHtml.push(
<td key={-1}>
<div>
{currentInputSelection}
<i
onClick={dispatchDeletePermission}
className={styles.permissionDelete + ' fa fa-trash'}
aria-hidden="true"
<input
onChange={dispatchBulkSelect}
checked={bulkSelect.filter(e => e === role).length}
data-role={role}
title="Select for bulk actions"
type="checkbox"
/>
{/*{deleteIcon}*/}
</div>
</td>
);
}

if (isNewPerm) {
if (newPermRow) {
const isNewRole = !roleList.includes(permsState.newRole);

_permissionsRowHtml.push(
<td key={-2}>
<input
Expand All @@ -441,7 +442,7 @@ class Permissions extends Component {
onChange={dispatchRoleNameChange}
type="text"
placeholder="Enter new role"
value={permsState.newRole}
value={isNewRole ? permsState.newRole : ''}
data-test="role-textbox"
/>
</td>
Expand Down Expand Up @@ -478,7 +479,7 @@ class Permissions extends Component {
key={i}
className={className}
onClick={onClick}
title="Click to edit permissions"
title="Edit permissions"
data-test={`${role}-${queryType}`}
>
{getRoleQueryPermission(
Expand Down Expand Up @@ -513,6 +514,7 @@ class Permissions extends Component {
{getPermissionsTableRow(
tableSchema,
role,
roleList,
queryTypes,
permissionsSymbols,
permsState
Expand All @@ -527,6 +529,7 @@ class Permissions extends Component {
{getPermissionsTableRow(
tableSchema,
'',
roleList,
queryTypes,
permissionsSymbols,
permsState,
Expand Down Expand Up @@ -606,9 +609,9 @@ class Permissions extends Component {
roleList
) => {
const permissionsSymbols = {
fullAccess: <i className="fa fa-check" aria-hidden="true" />,
noAccess: <i className="fa fa-times" aria-hidden="true" />,
partialAccess: <i className="fa fa-filter" aria-hidden="true" />,
fullAccess: <i className={'fa fa-check ' + styles.permissionSymbolFA} aria-hidden="true" />,
noAccess: <i className={'fa fa-times ' + styles.permissionSymbolNA} aria-hidden="true" />,
partialAccess: <i className={'fa fa-filter ' + styles.permissionSymbolPA} aria-hidden="true" />,
};

return (
Expand Down Expand Up @@ -1770,7 +1773,7 @@ class Permissions extends Component {
</div>
<div className={styles.padd_bottom}>
<Button onClick={handleBulkRemoveClick} color="red" size="sm">
Remove Permissions
Remove All Permissions
</Button>
</div>
</div>
Expand Down