-
Notifications
You must be signed in to change notification settings - Fork 67
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
namespace list view with new api #657
base: main
Are you sure you want to change the base?
Conversation
Might want to make this a draft before the API changes are merged and released? |
I'm pretty sure we'll have to fix any type errors before merging instead of hiding them. EDIT: we'll try to make the typescript rules a bit more relaxed, will discuss on the next AAP meeting (7/11) |
fbe19b0
to
3f385ac
Compare
@himdel a little note on the typing errors... on lines 37 in |
it should not be a problem in So .. likely the typing for the namespace itself is just fine, but |
const toolbarFilters = useCollectionFilters(); | ||
const tableColumns = useCollectionColumns(); | ||
const view = useHubView<Collection>({ | ||
url: hubAPI`/_ui/v1/repo/published/`, |
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 looks like it returns only collections from published repo. And it uses old API, it should use new collection_versions API, like the old application. For example old hub calls in namespace detail:
I have this in my PR: #683
Approvals uses the collection_version API just like collection list.
Note that you need new key function, not the keyFn: idKeyFn, but something else, for example:
keyFn: (item) => item.collection_version.pulp_href + ':' + item.repository.name,
Its because idKeyFN returns id, but the new collection API not returns id, it return collection_version object and repository object. And collection pulp_href cannot be used by itself, because the same collection can be in multiple repos. Thus we add repo name to the key and make it unique.
Feel free to reach me when you have some questions!
3f385ac
to
13b6d1e
Compare
@himdel yeah, you're right, thanks for looking at the typing:) I went ahead and created a new HubNamespaceResponse that works a lot better; I was able to push without applying the tsc ignore:) Lmk if this looks right |
7444329
to
0a249fd
Compare
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.
Good job @ShaiahWren, minor suggestions.
import { RouteObj } from '../../../Routes'; | ||
import { CollectionVersionSearch } from '../CollectionVersionSearch'; | ||
|
||
export function useCollectionVersionColumns(_options?: { |
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 are not passing down the _options
prop, neither using the destructed variables. Remove?
export function useCollectionVersionColumns(_options?: { | |
export function useCollectionVersionColumns( |
groups: string[]; | ||
} | ||
|
||
export interface HubNamespace { |
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.
export interface HubNamespace { | |
export interface HubNamespace { | |
description?: string; | |
company?: string; |
|
||
export function NamespaceDetails() { | ||
const { t } = useTranslation(); | ||
const params = useParams<{ id: string }>(); | ||
const { data } = useGet<HubItemsResponse<HubNamespace>>( | ||
hubAPI`/_ui/v1/namespaces/?limit=1&name=${params.id ?? ''}` | ||
const { data } = useGet<HubNamespaceResponse<HubNamespace>>( |
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.
Using ItemsResponse
seems to fix the typescript issues. I just looked at useGet
usage in other contexts. Not sure if It is not addressing something in particular here.
746903c
to
0872d53
Compare
export interface HubNamespaceResponse<T extends object> { | ||
count: number; | ||
results: T[]; | ||
} | ||
|
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 may want to replace this one with PulpItemsResponse
from usePulpView
- that matches the {count, results[], next?}
format
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.
see note above, but approving either way :)
0872d53
to
26214ac
Compare
8a27d50
to
a0af763
Compare
unselectItemsAndRefresh: (items: T[]) => void; | ||
}; | ||
|
||
export function usePulpSearchView<T extends object>({ |
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 file will not be needed, use useHubView)
export function hubAPI(strings: TemplateStringsArray, ...values: string[]) { | ||
let base = process.env.HUB_API_BASE_PATH; | ||
if (!base) { | ||
if (activeAutomationServer?.type === AutomationServerType.Galaxy) { |
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.
(remember to rebase, this file already exists on main, and the activeAutomationServer logic is obsolete)
[DO NOT MERGE- waiting on David's work on the ns api to be finished.]
This pr uses the new namespace api for the list and detail views. Additionally, it fixes the namespace create button for use with the correctly typed HubNamespace.
NOTES:
Please use:
ansible/galaxy_ng#1705
pulp/pulp_ansible#1437