Skip to content

Commit

Permalink
ft(integrationToolModal): Implement creation of integration modal
Browse files Browse the repository at this point in the history
- change AddIntegration to stateful component
- add integrationTool component
- add test for integrationTool component
- add mouse pointer to VisualFeedback failed icon

[Finishes #161381988]
  • Loading branch information
phemonick committed Oct 24, 2018
1 parent 439ca14 commit 98596b5
Show file tree
Hide file tree
Showing 6 changed files with 3,679 additions and 3,460 deletions.
146 changes: 92 additions & 54 deletions client/src/modules/common/Modals/AddIntegration.jsx
Original file line number Diff line number Diff line change
@@ -1,66 +1,104 @@
import React from 'react';
import React, { Component, Fragment } from 'react';
import Modal from 'react-modal';
import PropTypes from 'prop-types';
import IntegrationTool from './integrationTool';
import github from '../../../../public/resources/images/github.png';
import pt from '../../../../public/resources/images/pt.png';
import slack from '../../../../public/resources/images/slack.png';

// Modal.setAppElement('#app');

const AddIntegration = ({ isModalOpen, closeModal }) => (
<Modal
isOpen={isModalOpen}
contentLabel="Add Integration"
ariaHideApp={false}
overlayClassName="message-overlay"
onRequestClose={closeModal}
className="modalStyle integration-modal"
>
<div>
<header className="integration-header">
<h5>Add an Integration</h5>
</header>
<section className="integration-body">
<p className="">Select an integration to add</p>
<div className="integration-tools-container">
<div className="integration-tools">
<div className="integration-tool-names">
<img className="integration-tool-icon" src={github} alt="git" />
<p className="">Github Repository</p>
</div>
<i className="fas fa-greater-than" />
</div>
<div className="integration-tools">
<div className="integration-tool-names">
<img className="integration-tool-icon" src={pt} alt="git" />
<p className="">Pivotal Tracker</p>
</div>
<i className="fas fa-greater-than" />
</div>
<div className="integration-tools">
<div className="integration-tool-names">
<img className="integration-tool-icon" src={slack} alt="git" />
<p className="">Slack Channel (private)</p>
</div>
<i className="fas fa-greater-than" />
</div>
<div className="integration-tools no-border">
<div className="integration-tool-names">
<img className="integration-tool-icon" src={slack} alt="git" />
<p className="">Slack Channel (public)</p>
</div>
<i className="fas fa-greater-than" />
</div>
</div>
class AddIntegration extends Component {
constructor() {
super();
this.state = {
visible: true,
tool: 'github'
};
}

</section>
<footer onClick={() => closeModal()} className="integration-tool-footer">
<p>cancel</p>
</footer>
hideModal = (bool, tool) => {
this.setState({
visible: bool,
tool: tool
});
}

</div>
</Modal>
);
goBack = () => {
this.setState({
visible: true
});
}

closeModal = () => {
this.setState({
visible: true
});
this.props.closeModal();
}

render() {
return (
<Modal
isOpen={this.props.isModalOpen}
contentLabel="Add Integration"
ariaHideApp={false}
overlayClassName="message-overlay"
onRequestClose={this.state.visible ? this.closeModal : this.goBack}
className="modalStyle integration-modal"
>
<div className={this.state.visible ? '' : 'hide'}>
<header className="integration-header">
<h5>Add an Integration</h5>
</header>
<section className="integration-body">
<p className="">Select an integration to add</p>
<div className="integration-tools-container">
<div className="integration-tools mouse-pointer">
<div onClick={() => this.hideModal(false, 'github')} role="presentation" className="integration-tool-names">
<img className="integration-tool-icon" src={github} alt="git" />
<p className="">Github Repository</p>
</div>
<i className="fas fa-greater-than" />
</div>
<div onClick={() => this.hideModal(false, 'pt')} role="presentation" className="integration-tools mouse-pointer">
<div className="integration-tool-names">
<img className="integration-tool-icon" src={pt} alt="git" />
<p className="">Pivotal Tracker</p>
</div>
<i className="fas fa-greater-than" />
</div>
<div onClick={() => this.hideModal(false, 'slack private')} role="presentation" className="integration-tools mouse-pointer">
<div className="integration-tool-names">
<img className="integration-tool-icon" src={slack} alt="git" />
<p className="">Slack Channel (private)</p>
</div>
<i className="fas fa-greater-than" />
</div>
<div onClick={() => this.hideModal(false, 'slack')} role="presentation" className="integration-tools no-border mouse-pointer">
<div className="integration-tool-names">
<img className="integration-tool-icon" src={slack} alt="git" />
<p className="">Slack Channel (public)</p>
</div>
<i className="fas fa-greater-than" />
</div>
</div>

</section>
<footer onClick={() => this.props.closeModal()} role="presentation" className="integration-tool-footer">
<p>cancel</p>
</footer>
</div>
<Fragment>
<IntegrationTool
visible={this.state.visible}
tool={this.state.tool}
goBack={this.goBack}
/>
</Fragment>
</Modal>
);
}
}

AddIntegration.propTypes = {
isModalOpen: PropTypes.bool.isRequired,
Expand Down
76 changes: 76 additions & 0 deletions client/src/modules/common/Modals/integrationTool.jsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
import React from 'react';
import PropTypes from 'prop-types';
import { TextArea } from 'semantic-ui-react';
import github from '../../../../public/resources/images/github.png';
import pt from '../../../../public/resources/images/pt.png';
import slack from '../../../../public/resources/images/slack.png';

const IntegrationTool = ({ visible, tool, goBack }) => (
<div className={visible ? 'hide' : ''}>
<div onClick={goBack} role="presentation" className="go-back mouse-pointer">
<div className="flex-row center-axis flex-center">
<i className="fas fa-arrow-left arrow-back-pointer" />
<h5 className="remove-margin-top">go back</h5>
</div>
</div>
<header className="tool-header">
{tool === 'github' &&
<div className="flex-row flex-center">
<img className="integration-tool-icon" src={github} alt="git" />
<h5 className="remove-margin-top left-margin">Github Repository</h5>
</div>
}
{tool === 'pt' &&
<div className="flex-row flex-center">
<img className="integration-tool-icon" src={pt} alt="git" />
<h5 className="remove-margin-top left-margin">Pivotal Tracker</h5>
</div>
}
{tool === 'slack' &&
<div className="flex-row flex-center">
<img className="integration-tool-icon" src={slack} alt="git" />
<h5 className="remove-margin-top left-margin">Slack channel</h5>
</div>
}
{tool === 'slack private' &&
<div className="flex-row flex-center">
<img className="integration-tool-icon" src={slack} alt="git" />
<h5 className="remove-margin-top left-margin">Slack channel (private)</h5>
</div>
}
</header>
<section className="body-padding">
<div className="">
<div className="flex-column">
{tool === 'slack private' && <p className="remove-margin-bottom">Channel Name</p>}
{tool === 'slack' && <p className="remove-margin-bottom">Channel Name</p>}
{tool === 'github' && <p className="remove-margin-bottom">Repository Name</p>}
{tool === 'pt' && <p className="remove-margin-bottom">tool Name</p>}

<input
className="grey-border"
type="text"
/>
</div>
<div className="flex-column margin-top-12">
<p className="remove-margin-bottom">Description</p>
<TextArea
className="grey-border"
style={{ minHeight: 100 }}
/>
</div>
<div className="integration-btn-container flex-row flex-end">
<button className="btn">Submit</button>
</div>
</div>
</section>
</div>
);

IntegrationTool.propTypes = {
visible: PropTypes.bool.isRequired,
tool: PropTypes.string.isRequired,
goBack: PropTypes.func.isRequired
};

export default IntegrationTool;
22 changes: 22 additions & 0 deletions client/src/tests/toasts.js/integrationTool.test.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
import React from 'react';
import { shallow } from 'enzyme';
import IntegrationTool from '../../modules/common/Modals/integrationTool';

describe('Integration Tool Modal test-suite', () => {
const props = {
goBack: jest.fn(),
tool: 'github',
visible: false
};

it('renders properly', () => {
const IntegrationToolWrapper = shallow(<IntegrationTool {...props} />);
expect(IntegrationToolWrapper.exists()).toBeTruthy();
});

it('should close the modal when go-back is clicked', () => {
const IntegrationToolWrapper = shallow(<IntegrationTool {...props} />);
IntegrationToolWrapper.find('.go-back').simulate('click');
expect(props.goBack).toHaveBeenCalled();
});
});
2 changes: 1 addition & 1 deletion client/src/toasts/VisualFeedback.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ const VisualFeedback = ({ response, modalState, isModalOpened }) => {
{name.created ?
<p>created</p> :
<Popup
trigger={<p>failed</p>}
trigger={<p className="mouse-pointer">failed</p>}
className="failed-tooltip"
inverted
content={name.error}
Expand Down
89 changes: 86 additions & 3 deletions client/styles/components/_teams.scss
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
@import url('https://fonts.googleapis.com/css?family=Lato|Open+Sans+Condensed:300');
$grey: #dddddd;

.team-bg {
background: rgb(248, 248, 248);
Expand Down Expand Up @@ -51,12 +52,13 @@
display: flex;
align-items: center;
justify-content: space-between;
border-bottom: 1px solid #DDDDDD;
border-bottom: 1px solid $grey;
padding: 11px 10px;
font-family: 'Lato';
}

.integration-modal {
margin: 18% auto !important;
padding: 0 !important;
width: 29% !important;
}
Expand All @@ -82,8 +84,8 @@

.integration-body {
padding: 15px 29px;
border-bottom: 1px solid #DDDDDD;
border-top: 1px solid #DDDDDD;
border-bottom: 1px solid $grey;
border-top: 1px solid $grey;
}

.integration-tool-icon {
Expand Down Expand Up @@ -370,3 +372,84 @@ input[type="radio"]:checked+span:after, [type="radio"].with-gap:checked+span:bef
margin-top: 1rem;
margin-left: 8px;
}

.flex-column {
display: flex;
flex-direction: column;
}

.flex-row {
display: flex;
}

.body-padding {
padding: 16px;
}

.remove-margin-bottom {
margin-bottom: 0;
}

.hide {
display: none;
}

.remove-margin-top {
margin-top: 0;
}

.grey-border {
border: 1px solid $grey !important;
}

.flex-end {
justify-content: flex-end;
}

.flex-center {
align-items: center;
}

.center-axis {
justify-content: center;
}

.integration-btn-container {
padding-top: 15px;
}

.tool-header {
border-bottom: 1px solid $grey;
padding: 3px 11px;
}

.mouse-pointer {
cursor: pointer;
}

.arrow-back-pointer {
margin-right: 6px;
margin-top: 7px;
}

.left-margin {
margin-left: -12px;
}

.go-back {
position: absolute;
top: 16rem;
width: 29%;
}

.margin-top-12 {
margin-top: 12px;
}

@media only screen and (max-width: 1020px) {
.go-back {
position: absolute;
top: 9rem;
width: 29%;
}
}
Loading

0 comments on commit 98596b5

Please sign in to comment.