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

Fixes #33720 - Move collections to generic UI #9731

Merged
merged 1 commit into from Oct 28, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
7 changes: 4 additions & 3 deletions app/services/katello/repository_type.rb
Expand Up @@ -76,7 +76,7 @@ def default_managed_content_type(label = nil)

def content_type(model_class, options = {})
@content_types ||= []
@content_types << ContentType.new(options.merge(:model_class => model_class))
@content_types << ContentType.new(options.merge(:model_class => model_class, :content_type => model_class::CONTENT_TYPE))
end

def generic_content_type(content_type, options = {})
Expand Down Expand Up @@ -127,10 +127,11 @@ def pulp3_api(smart_proxy)

class ContentType
attr_accessor :model_class, :priority, :pulp2_service_class, :pulp3_service_class, :index, :uploadable, :removable,
:primary_content, :index_on_pulp3, :generic_browser
:primary_content, :index_on_pulp3, :generic_browser, :content_type

def initialize(options)
self.model_class = options[:model_class]
self.content_type = options[:content_type]
self.priority = options[:priority] || 99
self.pulp2_service_class = options[:pulp2_service_class]
self.pulp3_service_class = options[:pulp3_service_class]
Expand All @@ -157,7 +158,7 @@ def as_json(_options = {})
end

class GenericContentType < ContentType
attr_accessor :pulp3_api, :pulp3_model, :content_type, :filename_key, :duplicates_allowed, :pluralized_name,
attr_accessor :pulp3_api, :pulp3_model, :filename_key, :duplicates_allowed, :pluralized_name,
:model_name, :model_version, :model_filename

def initialize(options)
Expand Down
8 changes: 8 additions & 0 deletions app/services/katello/repository_type_manager.rb
Expand Up @@ -87,6 +87,14 @@ def generic_content_types(enabled_only = true)
list.flatten.map(&:content_type)
end

def generic_ui_content_types(enabled_only = true)
repo_types = enabled_only ? enabled_repository_types : defined_repository_types
list = repo_types.values.map do |type|
type.content_types.select { |ct| ct.generic_browser }
end
list.flatten.map(&:content_type)
end

def generic_content_type?(content_type, enabled_only = true)
types = generic_content_types(enabled_only)
types.include?(content_type)
Expand Down
6 changes: 3 additions & 3 deletions config/routes.rb
Expand Up @@ -24,15 +24,15 @@
match '/module_streams' => 'react#index', :via => [:get]
match '/module_streams/*page' => 'react#index', :via => [:get]

match '/ansible_collections' => 'react#index', :via => [:get]
match '/ansible_collections/*page' => 'react#index', :via => [:get]
match '/legacy_ansible_collections' => 'react#index', :via => [:get]
match '/legacy_ansible_collections/*page' => 'react#index', :via => [:get]

match '/content_views' => 'react#index', :via => [:get]
match '/content_views/*page' => 'react#index', :via => [:get]

match '/content' => 'react#index', :via => [:get]

