-
Notifications
You must be signed in to change notification settings - Fork 4.3k
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
OpenAPI CRUD views #6702
OpenAPI CRUD views #6702
Conversation
…th-help if none exist
…ucts the model once
…h new structure of pathHelp functions
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 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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Did this just insert a line break?
</ToolbarLink> | ||
</ToolbarActions> | ||
</Toolbar> | ||
{{#if model.meta.total}} |
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'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. |
model: null, | ||
tabType: 'authSettings', | ||
}); | ||
|
||
SectionTabs.reopenClass({ | ||
positionalParams: ['model', 'tabType'], | ||
positionalParams: ['model', 'tabType', 'paths'], |
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.
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.', | ||
}), | ||
|
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.
uau 👏
model(params) { | ||
// eslint-disable-line rule |
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 can be removed.
@@ -12,7 +15,10 @@ export default Route.extend({ | |||
set(error, 'httpStatus', 404); | |||
throw error; | |||
} | |||
return model; | |||
return this.pathHelp.getPaths(model.apiPath, path).then(paths => { | |||
model.set('paths', paths); |
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.
(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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
what's the type of paths.list
here?
@@ -1,3 +1,4 @@ | |||
/* eslint-disable prettier/prettier */ |
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.
Should this be here?
@@ -63,8 +62,7 @@ export default Route.extend(UnloadModelRoute, { | |||
if (['secret', 'secret-v2'].includes(modelType)) { | |||
return resolve(); | |||
} | |||
let owner = getOwner(this); | |||
return this.pathHelp.getNewModel(modelType, owner, backend); | |||
return this.pathHelp.getNewModel(modelType, backend); |
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 cool - I'll have to update these in the KMIP PR after this is merged too
//Makes a call to grab the OpenAPI document. | ||
//Returns relevant information from OpenAPI | ||
//as determined by the expandOpenApiProps util | ||
getProps(helpUrl, backend) { | ||
debug(`Fetching schema properties for ${backend} from ${helpUrl}`); |
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.
👌
@@ -24,37 +30,252 @@ export default Service.extend({ | |||
}); | |||
}, | |||
|
|||
getNewModel(modelType, backend, apiPath, itemType) { |
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 itemType
here? I think a comment with example usage of the method would help too
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.
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)
@@ -225,4 +179,4 @@ | |||
value=(if (get model valuePath) (stringify (get model valuePath)) emptyData) | |||
valueUpdated=(action "codemirrorUpdated" attr.name false) | |||
}} | |||
{{/if}} | |||
{{/if}} |
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.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is the div and contents we'd remove if we don't need the Delete button on the bottom.
</button> | ||
</div> | ||
</button> | ||
</div> |
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 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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
So I think this should be id of the method
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 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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.