Skip to content

Commit

Permalink
Integrated groups with backend
Browse files Browse the repository at this point in the history
  • Loading branch information
rmathis committed Jun 28, 2021
1 parent 8c91f7d commit 2c6ff28
Show file tree
Hide file tree
Showing 8 changed files with 37 additions and 29 deletions.
12 changes: 11 additions & 1 deletion backend/src/main/resources/i18n/messages.properties
Original file line number Diff line number Diff line change
Expand Up @@ -61,8 +61,10 @@ action.user-role=User Role
action.toggle-view=Toggle view
action.advanced=Advanced
action.add-new-attribute=Add new attribute
action.add-new-group=Add new group
action.add-attribute=Add Attribute
action.custom-entity-attributes=Custom Entity Attributes
action.groups=Groups

value.enabled=Enabled
value.disabled=Disabled
Expand Down Expand Up @@ -145,6 +147,9 @@ label.entity-attributes=Entity Attributes
label.custom-entity-attributes=Custom Entity Attributes
label.help-text=Help text
label.default-value=Default Value
label.groups-management=Groups Management
label.new-group=New Group
label.new-attribute=New Custom Entity Attribute

label.metadata-source=Metadata Source
label.metadata-sources=Metadata Sources
Expand All @@ -168,6 +173,8 @@ label.new-endpoint=New Endpoint
label.select-binding=Select Binding Type
label.mark-as-default=Mark as Default
label.attribute-name=Attribute Name
label.group-name=Group Name
label.group-description=Group Description
label.yes=Yes
label.check-all-attributes=Check All Attributes
label.clear-all-attributes=Clear All Attributes
Expand Down Expand Up @@ -644,4 +651,7 @@ tooltip.match=A regular expression against which the entityID is evaluated.
tooltip.remove-existing-formats=Whether to remove any existing formats from a role if any are added by the filter (unmodified roles will be untouched regardless of this setting)
tooltip.nameid-formats-format=Format
tooltip.nameid-formats-value=Value
tooltip.nameid-formats-type=Type
tooltip.nameid-formats-type=Type

tooltip.group-name=Group Name
tooltip.group-description=Group Description
7 changes: 7 additions & 0 deletions ui/public/assets/schema/groups/group.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,13 @@
"type": "string",
"minLength": 1,
"maxLength": 255
},
"description": {
"title": "label.group-description",
"description": "tooltip.group-description",
"type": "string",
"minLength": 1,
"maxLength": 255
}
}
}
2 changes: 1 addition & 1 deletion ui/src/app/admin/component/GroupForm.js
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ export function GroupForm ({group = {}, errors = [], loading = false, schema, on
</div>
<hr />
<div className="row">
<div className="col-12 col-lg-12 order-2">
<div className="col-12 col-lg-6 order-2">
<Form formData={group}
noHtml5Validate={true}
onChange={(form) => onChange(form)}
Expand Down
6 changes: 3 additions & 3 deletions ui/src/app/admin/container/EditGroup.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,12 @@ export function EditGroup() {

const history = useHistory();

const { post, response, loading } = useGroups({});
const { put, response, loading } = useGroups();

const [blocking, setBlocking] = React.useState(false);

async function save(metadata) {
await post(``, metadata);
await put(``, metadata);
if (response.ok) {
gotoDetail({ refresh: true });
}
Expand All @@ -48,7 +48,7 @@ export function EditGroup() {
<div className="section-header bg-info p-2 text-white">
<div className="row justify-content-between">
<div className="col-md-12">
<span className="display-6"><Translate value="label.new-group">Add a new group</Translate></span>
<span className="display-6"><Translate value="label.edit-group">Edit group</Translate></span>
</div>
</div>
</div>
Expand Down
7 changes: 2 additions & 5 deletions ui/src/app/admin/container/GroupsList.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,11 @@ import Button from 'react-bootstrap/Button';
import { Link } from 'react-router-dom';

import { Translate } from '../../i18n/components/translate';
import { useTranslator } from '../../i18n/hooks';

import { DeleteConfirmation } from '../../core/components/DeleteConfirmation';

export function GroupsList({ groups, onDelete }) {

const translator = useTranslator();

const remove = (id) => {
onDelete(id);
}
Expand Down Expand Up @@ -51,13 +48,13 @@ export function GroupsList({ groups, onDelete }) {
<tr key={i}>
<td>{group.name}</td>
<td className="text-right">
<Link to={`../groups/${group.name}/edit`} className="btn btn-link text-primary">
<Link to={`../groups/${group.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(group.name))}>
<Button variant="link" className="text-danger" onClick={() => block(() => remove(group.resourceId))}>
<FontAwesomeIcon icon={faTrash} size="lg" />
<span className="sr-only">
<Translate value="action.delete">Delete</Translate>
Expand Down
6 changes: 1 addition & 5 deletions ui/src/app/admin/hoc/GroupProvider.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,7 @@ import { useGroup } from '../hooks';
export function GroupProvider({ id, children }) {

const [group, setGroup] = React.useState();


const { get, response } = useGroup({
cachePolicy: 'no-cache'
});
const { get, response } = useGroup(id);

async function loadGroup() {
const group = await get(``);
Expand Down
8 changes: 2 additions & 6 deletions ui/src/app/admin/hoc/GroupsProvider.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,7 @@ import { useGroups } from '../hooks';

export function GroupsProvider({ children }) {

const [groups, setGroups] = React.useState([
{
name: 'foo'
}
]);
const [groups, setGroups] = React.useState([]);


const { get, del, response } = useGroups({
Expand All @@ -29,7 +25,7 @@ export function GroupsProvider({ children }) {
}

/*eslint-disable react-hooks/exhaustive-deps*/
// React.useEffect(() => { loadGroups() }, []);
React.useEffect(() => { loadGroups() }, []);

return (<>{children(groups, removeGroup)}</>);
}
18 changes: 10 additions & 8 deletions ui/src/app/admin/hooks.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,19 +2,21 @@ import useFetch from 'use-http';
import API_BASE_PATH from '../App.constant';

export function useGroups () {
return useFetch(`${API_BASE_PATH}/groups`);
return useFetch(`${API_BASE_PATH}/admin/groups`, {
cachePolicy: 'no-cache'
});
}

export function useGroup() {
return useFetch(`/group.json`);
export function useGroup(id) {
return useFetch(`${API_BASE_PATH}/admin/groups/${id}`, {
cachePolicy: 'no-cache'
});
}

/*export function useGroup() {
return useFetch(`${API_BASE_PATH}/group`);
}*/

export function useGroupUiSchema () {
return {

description: {
'ui:widget': 'textarea'
}
};
}

0 comments on commit 2c6ff28

Please sign in to comment.