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

panel admin page #2990

Merged
merged 4 commits into from
May 22, 2024
Merged
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
19 changes: 19 additions & 0 deletions src/Components/PanelAdministratorPage/PanelAdministratorPage.jsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
import { Route, Switch } from 'react-router-dom';
// import PropTypes from 'prop-types';
import PanelAdmin from 'Components/AdministratorPage/PanelAdmin';

const PanelAdministratorPage = () => (
<div className="usa-grid-full profile-content-container">
<Switch>
<Route path="/profile/panel_admin/panel/" render={() => <PanelAdmin />} />
</Switch>
</div>
);

PanelAdministratorPage.propTypes = {
};

PanelAdministratorPage.defaultProps = {
};

export default PanelAdministratorPage;
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
import { shallow } from 'enzyme';
import TestUtils from 'react-dom/test-utils';
import { Provider } from 'react-redux';
import { MemoryRouter } from 'react-router-dom';
import configureStore from 'redux-mock-store';
import thunk from 'redux-thunk';
import PanelAdministratorPage from './PanelAdministratorPage';

const middlewares = [thunk];
const mockStore = configureStore(middlewares);

describe('PanelAdministratorPage', () => {
it('mounts', () => {
const wrapper = TestUtils.renderIntoDocument(<Provider store={mockStore({})}><MemoryRouter>
<PanelAdministratorPage />
</MemoryRouter></Provider>);
expect(wrapper).toBeDefined();
});

it('is defined', () => {
const wrapper = shallow(<PanelAdministratorPage />);
expect(wrapper).toBeDefined();
});
});
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
import createLoader from '../Loadable';

export const path = () => import('./PanelAdministratorPage');

const PanelAdministratorPage = createLoader({ path, shouldPreload: false });

const PanelAdministratorPageLoadable = ({ ...rest }) => (
<PanelAdministratorPage {...rest} />
);

export default PanelAdministratorPageLoadable;
1 change: 1 addition & 0 deletions src/Components/PanelAdministratorPage/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export { default } from './PanelAdministratorPage';
Original file line number Diff line number Diff line change
Expand Up @@ -340,7 +340,7 @@ exports[`ProfileMenuExpandedComponent matches snapshot when isGlossaryEditor is
hidden={true}
iconName="calendar"
key="Panel"
link="/profile/panel_admin/"
link="/profile/panel_admin/panel"
search=""
title="Panel"
/>
Expand Down Expand Up @@ -879,7 +879,7 @@ exports[`ProfileMenuExpandedComponent matches snapshot when user is bidcycle_adm
hidden={true}
iconName="calendar"
key="Panel"
link="/profile/panel_admin/"
link="/profile/panel_admin/panel"
search=""
title="Panel"
/>
Expand Down
2 changes: 2 additions & 0 deletions src/Components/ProfilePage/ProfilePage.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ import Ao from 'Containers/Ao';
import Bureau from 'Containers/Bureau';
import Cdo from 'Containers/Cdo';
import Post from 'Containers/Post';
import PanelAdministrator from 'Containers/PanelAdministrator';
import GLOSSARY_EDITOR_PERM from 'Constants/Permissions';
import { USER_PROFILE } from 'Constants/PropTypes';
import Notifications from './Notifications';
Expand Down Expand Up @@ -50,6 +51,7 @@ const ProfilePage = ({ user, isLoading }) => (
<Route path="/profile/ao" component={Ao} />
<Route path="/profile/cdo" component={Cdo} />
<Route path="/profile/post" component={Post} />
<Route path="/profile/panel_admin" component={PanelAdministrator} />
<Route path="/profile/bidtracker" component={BidTracker} />
<Route path="/profile/biddingtool/:id" render={() => <BiddingTool />} />
<Route path="/profile/biddingtool/" render={() => <BiddingTool />} />
Expand Down
2 changes: 1 addition & 1 deletion src/Constants/Menu.js
Original file line number Diff line number Diff line change
Expand Up @@ -418,7 +418,7 @@ export const GET_PROFILE_MENU = () => MenuConfig([
children: [
{
text: 'Panel',
route: '/profile/panel_admin/',
route: '/profile/panel_admin/panel',
icon: 'calendar',
roles: [
'panel_admin',
Expand Down
37 changes: 37 additions & 0 deletions src/Containers/PanelAdministrator/PanelAdministrator.jsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
import { Component } from 'react';
import { connect } from 'react-redux';
import { includes } from 'lodash';
import { USER_PROFILE } from 'Constants/PropTypes';
import { DEFAULT_USER_PROFILE } from 'Constants/DefaultProps';
import PanelAdministratorPage from '../../Components/PanelAdministratorPage';

class PanelAdministratorContainer extends Component {
constructor(props) {
super(props);
this.state = {};
}

getIsPanelAdmin() {
return includes(this.props.userProfile.permission_groups, 'panel_admin');
}

render() {
return (
<PanelAdministratorPage isPost={this.getIsPanelAdmin()} />
);
}
}

PanelAdministratorContainer.propTypes = {
userProfile: USER_PROFILE,
};

PanelAdministratorContainer.defaultProps = {
userProfile: DEFAULT_USER_PROFILE,
};

const mapStateToProps = (state) => ({
userProfile: state.userProfile,
});

export default connect(mapStateToProps, null)(PanelAdministratorContainer);
19 changes: 19 additions & 0 deletions src/Containers/PanelAdministrator/PanelAdministrator.test.jsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
import TestUtils from 'react-dom/test-utils';
import { Provider } from 'react-redux';
import { MemoryRouter } from 'react-router-dom';
import configureStore from 'redux-mock-store';
import thunk from 'redux-thunk';
import PanelAdministrator from './PanelAdministrator';

const middlewares = [thunk];
const mockStore = configureStore(middlewares);

describe('PanelAdministrator', () => {
it('is defined', () => {
const wrapper = TestUtils.renderIntoDocument(<Provider store={mockStore({})}><MemoryRouter>
<PanelAdministrator />
</MemoryRouter></Provider>);
expect(wrapper).toBeDefined();
});
});

1 change: 1 addition & 0 deletions src/Containers/PanelAdministrator/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export { default } from './PanelAdministrator';
Loading