Skip to content
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.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line numberDiff line numberDiff line change
Expand Up@@ -42,6 +42,8 @@ def self.build_schema(collection, name)
schema = {
id: "#{collection.name}-#{action_index}-#{slug}",
name: name,
submitButtonLabel: action.submit_button_label,
description: action.description,
type: action.scope.downcase,
baseUrl: nil,
endpoint: "/forest/_actions/#{collection.name}/#{action_index}/#{slug}",
Expand Down
Original file line numberDiff line numberDiff line change
Expand Up@@ -25,6 +25,8 @@ module Schema
{
id: 'collection-0-send-email',
name: 'Send email',
submitButtonLabel: nil,
description: nil,
type: 'single',
baseUrl: nil,
endpoint: '/forest/_actions/collection/0/send-email',
Expand DownExpand Up@@ -69,6 +71,8 @@ module Schema
{
id: 'collection-0-send-email',
name: 'Send email',
submitButtonLabel: nil,
description: nil,
type: 'single',
baseUrl: nil,
endpoint: '/forest/_actions/collection/0/send-email',
Expand DownExpand Up@@ -101,7 +105,9 @@ module Schema
{
scope: Types::ActionScope::SINGLE,
static_form?: true,
is_generate_file: false
is_generate_file: false,
description: nil,
submit_button_label: nil
}
)
}
Expand DownExpand Up@@ -137,7 +143,9 @@ module Schema
{
scope: Types::ActionScope::SINGLE,
static_form?: true,
is_generate_file: false
is_generate_file: false,
description: nil,
submit_button_label: nil
}
)
}
Expand DownExpand Up@@ -168,7 +176,9 @@ module Schema
{
scope: Types::ActionScope::SINGLE,
static_form?: true,
is_generate_file: false
is_generate_file: false,
description: nil,
submit_button_label: nil
}
)
}
Expand DownExpand Up@@ -236,6 +246,8 @@ module Schema
{
id: 'collection-0-send-email',
name: 'Send email',
submitButtonLabel: nil,
description: nil,
type: 'single',
baseUrl: nil,
endpoint: '/forest/_actions/collection/0/send-email',
Expand DownExpand Up@@ -288,6 +300,8 @@ module Schema
{
id: 'collection-0-send-email',
name: 'Send email',
submitButtonLabel: nil,
description: nil,
type: 'single',
baseUrl: nil,
endpoint: '/forest/_actions/collection/0/send-email',
Expand DownExpand Up@@ -344,6 +358,8 @@ module Schema
{
id: 'collection-0-charge-credit-card',
name: 'Charge credit card',
submitButtonLabel: nil,
description: nil,
type: 'single',
baseUrl: nil,
endpoint: '/forest/_actions/collection/0/charge-credit-card',
Expand Down
Original file line numberDiff line numberDiff line change
Expand Up@@ -2,12 +2,14 @@ module ForestAdminDatasourceCustomizer
module Decorators
module Action
class BaseAction
attr_reader :scope, :form, :is_generate_file, :execute
attr_reader :scope, :form, :is_generate_file, :description, :submit_button_label, :execute

def initialize(scope:, form: nil, is_generate_file: false, &execute)
def initialize(scope:, form: nil, is_generate_file: false, description: nil, submit_button_label: nil, &execute)
@scope = scope
@form = form
@is_generate_file = is_generate_file
@description = description
@submit_button_label = submit_button_label
@execute = execute
end

Expand Down
Original file line numberDiff line numberDiff line change
Expand Up@@ -21,6 +21,16 @@ module Action
expect(action.form).to eq(form)
expect(action.is_generate_file).to be(false)
expect(action.execute).to be_nil
expect(action.description).to be_nil
expect(action.submit_button_label).to be_nil
end

it 'set description and submit_button_label when provided' do
description = 'Send a notification to the user'
submit_button_label = 'Send notification !'
action = described_class.new(scope: scope, form: form, description: description, submit_button_label: submit_button_label)
expect(action.description).to eq(description)
expect(action.submit_button_label).to eq(submit_button_label)
end
end

Expand Down