Skip to content
New issue

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

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

Already on GitHub? Sign in to your account

Fix user routes for admin panel #1323

Merged
merged 5 commits into from
Jun 22, 2022
Merged
Show file tree
Hide file tree
Changes from 2 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
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
* [Developer/UI]: Added in typescript support to webpack build, moving forward all new frontend development will use typescript. See [PR 1294](https://github.com/phac-nml/irida/pull/1294) for more.
* [Developer/UI]: Removed `styled-components` from page header and replaced with CSS variables. See [PR 1284](https://github.com/phac-nml/irida/pull/1284)
* [Developer/UI]: Updated eslint rule to check for object and array destructuring. See [PR 1322](https://github.com/phac-nml/irida/pull/1322)
* [UI]: Fixed user routes for admin panel. See [PR 1323](https://github.com/phac-nml/irida/pull/1323
joshsadam marked this conversation as resolved.
Show resolved Hide resolved

## [22.05.4] - 2022/06/16
* [UI]: Fixed bug preventing filter samples by file to fail on invalid url. See [PR 1318](https://github.com/phac-nml/irida/pull/1318)
Expand Down
125 changes: 72 additions & 53 deletions src/main/webapp/resources/js/pages/admin/components/Admin.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -19,17 +19,28 @@ import { AdminContent } from "./AdminContent";
import AdminHeader from "./AdminHeader";
import AdminSideMenu from "./AdminSideMenu";

import store from '../../user/store'
import { Provider } from 'react-redux'
import store from "../store";
import { Provider } from "react-redux";

const { Content } = Layout;

const AdvancedStatistics = lazy(() =>
import("./statistics/AdvancedStatistics")
);
const BasicStats = lazy(() => import("./statistics/BasicStats"));

const AdminUsersPage = lazy(() => import("./AdminUsersPage"));
const UserAccountLayout = React.lazy(() =>
import("../../user/components/UserAccountLayout")
);
const UserDetailsPage = React.lazy(() =>
import("../../user/components/UserDetailsPage")
);
const UserProjectsPage = React.lazy(() =>
import("../../user/components/UserProjectsPage")
);
const UserSecurityPage = React.lazy(() =>
import("../../user/components/UserSecurityPage")
);
const UserGroupsPage = lazy(() =>
import("../../UserGroupsPage/components/UserGroupsPage")
);
Expand Down Expand Up @@ -58,57 +69,65 @@ export default function Admin() {
* the components are only loaded if the corresponding tab is clicked
*/
return (
<Provider store={store}>
<Layout>
<AdminSideMenu />
<Provider store={store}>
<Layout>
<AdminHeader />
<Content>
<Suspense fallback={<ContentLoading />}>
<Routes>
<Route path={DEFAULT_URL} element={<AdminContent />}>
<Route index element={<BasicStats />} />
<Route
path={`${ADMIN.STATISTICS}/:statType`}
element={<AdvancedStatistics />}
/>
<Route path={ADMIN.USERS} element={<AdminUsersPage />} />

<Route
path={`${ADMIN.USERGROUPS}/list`}
element={
<UserGroupsPage
baseUrl={`${DEFAULT_URL}/${ADMIN.USERGROUPS}`}
/>
}
/>
<Route
path={`${ADMIN.USERGROUPS}/:id`}
element={<UserGroupsDetailsPage />}
/>
<Route path={ADMIN.CLIENTS} element={<ClientListingPage />} />
<Route
path={ADMIN.REMOTEAPI}
element={<AdminRemoteApiPage />}
/>
<Route
path={ADMIN.SEQUENCINGRUNS}
element={<AdminSequencingRunsPage />}
/>
<Route
path={ADMIN.NCBIEXPORTS}
element={<AdminNcbiExportsPage />}
/>
<Route
path={ADMIN.ANNOUNCEMENTS}
element={<AnnouncementAdminPage />}
/>
</Route>
</Routes>
</Suspense>
</Content>
<AdminSideMenu />
<Layout>
<AdminHeader />
<Content>
<Suspense fallback={<ContentLoading />}>
<Routes>
<Route path={DEFAULT_URL} element={<AdminContent />}>
<Route index element={<BasicStats />} />
<Route
path={`${ADMIN.STATISTICS}/:statType`}
element={<AdvancedStatistics />}
/>
<Route path={ADMIN.USERS} element={<AdminUsersPage />} />
<Route
path={`${ADMIN.USERS}/:userId`}
element={<UserAccountLayout />}
>
<Route index element={<UserDetailsPage />} />
<Route path="*" element={<UserDetailsPage />} />
<Route path="projects" element={<UserProjectsPage />} />
<Route path="security" element={<UserSecurityPage />} />
</Route>
<Route
path={`${ADMIN.USERGROUPS}/list`}
element={
<UserGroupsPage
baseUrl={`${DEFAULT_URL}/${ADMIN.USERGROUPS}`}
/>
}
/>
<Route
path={`${ADMIN.USERGROUPS}/:id`}
element={<UserGroupsDetailsPage />}
/>
<Route path={ADMIN.CLIENTS} element={<ClientListingPage />} />
<Route
path={ADMIN.REMOTEAPI}
element={<AdminRemoteApiPage />}
/>
<Route
path={ADMIN.SEQUENCINGRUNS}
element={<AdminSequencingRunsPage />}
/>
<Route
path={ADMIN.NCBIEXPORTS}
element={<AdminNcbiExportsPage />}
/>
<Route
path={ADMIN.ANNOUNCEMENTS}
element={<AnnouncementAdminPage />}
/>
</Route>
</Routes>
</Suspense>
</Content>
</Layout>
</Layout>
</Layout>
</Provider>
</Provider>
);
}
27 changes: 27 additions & 0 deletions src/main/webapp/resources/js/pages/admin/store.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
import { configureStore } from "@reduxjs/toolkit";
import { sequencingRunsApi } from "../../apis/sequencing-runs/sequencing-runs";
import { userApi } from "../../apis/users/users";
import { settingsApi } from "../../apis/settings/settings";
import { passwordResetApi } from "../../apis/password-reset";
import { projectSubscriptionsApi } from "../../apis/projects/project-subscriptions";
/*
Redux Store for admin panel.
For more information on redux stores see: https://redux.js.org/tutorials/fundamentals/part-4-store
*/
export default configureStore({
reducer: {
[passwordResetApi.reducerPath]: passwordResetApi.reducer,
[projectSubscriptionsApi.reducerPath]: projectSubscriptionsApi.reducer,
[userApi.reducerPath]: userApi.reducer,
[settingsApi.reducerPath]: settingsApi.reducer,
[sequencingRunsApi.reducerPath]: sequencingRunsApi.reducer,
},
middleware: (getDefaultMiddleware) =>
getDefaultMiddleware().concat(
passwordResetApi.middleware,
projectSubscriptionsApi.middleware,
userApi.middleware,
settingsApi.middleware,
sequencingRunsApi.middleware
),
});
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ export function UserTable() {
fixed: "left",
render(text, full) {
return IS_ADMIN ? (
joshsadam marked this conversation as resolved.
Show resolved Hide resolved
<a className="t-username" href={setBaseUrl(`users/${full.id}`)}>
<a className="t-username" href={setBaseUrl(`admin/users/${full.id}`)}>
joshsadam marked this conversation as resolved.
Show resolved Hide resolved
{text}
</a>
) : (
Expand Down