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 Pulp API to UI #288

Merged
merged 9 commits into from
Jan 26, 2021
Merged

Add Pulp API to UI #288

merged 9 commits into from
Jan 26, 2021

Conversation

ZitaNemeckova
Copy link
Member

@ZitaNemeckova ZitaNemeckova commented Jan 12, 2021

Closes-Issue: AAH-255

Populate DB via console:

for foo in  postgres treafik mongo mariadb redis node mysql busybox alpine docker python hhtpd nginx memcached golang  ; do  docker pull $foo; docker image tag $foo localhost:5001/$foo; docker push localhost:5001/$foo; done

Last modified will be added in followup UI PR.

TODO:

  • pagination
  • sorting - param ordering
  • filter - no partial filter

Sorry, something went wrong.

@ZitaNemeckova ZitaNemeckova marked this pull request as draft January 12, 2021 14:34
@ZitaNemeckova ZitaNemeckova force-pushed the pulp_api branch 2 times, most recently from 71eae78 to aca0047 Compare January 12, 2021 16:09
@newswangerd newswangerd changed the title Add Pupl API to UI Add Pulp API to UI Jan 12, 2021
Closes-Issue: AAH-255
@ZitaNemeckova ZitaNemeckova marked this pull request as ready for review January 13, 2021 13:08
@ZitaNemeckova
Copy link
Member Author

@newswangerd please have a look, thanks :)

Copy link
Member

@newswangerd newswangerd left a comment

Choose a reason for hiding this comment

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

Just need to DRY out the pulp api base.

});
}

list(params?: object, apiPath?: string) {
Copy link
Member

@newswangerd newswangerd Jan 19, 2021

Choose a reason for hiding this comment

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

These are all copy pasted from BaseAPI. They should really be moved to a reusable file or inherited from a shared base class.

I know we were attempting to not change the base class for the full API, but I think it should be fairly easy to make a new base class that contains the list, get, update, create, delete, patch, getPath, authHandler and mapPageToOffset methods and the apiPath and http properties without introducing any regressions.

You could also just move the shared methods to an api.utils module and import them here and in base.ts. That might be a little bit easier, but I think it's not quite as clean. It's up to you.

}
}

export const ExecutionEnvironmentAPI = new API();
Copy link
Member

Choose a reason for hiding this comment

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

I like the idea of just putting all EE related calls into a single module rather than presenting the different objects in the pulp API to the presentation layer. I'm curious to see how this will work in the final implementation,

Copy link
Member

Choose a reason for hiding this comment

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

One problem you might run into is that page loading will be blocked until all the APIs resolve. This is probably fine for details, but I know on the list views we'll have to make a call for each container to get the description, and that could slow down the list page a lot. If the APIs are called separately you could use a skeleton to show that the description is still loading: https://patternfly-react.surge.sh/components/skeleton. If all the descriptions are grabbed asynchronously, latency might not be an issue though.

src/api/pulp.ts Outdated
http: any;

constructor() {
this.apiPath = this.apiBaseURL;
Copy link
Member

Choose a reason for hiding this comment

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

I'm surprised these calls work without the CSRF token getting set. I guess it probably gets set by the other API calls and reused here. At any rate, it might be worth adding the authHandler here.

src/api/base.ts Outdated
apiPath: string;
http: any;

constructor() {
this.http = axios.create({
baseURL: this.apiBaseURL,
baseURL: this.apiBaseURL(),
Copy link
Member

Choose a reason for hiding this comment

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

I would recommend passing this as a constructor argument instead of getting it from some function that you then have to override.

// Use this function to get paths in the _ui API. That will ensure the API version
// gets updated when it changes
getUIPath(url: string) {
return `_ui/${this.UI_API_VERSION}/${url}`;
Copy link
Member

Choose a reason for hiding this comment

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

This function isn't necessary for anything other than the hub endpoints, so you can remove it here and just provide it in the hub base class.

src/api/pulp.ts Outdated
Comment on lines 19 to 22
const params = { ...p };
const sort = params['sort'];
params['ordering'] = sort;
delete params['sort'];
Copy link
Member

Choose a reason for hiding this comment

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

I would recommend moving mapPageToOffset to the base class and overriding the list method on the pulp class here to provide the mapping between ordering and sort.

Messing with sort in this function is kind of an unexpected side effect and this also makes it so that the actual code for the mapPageToOffset function is still duplicated in two places.

@ZitaNemeckova ZitaNemeckova merged commit 680d414 into ansible:master Jan 26, 2021
@ZitaNemeckova ZitaNemeckova deleted the pulp_api branch January 26, 2021 16:01
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants