Skip to content

Commit

Permalink
Prod code list security (#467)
Browse files Browse the repository at this point in the history
* feat: make contributor editable for a structure #362

* feat: add autorization for code list page #364

* Delete demo.js
  • Loading branch information
EmmanuelDemey authored Aug 4, 2023
1 parent a1e742f commit 041ee85
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 12 deletions.
10 changes: 6 additions & 4 deletions packages/codelists/src/components/codelist-detail/view.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ import {
CreationUpdateItems,
PublicationFemale,
useTitle,
ConfirmationDelete,
ConfirmationDelete, Auth,
} from 'bauhaus-utilities';
import D, { D1, D2 } from '../../i18n/build-dictionary';
import { CollapsiblePanel } from '../collapsible-panel';
Expand Down Expand Up @@ -67,9 +67,11 @@ export const CodeListDetailView = ({
)}
<ActionToolbar>
<ReturnButton action={handleBack} col={col} />
<ValidationButton callback={publish} object={codelist} />
{updatable && <UpdateButton action={handleUpdate} col={col} />}
{deletable && <DeleteButton action={handleDelete} col={col} />}
<Auth.AuthGuard roles={[Auth.ADMIN]}>
<ValidationButton callback={publish} object={codelist} />
{updatable && <UpdateButton action={handleUpdate} col={col} />}
{deletable && <DeleteButton action={handleDelete} col={col} />}
</Auth.AuthGuard>
</ActionToolbar>
<ErrorBloc error={serverSideError} />
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ import {
ValidationButton,
PublicationFemale,
useTitle,
ConfirmationDelete, CreationUpdateItems,
ConfirmationDelete, CreationUpdateItems, Auth,
} from 'bauhaus-utilities';
import D, { D1, D2 } from '../../i18n/build-dictionary';
import { CollapsiblePanel } from '../collapsible-panel';
Expand Down Expand Up @@ -63,9 +63,11 @@ export const CodeListPartialDetailView = ({
)}
<ActionToolbar>
<ReturnButton action={handleBack} col={col} />
<ValidationButton callback={publish} object={codelist} />
{updatable && <UpdateButton action={handleUpdate} col={col} />}
{deletable && <DeleteButton action={handleDelete} col={col} />}
<Auth.AuthGuard roles={[Auth.ADMIN]}>
<ValidationButton callback={publish} object={codelist} />
{updatable && <UpdateButton action={handleUpdate} col={col} />}
{deletable && <DeleteButton action={handleDelete} col={col} />}
</Auth.AuthGuard>
</ActionToolbar>
<ErrorBloc error={serverSideError} />
{
Expand Down
6 changes: 4 additions & 2 deletions packages/codelists/src/components/home/home.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import {
import { API } from '../../apis';
import { formatLabel } from '../../utils';
import D from '../../i18n/build-dictionary';
import { useTitle, SearchableList } from 'bauhaus-utilities';
import { useTitle, SearchableList, Auth } from 'bauhaus-utilities';

function CodeListsList() {
useTitle(D.codelistsTitle, D.codelistsTitle)
Expand All @@ -30,7 +30,9 @@ function CodeListsList() {
<div className="container codelists-list">
<div className="row">
<VerticalMenu>
<NewButton action="/codelists/create" wrapper={false} />
<Auth.AuthGuard roles={[Auth.ADMIN]}>
<NewButton action="/codelists/create" wrapper={false} />
</Auth.AuthGuard>
</VerticalMenu>
<div className="col-md-8 text-center pull-right">
<PageTitle title={D.codelistTitle} col={12} offset={0} />
Expand Down
6 changes: 4 additions & 2 deletions packages/codelists/src/components/home/partial-home.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import {
import { API } from '../../apis';
import { formatLabel } from '../../utils';
import D from '../../i18n/build-dictionary';
import { useTitle, SearchableList } from 'bauhaus-utilities';
import { useTitle, SearchableList, Auth } from 'bauhaus-utilities';

function CodeListsPartialHome() {
useTitle(D.codelistsPartialTitle, D.codelistsPartialTitle);
Expand All @@ -30,7 +30,9 @@ function CodeListsPartialHome() {
<div className="container codelists-list">
<div className="row">
<VerticalMenu>
<NewButton action="/codelists-partial/create" wrapper={false} />
<Auth.AuthGuard roles={[Auth.ADMIN]}>
<NewButton action="/codelists-partial/create" wrapper={false} />
</Auth.AuthGuard>
</VerticalMenu>
<div className="col-md-8 text-center pull-right">
<PageTitle title={D.codelistTitle} col={12} offset={0} />
Expand Down

0 comments on commit 041ee85

Please sign in to comment.