Katello::RepositoryTypeManager.generic_content_types.each do |type|
Katello::RepositoryTypeManager.generic_ui_content_types.each do |type|
get "/#{type.pluralize}", to: redirect("/content/#{type.pluralize}")
get "/#{type.pluralize}/:page", to: redirect("/content/#{type.pluralize}/%{page}")
match "/content/#{type.pluralize}" => 'react#index', :via => [:get]
Expand Down
Expand Up @@ -91,7 +91,7 @@
}
})
.state('product.repository.manage-content.docker-manifests', {
url: '/content/docker_manifests',
url: '/docker_manifests',
permission: 'view_products',
templateUrl: 'products/details/repositories/details/views/repository-manage-docker-manifests.html',
ncyBreadcrumb: {
Expand All @@ -100,7 +100,7 @@
}
})
.state('product.repository.manage-content.docker-tags', {
url: '/content/docker_tags',
url: '/docker_tags',
permission: 'view_products',
templateUrl: 'products/details/repositories/details/views/repository-manage-docker-tags.html',
ncyBreadcrumb: {
Expand All @@ -109,7 +109,7 @@
}
})
.state('product.repository.manage-content.docker-manifest-lists', {
url: '/content/docker_manifest_lists',
url: '/docker_manifest_lists',
permission: 'view_products',
templateUrl: 'products/details/repositories/details/views/repository-manage-docker-manifest-lists.html',
ncyBreadcrumb: {
Expand All @@ -118,7 +118,7 @@
}
})
.state('product.repository.manage-content.files', {
url: '/content/files',
url: '/files',
permission: 'view_products',
templateUrl: 'products/details/repositories/details/views/repository-manage-files.html',
ncyBreadcrumb: {
Expand All @@ -127,7 +127,7 @@
}
})
.state('product.repository.manage-content.ostree-branches', {
url: '/content/ostree_branches',
url: '/ostree_branches',
permission: 'view_products',
templateUrl: 'products/details/repositories/details/views/repository-manage-ostree-branches.html',
ncyBreadcrumb: {
Expand All @@ -145,7 +145,7 @@
}
})
.state('product.repository.manage-content.debs', {
url: '/content/debs',
url: '/debs',
permission: 'view_products',
templateUrl: 'products/details/repositories/details/views/repository-manage-debs.html',
ncyBreadcrumb: {
Expand All @@ -154,7 +154,7 @@
}
})
.state('product.repository.manage-content.ansible-collections', {
url: '/content/ansible_collections',
url: '/ansible_collections',
permission: 'view_products',
templateUrl: 'products/details/repositories/details/views/repository-manage-ansible-collections.html',
ncyBreadcrumb: {
Expand Down
3 changes: 2 additions & 1 deletion lib/katello/repository_types/ansible_collection.rb
Expand Up @@ -16,5 +16,6 @@
distribution_class PulpAnsibleClient::AnsibleAnsibleDistribution
repo_sync_url_class PulpAnsibleClient::AnsibleRepositorySyncURL

content_type Katello::AnsibleCollection, :pulp3_service_class => ::Katello::Pulp3::AnsibleCollection, :user_removable => true
content_type Katello::AnsibleCollection, :pulp3_service_class => ::Katello::Pulp3::AnsibleCollection, :user_removable => true, generic_browser: true
default_managed_content_type :ansible_collections
end
2 changes: 1 addition & 1 deletion webpack/components/RoutedTabs/index.js
Expand Up @@ -45,7 +45,7 @@ const RoutedTabs = ({
<Route key={`${key}-route`} path={`/${key}`}>
{content}
</Route>))}
<Redirect to={`/${currentTabFromUrl || tabs[defaultTabIndex].key}`} />
<Redirect to={`/${currentTabFromUrl || tabs[defaultTabIndex]?.key}`} />
</Switch>
</HashRouter>
</div>
Expand Down
10 changes: 5 additions & 5 deletions webpack/containers/Application/config.js
Expand Up @@ -47,11 +47,11 @@ export const links = [
component: WithOrganization(withHeader(ModuleStreamDetails, { title: __('Module Stream Details') })),
},
{
path: 'ansible_collections',
path: 'legacy_ansible_collections',
component: WithOrganization(withHeader(AnsibleCollections, { title: __('Ansible Collections') })),
},
{
path: 'ansible_collections/:id([0-9]+)',
path: 'legacy_ansible_collections/:id([0-9]+)',
component: WithOrganization(withHeader(AnsibleCollectionDetails, { title: __('Ansible Collection Details') })),
},
{
Expand All @@ -65,14 +65,14 @@ export const links = [
},
{
path: 'content',
component: WithOrganization(withHeader(Content, { title: __('Other Content Types') })),
component: WithOrganization(withHeader(Content, { title: __('Content') })),
},
{
path: 'content/:content_type([a-z_]+)',
component: WithOrganization(withHeader(Content, { title: __('Other Content Types') })),
component: WithOrganization(withHeader(Content, { title: __('Content') })),
},
{
path: 'content/:content_type([a-z_]+)/:id([0-9]+)',
component: WithOrganization(withHeader(ContentDetails, { title: __('Other Content Type Details') })),
component: WithOrganization(withHeader(ContentDetails, { title: __('Content Details') })),
},
];
Expand Up @@ -18,7 +18,7 @@ const TableSchema = [
formatters: [
(value, { rowData }) => (
<td>
<Link to={urlBuilder('ansible_collections', '', rowData.id)}>{rowData.name}</Link>
<Link to={urlBuilder('legacy_ansible_collections', '', rowData.id)}>{rowData.name}</Link>
</td>
),
],
Expand Down
67 changes: 66 additions & 1 deletion webpack/scenes/Content/ContentConfig.js
Expand Up @@ -47,7 +47,72 @@ export default () => [
{
title: __('Product'),
getProperty: unit =>
<a href={urlBuilder(`products/${unit?.product.id}/repositories`, '')}>{unit?.product.name}</a>,
<a href={urlBuilder(`products/${unit?.product.id}/`, '')}>{unit?.product.name}</a>,
},
{
title: __('Sync Status'),
getProperty: unit =>
<LastSync lastSyncWords={unit?.last_sync_words} lastSync={unit?.last_sync} />,
},
{
title: __('Content Count'),
getProperty: (unit, singularLabel) =>
(<ContentCounts
typeSingularLabel={singularLabel}
productId={unit.product.id}
repoId={unit.id}
counts={unit.content_counts}
/>),
},
],
},
],
},
{
names: {
pluralTitle: __('Ansible Collections'),
singularTitle: __('Ansible Collection'),
pluralLowercase: __('Ansible collections'),
singularLowercase: __('Ansible collection'),
pluralLabel: 'ansible_collections',
singularLabel: 'ansible_collection',
},
columnHeaders: [
{ title: __('Name'), getProperty: unit => (<Link to={urlBuilder(`content/ansible_collections/${unit?.id}`, '')}>{unit?.name}</Link>) },
{ title: __('Author'), getProperty: unit => unit?.namespace },
{ title: __('Version'), getProperty: unit => unit?.version },
{ title: __('Checksum'), getProperty: unit => unit?.checksum },

],
tabs: [
{
tabKey: 'details',
title: __('Details'),
getContent: (contentType, id, tabKey) => <ContentInfo {...{ contentType, id, tabKey }} />,
columnHeaders: [
{ title: __('Name'), getProperty: unit => unit?.name },
{ title: __('Description'), getProperty: unit => unit?.description },
{ title: __('Author'), getProperty: unit => unit?.namespace },
{ title: __('Version'), getProperty: unit => unit?.version },
{ title: __('Checksum'), getProperty: unit => unit?.checksum },
{ title: __('Tags'), getProperty: unit => unit?.tags?.join() },
],
},
{
tabKey: 'repositories',
title: __('Repositories'),
getContent: (contentType, id, tabKey) =>
<ContentRepositories {...{ contentType, id, tabKey }} />,
columnHeaders: [
{
title: __('Name'),
getProperty: unit =>
<a href={urlBuilder(`products/${unit?.product.id}/repositories/${unit?.id}`, '')}>{unit?.name}</a>,
},
{
title: __('Product'),
getProperty: unit =>
<a href={urlBuilder(`products/${unit?.product.id}`, '')}>{unit?.product.name}</a>,
},
{
title: __('Sync Status'),
Expand Down
7 changes: 6 additions & 1 deletion webpack/scenes/Content/ContentPage.js
Expand Up @@ -17,6 +17,7 @@ const ContentPage = () => {
const contentTypesResponse = useSelector(selectContentTypes);
const contentTypesStatus = useSelector(selectContentTypesStatus);
const [selectedContentType, setSelectedContentType] = useState(null);
const [showContentTypeSelector, setShowContentTypeSelector] = useState(true);
const [contentTypes, setContentTypes] = useState(null);
const { content_type: contentType } = useParams();

Expand Down Expand Up @@ -45,6 +46,7 @@ const ContentPage = () => {
Object.entries(enabledContentTypes).forEach(([key, value]) => {
if (value.includes(contentType)) {
setSelectedContentType(key);
setShowContentTypeSelector(false);
}
});
}
Expand Down Expand Up @@ -75,7 +77,10 @@ const ContentPage = () => {
</TextContent>
</GridItem>
<GridItem span={12}>
<ContentTable {...{ selectedContentType, setSelectedContentType, contentTypes }} />
<ContentTable {...{
selectedContentType, setSelectedContentType, contentTypes, showContentTypeSelector,
}}
/>
</GridItem>
</Grid>
);
Expand Down
2 changes: 1 addition & 1 deletion webpack/scenes/Content/Details/ContentDetails.js
Expand Up @@ -58,7 +58,7 @@ const ContentDetails = () => {
</Flex>
</GridItem>
<GridItem span={12}>
<RoutedTabs tabs={tabs} baseUrl={`/${contentType}/${contentId}`} defaultTabIndex={1} />
<RoutedTabs tabs={tabs} baseUrl={`/${contentType}/${contentId}`} defaultTabIndex={0} />
</GridItem>
</Grid>
);
Expand Down
@@ -0,0 +1,20 @@
{
"id": 51,
"name": "linux_system_roles",
"namespace": "fedora",
"version": "1.5.0",
"checksum": "edd27bbc1f6ba805760bf85a05efacca989492570e41d263fd804358ce9cef92",
"description": "Ansible roles for linux system components management",
"tags": [
"collection",
"system"
],
"repositories": [
{
"id": 698,
"name": "lin_collections",
"product_id": 296,
"product_name": "test_all_types"
}
]
}
@@ -0,0 +1,71 @@
{
"total": 1,
"subtotal": 1,
"page": "1",
"per_page": "20",
"error": null,
"search": null,
"sort": {
"by": "name",
"order": "asc"
},
"results": [
{
"backend_identifier": "b7e662ed-fd91-44ed-94c0-60fc9c5b2ccc",
"relative_path": "Default_Organization/Library/custom/test_all_types/lin_collections",
"container_repository_name": null,
"full_path": "https://centos7-devel4.samir.example.com/pulp_ansible/galaxy/Default_Organization/Library/custom/test_all_types/lin_collections/api/",
"library_instance_id": null,
"version_href": "/pulp/api/v3/repositories/ansible/ansible/59832f57-b06d-49aa-ab3e-ac07c847fb55/versions/1/",
"remote_href": "/pulp/api/v3/remotes/ansible/collection/66badf55-97c1-42be-9e55-c30fdfdd182c/",
"publication_href": null,
"content_counts": {
"ansible_collection": 17
},
"id": 698,
"name": "lin_collections",
"label": "lin_collections",
"description": null,
"last_sync": {
"id": "5b6b544a-767f-4558-926d-4c7c828afccc",
"username": "admin",
"started_at": "2021-10-15 11:34:51 -0400",
"ended_at": "2021-10-15 11:35:10 -0400",
"state": "stopped",
"result": "success",
"progress": 1
},
"content_view": {
"id": 1,
"name": "Default Organization View"
},
"content_view_version": {
"id": 1,
"name": "Default Organization View 1.0",
"content_view_id": 1
},
"kt_environment": {
"id": 1,
"name": "Library"
},
"content_type": "ansible_collection",
"url": "http://galaxy.ansible.com/",
"arch": "noarch",
"os_versions": null,
"content_id": "1634312081893",
"generic_remote_options": null,
"major": null,
"minor": null,
"product": {
"id": 296,
"cp_id": "292121829980",
"name": "test_all_types",
"orphaned": false,
"redhat": false,
"sync_plan": null
},
"content_label": "Default_Organization_test_all_types_lin_collections",
"last_sync_words": "12 days"
}
]
}