Skip to content

Commit

Permalink
Merge branch 'master' into dependabot/bundler/sidekiq-7.1.5
Browse files Browse the repository at this point in the history
  • Loading branch information
jlledom authored Oct 24, 2023
2 parents e61dbdf + 9068ff9 commit c2479c8
Showing 63 changed files with 932 additions and 362 deletions.
2 changes: 1 addition & 1 deletion .rubocop.yml
Original file line number Diff line number Diff line change
@@ -77,7 +77,7 @@ Metrics/ClassLength:

AllCops:
NewCops: enable
TargetRubyVersion: 2.5
TargetRubyVersion: 2.7
UseCache: true
Exclude:
- 'db/**/*'
2 changes: 2 additions & 0 deletions app/controllers/admin/api_docs/account_api_docs_controller.rb
Original file line number Diff line number Diff line change
@@ -4,6 +4,8 @@ class Admin::ApiDocs::AccountApiDocsController < Admin::ApiDocs::BaseController
activate_menu :audience, :cms, :ActiveDocs
sublayout 'api/service'

before_action :disable_client_cache, only: %i[preview]

class NotImplementedServiceScopeError < RuntimeError; end
rescue_from(NotImplementedServiceScopeError) do |exception|
System::ErrorReporting.report_error(exception)
2 changes: 2 additions & 0 deletions app/controllers/admin/api_docs/service_api_docs_controller.rb
Original file line number Diff line number Diff line change
@@ -6,6 +6,8 @@ class Admin::ApiDocs::ServiceApiDocsController < Admin::ApiDocs::BaseController
activate_menu :serviceadmin, :ActiveDocs
sublayout 'api/service'

before_action :disable_client_cache, only: :preview

private

def current_scope
1 change: 1 addition & 0 deletions app/controllers/api/integrations_controller.rb
Original file line number Diff line number Diff line change
@@ -5,6 +5,7 @@ class Api::IntegrationsController < Api::BaseController
before_action :find_proxy
before_action :authorize
before_action :find_registry_policies, only: :update
before_action :disable_client_cache

activate_menu :serviceadmin, :integration, :configuration
sublayout 'api/service'
2 changes: 2 additions & 0 deletions app/controllers/api/services_controller.rb
Original file line number Diff line number Diff line change
@@ -10,6 +10,8 @@ class Api::ServicesController < Api::BaseController
before_action :deny_on_premises_for_master
before_action :authorize_section
before_action :authorize_action, only: %i[new create]
before_action :disable_client_cache, only: :settings

load_and_authorize_resource :service, through: :current_user, through_association: :accessible_services, except: [:create]

helper_method :presenter
9 changes: 8 additions & 1 deletion app/controllers/application_controller.rb
Original file line number Diff line number Diff line change
@@ -18,7 +18,6 @@ class ApplicationController < ActionController::Base
skip_forgery_protection if: -> { api_controller? }

before_action :set_timezone

before_action :enable_analytics
before_action :check_browser

@@ -80,6 +79,14 @@ def sublayout
end
end

def disable_client_cache
response.headers.merge!(
'Cache-Control' => 'no-cache, no-store',
'Pragma' => 'no-cache',
'Expires' => 'Mon, 01 Jan 1990 00:00:00 GMT'
)
end

protected

def check_browser
4 changes: 2 additions & 2 deletions app/controllers/finance/provider/settings_controller.rb
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
# frozen_string_literal: true

class Finance::Provider::SettingsController < Finance::Provider::BaseController

before_action :set_strategy
layout 'provider'
before_action :disable_client_cache

layout 'provider'

def show
activate_menu :audience, :finance, :charging_and_gateway
Original file line number Diff line number Diff line change
@@ -3,6 +3,8 @@ class Provider::Admin::Account::AuthenticationProvidersController < Provider::Ad
before_action :authorize_changes, only: [:edit, :update, :destroy]
activate_menu :account, :users, :sso_integrations

before_action :disable_client_cache

def index
@presenter = Provider::Admin::Account::AuthenticationProvidersIndexPresenter.new(
current_user, self_authentication_providers, user_session)
1 change: 1 addition & 0 deletions app/controllers/provider/admin/accounts_controller.rb
Original file line number Diff line number Diff line change
@@ -8,6 +8,7 @@ class Provider::Admin::AccountsController < Provider::Admin::Account::BaseContro
before_action :find_account
before_action :deny_unless_can_update, :only => [:update, :edit]
before_action :check_provider_signup_possible, :only => %i[new create]
before_action :disable_client_cache

