-
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
Draft
ShaiahWren
wants to merge
30
commits into
main
Choose a base branch
from
shaiahwren-ns-list
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Draft
Changes from all commits
Commits
Show all changes
30 commits
Select commit
Hold shift + click to select a range
771dd37
update ns type interface
ShaiahWren e3b3a24
implement new api for list view.
ShaiahWren d072c9b
fix icontains filter
ShaiahWren 2579075
rebase
ShaiahWren 4c34801
use pulpAI in place of hubAPI
ShaiahWren b365800
use pulpAPI prefix in api call
ShaiahWren 1e0e260
add spot for queryParams
ShaiahWren e96c4ba
disable tsc for the time-being
ShaiahWren 1c76994
create a namespace metadata type file
ShaiahWren 26d5db4
add new HubNamespaceResponse and fix type errors
ShaiahWren d873a30
update Collection type to CollectionVersionSearch
ShaiahWren 73fed34
use CollectionVersionSearch in place of Collection
ShaiahWren 86bc059
reset files to origin
ShaiahWren a6d550a
use collection search for collections tab
ShaiahWren 63a92a1
fix HubNamespace type
ShaiahWren e8e8b7a
add collectionversionsearch
ShaiahWren c4cd163
dealing with tsc errors
ShaiahWren bd140cf
use ToolBarFilterType for filter
ShaiahWren 01cfea0
use v3/namespaces api for delete method
ShaiahWren 9de23e0
ns metadata tab in ns details
ShaiahWren 8cf081c
add namespace details tab info
ShaiahWren 7076979
namespace name on edit page should be readonly
ShaiahWren cf0cc82
edit forms for namespaces and sub-namespaces
ShaiahWren 232e646
update sorting and filters
ShaiahWren c3110ff
remove create button from ns details page
ShaiahWren a4fedec
fix repo filter
ShaiahWren 72eab49
change ns details edit route name
ShaiahWren ff89ec9
fix tsc error
ShaiahWren f646229
fix rebase issues
ShaiahWren a0af763
fix some eslint errors
ShaiahWren File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,103 @@ | ||
import { AutomationServerType } from '../automation-servers/AutomationServer'; | ||
import { activeAutomationServer } from '../automation-servers/AutomationServersProvider'; | ||
|
||
function apiTag(strings: TemplateStringsArray, ...values: string[]) { | ||
if (strings[0]?.[0] !== '/') { | ||
throw new Error('Invalid URL'); | ||
} | ||
|
||
let url = ''; | ||
strings.forEach((fragment, index) => { | ||
url += fragment; | ||
if (index !== strings.length - 1) { | ||
url += encodeURIComponent(`${values.shift() ?? ''}`); | ||
} | ||
}); | ||
|
||
return url; | ||
} | ||
|
||
export function hubAPI(strings: TemplateStringsArray, ...values: string[]) { | ||
let base = process.env.HUB_API_BASE_PATH; | ||
if (!base) { | ||
if (activeAutomationServer?.type === AutomationServerType.Galaxy) { | ||
base = '/api/galaxy'; | ||
} else { | ||
base = '/api/automation-hub'; | ||
} | ||
} | ||
return base + apiTag(strings, ...values); | ||
} | ||
|
||
export function pulpAPI(strings: TemplateStringsArray, ...values: string[]) { | ||
let base = process.env.HUB_API_BASE_PATH; | ||
if (!base) { | ||
if (activeAutomationServer?.type === AutomationServerType.Galaxy) { | ||
base = '/api/galaxy'; | ||
} else { | ||
base = '/api/automation-hub'; | ||
} | ||
} | ||
return base + '/pulp/api/v3' + apiTag(strings, ...values); | ||
} | ||
|
||
export type QueryParams = { | ||
[key: string]: string | undefined; | ||
}; | ||
|
||
export function getQueryString(queryParams: QueryParams) { | ||
return Object.entries(queryParams) | ||
.map(([key, value = '']) => `${encodeURIComponent(key)}=${encodeURIComponent(value)}`) | ||
.join('&'); | ||
} | ||
|
||
const UUIDRegEx = /\b[0-9a-f]{8}\b-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-\b[0-9a-f]{12}\b/i; | ||
|
||
export function parsePulpIDFromURL(url: string): string | null { | ||
for (const section of url.split('/')) { | ||
if (section.match(UUIDRegEx)) { | ||
return section; | ||
} | ||
} | ||
|
||
return null; | ||
} | ||
|
||
// pulp next links currently include full url - with the wrong server | ||
// "http://localhost:5001/api/page/next?what#ever" -> "/api/page/next?what#ever" | ||
// also has to handle hub links (starting with /api/) and undefined | ||
export function serverlessURL(url?: string) { | ||
if (!url || url.startsWith('/')) { | ||
return url; | ||
} | ||
|
||
const { pathname, search, hash } = new URL(url); | ||
return `${pathname}${search}${hash}`; | ||
} | ||
|
||
export function pulpIdKeyFn(item: { pulp_id: string }) { | ||
return item.pulp_id; | ||
} | ||
|
||
export function pulpHrefKeyFn(item: { pulp_href: string }) { | ||
return item.pulp_href; | ||
} | ||
|
||
export function nameKeyFn(item: { name: string }) { | ||
return item.name; | ||
} | ||
|
||
export function idKeyFn(item: { id: number | string }) { | ||
return item.id; | ||
} | ||
|
||
export function collectionKeyFn(item: { | ||
collection_version: { pulp_href: string }; | ||
repository: { name: string }; | ||
}) { | ||
return item.collection_version.pulp_href + '_' + item.repository.name; | ||
} | ||
|
||
export function appendTrailingSlash(url: string) { | ||
return url.endsWith('/') ? url : url + '/'; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
91 changes: 91 additions & 0 deletions
91
frontend/hub/collections/hooks/useCollectionVersionColumns.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,91 @@ | ||
import { Label } from '@patternfly/react-core'; | ||
import { | ||
AnsibleTowerIcon, | ||
CheckCircleIcon, | ||
ExclamationTriangleIcon, | ||
} from '@patternfly/react-icons'; | ||
import { useMemo } from 'react'; | ||
import { useTranslation } from 'react-i18next'; | ||
import { ITableColumn, TextCell } from '../../../../framework'; | ||
import { RouteObj } from '../../../Routes'; | ||
import { CollectionVersionSearch } from '../CollectionVersionSearch'; | ||
|
||
export function useCollectionVersionColumns() { | ||
const { t } = useTranslation(); | ||
return useMemo<ITableColumn<CollectionVersionSearch>[]>( | ||
() => [ | ||
{ | ||
header: t('Name'), | ||
value: (collection) => collection.collection_version.name, | ||
cell: (collection) => ( | ||
<TextCell | ||
text={collection.collection_version.name} | ||
to={RouteObj.CollectionDetails.replace(':id', collection.collection_version.name)} | ||
/> | ||
), | ||
card: 'name', | ||
list: 'name', | ||
icon: () => <AnsibleTowerIcon />, | ||
}, | ||
{ | ||
header: t('Repository'), | ||
type: 'text', | ||
value: (collection) => collection.repository.name, | ||
}, | ||
{ | ||
header: t('Namespace'), | ||
type: 'text', | ||
value: (collection) => collection.collection_version.namespace, | ||
}, | ||
{ | ||
header: t('Description'), | ||
type: 'description', | ||
value: (collection) => collection.collection_version.description, | ||
card: 'description', | ||
list: 'description', | ||
}, | ||
{ | ||
header: t('Modules'), | ||
type: 'count', | ||
value: (collection) => | ||
collection.collection_version.contents.filter((c) => c.content_type === 'module').length, | ||
}, | ||
{ | ||
header: t('Updated'), | ||
type: 'datetime', | ||
value: (collection) => collection.collection_version.pulp_created, | ||
card: 'hidden', | ||
list: 'secondary', | ||
}, | ||
{ | ||
header: t('Version'), | ||
type: 'text', | ||
value: (collection) => collection.collection_version.version, | ||
card: 'hidden', | ||
list: 'secondary', | ||
}, | ||
{ | ||
header: t('Signed state'), | ||
cell: (collection) => { | ||
switch (collection.is_signed) { | ||
case true: | ||
return ( | ||
<Label icon={<CheckCircleIcon />} variant="outline" color="green"> | ||
{t('Signed')} | ||
</Label> | ||
); | ||
case false: | ||
return ( | ||
<Label icon={<ExclamationTriangleIcon />} variant="outline" color="orange"> | ||
{t('Unsigned')} | ||
</Label> | ||
); | ||
} | ||
}, | ||
list: 'secondary', | ||
value: (collection) => collection.is_signed, | ||
}, | ||
], | ||
[t] | ||
); | ||
} |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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)