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

ASRU user perms UI improvements #72

Merged
merged 3 commits into from
Apr 5, 2019
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
11 changes: 11 additions & 0 deletions assets/sass/app.scss
Original file line number Diff line number Diff line change
Expand Up @@ -81,3 +81,14 @@ td .govuk-button {
margin-bottom: $govuk-gutter;
}
}

.asru-roles {
h3 {
margin-top: $govuk-gutter;
}

ul {
list-style: none;
padding-left: 0;
}
}
6 changes: 3 additions & 3 deletions package-lock.json

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

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
},
"homepage": "https://github.com/UKHomeOffice/asl-internal-ui#readme",
"dependencies": {
"@asl/components": "^3.13.0",
"@asl/components": "^3.13.1",
"@asl/pages": "^15.30.0",
"@asl/projects": "^3.0.0",
"@asl/service": "^7.1.2",
Expand Down
26 changes: 16 additions & 10 deletions pages/profile/components/asru-admin.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,13 @@ class ASRUAdmin extends React.Component {
if (!this.props.canAdmin) {
return <ASRURoles />;
}
return <Fragment>
<ManageRoles />
<ToggleASRU />
</Fragment>;

return (
<Fragment>
<ManageRoles />
<ToggleASRU />
</Fragment>
);
}

render () {
Expand All @@ -33,16 +36,19 @@ class ASRUAdmin extends React.Component {
return null;
}

return <Fragment>
<hr />
<h2><Snippet>asru.title</Snippet></h2>
{ this.renderRoles() }
</Fragment>
return (
<ul className="panel-list">
<li>
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We shouldn't have <li> as a direct child of <div> - it should only ever appear inside a <ul> or <ol>

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good spot, was just testing you were paying attention... 😅

<h2><Snippet>asru.title</Snippet></h2>
{ this.renderRoles() }
</li>
</ul>
);

}

}


const mapStateToProps = ({ model, static: { canAdmin } }) => ({ model, canAdmin });

export default connect(mapStateToProps)(ASRUAdmin);
22 changes: 11 additions & 11 deletions pages/profile/components/asru-roles.jsx
Original file line number Diff line number Diff line change
@@ -1,23 +1,23 @@
import React, { Fragment } from 'react';
import React from 'react';
import { connect } from 'react-redux';

import { Snippet } from '@asl/components';

class Roles extends React.Component {

render () {
const { model, roles } = this.props;

const userRoles = roles.filter(role => model[role]);
return <div className="asru-roles">
<h3><Snippet>asru.roles.title</Snippet></h3>
<ul>
{
userRoles.map(role => <li key={ role }><Snippet>{ `asru.roles.${role}` }</Snippet></li>)
}
</ul>
</div>;

return (
<div className="asru-roles">
<h3><Snippet>asru.roles.title</Snippet></h3>
<ul>
{
userRoles.map(role => <li key={ role }><Snippet>{ `asru.roles.${role}` }</Snippet></li>)
}
</ul>
</div>
);
}

}
Expand Down
8 changes: 4 additions & 4 deletions pages/profile/components/manage-roles.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,15 +8,15 @@ import ASRURoles from './asru-roles';

class ManageRoles extends React.Component {

componentWillMount () {
componentDidMount () {
this.setState({ expanded: false });
}

toggle (e) {
e.preventDefault();
this.setState({
expanded: !this.state.expanded
})
});
}

render () {
Expand All @@ -33,12 +33,12 @@ class ManageRoles extends React.Component {
return <Fragment>
<ASRURoles />
<Button onClick={e => this.toggle(e)}><Snippet>asru.roles.manage</Snippet></Button>
</Fragment>
</Fragment>;
}

return <Fragment>
<form action="" method="post">
<CheckboxGroup label={ <Snippet>asru.roles.title</Snippet> } name="roles" options={options} value={userRoles} className="box" />
<CheckboxGroup label={ <Snippet>asru.roles.title</Snippet> } name="roles" options={options} value={userRoles} />
<ControlBar>
<Button type="submit"><Snippet>asru.roles.save</Snippet></Button>
{
Expand Down
3 changes: 1 addition & 2 deletions pages/profile/components/toggle-asru.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ class ToggleASRU extends React.Component {

renderAdd() {
return <Fragment>
<h3><Snippet>asru.add</Snippet></h3>
<hr />
<form action="" method="post">
<input type="hidden" name="asruUser" value="true" />
<Button type="submit" className="button-secondary"><Snippet>asru.add</Snippet></Button>
Expand All @@ -19,7 +19,6 @@ class ToggleASRU extends React.Component {
renderRemove() {
return <Fragment>
<hr />
<h3><Snippet>asru.remove</Snippet></h3>
<form action="" method="post">
<input type="hidden" name="asruUser" value="false" />
<Button type="submit" className="button-secondary"><Snippet>asru.remove</Snippet></Button>
Expand Down
6 changes: 3 additions & 3 deletions pages/profile/content/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,9 @@ module.exports = merge({}, profileContent, {
add: 'Add to ASRU',
remove: 'Remove from ASRU',
roles: {
title: 'Roles',
manage: 'Manage roles',
save: 'Save changes',
title: 'Permissions',
manage: 'Edit',
save: 'Save',
cancel: 'Cancel',
asruAdmin: 'User admin',
asruLicensing: 'Licensing officer',
Expand Down