def new
@provider = current_account.buyers.new
Original file line number Diff line number Diff line change
@@ -1,4 +1,8 @@
# frozen_string_literal: true

class Provider::Admin::ApiDocs::AccountDataController < Provider::Admin::BaseController
before_action :disable_client_cache

def show
@data = ::ApiDocs::ProviderUserData.new(current_user)

2 changes: 2 additions & 0 deletions app/controllers/provider/admin/api_docs_controller.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
class Provider::Admin::ApiDocsController < Provider::Admin::BaseController
activate_menu :account, :integrate, :apidocs

before_action :disable_client_cache

layout 'provider'
end
1 change: 1 addition & 0 deletions app/controllers/provider/admin/applications_controller.rb
Original file line number Diff line number Diff line change
@@ -15,6 +15,7 @@ class Provider::Admin::ApplicationsController < FrontendController
before_action :find_service_plan, only: :create
before_action :find_cinstance, except: %i[index new create]
before_action :initialize_cinstance, only: :create
before_action :disable_client_cache

activate_menu :audience, :applications, :listing

Original file line number Diff line number Diff line change
@@ -2,11 +2,11 @@

class Provider::Admin::AuthenticationProvidersController < FrontendController
before_action :authorize_settings

activate_menu :audience, :cms, :sso_integrations

before_action :find_authentication_provider, only: %i[show edit update publish_or_hide destroy]
before_action :authorize_authentication_provider, only: %i[show edit destroy]
before_action :disable_client_cache, except: :index

activate_menu :audience, :cms, :sso_integrations

def index
@authentication_providers = current_account.authentication_provider_kinds
23 changes: 23 additions & 0 deletions app/controllers/provider/admin/messages/base_controller.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
# frozen_string_literal: true

class Provider::Admin::Messages::BaseController < FrontendController
helper_method :toolbar_props

def pagination_params
{ page: params.permit(:page)[:page] || 1, per_page: params.permit(:per_page)[:per_page] || 20 }
end

def toolbar_props
{
totalEntries: @messages.total_entries,
pageEntries: @messages.length,
newMessageHref: new_provider_admin_messages_outbox_path,
bulkActions: [{
name: 'Delete',
url: new_provider_admin_messages_bulk_trash_path(scope: scope),
title: 'Delete selected messages',
variant: 'danger'
}]
}
end
end
12 changes: 6 additions & 6 deletions app/controllers/provider/admin/messages/bulk/trash_controller.rb
Original file line number Diff line number Diff line change
@@ -1,14 +1,15 @@
class Provider::Admin::Messages::Bulk::TrashController < FrontendController
# frozen_string_literal: true

ALLOWED_SCOPES = %i(messages received_messages)
class Provider::Admin::Messages::Bulk::TrashController < FrontendController

respond_to :js
ALLOWED_SCOPES = %i[messages received_messages].freeze

before_action :check_association_scope!

class ForbiddenAccountScope < StandardError; end

def new
respond_to :js
end

def create
@@ -23,6 +24,7 @@ def create
@no_more_messages = no_more_messages

flash[:notice] = t('.success')
redirect_to request.referer
end

private
@@ -36,9 +38,7 @@ def no_more_messages
end

def check_association_scope!
unless ALLOWED_SCOPES.include?(scope)
raise ForbiddenAccountScope.new("Scope #{scope} is not allowed")
end
raise ForbiddenAccountScope, "Scope #{scope} is not allowed" unless ALLOWED_SCOPES.include?(scope)
end

def scope
17 changes: 14 additions & 3 deletions app/controllers/provider/admin/messages/inbox_controller.rb
Original file line number Diff line number Diff line change
@@ -1,9 +1,16 @@
class Provider::Admin::Messages::InboxController < FrontendController
before_action :find_message, :only => [:show, :destroy, :reply]
# frozen_string_literal: true

class Provider::Admin::Messages::InboxController < Provider::Admin::Messages::BaseController
before_action :find_message, only: %i[show destroy reply]

activate_menu :buyers, :messages, :inbox

def index
@messages = current_account.received_messages.not_system.latest_first.paginate(page: params[:page]).decorate
@messages = current_account.received_messages
.not_system
.latest_first
.paginate(pagination_params)
.decorate
end

def show
@@ -40,4 +47,8 @@ def message_params
def find_message
@message = current_account.received_messages.find(params.require(:id)).decorate
end

def scope
:received_messages
end
end
8 changes: 4 additions & 4 deletions app/controllers/provider/admin/messages/outbox_controller.rb
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# frozen_string_literal: true

