add integration users page

pull/381/head
Oleksandr Turchyn 1 year ago committed by GitHub
parent 350c4b1c2a
commit 9266694d65
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

@ -9,9 +9,11 @@ class UsersController < ApplicationController
def index
@users =
if params[:status] == 'archived'
@users.archived
@users.archived.where.not(role: 'integration')
elsif params[:status] == 'integration'
@users.active.where(role: 'integration')
else
@users.active
@users.active.where.not(role: 'integration')
end
@pagy, @users = pagy(@users.where(account: current_account).order(id: :desc))

@ -0,0 +1,14 @@
<div class="flex items-center space-x-1">
<% if %w[archived integration].include?(params[:status]) %>
<%= link_to t('view_active'), settings_users_path, class: 'link text-sm' %>
<% else %>
<% links = [] %>
<% if current_account.users.active.exists?(role: 'integration') %>
<% links << link_to(t('view_embedding_users'), settings_integration_users_path, class: 'link text-sm') %>
<% end %>
<% if current_account.users.archived.exists? %>
<% links << link_to(t('view_archived'), settings_archived_users_path, class: 'link text-sm') %>
<% end %>
<%= links.join('<span class="text-neutral-700">|</span>').html_safe %>
<% end %>
</div>

@ -1,12 +1,18 @@
<div class="flex-wrap space-y-4 md:flex md:flex-nowrap md:space-y-0 md:space-x-10">
<%= render 'shared/settings_nav' %>
<div class="md:flex-grow">
<div class="flex flex-col md:flex-row gap-2 md:justify-between md:items-end mb-4">
<div class="flex flex-col md:flex-row gap-2 md:justify-between md:items-end mb-4 min-h-12">
<h1 class="text-4xl font-bold">
<%= t('status_users', status: params[:status].to_s.titleize) %>
<% if params[:status] == 'archived' %>
<%= t('archived_users') %>
<% elsif params[:status] == 'integration' %>
<%= t('embedding_users') %>
<% else %>
<%= t('users') %>
<% end %>
</h1>
<div class="flex flex-col md:flex-row gap-y-2 gap-x-4 md:items-center">
<% if can?(:create, User.new(account: current_account)) %>
<% if params[:status].blank? && can?(:create, User.new(account: current_account)) %>
<%= render 'users/extra_buttons' %>
<% if content_for(:add_user_button) %>
<%= content_for(:add_user_button) %>
@ -57,17 +63,17 @@
<%= user.last_sign_in_at ? l(user.last_sign_in_at.in_time_zone(current_account.timezone), format: :short, locale: current_account.locale) : '-' %>
</td>
<td class="flex items-center space-x-2 justify-end">
<% if can?(:update, user) && user.archived_at.blank? %>
<% if params[:status].blank? && can?(:update, user) && user.archived_at.blank? %>
<%= link_to edit_user_path(user), class: 'btn btn-outline btn-xs', title: t('edit'), data: { turbo_frame: 'modal' } do %>
<%= t('edit') %>
<% end %>
<% end %>
<% if params[:status].blank? && can?(:destroy, user) && user != current_user %>
<% if params[:status] != 'archived' && can?(:destroy, user) && user != current_user %>
<%= button_to user_path(user), method: :delete, class: 'btn btn-outline btn-error btn-xs', title: t('remove'), data: { turbo_confirm: t('are_you_sure_') } do %>
<%= t('remove') %>
<% end %>
<% end %>
<% if params[:status].present? && can?(:manage, user) && user != current_user %>
<% if params[:status] == 'archived' && can?(:manage, user) && user != current_user && user.archived_at? %>
<%= button_to user_path(user), method: :put, params: { user: { archived_at: nil } }, class: 'btn btn-outline btn-xs', title: t('unarchive'), data: { turbo_confirm: t('are_you_sure_') } do %>
<%= t('unarchive') %>
<% end %>
@ -78,22 +84,11 @@
</tbody>
</table>
</div>
<% view_archived_html = capture do %>
<% if current_account.users.archived.exists? %>
<div>
<% if params[:status] == 'archived' %>
<a href="<%= settings_users_path %>" class="link text-sm"><%= t('view_active') %></a>
<% else %>
<a href="<%= settings_archived_users_path %>" class="link text-sm"><%= t('view_archived') %></a>
<% end %>
</div>
<% end %>
<% end %>
<% if @pagy.pages > 1 %>
<%= render 'shared/pagination', pagy: @pagy, items_name: 'users', left_additional_html: view_archived_html %>
<%= render 'shared/pagination', pagy: @pagy, items_name: 'users', left_additional_html: render('bottom_links') %>
<% else %>
<div class="mt-2">
<%= view_archived_html %>
<%= render 'bottom_links' %>
</div>
<% end %>
</div>

