-
Notifications
You must be signed in to change notification settings - Fork 326
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
18 changed files
with
167 additions
and
140 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
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
30 changes: 30 additions & 0 deletions
30
src/Sulu/Bundle/AdminBundle/Resources/js/components/Modal/Actions.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,30 @@ | ||
// @flow | ||
import React from 'react'; | ||
import type {Action} from './types'; | ||
import actionsStyles from './actions.scss'; | ||
|
||
type Props = { | ||
actions: Array<Action>, | ||
}; | ||
|
||
export default class Actions extends React.PureComponent<Props> { | ||
render() { | ||
if (this.props.actions.length > 0) { | ||
return ( | ||
<div className={actionsStyles.actions}> | ||
{this.props.actions.map((action, index) => { | ||
const handleButtonClick = action.onClick; | ||
return ( | ||
<button | ||
key={index} | ||
className={actionsStyles.action} | ||
onClick={handleButtonClick}>{action.title}</button> | ||
); | ||
})} | ||
</div> | ||
); | ||
} | ||
|
||
return null; | ||
} | ||
} |
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
20 changes: 20 additions & 0 deletions
20
src/Sulu/Bundle/AdminBundle/Resources/js/components/Modal/actions.scss
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,20 @@ | ||
@import '../../containers/Application/colors.scss'; | ||
|
||
$actionFontSize: 14px; | ||
$actionColor: $black; | ||
$height: 90px; | ||
|
||
.actions { | ||
line-height: $height; | ||
} | ||
|
||
.action { | ||
padding: 0; | ||
margin: 0 10px 0 0; | ||
border: 0; | ||
background: transparent; | ||
cursor: pointer; | ||
text-decoration: underline; | ||
font-size: $actionFontSize; | ||
color: $actionColor; | ||
} |
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
24 changes: 24 additions & 0 deletions
24
src/Sulu/Bundle/AdminBundle/Resources/js/components/Modal/tests/Actions.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,24 @@ | ||
/* eslint-disable flowtype/require-valid-file-annotation */ | ||
import React from 'react'; | ||
import {render, shallow} from 'enzyme'; | ||
import Actions from '../Actions'; | ||
|
||
test('The component should render', () => { | ||
const actions = [ | ||
{title: 'Action 1', onClick: () => {}}, | ||
{title: 'Action 2', onClick: () => {}}, | ||
]; | ||
const component = render(<Actions actions={actions} />); | ||
expect(component).toMatchSnapshot(); | ||
}); | ||
|
||
test('The component should call the corresponding callback when an action is clicked', () => { | ||
const actions = [ | ||
{title: 'Action 1', onClick: jest.fn()}, | ||
{title: 'Action 2', onClick: jest.fn()}, | ||
]; | ||
const component = shallow(<Actions actions={actions} />); | ||
component.find('button').first().simulate('click'); | ||
expect(actions[0].onClick).toBeCalled(); | ||
expect(actions[1].onClick).not.toBeCalled(); | ||
}); |
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
Oops, something went wrong.