diff --git a/app/javascript/packs/applications_show.scss b/app/javascript/packs/applications_show.scss index 18d7e5d772..bd8d4480cf 100644 --- a/app/javascript/packs/applications_show.scss +++ b/app/javascript/packs/applications_show.scss @@ -1,2 +1,3 @@ @import '~@patternfly/patternfly/layouts/Grid/grid.css'; @import '~@patternfly/patternfly/components/DescriptionList/description-list.css'; +@import '~@patternfly/patternfly/components/Table/table.css'; diff --git a/app/views/buyers/applications/_api_credentials.html.erb b/app/views/buyers/applications/_api_credentials.html.erb deleted file mode 100644 index 7c6e2d5b0f..0000000000 --- a/app/views/buyers/applications/_api_credentials.html.erb +++ /dev/null @@ -1,55 +0,0 @@ -<% if cinstance.backend_version.v2? %> - - Application ID - <%= cinstance.application_id %> - - <%= render :partial => 'provider/admin/keys/key', :collection => cinstance.application_keys, :locals => {:cinstance => cinstance} %> -<% elsif cinstance.backend_version.oauth? %> - - Client ID - <%= cinstance.application_id %> - - - - Client Secret - - <%= cinstance.keys.first %> - <% if cinstance.keys.empty? %> - <%= fancy_link_to 'Add Random key', provider_admin_application_keys_path(cinstance), - :method => :post, - :remote => true, - :class => 'create_key', id: 'regenerate-oauth-key' %> - <% else %> - <%= fancy_link_to("Regenerate", regenerate_provider_admin_application_key_path(:application_id => cinstance.id, :id => cinstance.keys.first), - :method => :put, :class => 'delete refresh', :remote => true, id: 'regenerate-oauth-key')%> - <% end %> - - - - - Redirect URL - - <%= cinstance.redirect_url %> - <%= link_to("Edit", edit_redirect_url_provider_admin_application_path(cinstance), class: 'fancybox action edit', 'data-autodimensions': 'true') %> - - - -<% else %> - - - <%= user_key_label(cinstance) %> - - - <%= cinstance.user_key %> - <% if cinstance.custom_keys_enabled? %> - <%= link_to '', edit_provider_admin_application_key_path(cinstance, cinstance.user_key), - class: 'fancybox action edit', - 'data-autodimensions' => 'true', - title: "Set a custom User Key" %> - <% end %> - <% if defined?(regenerate) && regenerate %> - <%= link_to 'Regenerate', change_user_key_provider_admin_application_path(cinstance), method: :put, data: {:confirm => "Are you sure?"}, class: ' action refresh' %> - <% end %> - - -<% end %> diff --git a/app/views/provider/admin/applications/show.html.slim b/app/views/provider/admin/applications/show.html.slim index 6674145bde..8f83f8e115 100644 --- a/app/views/provider/admin/applications/show.html.slim +++ b/app/views/provider/admin/applications/show.html.slim @@ -24,8 +24,7 @@ div class="pf-l-grid pf-m-gutter pf-m-all-6-col" div class="pf-l-flex__item" id="application_keys" data-object="cinstance" data-url=(provider_admin_application_path(@cinstance, format: :json)) div class="pf-c-card" div class="pf-c-card__title" API Credentials - div class="pf-c-card__body" - = render partial: 'provider/admin/keys/widget', locals: { cinstance: @cinstance } + = render partial: 'provider/admin/keys/widget', locals: { cinstance: @cinstance } - if @cinstance.service.referrer_filters_required? div class="pf-l-flex__item" diff --git a/app/views/provider/admin/keys/_widget.html.erb b/app/views/provider/admin/keys/_widget.html.erb index ce056371a2..e20d6e9338 100644 --- a/app/views/provider/admin/keys/_widget.html.erb +++ b/app/views/provider/admin/keys/_widget.html.erb @@ -1,29 +1,101 @@ - - <%= render :partial => 'buyers/applications/api_credentials', - :locals => {:cinstance => cinstance, :regenerate => true } %> -
+<% if cinstance.backend_version.v2? %> +
+ + + + + + <%= render partial: 'provider/admin/keys/key', collection: cinstance.application_keys, + locals: { cinstance: cinstance } %> +
Application ID<%= cinstance.application_id %>
+
- <% if cinstance.backend_version.v2? && cinstance.backend_version.app_keys_allowed? %> + <% if cinstance.backend_version.app_keys_allowed? %> + <%- can_add_keys = cinstance.application_keys.can_add? %> - - <% if cinstance.backend_version.v2? %> - - <% end %> +
> + > <% if cinstance.custom_keys_enabled? %> <%= link_to 'Add Custom key', new_provider_admin_application_key_path(cinstance), class: 'fancybox action add', 'data-autodimensions' => 'true', title: 'Add Custom key' %> - <% end -%> + <% end %> <%= link_to 'Add Random key', provider_admin_application_keys_path(cinstance), - :method => :post, - :remote => true, - :class => 'create_key add action' %> + method: :post, + remote: true, + class: 'create_key add action' %> ;'> - Keys limit reached. - > + Keys limit reached. +
<% end %> + +<% elsif cinstance.backend_version.oauth? %> + <%- keys = cinstance.keys %> +
+ + + + + + + + + + + + + + + +
Client ID<%= cinstance.application_id %>
Client Secret + <%= keys.first %> + <% if keys.empty? %> + <%= fancy_link_to 'Add Random key', provider_admin_application_keys_path(cinstance), + method: :post, + remote: true, + class: 'create_key', + id: 'regenerate-oauth-key' %> + <% else %> + <%= fancy_link_to 'Regenerate', regenerate_provider_admin_application_key_path(application_id: cinstance.id, id: keys.first), + method: :put, + class: 'delete refresh', + remote: true, + id: 'regenerate-oauth-key' %> + <% end %> +
Redirect URL + <%= cinstance.redirect_url %> + <%= link_to 'Edit', edit_redirect_url_provider_admin_application_path(cinstance), + class: 'fancybox action edit', + 'data-autodimensions': 'true' %> +
+
+ +<% else %> + + <%- user_key = cinstance.user_key %> + + + + +
+ <%= user_key_label(cinstance) %> + + ><%= user_key %> + + <% if cinstance.custom_keys_enabled? %> + <%= link_to '', edit_provider_admin_application_key_path(cinstance, user_key), + class: 'fancybox action edit', + 'data-autodimensions' => 'true', + title: "Set a custom User Key" %> + <% end %> + <%= link_to 'Regenerate', change_user_key_provider_admin_application_path(cinstance), + method: :put, + data: { confirm: "Are you sure?" }, + class: 'action refresh' %> +
+<% end %> diff --git a/app/views/provider/admin/keys/update.js.erb b/app/views/provider/admin/keys/update.js.erb index 1763b25d05..42762a95d3 100644 --- a/app/views/provider/admin/keys/update.js.erb +++ b/app/views/provider/admin/keys/update.js.erb @@ -1,14 +1,18 @@ <% if @error.nil? %> $.colorbox.close(); - document.getElementById('cinstance-user-key').innerHTML = '<%= @cinstance.user_key %>' + const userKey = document.getElementById('cinstance-user-key') + userKey.innerHTML = '<%= @cinstance.user_key %>' + userKey.title = '<%= @cinstance.user_key %>' + $.flash.notice('<%= @notice %>') <% else %> const input = document.getElementById('cinstance_user_key') + const constrol = input.closest('.pf-c-form__group-control') <%# HACK: Remove helperText and add it again, since replacing the text also removes the icon. %> - input.closest('.pf-c-form__group-control').children[1].remove() + constrol.children[1].remove() + constrol.insertAdjacentHTML('afterend', '<%= j render partial: "shared/pf_error_helper_text", locals: { error: @error } %>') - input.insertAdjacentHTML('afterend', '<%= j render partial: "shared/pf_error_helper_text", locals: { error: @error } %>') input.setAttribute('aria-invalid', 'true') $.colorbox.resize();