Skip to content

Commit

Permalink
Fixed role management update
Browse files Browse the repository at this point in the history
  • Loading branch information
rmathis committed Aug 18, 2021
1 parent 7fb3df2 commit d596598
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 17 deletions.
3 changes: 3 additions & 0 deletions backend/src/main/resources/i18n/messages.properties
Original file line number Diff line number Diff line change
Expand Up @@ -492,10 +492,13 @@ label.by=By
label.source=Metadata Source
label.provider=Metadata Provider



message.user-role-admin-group=Cannot change group for ROLE_ADMIN users.

label.roles-management=Role Management
label.new-role=New Role
label.edit-role=Edit Role
label.role-name=Role Name
label.role-description=Role Description
label.role=Role
Expand Down
2 changes: 1 addition & 1 deletion ui/src/app/admin/container/EditRole.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ export function EditRole() {

async function save(role) {
let toast;
const resp = await put(``, role);
const resp = await put(`/${role.resourceId}`, role);
if (response.ok) {
gotoDetail({ refresh: true });
toast = createNotificationAction(`Updated role successfully.`, NotificationTypes.SUCCESS);
Expand Down
28 changes: 15 additions & 13 deletions ui/src/app/admin/container/RoleList.js
Original file line number Diff line number Diff line change
Expand Up @@ -46,20 +46,22 @@ export function RoleList({ roles, onDelete }) {
<tbody>
{(roles?.length > 0) ? roles.map((role, i) =>
<tr key={i}>
<td>{role.name}</td>
<td className="align-middle">{role.name}</td>
<td className="text-right">
<Link to={`../roles/${role.resourceId}/edit`} className="btn btn-link text-primary">
<FontAwesomeIcon icon={faEdit} size="lg" />
<span className="sr-only">
<Translate value="action.edit">Edit</Translate>
</span>
</Link>
<Button variant="link" className="text-danger" onClick={() => block(() => remove(role.resourceId))}>
<FontAwesomeIcon icon={faTrash} size="lg" />
<span className="sr-only">
<Translate value="action.delete">Delete</Translate>
</span>
</Button>
<React.Fragment>
<Link disabled={role.name === 'ROLE_ADMIN'} to={`../roles/${role.resourceId}/edit`} className={`btn btn-link text-primary ${role.name === 'ROLE_ADMIN' ? 'disabled' : ''}`}>
<FontAwesomeIcon icon={faEdit} size="lg" />
<span className="sr-only">
<Translate value="action.edit">Edit</Translate>
</span>
</Link>
<Button disabled={role.name === 'ROLE_ADMIN'} variant="link" className="text-danger" onClick={() => block(() => remove(role.resourceId))}>
<FontAwesomeIcon icon={faTrash} size="lg" />
<span className="sr-only">
<Translate value="action.delete">Delete</Translate>
</span>
</Button>
</React.Fragment>
</td>
</tr>
) : <tr>
Expand Down
6 changes: 3 additions & 3 deletions ui/src/app/admin/hoc/RoleProvider.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,13 @@ import { useRole } from '../hooks';

export function RoleProvider({ id, children }) {

const [role, setRole] = React.useState({id: 'foo'});
const [role, setRole] = React.useState();
const { get, response } = useRole(id);

async function loadRole() {
const role = await get(``);
const r = await get(``);
if (response.ok) {
setRole(role);
setRole(r);
}
}

Expand Down

0 comments on commit d596598

Please sign in to comment.