-
Notifications
You must be signed in to change notification settings - Fork 1
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add UI for admin to create org and config messengers #2020
Open
mattwr18
wants to merge
23
commits into
main
Choose a base branch
from
1948_add_ui_for_admin_to_create_org_config_messengers
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
23 commits
Select commit
Hold shift + click to select a range
78c7316
Test drive creation of organizations by admin
mattwr18 d710f09
Test drive adding email from address
mattwr18 b818bd4
Test drive configuring telegram when creating an org
mattwr18 588beae
Test drive configuring Threema at org creation
mattwr18 4ff2168
Lint, improve dashboard field types
mattwr18 9b7887b
Test drive Twilio WhatsApp configuration
mattwr18 2c0604f
Improve descriptions of specs
mattwr18 b551f68
Add steps to add and register signal phone number
mattwr18 9167777
Fix specs to work with both docker and local
mattwr18 433c8b3
Remove Twilio for new orgs, update field types
mattwr18 e203ca0
Allow org to be created without Telegram as a channel
mattwr18 ad2e0d0
Set telegram webhook url on org creation
mattwr18 041cdd5
Move adding signal phone number to admin portal
mattwr18 0b9817a
Update admin root to organizations#index
mattwr18 740e3a9
Add link to register signal
mattwr18 e450e8b
Refactor signal registration process
mattwr18 9ea881b
Schedule a job to set the username
mattwr18 6a774a3
Lint
mattwr18 482dbaa
Fix failing tests
mattwr18 a9a9701
Fine tune signal setup
mattwr18 508cd06
Add job to set profile info for Signal
mattwr18 5e72aee
Remove undesired change
mattwr18 b4b7089
Avoid validating signal_server_phone_number
mattwr18 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 |
---|---|---|
|
@@ -438,7 +438,7 @@ GEM | |
|
||
PLATFORMS | ||
ruby | ||
x86_64-linux | ||
x86_64-linux-musl | ||
|
||
DEPENDENCIES | ||
active_model_otp | ||
|
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,7 @@ | ||
.SignalCaptchaForm-useVoiceSection { | ||
margin-top: var(--spacing-unit-s); | ||
} | ||
|
||
.SignalCaptchaForm .SubmitButton { | ||
margin-top: var(--spacing-unit); | ||
} |
30 changes: 30 additions & 0 deletions
30
app/components/signal_captcha_form/signal_captcha_form.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,30 @@ | ||
<%= c 'main', **attrs do %> | ||
<%= c 'page_header', styles: [:wide, :inheritBackgroundColor, :xlargePaddingTop] do %> | ||
<%= c 'heading', tag: :h2 do %> | ||
<%= t('.main_heading') %> | ||
<% end %> | ||
<% end %> | ||
|
||
<%= c 'section', styles: [:wide] do %> | ||
<p><%= t('.instructions.where_to_generate_html', link: 'https://signalcaptchas.org/registration/generate.html') %></p> | ||
<p><%= t('.instructions.after_solving_captcha') %></p> | ||
<% end %> | ||
|
||
<%= c 'section', styles: [:wide] do %> | ||
<%= c 'form', model: organization, url: organization_signal_register_path(organization), method: :post do %> | ||
<%= c 'base_field', id: 'organization[signal][captcha]', label: 'Captcha' do |field| %> | ||
<% c 'textarea', id: 'organization[signal][captcha]', value: nil %> | ||
<% end %> | ||
|
||
<section class="SignalCaptchaForm-useVoiceSection"> | ||
<label class="BaseField-labelText"> | ||
<%= c 'checkbox', id: 'organization[signal][use_voice]' %> | ||
<%= t('.instructions.use_voice.label') %> | ||
</label> | ||
<p class="BaseField-helpText"><%= t('.instructions.use_voice.help') %></p> | ||
</section> | ||
|
||
<%= c 'submit_button', label: t('save') %> | ||
<% 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
# frozen_string_literal: true | ||
|
||
module SignalCaptchaForm | ||
class SignalCaptchaForm < ApplicationComponent | ||
def initialize(organization:) | ||
super | ||
|
||
@organization = organization | ||
end | ||
|
||
attr_reader :organization | ||
end | ||
end |
3 changes: 3 additions & 0 deletions
3
app/components/signal_verify_phone_number_form/signal_verify_phone_number_form.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,3 @@ | ||
.SignalVerifyPhoneNumberForm .SubmitButton { | ||
margin-top: var(--spacing-unit); | ||
} |
10 changes: 5 additions & 5 deletions
10
...iews/settings/signal/verify_form.html.erb → .../signal_verify_phone_number_form.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
13 changes: 13 additions & 0 deletions
13
app/components/signal_verify_phone_number_form/signal_verify_phone_number_form.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,13 @@ | ||
# frozen_string_literal: true | ||
|
||
module SignalVerifyPhoneNumberForm | ||
class SignalVerifyPhoneNumberForm < ApplicationComponent | ||
def initialize(organization:) | ||
super | ||
|
||
@organization = organization | ||
end | ||
|
||
attr_reader :organization | ||
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,64 @@ | ||
# frozen_string_literal: true | ||
|
||
module Organizations | ||
class SignalController < ApplicationController | ||
def captcha_form; end | ||
|
||
def register | ||
response = SignalAdapter::RegisterPhoneNumberService.new(organization_id: @organization.id, register_data: register_data).call | ||
case response | ||
when Net::HTTPSuccess | ||
redirect_to organization_signal_verify_path | ||
else | ||
handle_error_response(response) | ||
render :captcha_form, status: :unprocessable_entity | ||
end | ||
end | ||
|
||
def verify_form; end | ||
|
||
def verify | ||
token = params[:organization][:signal][:token] | ||
response = SignalAdapter::VerifyPhoneNumberService.new(organization_id: @organization.id, token: token).call | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. same ☝️ |
||
case response | ||
when Net::HTTPSuccess | ||
SignalAdapter::SetTrustModeJob.perform_later(signal_server_phone_number: @organization.signal_server_phone_number) | ||
SignalAdapter::SetUsernameJob.perform_later(organization_id: @organization.id) | ||
SignalAdapter::SetProfileInfoJob.perform_later(organization_id: @organization.id) | ||
else | ||
handle_error_response(response) | ||
render :verify_form, status: :unprocessable_entity | ||
end | ||
end | ||
|
||
private | ||
|
||
def update_params | ||
params.require(:organization).permit(:signal_server_phone_number) | ||
end | ||
|
||
def signal_server_phone_number | ||
@organization.signal_server_phone_number | ||
end | ||
|
||
def register_data | ||
{ | ||
captcha: params[:organization][:signal][:captcha], | ||
use_voice: ActiveModel::Type::Boolean.new.cast(params[:organization][:signal][:use_voice]) | ||
} | ||
end | ||
|
||
def handle_error_response(response) | ||
error_message = JSON.parse(response.body)['error'] | ||
exception = SignalAdapter::BadRequestError.new(error_code: response.code, message: error_message) | ||
context = { | ||
code: response.code, | ||
message: response.message, | ||
headers: response.to_hash, | ||
body: error_message | ||
} | ||
ErrorNotifier.report(exception, context: context) | ||
flash.now[:error] = error_message | ||
end | ||
end | ||
end |
This file was deleted.
Oops, something went wrong.
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,13 @@ | ||
# frozen_string_literal: true | ||
|
||
require 'administrate/field/base' | ||
|
||
class SetupSignalLinkField < Administrate::Field::Base | ||
def setup_signal_url | ||
"/#{resource.id}/signal/register" | ||
end | ||
|
||
def signal_server_phone_number | ||
data | ||
end | ||
end |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.