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

Change library group permissions #99

Merged
merged 15 commits into from
Nov 13, 2023
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
6 changes: 3 additions & 3 deletions src/components/pages/content/ContentLibrary.js
Original file line number Diff line number Diff line change
Expand Up @@ -109,9 +109,9 @@ class ContentLibrary extends React.Component {
</div>
<Tabs
options={[
["Viewers", "accessor"],
["Contributors", "contributor"],
["Reviewers", "reviewer"]
["View", "accessor"],
["Contribute", "contributor"],
["Manage", "reviewer"]
]}
className="secondary"
selected={this.state.groupsView}
Expand Down
67 changes: 46 additions & 21 deletions src/components/pages/content/ContentLibraryGroupForm.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,7 @@ class ContentLibraryGroupForm extends React.Component {

this.state = {
groupAddress: "",
accessor: false,
reviewer: false,
contributor: false
selectedPermission: ""
};

this.PageContent = this.PageContent.bind(this);
Expand All @@ -28,19 +26,19 @@ class ContentLibraryGroupForm extends React.Component {

this.setState({
groupAddress: event.target.value,
accessor: !!permissions.accessor,
contributor: !!permissions.contributor,
reviewer: !!permissions.reviewer
selectedPermission: (
permissions.reviewer ? "MANAGE" : permissions.contributor ? "CONTRIBUTE" : permissions.accessor ? "VIEW" : ""
)
});
}

async HandleSubmit() {
await this.props.libraryStore.UpdateContentLibraryGroup({
libraryId: this.props.libraryStore.libraryId,
groupAddress: this.state.groupAddress,
accessor: this.state.accessor,
reviewer: this.state.reviewer,
contributor: this.state.contributor
accessor: this.state.selectedPermission === "VIEW",
reviewer: this.state.selectedPermission === "MANAGE",
contributor: this.state.selectedPermission === "CONTRIBUTE"
});

await this.props.LoadGroups();
Expand Down Expand Up @@ -102,27 +100,54 @@ class ContentLibraryGroupForm extends React.Component {
>
<div className="form-content">
{ this.Groups() }
</div>

<label htmlFor="accessor">Viewer</label>
<div className="radio-item">
<input
type="checkbox"
checked={this.state.accessor}
onChange={() => this.setState({accessor: !this.state.accessor})}
type="radio"
id="view"
checked={this.state.selectedPermission === "VIEW"}
value={this.state.selectedPermission === "VIEW"}
onChange={() => this.setState({selectedPermission: "VIEW"})}
/>
<div className="radio-label">
<label htmlFor="view">View</label>
<div className="radio-helper-text">
List content objects in the library. View library metadata.
</div>
</div>
</div>

<label htmlFor="contributor">Contributor</label>
<div className="radio-item">
<input
type="checkbox"
checked={this.state.contributor}
onChange={() => this.setState({contributor: !this.state.contributor})}
type="radio"
id="contribute"
checked={this.state.selectedPermission === "CONTRIBUTE"}
value={this.state.selectedPermission === "CONTRIBUTE"}
onChange={() => this.setState({selectedPermission: "CONTRIBUTE"})}
/>
<div className="radio-label">
<label htmlFor="contribute">Contribute</label>
<div className="radio-helper-text">
List and create new content objects in the library. View library metadata.
</div>
</div>
</div>

<label htmlFor="reviewer">Reviewer</label>
<div className="radio-item">
<input
type="checkbox"
checked={this.state.reviewer}
onChange={() => this.setState({reviewer: !this.state.reviewer})}
type="radio"
id="manage"
checked={this.state.selectedPermission === "MANAGE"}
value={this.state.selectedPermission === "MANAGE"}
onChange={() => this.setState({selectedPermission: "MANAGE"})}
/>
<div className="radio-label">
<label htmlFor="manage">Manage</label>
<div className="radio-helper-text">
List, create and delete content objects in the library. Edit library metadata.
</div>
</div>
</div>
</Form>
)}
Expand Down
26 changes: 26 additions & 0 deletions src/static/stylesheets/forms.scss
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,32 @@ form {
}
}

.-elv-form {
input {
&[type="radio"] {
cursor: pointer;
height: 100%;
margin: 3px 0 0;
width: 1rem;
}
}
}

.radio-item {
align-items: flex-start;
display: flex;
flex-direction: row;
gap: 2rem; // sass-lint:disable-line no-misspelled-properties
margin-bottom: 1rem;

.radio-helper-text {
color: $elv-color-text-lighter;
font-size: $elv-font-m;
margin-top: $elv-spacing-xxs;
}
}


fieldset {
display: flex;
flex-direction: column;
Expand Down