diff --git a/config/routes.rb b/config/routes.rb index 91b724bea05..2af5f61814b 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -63,6 +63,9 @@ match '/flatpak_remotes' => 'react#index', :via => [:get] match '/flatpak_remotes/*page' => 'react#index', :via => [:get] + match '/content_credentials' => 'react#index', :via => [:get] + match '/content_credentials/*page' => 'react#index', :via => [:get] + Katello::RepositoryTypeManager.generic_ui_content_types(false).each do |type| get "/#{type.pluralize}", to: redirect("/content/#{type.pluralize}") get "/#{type.pluralize}/:page", to: redirect("/content/#{type.pluralize}/%{page}") diff --git a/engines/bastion_katello/app/assets/javascripts/bastion_katello/bastion_katello.js b/engines/bastion_katello/app/assets/javascripts/bastion_katello/bastion_katello.js index 5a7f3a86796..01ee7f2d6a0 100644 --- a/engines/bastion_katello/app/assets/javascripts/bastion_katello/bastion_katello.js +++ b/engines/bastion_katello/app/assets/javascripts/bastion_katello/bastion_katello.js @@ -80,7 +80,7 @@ //= require_tree "./tasks" //= require "bastion_katello/content-credentials/content-credentials.module.js" -//= require_tree "./content-credentials" +//= require "bastion_katello/content-credentials/content-credential.factory.js" //= require "bastion_katello/tasks/tasks.module.js" //= require_tree "./tasks" diff --git a/engines/bastion_katello/app/assets/javascripts/bastion_katello/content-credentials/content-credentials.controller.js b/engines/bastion_katello/app/assets/javascripts/bastion_katello/content-credentials/content-credentials.controller.js deleted file mode 100644 index 640e9fde0fb..00000000000 --- a/engines/bastion_katello/app/assets/javascripts/bastion_katello/content-credentials/content-credentials.controller.js +++ /dev/null @@ -1,38 +0,0 @@ -/** - * @ngdoc object - * @name Bastion.content-credentials.controller:ContentCredentialsController - * - * @requires $scope - * @requires $location - * @requires Nutupane - * @requires ContentCredential - * @requires CurrentOrganization - * @requires translate - * - * @description - * Provides the functionality specific to ContentCredentials for use with the Nutupane UI pattern. - * Defines the columns to display and the transform function for how to generate each row - * within the table. - */ -angular.module('Bastion.content-credentials').controller('ContentCredentialsController', - ['$scope', '$location', 'Nutupane', 'ContentCredential', 'CurrentOrganization', 'translate', - function ($scope, $location, Nutupane, ContentCredential, CurrentOrganization, translate) { - var params = { - 'organization_id': CurrentOrganization, - 'search': $location.search().search || "", - 'sort_by': 'name', - 'sort_order': 'ASC', - 'paged': true - }; - - var nutupane = new Nutupane(ContentCredential, params); - - // Labels so breadcrumb strings can be translated - $scope.label = translate('Content Credential'); - - $scope.controllerName = 'katello_content_credentials'; - $scope.table = nutupane.table; - $scope.panel = {loading: false}; - $scope.removeRow = nutupane.removeRow; - }] -); diff --git a/engines/bastion_katello/app/assets/javascripts/bastion_katello/content-credentials/content-credentials.routes.js b/engines/bastion_katello/app/assets/javascripts/bastion_katello/content-credentials/content-credentials.routes.js deleted file mode 100644 index 9696465fc67..00000000000 --- a/engines/bastion_katello/app/assets/javascripts/bastion_katello/content-credentials/content-credentials.routes.js +++ /dev/null @@ -1,85 +0,0 @@ -/** - * @ngdoc object - * @name Bastion.content-credentials.config - * - * @requires $stateProvider - * - * @description - * Used for systems level configuration such as setting up the ui state machine. - */ -angular.module('Bastion.content-credentials').config(['$stateProvider', function ($stateProvider) { - $stateProvider.state('content-credentials', { - url: '/content_credentials', - permission: 'view_content_credentials', - views: { - '@': { - controller: 'ContentCredentialsController', - templateUrl: 'content-credentials/views/content-credentials.html' - } - }, - ncyBreadcrumb: { - label: "{{ 'Content Credential' | translate}}" - } - }) - .state('content-credentials.new', { - url: '/new', - permission: 'create_content_credentials', - views: { - '@': { - controller: 'NewContentCredentialController', - templateUrl: 'content-credentials/new/views/new-content-credential.html' - } - }, - ncyBreadcrumb: { - label: "{{'New Content Credential' | translate }}", - parent: 'content-credentials' - } - }) - .state("content-credential", { - abstract: true, - url: '/content_credentials/:contentCredentialId', - permission: 'view_content_credentials', - controller: 'ContentCredentialDetailsController', - templateUrl: 'content-credentials/details/views/content-credential-details.html' - }) - .state('content-credential.info', { - url: '', - permission: 'view_content_credentials', - controller: 'ContentCredentialDetailsInfoController', - templateUrl: 'content-credentials/details/views/content-credential-info.html', - ncyBreadcrumb: { - label: "{{ contentCredential.name }}", - parent: 'content-credentials' - } - }) - .state('content-credential.acs', { - url: '/alternate_content_sources', - permission: 'view_content_credentials', - controller: 'ContentCredentialACSController', - templateUrl: 'content-credentials/details/views/content-credential-acs.html', - ncyBreadcrumb: { - label: "{{ 'Alternate Content Sources' | translate }}", - parent: 'content-credential.info' - } - }) - .state('content-credential.products', { - url: '/products', - permission: 'view_content_credentials', - controller: 'ContentCredentialProductsController', - templateUrl: 'content-credentials/details/views/content-credential-products.html', - ncyBreadcrumb: { - label: "{{ 'Products' | translate }}", - parent: 'content-credential.info' - } - }) - .state('content-credential.repositories', { - url: '/repositories', - permission: 'view_content_credentials', - controller: 'ContentCredentialRepositoriesController', - templateUrl: 'content-credentials/details/views/content-credential-repositories.html', - ncyBreadcrumb: { - label: "{{ 'Repositories' | translate }}", - parent: 'content-credential.info' - } - }); -}]); diff --git a/engines/bastion_katello/app/assets/javascripts/bastion_katello/content-credentials/content-type.filter.js b/engines/bastion_katello/app/assets/javascripts/bastion_katello/content-credentials/content-type.filter.js deleted file mode 100644 index 965e067cc9a..00000000000 --- a/engines/bastion_katello/app/assets/javascripts/bastion_katello/content-credentials/content-type.filter.js +++ /dev/null @@ -1,25 +0,0 @@ -/** - * @ngdoc object - * @name Bastion.content-credentials.filter:contentTypeFilter - * - * @requires translate - * - * @description - * Provides filter functionality to replace cert with Certificates and gpg_key with GPG Key - */ - -angular.module('Bastion.content-credentials').filter('contentTypeFilter', - ['$filter', 'translate', - function ($filter, translate) { - return function (contentType) { - var filtered = translate("Unsupported Type!"); - - if (contentType === "cert") { - filtered = translate("Certificate"); - } else if (contentType === "gpg_key") { - filtered = translate("GPG Key"); - } - return filtered; - }; - }] -); diff --git a/engines/bastion_katello/app/assets/javascripts/bastion_katello/content-credentials/details/content-credential-acs.controller.js b/engines/bastion_katello/app/assets/javascripts/bastion_katello/content-credentials/details/content-credential-acs.controller.js deleted file mode 100644 index 9065d501f2b..00000000000 --- a/engines/bastion_katello/app/assets/javascripts/bastion_katello/content-credentials/details/content-credential-acs.controller.js +++ /dev/null @@ -1,41 +0,0 @@ -/** - * @ngdoc object - * @name Bastion.content-credentials.controller:ContentCredentialACSController - * - * @requires $scope - * @requires Nutupane - * @requires ContentCredential - * @requires ApiErrorHandler - * @requires translate - * - * @description - * Page for Content Credential acs - */ -(function () { - function ContentCredentialACSController($scope, Nutupane, ContentCredential, ApiErrorHandler, translate) { - var nutupane = new Nutupane(ContentCredential, { - id: $scope.$stateParams.contentCredentialId - }, 'acs'); - $scope.controllerName = 'katello_content_credentials'; - - // Labels so breadcrumb strings can be translated - $scope.label = translate('Alternate Content Sources'); - - nutupane.primaryOnly = true; - - $scope.panel = $scope.panel || {error: false, loading: false}; - - $scope.contentCredential = ContentCredential.get({id: $scope.$stateParams.contentCredentialId}, function () { - $scope.panel.error = false; - $scope.panel.loading = false; - }, function (response) { - $scope.panel.loading = false; - ApiErrorHandler.handleGETRequestErrors(response, $scope); - }); - - $scope.table = nutupane.table; - } - - angular.module('Bastion.content-credentials').controller('ContentCredentialACSController', ContentCredentialACSController); - ContentCredentialACSController.$inject = ['$scope', 'Nutupane', 'ContentCredential', 'ApiErrorHandler', 'translate']; -})(); diff --git a/engines/bastion_katello/app/assets/javascripts/bastion_katello/content-credentials/details/content-credential-details-info.controller.js b/engines/bastion_katello/app/assets/javascripts/bastion_katello/content-credentials/details/content-credential-details-info.controller.js deleted file mode 100644 index 4f17afa14d3..00000000000 --- a/engines/bastion_katello/app/assets/javascripts/bastion_katello/content-credentials/details/content-credential-details-info.controller.js +++ /dev/null @@ -1,54 +0,0 @@ -/** - * @ngdoc object - * @name Bastion.contentCredentials.controller:ContentCredentialDetailsInfoController - * - * @requires $scope - * @requires ContentCredential - * @requires translate - * @requires Notification - * - * @description - * Provides the functionality for the contentCredential details action pane. - */ -angular.module('Bastion.content-credentials').controller('ContentCredentialDetailsInfoController', - ['$scope', 'ContentCredential', 'translate', 'Notification', function ($scope, ContentCredential, translate, Notification) { - - $scope.panel = $scope.panel || {loading: false}; - $scope.progress = {uploading: false}; - - $scope.contentCredential = $scope.contentCredential || ContentCredential.get({id: $scope.$stateParams.contentCredentialId}, function () { - $scope.panel.loading = false; - }); - - $scope.contentCredential.$promise.then(function () { - $scope.uploadURL = 'katello/api/v2/content_credentials/' + $scope.contentCredential.id + '/content'; - }); - - $scope.uploadContent = function (content) { - if (content && (content !== "Please wait...")) { - if (content.status === 'success') { - Notification.setSuccessMessage(translate('Content Credential successfully uploaded')); - $scope.uploadStatus = 'success'; - $scope.contentCredential.$get(); - } else { - Notification.setErrorMessage(content.message); - $scope.uploadStatus = 'error'; - } - - $scope.progress.uploading = false; - } - }; - - $scope.uploadError = function (error, content) { - if (angular.isString(content) && content.indexOf("Request Entity Too Large")) { - error = translate('File too large.'); - } else { - error = content; - } - Notification.setErrorMessage(translate('Error during upload: ') + error); - $scope.uploadStatus = 'error'; - $scope.progress.uploading = false; - }; - - }] -); diff --git a/engines/bastion_katello/app/assets/javascripts/bastion_katello/content-credentials/details/content-credential-details.controller.js b/engines/bastion_katello/app/assets/javascripts/bastion_katello/content-credentials/details/content-credential-details.controller.js deleted file mode 100644 index 3aa0d483f83..00000000000 --- a/engines/bastion_katello/app/assets/javascripts/bastion_katello/content-credentials/details/content-credential-details.controller.js +++ /dev/null @@ -1,54 +0,0 @@ -/** - * @ngdoc object - * @name Bastion.content-credentials.controller:ContentCredentialDetailsController - * - * @requires $scope - * @requires ContentCredential - * @requires $q - * @requires translate - * @requires ApiErrorHandler - * @requires Notification - * - * @description - * Provides the functionality for the contentCredential details action pane. - */ -angular.module('Bastion.content-credentials').controller('ContentCredentialDetailsController', - ['$scope', 'ContentCredential', '$q', 'translate', 'ApiErrorHandler', 'Notification', function ($scope, ContentCredential, $q, translate, ApiErrorHandler, Notification) { - $scope.panel = $scope.panel || {error: false, loading: false}; - - $scope.contentCredential = ContentCredential.get({id: $scope.$stateParams.contentCredentialId}, function () { - $scope.panel.error = false; - $scope.panel.loading = false; - }, function (response) { - $scope.panel.loading = false; - ApiErrorHandler.handleGETRequestErrors(response, $scope); - }); - - $scope.save = function (contentCredential) { - var deferred = $q.defer(); - - contentCredential.$update(function (response) { - deferred.resolve(response); - Notification.setSuccessMessage(translate('Content credential updated')); - - }, function (response) { - deferred.reject(response); - Notification.setErrorMessage(response.data.message); - }); - - return deferred.promise; - }; - - $scope.removeContentCredential = function (contentCredential) { - var deferred = $q.defer(); - contentCredential.$delete(function (response) { - deferred.resolve(response); - $scope.transitionTo('content-credentials'); - }, function (response) { - deferred.reject(response); - Notification.setErrorMessage(response.data.message); - }); - return deferred.promise; - }; - }] -); diff --git a/engines/bastion_katello/app/assets/javascripts/bastion_katello/content-credentials/details/content-credential-products.controller.js b/engines/bastion_katello/app/assets/javascripts/bastion_katello/content-credentials/details/content-credential-products.controller.js deleted file mode 100644 index 6e222cfb017..00000000000 --- a/engines/bastion_katello/app/assets/javascripts/bastion_katello/content-credentials/details/content-credential-products.controller.js +++ /dev/null @@ -1,41 +0,0 @@ -/** - * @ngdoc object - * @name Bastion.content-credentials.controller:ContentCredentialProductsController - * - * @requires $scope - * @requires Nutupane - * @requires ContentCredential - * @requires ApiErrorHandler - * @requires translate - * - * @description - * Page for Content Credential products - */ -(function () { - function ContentCredentialProductsController($scope, Nutupane, ContentCredential, ApiErrorHandler, translate) { - var nutupane = new Nutupane(ContentCredential, { - id: $scope.$stateParams.contentCredentialId - }, 'products'); - $scope.controllerName = 'katello_content_credentials'; - - // Labels so breadcrumb strings can be translated - $scope.label = translate('Products'); - - nutupane.primaryOnly = true; - - $scope.panel = $scope.panel || {error: false, loading: false}; - - $scope.contentCredential = ContentCredential.get({id: $scope.$stateParams.contentCredentialId}, function () { - $scope.panel.error = false; - $scope.panel.loading = false; - }, function (response) { - $scope.panel.loading = false; - ApiErrorHandler.handleGETRequestErrors(response, $scope); - }); - - $scope.table = nutupane.table; - } - - angular.module('Bastion.content-credentials').controller('ContentCredentialProductsController', ContentCredentialProductsController); - ContentCredentialProductsController.$inject = ['$scope', 'Nutupane', 'ContentCredential', 'ApiErrorHandler', 'translate']; -})(); diff --git a/engines/bastion_katello/app/assets/javascripts/bastion_katello/content-credentials/details/content-credential-repositories.controller.js b/engines/bastion_katello/app/assets/javascripts/bastion_katello/content-credentials/details/content-credential-repositories.controller.js deleted file mode 100644 index 624c7bf8217..00000000000 --- a/engines/bastion_katello/app/assets/javascripts/bastion_katello/content-credentials/details/content-credential-repositories.controller.js +++ /dev/null @@ -1,41 +0,0 @@ -(function () { - function ContentCredentialRepositoriesController($scope, Nutupane, ContentCredential, ApiErrorHandler, translate) { - /** - * @ngdoc object - * @name Bastion.content-credentials.controller:ContentCredentialRepositoriesController - * - * @requires $scope - * @requires Nutupane - * @requires ContentCredential - * @requires ApiErrorHandler - * @requires translate - * - * @description - * Page for Content Credential repositories - */ - var nutupane = new Nutupane(ContentCredential, { - id: $scope.$stateParams.contentCredentialId - }, 'repositories'); - $scope.controllerName = 'katello_content_credentials'; - - // Labels so breadcrumb strings can be translated - $scope.label = translate('Repositories'); - - nutupane.primaryOnly = true; - - $scope.panel = $scope.panel || {error: false, loading: false}; - - $scope.contentCredential = ContentCredential.get({id: $scope.$stateParams.contentCredentialId}, function () { - $scope.panel.error = false; - $scope.panel.loading = false; - }, function (response) { - $scope.panel.loading = false; - ApiErrorHandler.handleGETRequestErrors(response, $scope); - }); - - $scope.table = nutupane.table; - } - - angular.module('Bastion.content-credentials').controller('ContentCredentialRepositoriesController', ContentCredentialRepositoriesController); - ContentCredentialRepositoriesController.$inject = ['$scope', 'Nutupane', 'ContentCredential', 'ApiErrorHandler', 'translate']; -})(); diff --git a/engines/bastion_katello/app/assets/javascripts/bastion_katello/content-credentials/details/views/content-credential-acs.html b/engines/bastion_katello/app/assets/javascripts/bastion_katello/content-credentials/details/views/content-credential-acs.html deleted file mode 100644 index 9829c14d4bd..00000000000 --- a/engines/bastion_katello/app/assets/javascripts/bastion_katello/content-credentials/details/views/content-credential-acs.html +++ /dev/null @@ -1,38 +0,0 @@ -{{ 'Alternate Content Sources for ' | translate }} {{ contentCredential.name }} - -
- - You currently don't have any Alternate Content Sources associated with this Content Credential. - - -
- -
- - -
- - - - - - - - - - - - - - -
NameUsed as
- - {{ alternate_content_source.name }} - - - {{ alternate_content_source.usedAs }} -
-
-
\ No newline at end of file diff --git a/engines/bastion_katello/app/assets/javascripts/bastion_katello/content-credentials/details/views/content-credential-details.html b/engines/bastion_katello/app/assets/javascripts/bastion_katello/content-credentials/details/views/content-credential-details.html deleted file mode 100644 index a383a5c605b..00000000000 --- a/engines/bastion_katello/app/assets/javascripts/bastion_katello/content-credentials/details/views/content-credential-details.html +++ /dev/null @@ -1,39 +0,0 @@ -
-
-

