-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1701 from tactilenews/163_activate_deactivate_cha…
…nnels_instance_wide
- Loading branch information
Showing
13 changed files
with
197 additions
and
69 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -6,4 +6,5 @@ | |
value='1' | ||
<%= checked ? 'checked' : '' %> | ||
<%= required ? 'required' : '' %> | ||
<%= attrs %> | ||
/> |
29 changes: 29 additions & 0 deletions
29
app/components/onboarding_channels_checkboxes/onboarding_channels_checkboxes.css
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
.OnboardingChannelsCheckboxes { | ||
border: 0; | ||
} | ||
|
||
.OnboardingChannelsCheckboxes-legend { | ||
display: block; | ||
font-weight: 600; | ||
font-size: var(--font-size); | ||
} | ||
|
||
.OnboardingChannelsCheckboxes-helpText { | ||
font-size: var(--font-size-s); | ||
color: var(--color-text-light); | ||
} | ||
|
||
.OnboardingChannelsCheckboxes-list { | ||
list-style: none; | ||
display: flex; | ||
justify-content: space-between; | ||
} | ||
|
||
.OnboardingChannelsCheckboxes-listItem { | ||
display: flex; | ||
align-items: center; | ||
} | ||
|
||
.OnboardingChannelsCheckboxes-listItem > .Checkbox { | ||
margin-right: var(--spacing-unit-xs); | ||
} |
16 changes: 16 additions & 0 deletions
16
app/components/onboarding_channels_checkboxes/onboarding_channels_checkboxes.html.erb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
<fieldset <%= attrs %>> | ||
<legend class="OnboardingChannelsCheckboxes-legend"> | ||
<%= t '.legend' %> | ||
</legend> | ||
<p class="OnboardingChannelsCheckboxes-helpText"> | ||
<%= t '.help_text' %> | ||
</p> | ||
<ul class="OnboardingChannelsCheckboxes-list"> | ||
<% Setting.channels.each do |key, value| %> | ||
<li class="OnboardingChannelsCheckboxes-listItem"> | ||
<%= c 'checkbox', id: "setting[channels][#{key}]", checked: value %> | ||
<label for=<%= "setting[channels][#{key}]" %>><%= key.to_s.camelize %> | ||
</li> | ||
<% end %> | ||
</ul> | ||
</fieldset> |
5 changes: 5 additions & 0 deletions
5
app/components/onboarding_channels_checkboxes/onboarding_channels_checkboxes.rb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
# frozen_string_literal: true | ||
|
||
module OnboardingChannelsCheckboxes | ||
class OnboardingChannelsCheckboxes < ApplicationComponent; end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
.SettingsForm { | ||
padding-left: var(--limit-max-inner-width); | ||
padding-right: var(--limit-max-inner-width); | ||
margin: var(--spacing-unit) 0; | ||
} | ||
|
||
.SettingsForm .Section { | ||
padding-left: 0; | ||
padding-right: 0; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,78 +1,76 @@ | ||
<%= c 'form', model: Setting.new, multipart: true do %> | ||
<%= c 'stack', space: :xlarge do %> | ||
<%= c 'form', model: Setting.new, multipart: true, **attrs do %> | ||
<%= c 'section' do %> | ||
<%= c('heading', tag: :h2) { t('setting.form.groups.project_settings') } %> | ||
<%= c('settings_field', type: :input, attr: :project_name) %> | ||
<% end %> | ||
|
||
<%= c 'stack' do %> | ||
<%= c('heading', tag: :h2) { t('setting.form.groups.project_settings') } %> | ||
<%= c('settings_field', type: :input, attr: :project_name) %> | ||
<%= c 'section' do %> | ||
<%= c('heading', tag: :h2) { t('setting.form.groups.onboarding') } %> | ||
<%= c('settings_field', type: :image_input, attr: :onboarding_logo) %> | ||
<%= c('settings_field', type: :input, attr: :onboarding_byline) %> | ||
<%= c('settings_field', type: :image_input, attr: :onboarding_hero) %> | ||
<%= c('settings_field', type: :input, attr: :onboarding_title) %> | ||
<%= c('settings_field', type: :textarea, attr: :onboarding_page) %> | ||
<% if current_user.admin? %> | ||
<%= c 'onboarding_channels_checkboxes' %> | ||
<%= c('settings_field', type: :url_input, attr: :onboarding_data_protection_link) %> | ||
<%= c('settings_field', type: :textarea, attr: :onboarding_data_processing_consent_additional_info) %> | ||
<%= c('settings_field', type: :url_input, attr: :onboarding_imprint_link) %> | ||
<% end %> | ||
<% end %> | ||
|
||
<% if current_user.admin? %> | ||
<%= c 'stack' do %> | ||
<%= c('heading', tag: :h2) { t('setting.form.groups.onboarding') } %> | ||
<%= c('settings_field', type: :image_input, attr: :onboarding_logo) %> | ||
<%= c('settings_field', type: :input, attr: :onboarding_byline) %> | ||
<%= c('settings_field', type: :image_input, attr: :onboarding_hero) %> | ||
<%= c('settings_field', type: :input, attr: :onboarding_title) %> | ||
<%= c('settings_field', type: :textarea, attr: :onboarding_page) %> | ||
<% if current_user.admin? %> | ||
<%= c('settings_field', type: :url_input, attr: :onboarding_data_protection_link) %> | ||
<%= c('settings_field', type: :textarea, attr: :onboarding_data_processing_consent_additional_info) %> | ||
<%= c('settings_field', type: :url_input, attr: :onboarding_imprint_link) %> | ||
<% end %> | ||
<% end %> | ||
|
||
<% if current_user.admin? %> | ||
<%= c 'stack' do %> | ||
<%= c('heading', tag: :h2) { t 'setting.form.groups.onboarding_additional_consent' } %> | ||
<%= c('heading', tag: :h2) { t 'setting.form.groups.onboarding_additional_consent' } %> | ||
|
||
<%= c('field', | ||
object: Setting.new, | ||
attr: :onboarding_ask_for_additional_consent, | ||
styles: [:horizontal, :leftAligned], | ||
) do |field| %> | ||
<%= c 'checkbox', **field.input_defaults, checked: Setting.onboarding_ask_for_additional_consent %> | ||
<% end %> | ||
|
||
<%= c('settings_field', type: :input, attr: :onboarding_additional_consent_heading) %> | ||
<%= c('settings_field', type: :input, attr: :onboarding_additional_consent_text) %> | ||
<%= c('field', | ||
object: Setting.new, | ||
attr: :onboarding_ask_for_additional_consent, | ||
styles: [:horizontal, :leftAligned], | ||
) do |field| %> | ||
<%= c 'checkbox', **field.input_defaults, checked: Setting.onboarding_ask_for_additional_consent %> | ||
<% end %> | ||
<% end %> | ||
|
||
<%= c 'stack' do %> | ||
<%= c('heading', tag: :h2) { t('setting.form.groups.onboarding_success') } %> | ||
<%= c('settings_field', type: :input, attr: :onboarding_success_heading) %> | ||
<%= c('settings_field', type: :textarea, attr: :onboarding_success_text) %> | ||
<%= c('settings_field', type: :input, attr: :onboarding_additional_consent_heading) %> | ||
<%= c('settings_field', type: :input, attr: :onboarding_additional_consent_text) %> | ||
<% end %> | ||
<% end %> | ||
|
||
<%= c 'stack' do %> | ||
<%= c('heading', tag: :h2) { t('setting.form.groups.onboarding_unauthorized') } %> | ||
<%= c('settings_field', type: :input, attr: :onboarding_unauthorized_heading) %> | ||
<%= c('settings_field', type: :textarea, attr: :onboarding_unauthorized_text) %> | ||
<% end %> | ||
<%= c 'stack' do %> | ||
<%= c('heading', tag: :h2) { t('setting.form.groups.onboarding_success') } %> | ||
<%= c('settings_field', type: :input, attr: :onboarding_success_heading) %> | ||
<%= c('settings_field', type: :textarea, attr: :onboarding_success_text) %> | ||
<% end %> | ||
|
||
<%= c 'stack' do %> | ||
<%= c('heading', tag: :h2) { t('setting.form.groups.signal') } %> | ||
<%= c('settings_field', type: :textarea, attr: :signal_unknown_content_message) %> | ||
<% end %> | ||
<%= c 'stack' do %> | ||
<%= c('heading', tag: :h2) { t('setting.form.groups.onboarding_unauthorized') } %> | ||
<%= c('settings_field', type: :input, attr: :onboarding_unauthorized_heading) %> | ||
<%= c('settings_field', type: :textarea, attr: :onboarding_unauthorized_text) %> | ||
<% end %> | ||
|
||
<%= c 'stack' do %> | ||
<%= c('heading', tag: :h2) { t('setting.form.groups.telegram') } %> | ||
<%= c('settings_field', type: :textarea, attr: :telegram_unknown_content_message) %> | ||
<%= c('settings_field', type: :textarea, attr: :telegram_contributor_not_found_message) %> | ||
<% end %> | ||
<%= c 'stack' do %> | ||
<%= c('heading', tag: :h2) { t('setting.form.groups.signal') } %> | ||
<%= c('settings_field', type: :textarea, attr: :signal_unknown_content_message) %> | ||
<% end %> | ||
|
||
<%= c 'stack' do %> | ||
<%= c('heading', tag: :h2) { t('setting.form.groups.threema') } %> | ||
<%= c('settings_field', type: :textarea, attr: :threema_unknown_content_message) %> | ||
<% end %> | ||
<%= c 'stack' do %> | ||
<%= c('heading', tag: :h2) { t('setting.form.groups.telegram') } %> | ||
<%= c('settings_field', type: :textarea, attr: :telegram_unknown_content_message) %> | ||
<%= c('settings_field', type: :textarea, attr: :telegram_contributor_not_found_message) %> | ||
<% end %> | ||
|
||
<% if current_user.admin? %> | ||
<%= c 'stack' do %> | ||
<%= c('heading', tag: :h2) { t('setting.form.groups.all') } %> | ||
<%= c('settings_field', type: :image_input, attr: :channel_image) %> | ||
<%= c('settings_field', type: :textarea, attr: :about) %> | ||
<% end %> | ||
<% end %> | ||
<%= c 'stack' do %> | ||
<%= c('heading', tag: :h2) { t('setting.form.groups.threema') } %> | ||
<%= c('settings_field', type: :textarea, attr: :threema_unknown_content_message) %> | ||
<% end %> | ||
|
||
<%= c 'submit_button', label: t('save') %> | ||
<% if current_user.admin? %> | ||
<%= c 'stack' do %> | ||
<%= c('heading', tag: :h2) { t('setting.form.groups.all') } %> | ||
<%= c('settings_field', type: :image_input, attr: :channel_image) %> | ||
<%= c('settings_field', type: :textarea, attr: :about) %> | ||
<% end %> | ||
<% end %> | ||
|
||
<%= c 'submit_button', label: t('save') %> | ||
<% end %> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
# frozen_string_literal: true | ||
|
||
require 'rails_helper' | ||
|
||
RSpec.describe 'Configuring Onboarding Channels' do | ||
let(:admin) { create(:user, admin: true) } | ||
let(:organization) { create(:organization) } | ||
let(:jwt_payload) { { invite_code: SecureRandom.base64(16), action: 'onboarding', organization_id: organization.id } } | ||
let(:jwt) do | ||
JsonWebToken.encode(jwt_payload) | ||
end | ||
|
||
it 'allows activating and deactivating onboarding channels' do | ||
visit settings_path(as: admin) | ||
|
||
# All activated by default | ||
within('.OnboardingChannelsCheckboxes') do | ||
Setting.channels.each_key do |key| | ||
expect(page).to have_field(key.to_s.camelize, id: "setting[channels][#{key}]", checked: true) | ||
end | ||
|
||
uncheck 'Email' | ||
end | ||
|
||
click_on 'Speichern' | ||
expect(page).to have_current_path(settings_path(as: admin)) | ||
|
||
within('.OnboardingChannelsCheckboxes') do | ||
Setting.channels.keys.map(&:to_sym).each do |key| | ||
checked_status = !key.eql?(:email) | ||
expect(page).to have_field(key.to_s.camelize, id: "setting[channels][#{key}]", checked: checked_status) | ||
end | ||
end | ||
|
||
visit onboarding_path(jwt: jwt) | ||
|
||
within('.OnboardingChannelButtons') do | ||
Setting.channels.keys.map(&:to_sym).each do |key| | ||
unless key.eql?(:email) | ||
expect(page).to have_link(key.to_s.camelize, class: 'Button', href: "/onboarding/#{key.to_s.dasherize}?jwt=#{jwt}") | ||
end | ||
end | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters