Skip to content
This repository was archived by the owner on Aug 25, 2021. It is now read-only.

Rbac components fix #77

Merged
merged 3 commits into from
Aug 29, 2018
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
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,7 @@
"babel-preset-env": "^1.7.0",
"babel-preset-es2015": "^6.24.1",
"babel-preset-react": "^6.24.1",
"@babel/runtime": "7.0.0-beta.55",
"bootstrap": "^4.1.1",
"copy-webpack-plugin": "^4.3.1",
"coveralls": "^3.0.0",
Expand Down
6 changes: 1 addition & 5 deletions src/rbac-forms/rbacAssignUserTags.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -170,11 +170,7 @@ class RbacAssignCompanyTags extends Component {
type: 'pf',
name: 'user',
}}
rows={[...users.map(({ role, current_group, ...rest }) => ({ // eslint-disable-line camelcase
role: role.label,
current_group: current_group.label,
...rest,
}))]}
rows={[...users]}
columns={columns}
rowKey="id"
rowClick={() => {}}
Expand Down
2 changes: 1 addition & 1 deletion src/rbac-forms/rbacUserForm.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ const RbacUserForm = ({
form: { change, reset },
}) => (
<PfForm horizontal>
<Grid>
<Grid fluid>
<Row>
<Col xs={12}>
<Field
Expand Down
320 changes: 119 additions & 201 deletions src/rbac-forms/tests/__snapshots__/rbacAssignUserTags.test.jsx.snap

Large diffs are not rendered by default.

78 changes: 70 additions & 8 deletions src/rbac-forms/tests/__snapshots__/rbacUserForm.test.jsx.snap
Original file line number Diff line number Diff line change
Expand Up @@ -116,10 +116,10 @@ exports[`RbacUserForm component Should render correctly 1`] = `
<Grid
bsClass="container"
componentClass="div"
fluid={false}
fluid={true}
>
<div
className="container"
className="container-fluid"
>
<Row
bsClass="row"
Expand Down Expand Up @@ -587,6 +587,25 @@ exports[`RbacUserForm component Should render correctly 1`] = `
</FormControl>
</div>
</Col>
<Col
bsClass="col"
componentClass="div"
md={2}
>
<div
className="col-md-2"
>
<button
className="button-link"
id="password-change-enabler"
onClick={[Function]}
tabIndex="-1"
type="button"
>
Change stored password
</button>
</div>
</Col>
</div>
</FormGroup>
</FinalFormComponent>
Expand Down Expand Up @@ -1298,7 +1317,7 @@ exports[`RbacUserForm component Should render correctly 1`] = `
onTouchMove={[Function]}
onTouchStart={[Function]}
>
<span
<div
className="Select-multi-value-wrapper"
id="react-select-2--value"
>
Expand All @@ -1325,7 +1344,7 @@ exports[`RbacUserForm component Should render correctly 1`] = `
}
tabIndex={0}
/>
</span>
</div>
<span
className="Select-arrow-zone"
onMouseDown={[Function]}
Expand Down Expand Up @@ -1582,10 +1601,10 @@ exports[`RbacUserForm component Should render editing version 1`] = `
<Grid
bsClass="container"
componentClass="div"
fluid={false}
fluid={true}
>
<div
className="container"
className="container-fluid"
>
<Row
bsClass="row"
Expand Down Expand Up @@ -2053,6 +2072,25 @@ exports[`RbacUserForm component Should render editing version 1`] = `
</FormControl>
</div>
</Col>
<Col
bsClass="col"
componentClass="div"
md={2}
>
<div
className="col-md-2"
>
<button
className="button-link"
id="password-change-enabler"
onClick={[Function]}
tabIndex="-1"
type="button"
>
Change stored password
</button>
</div>
</Col>
</div>
</FormGroup>
</FinalFormComponent>
Expand Down Expand Up @@ -2795,7 +2833,7 @@ exports[`RbacUserForm component Should render editing version 1`] = `
onTouchMove={[Function]}
onTouchStart={[Function]}
>
<span
<div
className="Select-multi-value-wrapper"
id="react-select-3--value"
>
Expand All @@ -2813,6 +2851,18 @@ exports[`RbacUserForm component Should render editing version 1`] = `
"value": "10000000000026",
}
}
values={
Array [
Object {
"label": "Cloud-Users",
"value": "10000000000026",
},
Object {
"label": "EvmGroup-consumption_administrator",
"value": "10000000000016",
},
]
}
>
<div
className="Select-value"
Expand Down Expand Up @@ -2856,6 +2906,18 @@ exports[`RbacUserForm component Should render editing version 1`] = `
"value": "10000000000016",
}
}
values={
Array [
Object {
"label": "Cloud-Users",
"value": "10000000000026",
},
Object {
"label": "EvmGroup-consumption_administrator",
"value": "10000000000016",
},
]
}
>
<div
className="Select-value"
Expand Down Expand Up @@ -2903,7 +2965,7 @@ exports[`RbacUserForm component Should render editing version 1`] = `
}
tabIndex={0}
/>
</span>
</div>
<span
className="Select-arrow-zone"
onMouseDown={[Function]}
Expand Down
63 changes: 56 additions & 7 deletions src/rbac-forms/tests/rbacAssignUserTags.test.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ describe('Rbac assign user tags component', () => {
}],
}));
beforeEach(() => {
initialProps.users = users;
initialProps.users = users.map(user => ({ ...user, current_group: 'foo', role: 'bar' }));
initialProps.columns = usersTableColumns;
initialProps.categories = categories.map(category => ({ ...category, label: category.description, value: category.id }));
initialProps.loadCategoryEntry = mockLoadCategoryEntry;
Expand Down Expand Up @@ -83,7 +83,15 @@ describe('Rbac assign user tags component', () => {
});

it('should render correctly without initial assignmets', () => {
const wrapper = mount(<RbacAssignCompanyTags {...initialProps} users={[users[0]]} />);
const wrapper = mount(<RbacAssignCompanyTags
{...initialProps}
users={[{
...users[0],
currentgroup: 'foo',
role: 'bar',
tags: [],
}]}
/>);
wrapper.setState({ isLoaded: true });
wrapper.update();
expect(toJson(wrapper)).toMatchSnapshot();
Expand All @@ -104,7 +112,16 @@ describe('Rbac assign user tags component', () => {

it('should call save function', () => {
const handleSave = jest.fn();
const wrapper = mount(<RbacAssignCompanyTags {...initialProps} users={[{ ...users[0], tags: [] }]} handleSave={handleSave} />);
const wrapper = mount(<RbacAssignCompanyTags
{...initialProps}
users={[{
...users[0],
currentgroup: 'foo',
role: 'bar',
tags: [],
}]}
handleSave={handleSave}
/>);
expect.assertions(1);
return mockInitialLoad()
.then(() => {
Expand Down Expand Up @@ -134,7 +151,15 @@ describe('Rbac assign user tags component', () => {
});

it('should call remove entry', () => {
const wrapper = mount(<RbacAssignCompanyTags {...initialProps} users={[{ ...users[0], tags: [] }]} />);
const wrapper = mount(<RbacAssignCompanyTags
{...initialProps}
users={[{
...users[0],
currentgroup: 'foo',
role: 'bar',
tags: [],
}]}
/>);
expect.assertions(1);
return mockInitialLoad()
.then(() => {
Expand Down Expand Up @@ -165,7 +190,15 @@ describe('Rbac assign user tags component', () => {
});

it('should call reset function', () => {
const wrapper = mount(<RbacAssignCompanyTags {...initialProps} users={[{ ...users[0], tags: [] }]} />);
const wrapper = mount(<RbacAssignCompanyTags
{...initialProps}
users={[{
...users[0],
currentgroup: 'foo',
role: 'bar',
tags: [],
}]}
/>);
expect.assertions(1);
return mockInitialLoad()
.then(() => {
Expand Down Expand Up @@ -195,7 +228,15 @@ describe('Rbac assign user tags component', () => {
});

it('should select new entry state', () => {
const wrapper = mount(<RbacAssignCompanyTags {...initialProps} users={[{ ...users[0], tags: [] }]} />);
const wrapper = mount(<RbacAssignCompanyTags
{...initialProps}
users={[{
...users[0],
currentgroup: 'foo',
role: 'bar',
tags: [],
}]}
/>);
wrapper.setState({
categoryEntries: {
10000000000085: [{
Expand All @@ -222,7 +263,15 @@ describe('Rbac assign user tags component', () => {
});

it('should select new entry state', () => {
const wrapper = mount(<RbacAssignCompanyTags {...initialProps} users={[{ ...users[0], tags: [] }]} />);
const wrapper = mount(<RbacAssignCompanyTags
{...initialProps}
users={[{
...users[0],
currentgroup: 'foo',
role: 'bar',
tags: [],
}]}
/>);
wrapper.instance().handleCategorySelect({ value: 'foo', label: 'bar' });
expect(wrapper.state().selectedCategory).toEqual('foo');
});
Expand Down
4 changes: 2 additions & 2 deletions src/tagging/tests/__snapshots__/tag.modifier.test.js.snap
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP

exports[`Tagging modifier match snapshot 1`] = `
<React.Fragment>
<Fragment>
<Row
bsClass="row"
componentClass="div"
Expand Down Expand Up @@ -80,5 +80,5 @@ exports[`Tagging modifier match snapshot 1`] = `
}
/>
</Form>
</React.Fragment>
</Fragment>
`;
4 changes: 2 additions & 2 deletions src/tagging/tests/__snapshots__/tag.view.test.js.snap
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP

exports[`Tag view match snapshot 1`] = `
<React.Fragment>
<Fragment>
<Row
bsClass="row"
componentClass="div"
Expand Down Expand Up @@ -55,5 +55,5 @@ exports[`Tag view match snapshot 1`] = `
</ul>
</Col>
</Row>
</React.Fragment>
</Fragment>
`;
8 changes: 4 additions & 4 deletions src/tagging/tests/__snapshots__/tagging.test.js.snap
Original file line number Diff line number Diff line change
Expand Up @@ -387,7 +387,7 @@ exports[`Tagging component without redux mapping match snapshot 1`] = `
onTouchMove={[Function]}
onTouchStart={[Function]}
>
<span
<div
className="Select-multi-value-wrapper"
id="react-select-2--value"
>
Expand Down Expand Up @@ -474,7 +474,7 @@ exports[`Tagging component without redux mapping match snapshot 1`] = `
/>
</div>
</AutosizeInput>
</span>
</div>
<span
className="Select-arrow-zone"
onMouseDown={[Function]}
Expand Down Expand Up @@ -648,7 +648,7 @@ exports[`Tagging component without redux mapping match snapshot 1`] = `
onTouchMove={[Function]}
onTouchStart={[Function]}
>
<span
<div
className="Select-multi-value-wrapper"
id="react-select-3--value"
>
Expand Down Expand Up @@ -713,7 +713,7 @@ exports[`Tagging component without redux mapping match snapshot 1`] = `
/>
</div>
</AutosizeInput>
</span>
</div>
<span
className="Select-arrow-zone"
onMouseDown={[Function]}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,6 @@ exports[`GenericGroup renders just fine 1`] = `
</td>
<td>
<IconOrImage
background={null}
icon={null}
image={null}
title={null}
Expand Down Expand Up @@ -89,7 +88,6 @@ exports[`GenericGroup renders just fine 1`] = `
</td>
<td>
<IconOrImage
background={null}
icon={null}
image={null}
title={null}
Expand Down
Loading