@ -474,7 +474,6 @@ en: &en
back: Back
add_secret: Add Secret
submission_example_payload: Submission example payload
status_users: '%{status} Users'
there_are_no_signatures: There are no signatures
signed_with_trusted_certificate: Signed with trusted certificate
signed_with_external_certificate: Signed with external certificate
@ -619,6 +618,10 @@ en: &en
use_international_format_1xxx_: 'Use internatioanl format: +1xxx...'
submitter_cannot_be_updated: Submitter cannot be updated.
at_least_one_field_must_be_filled: At least one field must be filled.
archived_users: Archived Users
embedding_users: Embedding Users
view_embedding_users: View Embedding Users
view_users: View Users
submission_event_names:
send_email_to_html: '<b>Email sent</b> to %{submitter_name}'
send_reminder_email_to_html: '<b>Reminder email sent</b> to %{submitter_name}'
@ -1111,7 +1114,6 @@ es: &es
back: Atrás
add_secret: Agregar secreto
submission_example_payload: Ejemplo de payload de envío
status_users: '%{status} Usuarios'
there_are_no_signatures: No hay firmas
signed_with_trusted_certificate: Firmado con certificado de confianza
signed_with_external_certificate: Firmado con certificado externo
@ -1256,6 +1258,9 @@ es: &es
use_international_format_1xxx_: 'Usa el formato internacional: +1xxx...'
submitter_cannot_be_updated: El remitente no puede ser actualizado.
at_least_one_field_must_be_filled: Al menos un campo debe estar completo.
archived_users: Usuarios Archivados
embedding_users: Usuarios Integrados
view_embedding_users: Ver Usuarios Integrado
submission_event_names:
send_email_to_html: '<b>Correo electrónico enviado</b> a %{submitter_name}'
send_reminder_email_to_html: '<b>Correo de recordatorio enviado</b> a %{submitter_name}'
@ -1748,7 +1753,6 @@ it: &it
back: Indietro
add_secret: Aggiungi segreto
submission_example_payload: Esempio di payload di invio
status_users: '%{status} Utenti'
there_are_no_signatures: Non ci sono firme
signed_with_trusted_certificate: Firmato con certificato affidabile
signed_with_external_certificate: Firmato con certificato esterno
@ -1893,6 +1897,9 @@ it: &it
use_international_format_1xxx_: 'Utilizza il formato internazionale: +1xxx...'
submitter_cannot_be_updated: Il mittente non può essere aggiornato.
at_least_one_field_must_be_filled: Almeno un campo deve essere compilato.
archived_users: Utenti Archiviati
embedding_users: Utenti Incorporati
view_embedding_users: Visualizza Utenti Incorporati
submission_event_names:
send_email_to_html: '<b>E-mail inviato</b> a %{submitter_name}'
send_reminder_email_to_html: '<b>E-mail di promemoria inviato</b> a %{submitter_name}'
@ -2386,7 +2393,6 @@ fr: &fr
back: Retour
add_secret: Ajouter un secret
submission_example_payload: Exemple de payload de soumission
status_users: '%{status} Utilisateurs'
there_are_no_signatures: "Il n'y a pas de signatures"
signed_with_trusted_certificate: Signé avec un certificat de confiance
signed_with_external_certificate: Signé avec un certificat externe
@ -2531,6 +2537,9 @@ fr: &fr
use_international_format_1xxx_: 'Utilizza il formato internazionale: +1xxx...'
submitter_cannot_be_updated: Il mittente non può essere aggiornato.
at_least_one_field_must_be_filled: Almeno un campo deve essere compilato.
archived_users: Utilisateurs Archivés
embedding_users: Utilisateurs Intégrés
view_embedding_users: Voir les Utilisateurs Intégrés
submission_event_names:
send_email_to_html: '<b>E-mail envoyé</b> à %{submitter_name}'
send_reminder_email_to_html: '<b>E-mail de rappel envoyé</b> à %{submitter_name}'
@ -3023,7 +3032,6 @@ pt: &pt
back: Voltar
add_secret: Adicionar segredo
submission_example_payload: Exemplo de payload de submissão
status_users: '%{status} Usuários'
there_are_no_signatures: Não há assinaturas
signed_with_trusted_certificate: Assinado com certificado confiável
signed_with_external_certificate: Assinado com certificado externo
@ -3168,6 +3176,9 @@ pt: &pt
use_international_format_1xxx_: 'Use o formato internacional: +1xxx...'
submitter_cannot_be_updated: O remetente não pode ser atualizado.
at_least_one_field_must_be_filled: Pelo menos um campo deve ser preenchido.
archived_users: Usuários Arquivados
embedding_users: Usuários Incorporados
view_embedding_users: Ver Usuários Incorporados
submission_event_names:
send_email_to_html: '<b>E-mail enviado</b> para %{submitter_name}'
send_reminder_email_to_html: '<b>E-mail de lembrete enviado</b> para %{submitter_name}'
@ -3660,7 +3671,6 @@ de: &de
back: Zurück
add_secret: Geheimnis hinzufügen
submission_example_payload: Beispiel-Payload für Einreichung
status_users: '%{status} Benutzer'
there_are_no_signatures: Es gibt keine Unterschriften
signed_with_trusted_certificate: Signiert mit vertrauenswürdigem Zertifikat
signed_with_external_certificate: Signiert mit externem Zertifikat
@ -3805,6 +3815,9 @@ de: &de
use_international_format_1xxx_: 'Verwenden Sie das internationale Format: +1xxx...'
submitter_cannot_be_updated: Der Absender kann nicht aktualisiert werden.
at_least_one_field_must_be_filled: Mindestens ein Feld muss ausgefüllt werden.
archived_users: Archivierte Benutzer
embedding_users: Einbettende Benutzer
view_embedding_users: Einbettende Benutzer anzeigen
submission_event_names:
send_email_to_html: '<b>E-Mail gesendet</b> an %{submitter_name}'
send_reminder_email_to_html: '<b>Erinnerungs-E-Mail gesendet</b> an %{submitter_name}'

