Skip to content

Commit

Permalink
Merge pull request #3876 from jlledom/THREESCALE-1789-rebased-managed…
Browse files Browse the repository at this point in the history
…-operator-ui

THREESCALE-1789: Add "Managed by operator" banner (UI)
  • Loading branch information
jlledom authored Sep 16, 2024
2 parents f95cca5 + b40c707 commit 703614c
Show file tree
Hide file tree
Showing 10 changed files with 53 additions and 11 deletions.
41 changes: 30 additions & 11 deletions app/helpers/patternfly_components_helper.rb
Original file line number Diff line number Diff line change
@@ -1,24 +1,43 @@
# frozen_string_literal: true

module PatternflyComponentsHelper
def pf_inline_alert(text, variant: nil)
icon_name = case variant
when :info then 'info-circle'
when :success then 'check-circled'
when :warning, :danger then 'exclamation-triangle'
else 'bell'

def icon_name(variant)
case variant
when :info then 'info-circle'
when :success then 'check-circled'
when :warning, :danger then 'exclamation-triangle'
else 'bell'
end
end

def icon_tag(variant)
tag.div class: 'pf-c-alert__icon' do
tag.i class: "fas fa-fw fa-#{icon_name(variant)}", 'aria-hidden': 'true'
end
end

icon = tag.div class: 'pf-c-alert__icon' do
tag.i class: "fas fa-fw fa-#{icon_name}", 'aria-hidden': 'true'
def title_tag(title)
tag.div class: 'pf-c-alert__title' do
tag.p title
end
end

title = tag.p class: 'pf-c-alert__title' do
text
def body_tag(body)
tag.div class: 'pf-c-alert__description' do
tag.p body
end
end

def pf_inline_alert(title, body, variant: nil)
tag.div class: "pf-c-alert pf-m-#{variant} pf-m-inline" do
icon + title
icon_tag(variant) + title_tag(title) + body_tag(body)
end
end

def pf_inline_alert_plain(title, variant: nil)
tag.div class: "pf-c-alert pf-m-#{variant} pf-m-inline pf-m-plain" do
icon_tag(variant) + title_tag(title)
end
end
end
2 changes: 2 additions & 0 deletions app/views/api/services/edit.html.slim
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
- content_for :page_header_title, 'Naming'
- content_for :page_header_annotation do
= render partial: 'shared/annotations', locals: { resource: @service, description: true, variant: :warning }

= semantic_form_for @service, url: admin_service_path(@service) do |form|
= render partial: 'api/services/forms/naming', locals: { form: form }
Expand Down
2 changes: 2 additions & 0 deletions app/views/api/services/show.html.slim
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
- content_for :page_header_title, 'Product Overview'
- content_for :page_header_annotation do
= render partial: 'shared/annotations', locals: { resource: @service, plain: true }

section.Section
.SettingsBox
Expand Down
2 changes: 2 additions & 0 deletions app/views/buyers/accounts/edit.html.slim
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@
= render 'menu'

- content_for :page_header_title, "Edit account #{@account.org_name} details"
- content_for :page_header_annotation do
= render partial: 'shared/annotations', locals: { resource: @account, description: true, variant: :warning }

div class="pf-c-card"
div class="pf-c-card__body"
Expand Down
1 change: 1 addition & 0 deletions app/views/buyers/accounts/show.html.slim
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
' Account: #{@account.org_name}
- if can? :update, @account
= link_to 'Edit', edit_admin_buyers_account_path(@account), class: 'action edit'
= render partial: 'shared/annotations', locals: { resource: @account, plain: true }

div class="pf-l-grid pf-m-gutter pf-m-all-6-col"
/ Left column
Expand Down
2 changes: 2 additions & 0 deletions app/views/provider/admin/backend_apis/edit.html.slim
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
- content_for :page_header_title, 'Edit Backend'
- content_for :page_header_annotation do
= render partial: 'shared/annotations', locals: { resource: @backend_api, description: true, variant: :warning }

div class="pf-l-flex pf-m-column"
div class="pf-l-flex__item"
Expand Down
2 changes: 2 additions & 0 deletions app/views/provider/admin/backend_apis/show.html.slim
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
- content_for :page_header_title, 'Backend Overview'
- content_for :page_header_annotation do
= render partial: 'shared/annotations', locals: { resource: @backend_api, plain: true }

section.Section
.SettingsBox
Expand Down
7 changes: 7 additions & 0 deletions app/views/shared/_annotations.html.slim
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
- if resource.respond_to?(:managed_by) && resource.managed_by.present?
- var = defined?(variant) ? variant : :info
- if defined?(plain)
= pf_inline_alert_plain t('.managed_title', value: resource.managed_by), variant: var
- else
- body = (defined?(description) && description) ? t('.managed_description') : nil
= pf_inline_alert t('.managed_title', value: resource.managed_by), body, variant: var
2 changes: 2 additions & 0 deletions app/views/shared/provider/_page_header.html.slim
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@
h1 = title
- if (subtitle = content_for(:page_header_body).presence)
p = subtitle
- if (annotation = content_for(:page_header_annotation).presence)
= annotation
- if (alert = content_for(:page_header_alert).presence)
= alert

Expand Down
3 changes: 3 additions & 0 deletions config/locales/en.yml
Original file line number Diff line number Diff line change
Expand Up @@ -1672,6 +1672,9 @@ en:
unknown_format: 'The server does not understand "%{request_format}" request.'

shared:
annotations:
managed_title: Managed by %{value}
managed_description: This resource is managed externally and any modifications may be overwritten.
empty_search_state:
title: No results
body: There are no items matching your search criteria.
Expand Down

0 comments on commit 703614c

Please sign in to comment.