class Provider::Admin::Messages::OutboxController < FrontendController
class Provider::Admin::Messages::OutboxController < Provider::Admin::Messages::BaseController
activate_menu :buyers, :messages, :sent_messages

delegate :messages, to: :current_account
@@ -15,7 +15,7 @@ def destroy
@message.hide!

flash[:notice] = 'Message was deleted.'
redirect_to action: :index
redirect_to request.referer
end

def create
@@ -95,7 +95,7 @@ def message_id_param
params.require(:id)
end

def pagination_params
{ page: params.permit(:page)[:page] }
def scope
:messages
end
end
Original file line number Diff line number Diff line change
@@ -6,6 +6,7 @@ class Provider::Admin::User::AccessTokensController < Provider::Admin::User::Bas
authorize_resource
activate_menu :account, :personal, :tokens
before_action :authorize_access_tokens
before_action :disable_client_cache

def create
create! do |success, _failure|
3 changes: 3 additions & 0 deletions app/controllers/provider/admin/webhooks_controller.rb
Original file line number Diff line number Diff line change
@@ -1,7 +1,10 @@
# frozen_string_literal: true

class Provider::Admin::WebhooksController < Sites::BaseController

before_action :find_webhook
before_action :authorize_web_hooks
before_action :disable_client_cache

activate_menu! :account, :integrate, :webhooks

1 change: 1 addition & 0 deletions app/controllers/sites/dns_controller.rb
Original file line number Diff line number Diff line change
@@ -2,6 +2,7 @@ class Sites::DnsController < Sites::BaseController
activate_menu :audience, :cms, :admin_site_dns

before_action :find_account
before_action :disable_client_cache

def show
end
30 changes: 0 additions & 30 deletions app/javascript/packs/bulk_operations.ts
Original file line number Diff line number Diff line change
@@ -3,8 +3,6 @@

document.addEventListener('DOMContentLoaded', () => {
const dataSelectedTotal = 'data-selected-total-entries'
const dataTotalEntries = 'data-total-entries'
const dataModelName = 'data-association-name'
const dataDefaultText = 'data-default-text'
const dataSelectedTotalEntries = 'data-selected-total-entries'

@@ -119,39 +117,11 @@ document.addEventListener('DOMContentLoaded', () => {
})
}

function handleSelectTotalEntries () {
const selectTotalEntries = findSelectTotalEntries()

if (!selectTotalEntries) {
return
}

selectTotalEntries.addEventListener('click', function (e) {
e.preventDefault()

const selected = selectedRows()

if (selectTotalEntries.hasAttribute(dataSelectedTotal)) {
selectTotalEntries.removeAttribute(dataSelectedTotal)
selectTotalEntries.innerText = selectTotalEntries.getAttribute(dataDefaultText)!
setSelectedCount(selected)
} else {
selectTotalEntries.setAttribute(dataSelectedTotal, 'true')

const newText = `(only select the ${selected} ${selectTotalEntries.getAttribute(dataModelName)!} on this page)`
selectTotalEntries.innerText = newText

setSelectedCount(selectTotalEntries.getAttribute(dataTotalEntries)!)
}
})
}

function selectedRows () {
return document.querySelectorAll('table tr.selected').length
}

prepareOperations()
prepareSelectAllCheckbox()
prepareSingleCheckboxes()
handleSelectTotalEntries()
})
21 changes: 21 additions & 0 deletions app/javascript/packs/messages_toolbar.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
import { ToolbarWrapper } from 'Messages/component/Toolbar'

import type { Props } from 'Messages/component/Toolbar'

document.addEventListener('DOMContentLoaded', () => {
const table = document.querySelector<HTMLTableElement>('table.pf-c-table#messages')

if (!table) {
throw new Error('Table was not found')
}

const data = table.dataset.toolbarProps

if (!data) {
throw new Error('missing props for Toolbar')
}

const props = JSON.parse(data) as Props

ToolbarWrapper(props, table)
})
3 changes: 3 additions & 0 deletions app/javascript/packs/provider.scss
Original file line number Diff line number Diff line change
@@ -22,3 +22,6 @@
@import '~@patternfly/patternfly/components/OverflowMenu/overflow-menu.css';
@import '~@patternfly/patternfly/components/Radio/radio.css';
@import '~@patternfly/patternfly/components/Table/table.css';

// Patternfly QuickStarts
@import '~@patternfly/quickstarts/dist/quickstarts.min.css';
Loading

0 comments on commit c2479c8

Please sign in to comment.