OpenAPI CRUD views#6702
Conversation
…th-help if none exist
…ucts the model once
…h new structure of pathHelp functions
meirish
left a comment
There was a problem hiding this comment.
This is looking good! I haven't pulled it down yet to try it out, but wanted to get these published - I know you're still planning on a cleanup pass - I think some of the comments I left might help with that.
Re: documentation - I think the comments are good, but could we also include a high level "this is how you use this" maybe at the top of the service?
What do you think about dropping in some https://api.emberjs.com/ember/3.10/functions/@ember%2Fdebug/debug calls in the service function s "Generating ____ model/adapter from ____ Open API endpoint" or something like that? Just thinking it'd be nice to have along with the route transition logs that we do as a check to make sure things are running properly.
| this._super(...arguments); | ||
| const { item_type: itemType } = this.paramsFor(this.routeName); | ||
| const { path } = this.paramsFor('vault.cluster.access.method'); | ||
| const { apiPath } = this.modelFor('vault.cluster.access.method'); |
There was a problem hiding this comment.
We could wrap these into a helper method to use in both places.
| //we always want to keep list endpoints for menus | ||
| //but only use scoped post/delete endpoints | ||
| if (itemType) { | ||
| paths = paths.filter(path => path.includes(itemType)); |
There was a problem hiding this comment.
Didn't we come across a backend that had sibling paths instead of nested ones? Will we just handle that when we come across it?
| } | ||
| }) | ||
| .filter(path => path != undefined); | ||
|
|
There was a problem hiding this comment.
I think you could do all of this in one pass with a reduce, but that's more of a cleanup thing than a must have.
| {{form-field data-test-field attr=attr model=model onChange=onChange}} | ||
| {{#unless (and (not-eq mode "create") (eq attr.name "name"))}} | ||
| {{form-field data-test-field attr=attr model=model onChange=onChange | ||
| }} |
There was a problem hiding this comment.
Did this just insert a line break?
| </ToolbarLink> | ||
| </ToolbarActions> | ||
| </Toolbar> | ||
| {{#if model.meta.total}} |
There was a problem hiding this comment.
There's a ListView and ListItem component that might be helpful here (not sure - it's been a while since I looked at them).
|
One other thing I didn't fully track down - if you go directly to the the method via the URL since there's no way to navigate there yet (we should probably link up ldap in the auth method list) - then you end up on the configuration page - can we change that so that we go to the first tab instead? |
|
I don't think we want the delete button in the toolbar and at the bottom of the form - I think just in the toolbar - but @joshuaogle would know for sure! |
|
Functionally this looks great - there's a couple of things I'd like to see changed (and I can help track them down too) -
Going to look through the code now. |
|
|
||
| SectionTabs.reopenClass({ | ||
| positionalParams: ['model', 'tabType'], | ||
| positionalParams: ['model', 'tabType', 'paths'], |
There was a problem hiding this comment.
Just a note here that positionParams are going away in Glimmer components, so we'll eventually want to move away from this.
| helpText: | ||
| 'Use the Active Directory tokenGroups constructed attribute to find the group memberships. This returns all security groups for the user, including nested groups. In an Active Directory environment with a large number of groups this method offers increased performance. Selecting this will cause Group DN, Attribute, and Filter to be ignored.', | ||
| }), | ||
|
|
| export default Route.extend({ | ||
| pathHelp: service('path-help'), | ||
| model(params) { | ||
| // eslint-disable-line rule |
There was a problem hiding this comment.
I think this can be removed.
| } | ||
| return model; | ||
| return this.pathHelp.getPaths(model.apiPath, path).then(paths => { | ||
| model.set('paths', paths); |
There was a problem hiding this comment.
(for later) we should document what attributes OpenAPI models have on them - paths, newFields, etc.
| controller.set('method', path); | ||
| const { apiPath } = this.modelFor('vault.cluster.access.method'); | ||
| this.pathHelp.getPaths(apiPath, path, itemType).then(paths => { | ||
| controller.set('paths', Array.from(paths.list, pathInfo => pathInfo.path)); |
There was a problem hiding this comment.
what's the type of paths.list here?
| @@ -1,3 +1,4 @@ | |||
| /* eslint-disable prettier/prettier */ | |||
| } | ||
| let owner = getOwner(this); | ||
| return this.pathHelp.getNewModel(modelType, owner, backend); | ||
| return this.pathHelp.getNewModel(modelType, backend); |
There was a problem hiding this comment.
Ah cool - I'll have to update these in the KMIP PR after this is merged too
| //Returns relevant information from OpenAPI | ||
| //as determined by the expandOpenApiProps util | ||
| getProps(helpUrl, backend) { | ||
| debug(`Fetching schema properties for ${backend} from ${helpUrl}`); |
| }); | ||
| }, | ||
|
|
||
| getNewModel(modelType, backend, apiPath, itemType) { |
There was a problem hiding this comment.
what is itemType here? I think a comment with example usage of the method would help too
There was a problem hiding this comment.
itemType is the type of nested item, i.e. a LDAP group or userpass user. here's an example of where the itemType is set in the go code: https://github.com/hashicorp/vault/pull/7513/files#diff-cb2f72de1a3a7afc5227ef80f58f99f9R24
(also lol hi delayed answer here 🙈 -- just marking up this PR with notes for the rest of the team)
| valueUpdated=(action "codemirrorUpdated" attr.name false) | ||
| }} | ||
| {{/if}} | ||
| {{/if}} No newline at end of file |
There was a problem hiding this comment.
Are there any changes in this file other than whitespace? I think the formatting before was easier to read fwiw - if it's just whitespace changes, could we back these out?
| {{/link-to}} | ||
| {{/if}} | ||
| </div> | ||
| <div class="control"> |
There was a problem hiding this comment.
This is the div and contents we'd remove if we don't need the Delete button on the bottom.
| </button> | ||
| </div> | ||
| </button> | ||
| </div> No newline at end of file |
There was a problem hiding this comment.
I see the old one was broken with some indentation, but I think the whitespace was better before even with the bad indentation.
| </p.top> | ||
| <p.levelLeft> | ||
| <h1 class="title is-3"> | ||
| {{capitalize method}} |
There was a problem hiding this comment.
Do we want to add an Icon above this? - should this be method or the path for the auth method?
There was a problem hiding this comment.
So I think this should be id of the method
meirish
left a comment
There was a problem hiding this comment.
I think we should merge this and iterate on it after merge, but this should be good for the beta 🙌
|
|
||
| export default AuthConfig.extend({ | ||
| useOpenAPI: true, | ||
| binddn: attr('string', { |
There was a problem hiding this comment.
notice here that when we set useOpenAPI to true, we can get rid of the duplicate attrs. OpenAPI gives us the attrs and sets them on the model here: https://github.com/hashicorp/vault/pull/6702/files#diff-cd3b672bded0741ca8ec360a4deb124fR37
| let methodModel = this.modelFor('vault.cluster.access.method'); | ||
| let { apiPath, type } = methodModel; | ||
| let modelType = `generated-${singularize(itemType)}-${type}`; | ||
| return this.pathHelp.getNewModel(modelType, method, apiPath, itemType); |
There was a problem hiding this comment.
this is an example of how we call OpenAPI and generate a model on the auth method items pages.

This adds functionality to our path help service to grab relevant paths from OpenAPI to be displayed as tabs for auth methods.