@ -162,6 +162,8 @@ Rails.application.routes.draw do
resources :users, only: %i[index]
resources :archived_users, only: %i[index], path: 'users/:status', controller: 'users',
defaults: { status: :archived }
resources :integration_users, only: %i[index], path: 'users/:status', controller: 'users',
defaults: { status: :integration }
resource :personalization, only: %i[show create], controller: 'personalization_settings'
resources :api, only: %i[index create], controller: 'api_settings'
resource :webhooks, only: %i[show create update], controller: 'webhook_settings'

@ -18,13 +18,19 @@ RSpec.describe 'Team Settings' do
visit settings_users_path
end
it 'shows all users' do
it 'shows only active users' do
within '.table' do
users.each do |user|
expect(page).to have_content(user.full_name)
expect(page).to have_content(user.email)
expect(page).to have_no_content(other_user.email)
expect(page).to have_link('Edit', href: edit_user_path(user))
end
expect(page).to have_button('Remove')
expect(page).to have_no_button('Unarchive')
expect(page).to have_no_content(other_user.full_name)
expect(page).to have_no_content(other_user.email)
end
end
@ -89,4 +95,58 @@ RSpec.describe 'Team Settings' do
expect(page).to have_no_content('User has been removed')
end
end
context 'when some users are archived' do
let!(:users) { create_list(:user, 2, account:) }
let!(:archived_users) { create_list(:user, 2, account:, archived_at: Time.current) }
let!(:other_user) { create(:user) }
it 'shows only active users' do
visit settings_users_path
within '.table' do
users.each do |user|
expect(page).to have_content(user.full_name)
expect(page).to have_content(user.email)
end
archived_users.each do |user|
expect(page).to have_no_content(user.full_name)
expect(page).to have_no_content(user.email)
end
expect(page).to have_no_content(other_user.full_name)
expect(page).to have_no_content(other_user.email)
end
expect(page).to have_link('View Archived', href: settings_archived_users_path)
end
it 'shows only archived users' do
visit settings_archived_users_path
within '.table' do
archived_users.each do |user|
expect(page).to have_content(user.full_name)
expect(page).to have_content(user.email)
expect(page).to have_no_link('Edit', href: edit_user_path(user))
end
users.each do |user|
expect(page).to have_no_content(user.full_name)
expect(page).to have_no_content(user.email)
expect(page).to have_no_link('Edit', href: edit_user_path(user))
end
expect(page).to have_button('Unarchive')
expect(page).to have_no_button('Remove')
expect(page).to have_no_content(other_user.full_name)
expect(page).to have_no_content(other_user.email)
end
expect(page).to have_content('Archived Users')
expect(page).to have_link('View Active', href: settings_users_path)
end
end
end

Loading…
Cancel
Save