Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add Bindings view in Hooks create page #730

Closed
Closed
Changes from 1 commit
Commits
Show all changes
49 commits
Select commit Hold shift + click to select a range
2936bca
Add Bindings view in Hooks create page
arshadkazmi42 May 12, 2019
641d42b
Create PulseBinding Component and use in PulseMessages and HookForm
arshadkazmi42 May 13, 2019
b8f864b
add static props in PulseBindings component
arshadkazmi42 May 17, 2019
f266cfc
Add binding to return from getDefinition
arshadkazmi42 May 17, 2019
5b9d224
Add bindings to payload
arshadkazmi42 May 23, 2019
f4984a0
Change routingKeyPattern to pattern for bindings in payload
arshadkazmi42 May 24, 2019
7776395
Change pattern to routingKeyPattern
arshadkazmi42 May 24, 2019
81ca99c
merge master
owlishDeveloper May 13, 2019
19a54e6
Add Create Worker Type button. Add Editor view
owlishDeveloper May 16, 2019
d623a5a
Define the workertype creation form
owlishDeveloper May 22, 2019
01ce1c8
Make the form functional
owlishDeveloper May 22, 2019
c9f2079
Cleanup
owlishDeveloper May 27, 2019
09636fd
Correct the provider config part of the component state
owlishDeveloper May 30, 2019
228f4f0
Change fetch query in webserver and change UI to render fetched values
arshadkazmi42 May 30, 2019
c9b3266
Rename worker type to worker pool
owlishDeveloper May 30, 2019
1d3da94
Implement review suggestions. Styling changes
owlishDeveloper May 31, 2019
af8de5e
More suggestions
owlishDeveloper May 31, 2019
eb645b9
Use different icon for Save button
owlishDeveloper May 31, 2019
a409b74
Change field labels. Add some useful styling
owlishDeveloper May 31, 2019
3d50fc2
Merge master
owlishDeveloper May 31, 2019
879ab4f
Finish merging master
owlishDeveloper May 31, 2019
34e753e
Finish merging master
owlishDeveloper May 31, 2019
9f06ab0
Return Dashboard. Remove button spacing for now. Remove some styles
owlishDeveloper Jun 1, 2019
bd061c2
Change imports
owlishDeveloper Jun 3, 2019
6d1929e
Replace FormLabel with ListSubheader. Ensure minimum width of the dro…
owlishDeveloper Jun 3, 2019
a9eeb15
Change name of a field. Change padding
owlishDeveloper Jun 3, 2019
6a7878e
Use vertical spacing instead of indentation to organize the form fields
owlishDeveloper Jun 3, 2019
9af784f
Add skeleton of worker-scanner tests
imbstack May 23, 2019
3f681f7
Add another check to provisioner testing
imbstack May 23, 2019
1cc3491
Add worker-scanner tests
imbstack May 28, 2019
bd28bd5
Parallelize coverage fetching
imbstack Jun 3, 2019
0936543
Add tests for reporting workerpool errors
imbstack Jun 3, 2019
3e35cea
Css cleanup, delete all bindings and save button enable fix
arshadkazmi42 Jun 4, 2019
a8980c3
Add minor changes
owlishDeveloper Jun 4, 2019
645cac1
Worker manager updates (#831)
imbstack Jun 4, 2019
9aa285d
Merge pull request #814 from owlishDeveloper/bug1542905-3
owlishDeveloper Jun 4, 2019
d28d642
Don't specify an explicit PORT for tc-web-ui
djmitche Jun 4, 2019
949fbc5
Merge pull request #836 from djmitche/no-explicit-PORT-for-web-ui
djmitche Jun 4, 2019
21fd0ef
Make setTimeout work with large timeout values (#838)
helfi92 Jun 4, 2019
989c444
Add Bindings view in Hooks create page
arshadkazmi42 May 12, 2019
3bbbb11
Create PulseBinding Component and use in PulseMessages and HookForm
arshadkazmi42 May 13, 2019
76a6f49
add static props in PulseBindings component
arshadkazmi42 May 17, 2019
019d25c
Add binding to return from getDefinition
arshadkazmi42 May 17, 2019
023761b
Add bindings to payload
arshadkazmi42 May 23, 2019
a31db51
Change routingKeyPattern to pattern for bindings in payload
arshadkazmi42 May 24, 2019
61a4307
Change pattern to routingKeyPattern
arshadkazmi42 May 24, 2019
16d71d2
Change fetch query in webserver and change UI to render fetched values
arshadkazmi42 May 30, 2019
badc0a3
Css cleanup, delete all bindings and save button enable fix
arshadkazmi42 Jun 4, 2019
bf4c6e0
Merge branch 'bindings-hook-view' of https://github.com/arshadkazmi42…
arshadkazmi42 Jun 5, 2019
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
123 changes: 123 additions & 0 deletions ui/src/components/HookForm/index.jsx
Expand Up @@ -17,6 +17,7 @@ import Switch from '@material-ui/core/Switch';
import FormGroup from '@material-ui/core/FormGroup';
import FormControlLabel from '@material-ui/core/FormControlLabel';
import Grid from '@material-ui/core/Grid';
import Tooltip from '@material-ui/core/Tooltip';
import IconButton from '@material-ui/core/IconButton';
import Typography from '@material-ui/core/Typography';
import FlashIcon from 'mdi-react/FlashIcon';
Expand Down Expand Up @@ -91,6 +92,10 @@ const initialHook = {
fill: theme.palette.text.primary,
},
},
plusIcon: {
marginTop: 80,
marginRight: 0,
},
listItemButton: {
...theme.mixins.listItemButton,
},
Expand All @@ -115,6 +120,18 @@ const initialHook = {
subheader: {
fontSize: theme.typography.pxToRem(16),
},
bindingListItem: {
paddingTop: 0,
paddingBottom: 0,
},
inputWrapper: {
display: 'flex',
justifyContent: 'space-between',
alignItems: 'center',
},
inputList: {
flex: 1,
},
errorPanel: {
maxHeight: '88vh',
overflow: 'scroll',
Expand Down Expand Up @@ -183,6 +200,9 @@ export default class HookForm extends Component {
hookLastFires: null,
// eslint-disable-next-line react/no-unused-state
previousHook: null,
pattern: '#',
pulseExchange: '',
bindings: [],
taskInput: '',
triggerSchemaInput: '',
triggerContextInput: '',
Expand Down Expand Up @@ -446,6 +466,36 @@ export default class HookForm extends Component {
});
};

handleInputChange = ({ target: { name, value } }) => {
this.setState({ [name]: value });
};

handleAddBinding = () => {
const { pulseExchange, pattern } = this.state;
const bindings = this.state.bindings.concat([
{
exchange: pulseExchange,
pattern,
},
]);

this.setState({
pulseExchange: '',
pattern: '#',
bindings,
});
};

handleDeleteBinding = ({ exchange, pattern }) => {
const bindings = this.state.bindings.filter(
binding => binding.exchange !== exchange || binding.pattern !== pattern
);

this.setState({
bindings,
});
};

render() {
const {
actionLoading,
Expand All @@ -458,6 +508,8 @@ export default class HookForm extends Component {
onDialogOpen,
} = this.props;
const {
pattern,
pulseExchange,
scheduleTextField,
taskInput,
triggerSchemaInput,
Expand All @@ -467,6 +519,7 @@ export default class HookForm extends Component {
validation,
drawerOpen,
drawerData,
bindings,
} = this.state;
const isHookDirty = !equals(hook, this.props.hook);

Expand Down Expand Up @@ -594,6 +647,76 @@ export default class HookForm extends Component {
</ListItem>
</Fragment>
)}
<div className={classes.inputWrapper}>
<List
className={classes.inputList}
subheader={
<ListSubheader className={classes.subheader}>
Bindings
</ListSubheader>
}>
<ListItem>
<ListItemText
primary={
<TextField
required
label="Pulse Exchange"
name="pulseExchange"
placeholder="exchange/<username>/some-exchange-name"
onChange={this.handleInputChange}
fullWidth
value={pulseExchange}
/>
}
/>
</ListItem>
<ListItem>
<ListItemText
primary={
<TextField
required
label="Routing Key Pattern"
placeholder="#.some-interesting-key.#"
name="pattern"
onChange={this.handleInputChange}
fullWidth
value={pattern}
/>
}
/>
</ListItem>
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There seems to be a lot of duplicated logic with localhost:5080/pulse-messages. I was thinking maybe we could create a PulseBindings component that will take care of creating

Screen Shot 2019-05-13 at 10 12 36 AM

component/HookForm and views/PulseMessages would then use that component and feed the appropriate props. Maybe something like:

<PulseBindings bindings={...} onBindingAdd={this.handleBindingAdd} onBindingRemove={this.handleBindingRemove} ... />

What do you think?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actually, I was thinking the same, I was thinking of using existing PulseMessages but that does not seem to help.
I didn't think of creating a new component.
This sounds good. Let me work on it.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Awesome, thanks @arshadkazmi42.

</List>
<Tooltip title="Add Binding">
<IconButton
className={classNames(classes.iconButton, classes.plusIcon)}
onClick={this.handleAddBinding}>
<PlusIcon />
</IconButton>
</Tooltip>
</div>
<List>
{bindings.map(binding => (
<ListItem
className={classes.bindingListItem}
key={`${binding.exchange}-${binding.routingKeyPattern}`}>
<ListItemText
disableTypography
primary={
<Typography variant="body2">
<code>{binding.exchange}</code> with{' '}
<code>{binding.pattern}</code>
</Typography>
}
/>
<IconButton
className={classes.iconButton}
name={binding}
onClick={() => this.handleDeleteBinding(binding)}>
<DeleteIcon />
</IconButton>
</ListItem>
))}
</List>
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Now that we have bindings, we should add a "Schedule" subheader below it and remove the label="Schedule" prop from the TextField component.

Screen Shot 2019-05-13 at 10 09 15 AM

<List>
<ListItem>
<ListItemText
Expand Down