Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

enhancement/profile-failure-workflow #241

Open
wants to merge 7 commits into
base: develop
Choose a base branch
from
Open
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
42 changes: 9 additions & 33 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "hhd-ui",
"version": "0.18.1",
"version": "0.18.2",
"private": true,
"dependencies": {
"@ag-grid-community/client-side-row-model": "^30.0.3",
Expand All @@ -24,7 +24,7 @@
"date-fns": "^2.30.0",
"graceful-fs": "^4.2.11",
"internal-nav-helper": "^3.1.0",
"keycloak-js": "^25.0.2",
"keycloak-js": "^25.0.5",
"lodash.debounce": "^4.0.8",
"lodash.isequal": "^4.5.0",
"luxon": "^3.3.0",
Expand Down
12 changes: 6 additions & 6 deletions src/app-bundles/create-rest-bundle.js
Original file line number Diff line number Diff line change
Expand Up @@ -274,7 +274,7 @@ const createRestBundle = (opts) => {
dispatch({
type: actions.ERROR,
payload: {
_err: { err: err },
_err: { err: err, response: body },
_isLoading: false,
_isSaving: false,
_fetchCount: ++fetchCount,
Expand Down Expand Up @@ -348,7 +348,7 @@ const createRestBundle = (opts) => {
dispatch({
type: actions.ERROR,
payload: {
_err: { err: err },
_err: { err: err, response: body },
_isSaving: false,
},
});
Expand Down Expand Up @@ -392,12 +392,12 @@ const createRestBundle = (opts) => {
});

// save changes to the server
apiPut(url, item, (err, _body) => {
apiPut(url, item, (err, body) => {
if (err) {
dispatch({
type: actions.ERROR,
payload: {
_err: { err: err },
_err: { err: err, response: body },
_isSaving: false,
},
});
Expand Down Expand Up @@ -446,12 +446,12 @@ const createRestBundle = (opts) => {
});

// update the state on the server now
apiDelete(url, (err, _body) => {
apiDelete(url, (err, body) => {
if (err) {
dispatch({
type: actions.ERROR,
payload: {
_err: { err: err },
_err: { err: err, response: body },
_isSaving: false,
},
});
Expand Down
2 changes: 0 additions & 2 deletions src/app-bundles/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,6 @@ import notificationBundle from './notification-bundle';
import printBundle from './print-bundle';
import profileAlertsBundle from './profile-alerts-bundle';
import profileAlertSubscriptionsBundle from './profile-alert-subscriptions-bundle';
import profileBundle from './profile-bundle';
import projectAlertConfigs from './project-alert-configs';
import projectMembersBundle from './project-members-bundle';
import projectionBundle from './projection-bundle';
Expand Down Expand Up @@ -141,7 +140,6 @@ export default composeBundles(
printBundle,
profileAlertsBundle,
profileAlertSubscriptionsBundle,
profileBundle,
projectAlertConfigs,
projectMembersBundle,
projectionBundle,
Expand Down
88 changes: 0 additions & 88 deletions src/app-bundles/profile-bundle.js

This file was deleted.

2 changes: 1 addition & 1 deletion src/app-bundles/project-members-bundle.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ export default createRestBundle({
staleAfter: 0,
persist: false,
getTemplate: '/projects/:projectId/members',
urlParamSelectors: ['selectProjectsIdByRoute', 'selectProfileId'],
urlParamSelectors: ['selectProjectsIdByRoute'],
fetchActions: ['URL_UPDATED', 'PROJECTS_FETCH_FINISHED'],
forceFetchActions: [
'PROJECTMEMBERS_ADD_USER_FINISHED',
Expand Down
26 changes: 4 additions & 22 deletions src/app-components/pageContent.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,29 +2,9 @@ import React from 'react';
import { connect } from 'redux-bundler-react';

import { classArray } from '../common/helpers/utils';
import { useGetMyProfile } from '../app-services/collections/profiles.ts';

const hasDevBanner = import.meta.env.VITE_DEVELOPMENT_BANNER === 'true';
// const blacklist = ['/', '/help'];

// const PageContent = connect(
// 'selectRelativePathname',
// ({
// relativePathname: pathname,
// children,
// }) => {
// const pageClasses = classArray([
// 'page-margin',
// hasDevBanner && 'banner',
// ]);

// return (
// <div className={pageClasses}>
// {children}
// </div>
// );
// }
// );

const blacklist = ['/', '/help'];

const PageContent = connect(
Expand All @@ -33,6 +13,8 @@ const PageContent = connect(
relativePathname: pathname,
children,
}) => {
const { data: profile } = useGetMyProfile({ showToast: true });

const pageClasses = classArray([
blacklist.includes(pathname) ? '' : 'page-margin',
hasDevBanner && 'banner',
Expand All @@ -43,7 +25,7 @@ const PageContent = connect(
{children}
</div>
);
}
},
);

export default PageContent;
41 changes: 20 additions & 21 deletions src/app-components/role-filter.jsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import React from 'react';
import { connect } from 'redux-bundler-react';

import { extractRolesObject, useGetMyProfile } from '../app-services/collections/profiles.ts';

export const isUserAllowed = (profileRoles, isAdmin, allowRoles = [], denyRoles = []) => {
// If there are no profile roles, user shouldn't be here
Expand Down Expand Up @@ -40,24 +41,22 @@ export const isUserAllowed = (profileRoles, isAdmin, allowRoles = [], denyRoles
return showChildren;
};

export default connect(
'selectProfileRolesObject',
'selectProfileIsAdmin',
({
profileRolesObject,
profileIsAdmin,
allowRoles = [],
denyRoles = [],
alt = null,
children,
}) => {
const showChildren = isUserAllowed(profileRolesObject, profileIsAdmin, allowRoles, denyRoles);

if (showChildren) {
return <>{children}</>;
} else {
const Alt = alt ? alt : null;
return Alt ? <Alt /> : null;
}
export default ({
allowRoles = [],
denyRoles = [],
alt = null,
children,
}) => {
const { data: profile } = useGetMyProfile({});
const { is_admin } = profile || {};
const roles = extractRolesObject(profile);

const showChildren = isUserAllowed(roles, is_admin, allowRoles, denyRoles);

if (showChildren) {
return <>{children}</>;
} else {
const Alt = alt ? alt : null;
return Alt ? <Alt /> : null;
}
);
};
6 changes: 3 additions & 3 deletions src/app-pages/instrument/notes.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import { Edit } from '@mui/icons-material';
import Button from '../../app-components/button';
import Card from '../../app-components/card';
import RoleFilter from '../../app-components/role-filter';
import { useGetMyProfile } from '../../app-services/collections/profiles.ts';

const NoteEditor = connect(
'selectInstrumentsByRoute',
Expand Down Expand Up @@ -105,22 +106,21 @@ const NoteItem = ({ note, editable, save }) => {
};

export default connect(
'selectProfileActive',
'selectProjectsByRoute',
'selectInstrumentNotesItems',
'doInstrumentNotesSave',
'doInstrumentNotesDelete',
({
profileActive,
projectsByRoute: project,
instrumentNotesItems: notes,
doInstrumentNotesSave: save,
doInstrumentNotesDelete: del,
}) => {
const [isAdding, setIsAdding] = useState(false);
const { data: profile } = useGetMyProfile({});

const { id } = profile || {};
const sorted = notes.sort();
const { id } = profileActive || {};

return (
project && (
Expand Down
Loading