{{ contentCredential.name }}

-
- -
- - -
-
Remove Content Credential {{ contentCredential.name }}
-
Are you sure you want to remove Content Credential {{ contentCredential.name }}?
-
-
- - - -
-
-
-
diff --git a/engines/bastion_katello/app/assets/javascripts/bastion_katello/content-credentials/details/views/content-credential-info.html b/engines/bastion_katello/app/assets/javascripts/bastion_katello/content-credentials/details/views/content-credential-info.html deleted file mode 100644 index f793e48a7c8..00000000000 --- a/engines/bastion_katello/app/assets/javascripts/bastion_katello/content-credentials/details/views/content-credential-info.html +++ /dev/null @@ -1,64 +0,0 @@ - -
-
-
-
Name
-
-
- -
Type
-
{{ contentCredential.content_type | contentTypeFilter }}
- -
Content
-
-
- -
- -
- -
- -
- -
- -
-
-
- -
Products
-
- - {{ contentCredential.gpg_key_products.length + - contentCredential.ssl_ca_products.length + - contentCredential.ssl_client_products.length + - contentCredential.ssl_key_products.length }} - -
- -
Repositories
-
- - {{ contentCredential.gpg_key_repos.length + - contentCredential.ssl_ca_root_repos.length + - contentCredential.ssl_client_root_repos.length + - contentCredential.ssl_key_root_repos.length }} - -
-
-
-
diff --git a/engines/bastion_katello/app/assets/javascripts/bastion_katello/content-credentials/details/views/content-credential-products.html b/engines/bastion_katello/app/assets/javascripts/bastion_katello/content-credentials/details/views/content-credential-products.html deleted file mode 100644 index 46fff86612f..00000000000 --- a/engines/bastion_katello/app/assets/javascripts/bastion_katello/content-credentials/details/views/content-credential-products.html +++ /dev/null @@ -1,44 +0,0 @@ -{{ 'Repositories for ' | translate }} {{ contentCredential.name }} - -
- - You currently don't have any Products associated with this Content Credential. - - -
- -
- - -
- - - - - - - - - - - - - - - - -
NameUsed asRepositories
- - {{ product.name }} - - - {{ product.usedAs }} - - - {{ product.repository_count }} - -
-
-
diff --git a/engines/bastion_katello/app/assets/javascripts/bastion_katello/content-credentials/details/views/content-credential-repositories.html b/engines/bastion_katello/app/assets/javascripts/bastion_katello/content-credentials/details/views/content-credential-repositories.html deleted file mode 100644 index f3712faa6ea..00000000000 --- a/engines/bastion_katello/app/assets/javascripts/bastion_katello/content-credentials/details/views/content-credential-repositories.html +++ /dev/null @@ -1,41 +0,0 @@ -{{ 'Products for ' | translate }} {{ contentCredential.name }} - -
- - You currently don't have any Repositories associated with this Content Credential. - - -
- -
- -
- - - - - - - - - - - - - - - - - - -
NameProductTypeUsed as
- {{ repository.name }} - - - {{ repository.product.name }} - - {{ repository.content_type }}{{ repository.usedAs }}
-
-
diff --git a/engines/bastion_katello/app/assets/javascripts/bastion_katello/content-credentials/new/new-content-credential.controller.js b/engines/bastion_katello/app/assets/javascripts/bastion_katello/content-credentials/new/new-content-credential.controller.js deleted file mode 100644 index 1fbe98c3aae..00000000000 --- a/engines/bastion_katello/app/assets/javascripts/bastion_katello/content-credentials/new/new-content-credential.controller.js +++ /dev/null @@ -1,42 +0,0 @@ -/** - * @ngdoc object - * @name Bastion.content-credentials.controller:NewContentCredentialController - * - * @requires $scope - * @requires $state - * @requires translate - * @requires ContentCredential - * @requires CurrentOrganization - * @requires Notification - * - * @description - * Controls the creation of an empty ContentCredential object for use by sub-controllers. - */ -angular.module('Bastion.content-credentials').controller('NewContentCredentialController', - ['$scope', '$state', 'translate', 'ContentCredential', 'CurrentOrganization', 'Notification', - function ($scope, $state, translate, ContentCredential, CurrentOrganization, Notification) { - $scope.panel = {loading: false}; - $scope.contentCredential = new ContentCredential(); - $scope.CurrentOrganization = CurrentOrganization; - $scope.progress = {uploading: false}; - $scope.uploadURL = 'katello/api/v2/content_credentials?organization_id=' + CurrentOrganization; - - // Labels so breadcrumb strings can be translated - $scope.label = translate('New Content Credential'); - - $scope.uploadContent = function (response) { - if (response) { - if (angular.isUndefined(response.errors)) { - $scope.uploadStatus = 'success'; - $scope.transitionTo('content-credential.info', {contentCredentialId: response.id}); - Notification.setSuccessMessage(translate('Content Credential %s has been created.').replace('%s', response.name)); - } else { - Notification.setErrorMessage(translate("An error occurred while creating the Content Credential: ") + response.message); - $scope.uploadStatus = 'error'; - } - - $scope.progress.uploading = false; - } - }; - }] -); diff --git a/engines/bastion_katello/app/assets/javascripts/bastion_katello/content-credentials/new/views/new-content-credential.html b/engines/bastion_katello/app/assets/javascripts/bastion_katello/content-credentials/new/views/new-content-credential.html deleted file mode 100644 index 19af391ff51..00000000000 --- a/engines/bastion_katello/app/assets/javascripts/bastion_katello/content-credentials/new/views/new-content-credential.html +++ /dev/null @@ -1,55 +0,0 @@ -
-
-

Create Content Credential

-
- -
-
- -
- -
- -
- -
- -
- -
- -
- -

Upload Content Credential file

-
- -
-
-
-
-
diff --git a/engines/bastion_katello/app/assets/javascripts/bastion_katello/content-credentials/views/content-credentials.html b/engines/bastion_katello/app/assets/javascripts/bastion_katello/content-credentials/views/content-credentials.html deleted file mode 100644 index c5124744cd3..00000000000 --- a/engines/bastion_katello/app/assets/javascripts/bastion_katello/content-credentials/views/content-credentials.html +++ /dev/null @@ -1,60 +0,0 @@ -{{ 'Content Credentials' | translate }} - -
-
-

Content Credentials

-
- -
- -
- - - You currently don't have any Content Credential, you can add Content Credentials using the button on the right. - - - - Your search returned zero Content Credential. - - -
- - - - - - - - - - - - - - - - - - - - - - -
NameOrganizationTypeProductsRepositoriesAlternate Content Sources
- {{ contentCredential.name }} - {{ contentCredential.organization.name }}{{ contentCredential.content_type | contentTypeFilter }}{{ contentCredential.gpg_key_products.length + - contentCredential.ssl_ca_products.length + - contentCredential.ssl_client_products.length + - contentCredential.ssl_key_products.length || 0 }}{{ contentCredential.gpg_key_repos.length + - contentCredential.ssl_ca_root_repos.length + - contentCredential.ssl_client_root_repos.length + - contentCredential.ssl_key_root_repos.length || 0 }} - {{ contentCredential.ssl_ca_alternate_content_sources.length + - contentCredential.ssl_client_alternate_content_sources.length + - contentCredential.ssl_key_alternate_content_sources.length || 0 }} -
- -
-
diff --git a/engines/bastion_katello/app/assets/javascripts/bastion_katello/katello-features.run.js b/engines/bastion_katello/app/assets/javascripts/bastion_katello/katello-features.run.js index 5d5871cea2c..e41c5cf6178 100644 --- a/engines/bastion_katello/app/assets/javascripts/bastion_katello/katello-features.run.js +++ b/engines/bastion_katello/app/assets/javascripts/bastion_katello/katello-features.run.js @@ -13,13 +13,7 @@ 'products.new.form', 'products.discovery', 'products.discovery.scan', - 'products.discovery.create', - 'content-credentials', - 'content-credentials.new', - 'content-credential.info', - 'content-credential.products', - 'content-credential.acs', - 'content-credential.repositories' + 'products.discovery.create' ]; FeatureFlag.addStates('custom_products', customProducts); diff --git a/engines/bastion_katello/app/assets/javascripts/bastion_katello/organizations/fenced-pages.service.js b/engines/bastion_katello/app/assets/javascripts/bastion_katello/organizations/fenced-pages.service.js index d46ad8d76e0..14023ef3177 100644 --- a/engines/bastion_katello/app/assets/javascripts/bastion_katello/organizations/fenced-pages.service.js +++ b/engines/bastion_katello/app/assets/javascripts/bastion_katello/organizations/fenced-pages.service.js @@ -13,7 +13,6 @@ angular.module('Bastion.organizations').service('FencedPages', ['$state', 'content-views', 'docker-tags', 'errata', - 'content-credentials', 'host-collections', 'lifecycle-environments', 'packages', diff --git a/engines/bastion_katello/lib/bastion_katello/engine.rb b/engines/bastion_katello/lib/bastion_katello/engine.rb index ecf07417d29..851b9503e18 100644 --- a/engines/bastion_katello/lib/bastion_katello/engine.rb +++ b/engines/bastion_katello/lib/bastion_katello/engine.rb @@ -17,7 +17,6 @@ class Engine < ::Rails::Engine :stylesheet => 'bastion_katello/bastion_katello', :pages => %w( activation_keys - content_credentials debs docker_tags files diff --git a/engines/bastion_katello/test/content-credentials/content-credentials.factory.test.js b/engines/bastion_katello/test/content-credentials/content-credentials.factory.test.js deleted file mode 100644 index 27f53aff985..00000000000 --- a/engines/bastion_katello/test/content-credentials/content-credentials.factory.test.js +++ /dev/null @@ -1,132 +0,0 @@ -describe("Factory: ContentCredential", function() { - var $httpBackend, contentCredentials, contentCredential; - - beforeEach(module("Bastion.content-credentials", "Bastion.test-mocks")); - - beforeEach( - module(function($provide) { - contentCredential = { - name: "fakegpg", - content_type: "gpg_key", - content: "hello", - id: 2, - organization_id: 4, - organization: { name: "org-4351", label: "org-4351", id: 4 }, - created_at: "2018-12-04 16:05:47 -0500", - updated_at: "2018-12-04 16:05:47 -0500", - gpg_key_products: [ - { - id: 1, - cp_id: "644602083972", - name: "test_product", - provider: { name: "Anonymous", id: 17 }, - repository_count: 5 - } - ], - gpg_key_repos: [ - { - id: 5, - name: "fakegpg", - content_type: "yum", - product: { id: 1, cp_id: "644602083972", name: "test_product" } - }, - { - id: 1, - name: "yum", - content_type: "yum", - product: { id: 1, cp_id: "644602083972", name: "test_product" } - } - ], - ssl_ca_alternate_content_sources: [{ id: 1, name: "fakeacs" }], - ssl_client_alternate_content_sources: [], - ssl_key_alternate_content_sources: [], - ssl_ca_products: [], - ssl_ca_root_repos: [], - ssl_client_products: [], - ssl_client_root_repos: [], - ssl_key_products: [], - ssl_key_root_repos: [], - permissions: { - view_content_credentials: true, - edit_content_credentials: true, - destroy_content_credentials: true - } - }; - - contentCredentials = { - records: [ - contentCredential - ], - total: 3, - subtotal: 1 - }; - - $provide.value("CurrentOrganization", "ACME"); - }) - ); - - beforeEach(inject(function($injector) { - $httpBackend = $injector.get("$httpBackend"); - ContentCredential = $injector.get("ContentCredential"); - })); - - afterEach(function() { - $httpBackend.flush(); - $httpBackend.verifyNoOutstandingExpectation(); - $httpBackend.verifyNoOutstandingRequest(); - }); - - it("provides a way to get a list of repositories", function() { - $httpBackend - .expectGET("katello/api/v2/content_credentials?organization_id=ACME") - .respond(contentCredentials); - - ContentCredential.queryPaged(function(contentCredentials) { - expect(contentCredentials.records.length).toBe(1); - }); - }); - - it("provides a way to get a list of acs", function() { - $httpBackend - .expectGET("katello/api/v2/content_credentials?organization_id=ACME") - .respond(contentCredentials); - - ContentCredential.queryPaged(function(contentCredentials) { - expect(contentCredentials.records[0].ssl_ca_alternate_content_sources).toBeDefined(); - expect(contentCredentials.records[0].ssl_ca_alternate_content_sources.length).toBe(1); - expect(contentCredentials.records[0].ssl_ca_alternate_content_sources[0].id).toBe(1); - expect(contentCredentials.records[0].ssl_ca_alternate_content_sources[0].name).toBe("fakeacs"); - }); - }); - - it("provide a way to get a single content credential's repositories", function() { - $httpBackend - .expectGET("katello/api/v2/content_credentials/1/repositories?organization_id=ACME") - .respond(contentCredential); - - ContentCredential.repositories({id: 1, action: 'repositories'}, function(response) { - var results = response.results; - expect(results.length).toBe(2); - angular.forEach(results, function(result) { - expect(result.name).toBeDefined(); - expect(result.content_type).toBe('yum'); - expect(result.usedAs).toBe('GPG Key'); - }) - }); - }); - - it("provide a way to get a single content credential's products", function() { - $httpBackend - .expectGET("katello/api/v2/content_credentials/1/products?organization_id=ACME") - .respond(contentCredential); - - ContentCredential.products({id: 1, action: 'products'}, function(response) { - var results = response.results; - expect(results.length).toBe(1); - angular.forEach(results, function(result) { - expect(result.name).toBeDefined(); - expect(result.usedAs).toBe('GPG Key'); - }) - }); - }); -}); diff --git a/engines/bastion_katello/test/content-credentials/details/content-credential-acs.controller.test.js b/engines/bastion_katello/test/content-credentials/details/content-credential-acs.controller.test.js deleted file mode 100644 index 5f70ed658cf..00000000000 --- a/engines/bastion_katello/test/content-credentials/details/content-credential-acs.controller.test.js +++ /dev/null @@ -1,39 +0,0 @@ -describe('Controller: ContentCredentialACSController', function() { - var $scope; - - beforeEach(module( - 'Bastion.content-credentials', - 'Bastion.test-mocks' - )); - - beforeEach(inject(function($injector) { - var $controller = $injector.get('$controller'), - $q = $injector.get('$q'), - ContentCredential = $injector.get('MockResource').$new(), - Nutupane; - - $scope = $injector.get('$rootScope').$new(); - $scope.$stateParams = { - contentCredentialId: 1 - }; - - Nutupane = function() { - this.table = {}; - }; - - $controller('ContentCredentialACSController', { - $scope: $scope, - Nutupane: Nutupane, - ContentCredential: ContentCredential - }); - - })); - - it('retrieves and puts a content credential on the scope', function() { - expect($scope.contentCredential).toBeDefined(); - }); - - it("sets up the content credential products nutupane table", function() { - expect($scope.table).toBeDefined(); - }); -}); \ No newline at end of file diff --git a/engines/bastion_katello/test/content-credentials/details/content-credential-details-info.controller.test.js b/engines/bastion_katello/test/content-credentials/details/content-credential-details-info.controller.test.js deleted file mode 100644 index 6a71de0d83f..00000000000 --- a/engines/bastion_katello/test/content-credentials/details/content-credential-details-info.controller.test.js +++ /dev/null @@ -1,80 +0,0 @@ -describe('Controller: ContentCredentialDetailsInfoController', function() { - var $scope, translate, Notification; - - beforeEach(module( - 'Bastion.content-credentials', - 'Bastion.test-mocks' - )); - - beforeEach(inject(function($injector) { - var $controller = $injector.get('$controller'), - ContentCredential = $injector.get('MockResource').$new(); - - $scope = $injector.get('$rootScope').$new(); - $scope.$stateParams = { - contentCredentialId: 1 - }; - translate = function(message) { - return message; - }; - - Notification = { - setSuccessMessage: function () {}, - setErrorMessage: function () {} - }; - - $controller('ContentCredentialDetailsInfoController', { - $scope: $scope, - ContentCredential: ContentCredential, - translate: translate, - Notification: Notification - }); - - })); - - it('retrieves and puts a content credential on the scope', function() { - expect($scope.contentCredential).toBeDefined(); - }); - - it('should save a new content credential resource on upload', function() { - spyOn(Notification, 'setSuccessMessage'); - - spyOn($scope.contentCredential, '$get'); - $scope.uploadContent({"status": "success"}); - - expect(Notification.setSuccessMessage).toHaveBeenCalled(); - - expect($scope.uploadStatus).toBe('success'); - expect($scope.contentCredential.$get).toHaveBeenCalled(); - }); - - it('should error on a new content credential resource on upload', function() { - spyOn(Notification, 'setErrorMessage'); - - spyOn($scope.contentCredential, '$get'); - $scope.uploadContent({"errors": "....", "message":"......"}); - - expect(Notification.setErrorMessage).toHaveBeenCalled(); - expect($scope.contentCredential.$get).not.toHaveBeenCalled(); - }); - - it('should handle a 413 error', function() { - var error = 'Could not parse JSON', - text = ' \ - 413 Request Entity Too Large \ - \ -

Request Entity Too Large

\ - The requested resource
/katello/api/v2/repositories/1/upload_content
\ - does not allow request data with POST requests, or the amount of data provided in \ - the request exceeds the capacity limit. \ - '; - - spyOn(Notification, 'setErrorMessage'); - spyOn($scope.contentCredential, '$get'); - $scope.uploadError(error, text); - - expect(Notification.setErrorMessage).toHaveBeenCalledWith('Error during upload: File too large.'); - expect($scope.uploadStatus).toBe('error'); - expect($scope.contentCredential.$get).not.toHaveBeenCalled(); - }); -}); diff --git a/engines/bastion_katello/test/content-credentials/details/content-credential-details.controller.test.js b/engines/bastion_katello/test/content-credentials/details/content-credential-details.controller.test.js deleted file mode 100644 index 240479f7a3a..00000000000 --- a/engines/bastion_katello/test/content-credentials/details/content-credential-details.controller.test.js +++ /dev/null @@ -1,76 +0,0 @@ -describe('Controller: ContentCredentialDetailsController', function() { - var $scope, translate, Notification; - - beforeEach(module( - 'Bastion.content-credentials', - 'Bastion.test-mocks' - )); - - beforeEach(inject(function($injector) { - var $controller = $injector.get('$controller'), - $q = $injector.get('$q'), - ContentCredential = $injector.get('MockResource').$new(); - - $scope = $injector.get('$rootScope').$new(); - $scope.$stateParams = { - contentCredentialId: 1 - }; - - translate = function(message) { - return message; - }; - - Notification = { - setSuccessMessage: function () {}, - setErrorMessage: function () {} - }; - - $scope.removeRow = function(id) {}; - $scope.table = { - replaceRow: function() {} - }; - - $controller('ContentCredentialDetailsController', { - $scope: $scope, - ContentCredential: ContentCredential, - $q: $q, - translate: translate, - Notification: Notification - }); - - })); - - it('retrieves and puts a content credential on the scope', function() { - expect($scope.contentCredential).toBeDefined(); - }); - - it('should save the content credential and return a promise', function() { - var promise = $scope.save($scope.contentCredential); - - expect(promise.then).toBeDefined(); - }); - - it('should save the content credential successfully', function() { - spyOn(Notification, 'setSuccessMessage'); - - $scope.save($scope.contentCredential); - - expect(Notification.setSuccessMessage).toHaveBeenCalled(); - }); - - it('should fail to save the content credential', function() { - spyOn(Notification, 'setErrorMessage'); - - $scope.contentCredential.failed = true; - $scope.save($scope.contentCredential); - - expect(Notification.setErrorMessage).toHaveBeenCalled(); - }); - - it('should provide a way to remove a content credential', function() { - spyOn($scope, 'transitionTo'); - $scope.removeContentCredential($scope.contentCredential); - expect($scope.transitionTo).toHaveBeenCalledWith('content-credentials'); - }); - -}); diff --git a/engines/bastion_katello/test/content-credentials/details/content-credential-products.controller.test.js b/engines/bastion_katello/test/content-credentials/details/content-credential-products.controller.test.js deleted file mode 100644 index f42e689694a..00000000000 --- a/engines/bastion_katello/test/content-credentials/details/content-credential-products.controller.test.js +++ /dev/null @@ -1,39 +0,0 @@ -describe('Controller: ContentCredentialProductsController', function() { - var $scope; - - beforeEach(module( - 'Bastion.content-credentials', - 'Bastion.test-mocks' - )); - - beforeEach(inject(function($injector) { - var $controller = $injector.get('$controller'), - $q = $injector.get('$q'), - ContentCredential = $injector.get('MockResource').$new(), - Nutupane; - - $scope = $injector.get('$rootScope').$new(); - $scope.$stateParams = { - contentCredentialId: 1 - }; - - Nutupane = function() { - this.table = {}; - }; - - $controller('ContentCredentialProductsController', { - $scope: $scope, - Nutupane: Nutupane, - ContentCredential: ContentCredential - }); - - })); - - it('retrieves and puts a content credential on the scope', function() { - expect($scope.contentCredential).toBeDefined(); - }); - - it("sets up the content credential products nutupane table", function() { - expect($scope.table).toBeDefined(); - }); -}); diff --git a/engines/bastion_katello/test/content-credentials/details/content-credential-repositorires.controller.test.js b/engines/bastion_katello/test/content-credentials/details/content-credential-repositorires.controller.test.js deleted file mode 100644 index 8710595e919..00000000000 --- a/engines/bastion_katello/test/content-credentials/details/content-credential-repositorires.controller.test.js +++ /dev/null @@ -1,39 +0,0 @@ -describe('Controller: ContentCredentialRepositoriesController', function() { - var $scope; - - beforeEach(module( - 'Bastion.content-credentials', - 'Bastion.test-mocks' - )); - - beforeEach(inject(function($injector) { - var $controller = $injector.get('$controller'), - $q = $injector.get('$q'), - ContentCredential = $injector.get('MockResource').$new(), - Nutupane; - - $scope = $injector.get('$rootScope').$new(); - $scope.$stateParams = { - contentCredentialId: 1 - }; - - Nutupane = function() { - this.table = {}; - }; - - $controller('ContentCredentialRepositoriesController', { - $scope: $scope, - Nutupane: Nutupane, - ContentCredential: ContentCredential - }); - - })); - - it('retrieves and puts a content credential on the scope', function() { - expect($scope.contentCredential).toBeDefined(); - }); - - it("sets up the content credential products nutupane table", function() { - expect($scope.table).toBeDefined(); - }); -}); diff --git a/engines/bastion_katello/test/content-credentials/new/new-content-credential-controller.test.js b/engines/bastion_katello/test/content-credentials/new/new-content-credential-controller.test.js deleted file mode 100644 index d93ee730ae1..00000000000 --- a/engines/bastion_katello/test/content-credentials/new/new-content-credential-controller.test.js +++ /dev/null @@ -1,60 +0,0 @@ -describe('Controller: NewContentCredentialController', function() { - var $scope, translate, Notification; - - beforeEach(module( - 'Bastion.content-credentials', - 'Bastion.test-mocks' - )); - - beforeEach(inject(function($injector) { - var $controller = $injector.get('$controller'), - $q = $injector.get('$q'), - ContentCredential = $injector.get('MockResource').$new(), - CurrentOrganization = "Foo"; - - $scope = $injector.get('$rootScope').$new(); - Notification = $injector.get('Notification'); - - $scope.table = { - addRow: function() {}, - closeItem: function() {} - }; - - $controller('NewContentCredentialController', { - $scope: $scope, - ContentCredential: ContentCredential, - CurrentOrganization:CurrentOrganization, - Notification: Notification - }); - - })); - - it('should attach a content credential resource on to the scope', function() { - expect($scope.contentCredential).toBeDefined(); - }); - - it('should save a new content credential resource', function() { - spyOn($scope, 'transitionTo'); - spyOn(Notification, "setSuccessMessage"); - $scope.uploadContent({"status": "success"}); - - expect(Notification.setSuccessMessage).toHaveBeenCalled(); - expect($scope.uploadStatus).toBe('success'); - - expect($scope.transitionTo).toHaveBeenCalledWith('content-credential.info', jasmine.any(Object)); - }); - - it('should error on a new content credential resource', function() { - spyOn($scope, 'transitionTo'); - spyOn(Notification, "setSuccessMessage"); - spyOn(Notification, 'setErrorMessage'); - - $scope.uploadContent({"errors": "....", "message":"......"}); - - expect(Notification.setSuccessMessage).not.toHaveBeenCalled(); - expect(Notification.setErrorMessage).toHaveBeenCalled(); - - expect($scope.uploadStatus).toBe('error'); - }); - -}); diff --git a/lib/katello/plugin.rb b/lib/katello/plugin.rb index 9290f65f8fb..9c585c01121 100644 --- a/lib/katello/plugin.rb +++ b/lib/katello/plugin.rb @@ -211,16 +211,6 @@ :after => :newhost, :turbolinks => false - menu :labs_menu, - :content_credentials, - :caption => N_('Content Credentials'), - :url => '/labs/content_credentials', - :url_hash => {:controller => 'katello/api/v2/content_credentials_controller', - :action => 'index'}, - :engine => Katello::Engine, - :parent => :lab_features_menu, - :turbolinks => false - extend_template_helpers Katello::KatelloUrlsHelper extend_template_helpers Katello::Concerns::BaseTemplateScopeExtensions diff --git a/webpack/containers/Application/config.js b/webpack/containers/Application/config.js index 97ae21cf218..41b9517d405 100644 --- a/webpack/containers/Application/config.js +++ b/webpack/containers/Application/config.js @@ -103,11 +103,11 @@ export const links = [ exact: false, }, { - path: 'labs/content_credentials', + path: 'content_credentials', component: WithOrganization(withHeader(ContentCredentials, { title: __('Content Credentials') })), }, { - path: 'labs/content_credentials/:id([0-9]+)', + path: 'content_credentials/:id([0-9]+)', component: WithOrganization(withHeader(ContentCredentialsDetails, { title: __('Content Credential Details') })), exact: false, }, diff --git a/webpack/scenes/ContentCredentials/ContentCredentialsPage.js b/webpack/scenes/ContentCredentials/ContentCredentialsPage.js index 6266bd4d406..fc66d651a19 100644 --- a/webpack/scenes/ContentCredentials/ContentCredentialsPage.js +++ b/webpack/scenes/ContentCredentials/ContentCredentialsPage.js @@ -92,7 +92,7 @@ const ContentCredentialsPage = () => { title: __('Name'), isSorted: true, wrapper: rowData => ( - + {rowData.name} ), diff --git a/webpack/scenes/ContentCredentials/Create/CreateContentCredentialForm.js b/webpack/scenes/ContentCredentials/Create/CreateContentCredentialForm.js index 112e99fce28..97761d99ea3 100644 --- a/webpack/scenes/ContentCredentials/Create/CreateContentCredentialForm.js +++ b/webpack/scenes/ContentCredentials/Create/CreateContentCredentialForm.js @@ -47,7 +47,7 @@ const CreateContentCredentialForm = ({ setModalOpen, setFormState, refreshTable setSaving(false); setModalOpen(false); refreshTable(); - history.push('/labs/content_credentials'); + history.push('/content_credentials'); } else if (status === STATUS.ERROR) { setSaving(false); } diff --git a/webpack/scenes/ContentCredentials/Create/__tests__/CreateContentCredentialModal.test.js b/webpack/scenes/ContentCredentials/Create/__tests__/CreateContentCredentialModal.test.js index d0d4d07e1a3..c98f132648a 100644 --- a/webpack/scenes/ContentCredentials/Create/__tests__/CreateContentCredentialModal.test.js +++ b/webpack/scenes/ContentCredentials/Create/__tests__/CreateContentCredentialModal.test.js @@ -131,7 +131,7 @@ describe('CreateContentCredentialModal', () => { await patientlyWaitFor(() => { assertNockRequest(scope); - expect(mockPush).toHaveBeenCalledWith('/labs/content_credentials'); + expect(mockPush).toHaveBeenCalledWith('/content_credentials'); }); }); @@ -166,7 +166,7 @@ describe('CreateContentCredentialModal', () => { await patientlyWaitFor(() => { assertNockRequest(scope); - expect(mockPush).toHaveBeenCalledWith('/labs/content_credentials'); + expect(mockPush).toHaveBeenCalledWith('/content_credentials'); }); }); diff --git a/webpack/scenes/ContentCredentials/Delete/DeleteContentCredentialModal.js b/webpack/scenes/ContentCredentials/Delete/DeleteContentCredentialModal.js index a6ba969573b..2188b121073 100644 --- a/webpack/scenes/ContentCredentials/Delete/DeleteContentCredentialModal.js +++ b/webpack/scenes/ContentCredentials/Delete/DeleteContentCredentialModal.js @@ -28,7 +28,7 @@ const DeleteContentCredentialModal = ({ if (!credentialId) return; dispatch(deleteContentCredential(credentialId, () => { refreshTable(); - history.push('/labs/content_credentials'); + history.push('/content_credentials'); })); handleModalToggle(); }; diff --git a/webpack/scenes/ContentCredentials/Delete/__tests__/DeleteContentCredentialModal.test.js b/webpack/scenes/ContentCredentials/Delete/__tests__/DeleteContentCredentialModal.test.js index cd9e3742024..34b6045bf1e 100644 --- a/webpack/scenes/ContentCredentials/Delete/__tests__/DeleteContentCredentialModal.test.js +++ b/webpack/scenes/ContentCredentials/Delete/__tests__/DeleteContentCredentialModal.test.js @@ -144,7 +144,7 @@ describe('DeleteContentCredentialModal', () => { assertNockRequest(scope); expect(handleModalToggle).toHaveBeenCalled(); expect(refreshTable).toHaveBeenCalled(); - expect(mockPush).toHaveBeenCalledWith('/labs/content_credentials'); + expect(mockPush).toHaveBeenCalledWith('/content_credentials'); }); }); diff --git a/webpack/scenes/ContentCredentials/Details/ContentCredentialsDetails.js b/webpack/scenes/ContentCredentials/Details/ContentCredentialsDetails.js index 262067f2f8b..f02c28c259d 100644 --- a/webpack/scenes/ContentCredentials/Details/ContentCredentialsDetails.js +++ b/webpack/scenes/ContentCredentials/Details/ContentCredentialsDetails.js @@ -24,10 +24,9 @@ import { import { STATUS } from 'foremanReact/constants'; import { ExternalLinkAltIcon } from '@patternfly/react-icons'; import { translate as __ } from 'foremanReact/common/I18n'; -import { addToast } from 'foremanReact/components/ToastsList'; -import { getResponseErrorMsgs } from '../../../utils/helpers'; import { getContentCredentialDetails } from './ContentCredentialsDetailsActions'; +import { deleteContentCredential } from '../ContentCredentialActions'; import Loading from '../../../components/Loading'; import DetailsTab from './DetailsTab'; import ProductsTab from './ProductsTab'; @@ -41,7 +40,6 @@ import { import RoutedTabs from '../../../components/RoutedTabs'; import EmptyStateMessage from '../../../components/Table/EmptyStateMessage'; import { CONTENT_CREDENTIAL_GPG_TYPE } from '../ContentCredentialConstants'; -import api, { orgId } from '../../../services/api'; const ContentCredentialsDetails = () => { const { id } = useParams(); @@ -66,23 +64,11 @@ const ContentCredentialsDetails = () => { isMountedRef.current = false; }, []); - const handleDelete = async () => { - try { - await api.delete(`/content_credentials/${credentialId}`, {}, { - organization_id: orgId(), - }); - history.push('/labs/content_credentials'); - } catch (deleteError) { - const [errorMessage] = getResponseErrorMsgs(deleteError.response) - .filter(Boolean); - dispatch(addToast({ - type: 'danger', - message: errorMessage || __('Failed to delete content credential. Please try again.'), - })); - } - if (isMountedRef.current) { - setDeleting(false); - } + const handleDelete = () => { + dispatch(deleteContentCredential(credentialId, () => { + history.push('/content_credentials'); + })); + setDeleting(false); }; if (status === STATUS.PENDING) return (); @@ -140,7 +126,7 @@ const ContentCredentialsDetails = () => { - + {__('Content Credentials')} {name} diff --git a/webpack/scenes/ContentCredentials/Details/__tests__/ContentCredentialsDetails.test.js b/webpack/scenes/ContentCredentials/Details/__tests__/ContentCredentialsDetails.test.js index 391c0cceeb5..26e0c4450de 100644 --- a/webpack/scenes/ContentCredentials/Details/__tests__/ContentCredentialsDetails.test.js +++ b/webpack/scenes/ContentCredentials/Details/__tests__/ContentCredentialsDetails.test.js @@ -4,30 +4,21 @@ import { screen } from '@testing-library/react'; import '@testing-library/jest-dom'; import { renderWithRedux, patientlyWaitFor, fireEvent } from 'react-testing-lib-wrapper'; import { MemoryRouter, Route } from 'react-router-dom'; -import { addToast } from 'foremanReact/components/ToastsList'; import ContentCredentialsDetails from '../ContentCredentialsDetails'; import api from '../../../../services/api'; import { nockInstance, assertNockRequest } from '../../../../test-utils/nockWrapper'; -jest.mock('foremanReact/components/ToastsList', () => ({ - addToast: jest.fn(() => ({ type: 'ADD_TOAST' })), -})); - -afterEach(() => { - jest.clearAllMocks(); -}); - const credentialId = 1; const credentialDetailsPath = api.getApiUrl(`/content_credentials/${credentialId}`); const withCredentialRoute = component => ( - {component} + {component} ); const renderOptions = { apiNamespace: 'CONTENT_CREDENTIAL_DETAILS', routerParams: { - initialEntries: [{ pathname: `/labs/content_credentials/${credentialId}` }], + initialEntries: [{ pathname: `/content_credentials/${credentialId}` }], }, }; @@ -94,7 +85,7 @@ const mockCredentialData = { }; const TestWrapper = ({ children }) => ( - + {withCredentialRoute(children)} ); @@ -236,7 +227,7 @@ test('cancel button closes delete modal without deleting', async () => { assertNockRequest(getScope); }); -test('shows error toast when delete fails', async () => { +test('closes modal when delete fails', async () => { const getScope = nockInstance .get(credentialDetailsPath) .query(true) @@ -257,7 +248,6 @@ test('shows error toast when delete fails', async () => { expect(queryByText('Test GPG Key (GPG Key)')).toBeInTheDocument(); }); - // Open kebab menu and click Delete fireEvent.click(getByLabelText('Actions')); fireEvent.click(getByText('Delete')); @@ -265,14 +255,10 @@ test('shows error toast when delete fails', async () => { expect(queryByText('Delete Content Credential')).toBeInTheDocument(); }); - // Confirm deletion fireEvent.click(getByText('Delete', { selector: '[data-ouia-component-id="delete-confirm-button"]' })); - // Wait for the error toast to be dispatched await patientlyWaitFor(() => { - expect(addToast).toHaveBeenCalledWith(expect.objectContaining({ - type: 'danger', - })); + expect(queryByText('Delete Content Credential')).not.toBeInTheDocument(); }); assertNockRequest(getScope); @@ -379,7 +365,7 @@ test('breadcrumb links back to content credentials list', async () => { await patientlyWaitFor(() => { const breadcrumbLink = screen.getByRole('link', { name: 'Content Credentials' }); - expect(breadcrumbLink).toHaveAttribute('href', '/labs/content_credentials'); + expect(breadcrumbLink).toHaveAttribute('href', '/content_credentials'); }); assertNockRequest(scope);