-
Notifications
You must be signed in to change notification settings - Fork 115
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
ENH Disable actions users does not have permissions for
Co-authored-by: Scott Hutchinson <scott@silverstripe.com>
- Loading branch information
1 parent
817c49c
commit a30ac14
Showing
20 changed files
with
175 additions
and
14 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Large diffs are not rendered by default.
Oops, something went wrong.
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
51 changes: 51 additions & 0 deletions
51
client/src/components/ElementActions/tests/DuplicateAction-test.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
/* eslint-disable import/no-extraneous-dependencies */ | ||
/* global jest, describe, it, expect */ | ||
|
||
import React from 'react'; | ||
import { Component as DuplicateAction } from '../DuplicateAction'; | ||
import Enzyme, { mount } from 'enzyme'; | ||
import Adapter from 'enzyme-adapter-react-16'; | ||
|
||
Enzyme.configure({ adapter: new Adapter() }); | ||
|
||
describe('DuplicateAction', () => { | ||
let wrapper = null; | ||
const mockMutation = jest.fn(() => new Promise((resolve) => { resolve(); })); | ||
const WrappedComponent = (props) => <div>{props.children}</div>; | ||
const ActionComponent = DuplicateAction(WrappedComponent); | ||
|
||
beforeEach(() => { | ||
wrapper = mount( | ||
<ActionComponent | ||
title="My duplicate action" | ||
element={{ | ||
ID: 123, | ||
BlockSchema: { type: 'Test' }, | ||
canCreate: true | ||
}} | ||
actions={{ handlePublishBlock: mockMutation }} | ||
toggle={false} | ||
/> | ||
); | ||
}); | ||
|
||
it('renders a button', () => { | ||
expect(wrapper.find('button').length).toBe(1); | ||
}); | ||
|
||
it('is disabled when user doesn\'t have correct permissions', () => { | ||
const duplicateWrapper = mount( | ||
<ActionComponent | ||
title="My duplicate action" | ||
element={{ | ||
BlockSchema: { type: 'Test' }, | ||
canCreate: false | ||
}} | ||
actions={{ handleDuplicateBlock: mockMutation }} | ||
toggle={false} | ||
/> | ||
); | ||
|
||
expect(duplicateWrapper.find('button').first().prop('disabled')).toBe(true); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
.element-editor .action-menu { | ||
|
||
& .dropdown-item.disabled { | ||
font-style: italic; | ||
pointer-events: initial; | ||
cursor: not-allowed; | ||
color: $gray-500 | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters