Skip to content

Commit

Permalink
Updated error message
Browse files Browse the repository at this point in the history
  • Loading branch information
rmathis committed Aug 20, 2021
1 parent 44dba26 commit 2b9c2ff
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 16 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ public class User extends AbstractAuditable implements Owner, Ownable {
private Set<Role> roles = new HashSet<>();

@EqualsAndHashCode.Exclude
@JsonIgnore
// @JsonIgnore
@Transient
private Set<Group> userGroups = new HashSet<>();

Expand Down
16 changes: 3 additions & 13 deletions ui/src/app/core/user/UserContext.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,6 @@ const UserContext = React.createContext();
const { Provider, Consumer } = UserContext;

const path = '/admin/users/current';
const group = {
"name": "ADMIN-GROUP",
"resourceId": "admingroup",
"validationRegex": "^(R\\d*\\/)?P(?:\\d+(?:\\.\\d+)?Y)?(?:\\d+(?:\\.\\d+)?M)?(?:\\d+(?:\\.\\d+)?W)?(?:\\d+(?:\\.\\d+)?D)?(?:T(?:\\d+(?:\\.\\d+)?H)?(?:\\d+(?:\\.\\d+)?M)?(?:\\d+(?:\\.\\d+)?S)?)?$",
"ownerType": "GROUP",
"ownerId": "admingroup"
};

/*eslint-disable react-hooks/exhaustive-deps*/
function UserProvider({ children }) {
Expand All @@ -26,10 +19,7 @@ function UserProvider({ children }) {

async function loadUser() {
const user = await get(`${path}`);
if (response.ok) setUser({
...user,
group
});
if (response.ok) setUser(user);
}

const [user, setUser] = React.useState({});
Expand Down Expand Up @@ -62,12 +52,12 @@ function useIsAdminOrInGroup() {

function useUserGroup() {
const user = useCurrentUser();
return user?.group;
return user?.userGroups[0];
}

function useUserGroupRegexValidator () {
const user = useCurrentUser();
return user?.group?.validationRegex;
return (user?.userGroups && user.userGroups.length > 0) ? user?.userGroups[0].validationRegex : null;
}


Expand Down
10 changes: 8 additions & 2 deletions ui/src/app/metadata/view/MetadataUpload.js
Original file line number Diff line number Diff line change
Expand Up @@ -51,8 +51,14 @@ export function MetadataUpload() {
setSaving(false);
history.push('/dashboard');
} else {
const message = await response.json();
dispatch(createNotificationAction(`${message.errorCode}: Unable to create file ... ${message.errorMessage}`, 'danger', 5000));
let msg;
if (f) {
const message = await response.json();
msg = `${message.errorCode}: Unable to create file ... ${message.errorMessage}`
} else {
msg = await response.text();
}
dispatch(createNotificationAction(msg, 'danger', 5000));
setSaving(false);
}
}
Expand Down

0 comments on commit 2b9c2ff

Please sign in to comment.