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
Add Bindings view in Hooks create page #730
Conversation
ui/src/components/HookForm/index.jsx
Outdated
</IconButton> | ||
</ListItem> | ||
))} | ||
</List> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ui/src/components/HookForm/index.jsx
Outdated
/> | ||
} | ||
/> | ||
</ListItem> |
There was a problem hiding this comment.
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
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?
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Awesome, thanks @arshadkazmi42.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks really good overall :)
<ListSubheader className={classes.subheader}> | ||
Bindings | ||
</ListSubheader> | ||
}> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
<List | ||
className={classes.inputList} | ||
subheader={ | ||
<ListSubheader className={classes.subheader}> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
subheader
doesn't seem to be used.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This was related to the above comment.
onBindingAdd, | ||
onBindingRemove, | ||
onChange, | ||
} = this.props; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let's add static propTypes
. We can also add static defaultProps
if certain props are not required.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I feel all the props are required for this.
I have written static propTypes
something like this.
static propTypes = {
pulseExchange: string.isRequired,
pattern: string.isRequired,
bindings: arrayOf(object).isRequired,
onBindingAdd: func.isRequired,
onBindingRemove: func.isRequired,
onChange: func.isRequired,
};
Also, I am not sure if we would not need static defaultProps
in this.
Let me know if there is anything missing
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
STR:
- Navigate to http://localhost:5080/hooks/garbage/abc456 and login
- Add a dummy binding and click on "+"
Actual: The save button is not clickable. The form is not aware of the binding.
Expected: The save button becomes clickable. Clicking on the save icon and then refreshing the page should show the saved binding.
@helfi92 |
Sure thing. You can look at:
Let me know if you have any questions. |
@helfi92 I got the backend setup.
I am not sure what is the key I have to use to pass binding. |
Good question! I think the bindings is part of the payload. The data structure for a hook is defined in https://github.com/taskcluster/taskcluster/blob/87facc8e7fc4580440bf730e2a0f5e080aba3154/services/hooks/schemas/v1/hook-definition.yml. You will probably just need to do: diff --git a/services/web-server/src/graphql/Hooks.graphql b/services/web-server/src/graphql/Hooks.graphql
index 92f378b8a..808cd6f52 100644
--- a/services/web-server/src/graphql/Hooks.graphql
+++ b/services/web-server/src/graphql/Hooks.graphql
@@ -72,11 +72,17 @@ type DeleteHook {
hookId: ID
}
+type HookBinding {
+ exchange: String!
+ routingKeyPattern: String!
+}
+
input HookInput {
metadata: HookMetadataInput!
schedule: [String]
expires: String
deadline: String
+ bindings: [HookBinding]
task: JSON!
triggerSchema: JSON
} Hope that helps. |
@@ -72,11 +72,17 @@ type DeleteHook { | |||
hookId: ID | |||
} | |||
|
|||
input HookBinding { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Does this work for you? I think it should be type
, not input
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
On adding type
web-server was throwing error and changing it to type was suggested. So I changed it to input
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You are correct. My mistake :)
@@ -182,7 +183,7 @@ export default class HookForm extends Component { | |||
state = { | |||
hook: null, | |||
hookLastFires: null, | |||
pattern: '#', | |||
routingKeyPattern: '#', |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The server expects this property name to be pattern
. I don't think this will work atm.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It turns out the hook service expects it to be routingKeyPattern
. Sorry for that. Now that you have the server setup, are you able to add a hook to http://localhost:5080/hooks/garbage/abc456 and see if it saves successfully?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
When trying to save i was getting 401 Authentication failed.
I thought it needs some level of access to save it. So couldn't validate it
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
How were you signing in? I can provide you with the required level of access.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You will need to use the manual siginin ./taskcluster signin --name taskcluster-web-server
. The taskcluster binary can be downloaded from https://github.com/taskcluster/taskcluster-cli#installation. The taskcluster signin
command will open a browser where you will be able to login then upon logging in, the binary will output the credentials in the terminal. Those credentials is what you need to login.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I am doing this, in browser I used auth0 login and used those credentials to login in UI
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What is the exact error you are seeing when you try to create/update a hook?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do you get the same error when creating/updating a hook via https://tools.taskcluster.net/?
This is the error I am getting on this website create |
That looks better. The error is about insufficient scopes. What are you missing for editing http://localhost:5080/hooks/garbage/arshad? Can you post a screenshot of the error you are seeing in the UI? |
|
OK, can you try again. I've given you permissions to play with the garbage/arshad hook. |
Got it working now. Its saving. |
@@ -72,11 +72,17 @@ type DeleteHook { | |||
hookId: ID | |||
} | |||
|
|||
input HookBinding { | |||
exchange: String! | |||
pattern: String! |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this property needs to be renamed to be in line with what the hook client expects.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The actual mutations are happening in services/web-server/src/resolvers/hooks.js
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Defintion of a hook: https://github.com/taskcluster/taskcluster/blob/87facc8e7fc4580440bf730e2a0f5e080aba3154/services/hooks/schemas/v1/hook-definition.yml
Definition of a binding: https://github.com/taskcluster/taskcluster/blob/87facc8e7fc4580440bf730e2a0f5e080aba3154/services/hooks/schemas/v1/bindings.yml
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this property needs to be renamed to be in line with what the hook client expects.
I have updated this
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let me checkin my latest changes
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
After saving, reloading the page should display the existent bindings that were saved earlier.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
On page load this query is getting fired
"query Hook($hookGroupId: ID!, $hookId: ID!) {
hook(hookGroupId: $hookGroupId, hookId: $hookId) {
hookGroupId
hookId
schedule
metadata {
name
description
owner
emailOnError
__typename
}
status {
nextScheduledDate
lastFire {
... on HookSuccessfulFire {
time
taskId
__typename
}
... on HookFailedFire {
time
error
__typename
}
... on NoFire {
result
__typename
}
__typename
}
__typename
}
triggerSchema
task
__typename
}
hookLastFires(hookGroupId: $hookGroupId, hookId: $hookId) {
taskId
firedBy
taskCreateTime
result
error
__typename
}
}
"
And I don't see bindings
field getting queried in this.
I tried adding bindings in this query but its giving 404 after adding bindings in the above query
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah, you would need to add it in web-server:
diff --cc ui/src/views/PulseMessages/index.jsx
index 85010860d,4371e89d6..000000000
--- a/ui/src/views/PulseMessages/index.jsx
+++ b/ui/src/views/PulseMessages/index.jsx
diff --git a/services/web-server/src/graphql/Hooks.graphql b/services/web-server/src/graphql/Hooks.graphql
index 1c59765f3..040ca0f52 100644
--- a/services/web-server/src/graphql/Hooks.graphql
+++ b/services/web-server/src/graphql/Hooks.graphql
@@ -51,6 +51,7 @@ type HookStatus {
type Hook {
hookGroupId: ID!
hookId: ID!
+ bindings: [HookBinding]
metadata: HookMetadata!
schedule: [String]!
task: JSON!
@@ -72,7 +73,12 @@ type DeleteHook {
hookId: ID
}
-input HookBinding {
+type HookBinding {
+ exchange: String!
+ routingKeyPattern: String!
+}
+
+input HookBindingInput {
exchange: String!
routingKeyPattern: String!
}
@@ -82,7 +88,7 @@ input HookInput {
schedule: [String]
expires: String
deadline: String
- bindings: [HookBinding]
+ bindings: [HookBindingInput]
task: JSON!
triggerSchema: JSON
}
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I am getting insufficient scopes error again
{"errors":[{"message":"Client ID mozilla-auth0/oauth2|firefoxaccounts|967134a2ed244f61b75935fc10b9119c|arshadkazmi42@gmail.com/taskcluster-web-server does not have sufficient scopes and is missing the following scopes:\n\n```\n{\n \"AllOf\": [\n \"hooks:modify-hook:garbage/arshad\",\n \"assume:hook-id:garbage/arshad\"\n ]\n}\n```\n\n
can you add access for this client id to add bindings? Or can you let me know how can I do this, if my client id changes
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done.
@@ -50,6 +50,7 @@ import DeleteIcon from 'mdi-react/DeleteIcon'; | |||
})) | |||
export default class PulseBindings extends Component { | |||
static propTypes = { | |||
patternName: string, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why do we need a patternName
prop?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
in PulseMessages component, for bindings pattern
key is used so I am passing patternName as input to component, if there is no name passed it will default it to pattern
.
As on addBinding function call, uses this name as key and same key is used while rendering
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@helfi92 Can you also look at this comment, I don't want this to get lost in our discussions.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I was planning to look at this once the rebase is done. Right now there's some merge conflict in this file so I didn't bother looking at it. I plan on looking at it after the rebase :)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Cool. I am rebasing it now, will push fresh commits in sometime
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Seems like there's a small regression. Added some comments. When you get a chance, could you perform a rebase, please. Sorry for not reviewing this on Friday, I had to leave early.
ui/src/components/HookForm/index.jsx
Outdated
@@ -387,6 +391,8 @@ export default class HookForm extends Component { | |||
hook.hookId && | |||
hook.metadata.name && | |||
hook.metadata.owner && | |||
hook.bindings && | |||
hook.bindings.length > 0 && |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
STR:
- Add 1 binding only
- Save the page
- Refresh the page
- Delete the binding
- Try to save
Expected: The save button is clickable
Actual: The save button is not clickable.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@helfi92 Can you configure this client id
mozilla-auth0/oauth2|firefoxaccounts|967134a2ed244f61b75935fc10b9119c|arshadkazmi42@gmail.com/taskcluster-web-server
I have refreshed my token
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks
marginTop: 80, | ||
}, | ||
deleteIcon: { | ||
marginRight: -15, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
marginRight: -theme.spacing.double,
marginRight: -15, | ||
[theme.breakpoints.down('sm')]: { | ||
marginRight: -14, | ||
}, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think we can remove L31-33.
@helfi92 I think I broke something in rebase, its showing up 323 files change Is there some way to revert this? Or I need to open a new PR?
|
357e0f5
to
3e35cea
Compare
I managed to roll back the rebase. Do I have to do |
Worker manager updates
Sometimes
I don't think you need to # rebase current branch on upstream master
git pull upstream master --rebase Once the rebase is done, you can |
Add workerPool (née workerType) creation interface (non-working)
This env var gets overridden by `infrastructure/terraform/modules/deployment/deployment.yaml` anyway.
…-web-ui Don't specify an explicit PORT for tc-web-ui
…/taskcluster into bindings-hook-view
I have done this
|
@arshadkazmi42 I think a merge commit was done. I am seeing other commits on this branch. Any chance you could open a separate PR instead with the change, please? |
Sure. will do. |
Fixes #610
Attaching snapshot of the page after changes