[go: nahoru, domu]

Skip to content

Commit

Permalink
[frontend] Fix workspace creation in explore view list (#210)
Browse files Browse the repository at this point in the history
  • Loading branch information
Samuel Hassine authored and richard-julien committed Oct 14, 2019
1 parent d67d69d commit 3d4ea6e
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 47 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import IconButton from '@material-ui/core/IconButton';
import Fab from '@material-ui/core/Fab';
import { Add, Close } from '@material-ui/icons';
import {
compose, pathOr, pipe, map, pluck, union, assoc,
compose, pathOr, pipe, map, pluck, assoc,
} from 'ramda';
import * as Yup from 'yup';
import graphql from 'babel-plugin-relay/macro';
Expand All @@ -19,9 +19,6 @@ import { fetchQuery, commitMutation } from '../../../relay/environment';
import Autocomplete from '../../../components/Autocomplete';
import TextField from '../../../components/TextField';
import { markingDefinitionsSearchQuery } from '../settings/MarkingDefinitions';
import IdentityCreation, {
identityCreationIdentitiesSearchQuery,
} from '../common/identities/IdentityCreation';

const styles = theme => ({
drawerPaper: {
Expand Down Expand Up @@ -94,9 +91,6 @@ class WorkspaceCreation extends Component {
super(props);
this.state = {
open: false,
identities: [],
identityCreation: false,
identityInput: '',
markingDefinitions: [],
};
}
Expand All @@ -109,27 +103,6 @@ class WorkspaceCreation extends Component {
this.setState({ open: false });
}

searchIdentities(event) {
fetchQuery(identityCreationIdentitiesSearchQuery, {
search: event.target.value,
first: 10,
}).then((data) => {
const identities = pipe(
pathOr([], ['identities', 'edges']),
map(n => ({ label: n.node.name, value: n.node.id })),
)(data);
this.setState({ identities: union(this.state.identities, identities) });
});
}

handleOpenIdentityCreation(inputValue) {
this.setState({ identityCreation: true, identityInput: inputValue });
}

handleCloseIdentityCreation() {
this.setState({ identityCreation: false });
}

searchMarkingDefinitions(event) {
fetchQuery(markingDefinitionsSearchQuery, {
search: event.target.value,
Expand Down Expand Up @@ -214,12 +187,7 @@ class WorkspaceCreation extends Component {
validationSchema={workspaceValidation(t)}
onSubmit={this.onSubmit.bind(this)}
onReset={this.onReset.bind(this)}
render={({
submitForm,
handleReset,
isSubmitting,
setFieldValue,
}) => (
render={({ submitForm, handleReset, isSubmitting }) => (
<div>
<Form style={{ margin: '20px 0 20px 0' }}>
<Field
Expand Down Expand Up @@ -265,18 +233,6 @@ class WorkspaceCreation extends Component {
</Button>
</div>
</Form>
<IdentityCreation
contextual={true}
inputValue={this.state.identityInput}
open={this.state.identityCreation}
handleClose={this.handleCloseIdentityCreation.bind(this)}
creationCallback={(data) => {
setFieldValue('createdByRef', {
label: data.identityAdd.name,
value: data.identityAdd.id,
});
}}
/>
</div>
)}
/>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -97,15 +97,20 @@ class Workspaces extends Component {
const {
view, sortBy, orderAsc, searchTerm,
} = this.state;
const { workspaceType } = this.props;
const paginationOptions = {
search: searchTerm,
orderBy: sortBy,
orderMode: orderAsc ? 'asc' : 'desc',
workspaceType,
};
return (
<div>
{view === 'lines' ? this.renderLines(paginationOptions) : ''}
<WorkspaceCreation paginationOptions={paginationOptions} />
<WorkspaceCreation
paginationOptions={paginationOptions}
workspaceType={workspaceType}
/>
</div>
);
}
Expand All @@ -115,6 +120,7 @@ Workspaces.propTypes = {
t: PropTypes.func,
history: PropTypes.object,
location: PropTypes.object,
workspaceType: PropTypes.string,
};

export default compose(
Expand Down

0 comments on commit 3d4ea6e

Please sign in to comment.