From 81d8d3862d4d114347071ef8db50e51955c11681 Mon Sep 17 00:00:00 2001 From: Petterson <58094725+hahuma@users.noreply.github.com> Date: Mon, 11 Aug 2025 16:23:05 -0300 Subject: [PATCH 1/6] feat: Add route to list accounts that belongs to a platform_app (#12140) This PR creates a new route to list all accounts that a platform_app has access to. Fixes: #12109 --- .../platform/api/v1/accounts_controller.rb | 7 ++++ .../api/v1/accounts/index.json.jbuilder | 3 ++ config/routes.rb | 2 +- .../api/v1/accounts_controller_spec.rb | 36 +++++++++++++++++++ 4 files changed, 47 insertions(+), 1 deletion(-) create mode 100644 app/views/platform/api/v1/accounts/index.json.jbuilder diff --git a/app/controllers/platform/api/v1/accounts_controller.rb b/app/controllers/platform/api/v1/accounts_controller.rb index e11cf9d4a..4521930a6 100644 --- a/app/controllers/platform/api/v1/accounts_controller.rb +++ b/app/controllers/platform/api/v1/accounts_controller.rb @@ -1,4 +1,11 @@ class Platform::Api::V1::AccountsController < PlatformController + def index + @resources = @platform_app.platform_app_permissibles + .where(permissible_type: 'Account') + .includes(:permissible) + .map(&:permissible) + end + def show; end def create diff --git a/app/views/platform/api/v1/accounts/index.json.jbuilder b/app/views/platform/api/v1/accounts/index.json.jbuilder new file mode 100644 index 000000000..2e8e9f73f --- /dev/null +++ b/app/views/platform/api/v1/accounts/index.json.jbuilder @@ -0,0 +1,3 @@ +json.array! @resources do |account| + json.partial! 'platform/api/v1/models/account', formats: [:json], resource: account +end diff --git a/config/routes.rb b/config/routes.rb index 7fb348084..10749062e 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -425,7 +425,7 @@ Rails.application.routes.draw do resources :agent_bots, only: [:index, :create, :show, :update, :destroy] do delete :avatar, on: :member end - resources :accounts, only: [:create, :show, :update, :destroy] do + resources :accounts, only: [:index, :create, :show, :update, :destroy] do resources :account_users, only: [:index, :create] do collection do delete :destroy diff --git a/spec/controllers/platform/api/v1/accounts_controller_spec.rb b/spec/controllers/platform/api/v1/accounts_controller_spec.rb index c7b5b275b..63f53d0d6 100644 --- a/spec/controllers/platform/api/v1/accounts_controller_spec.rb +++ b/spec/controllers/platform/api/v1/accounts_controller_spec.rb @@ -78,6 +78,42 @@ RSpec.describe 'Platform Accounts API', type: :request do end end + describe 'GET /platform/api/v1/accounts' do + context 'when it is an unauthenticated platform app' do + it 'returns unauthorized' do + get '/platform/api/v1/accounts' + expect(response).to have_http_status(:unauthorized) + end + end + + context 'when it is an invalid platform app token' do + it 'returns unauthorized' do + get '/platform/api/v1/accounts', headers: { api_access_token: 'invalid' }, as: :json + expect(response).to have_http_status(:unauthorized) + end + end + + context 'when it is an authenticated platform app' do + let(:platform_app) { create(:platform_app) } + let!(:account1) { create(:account, name: 'Account A') } + let!(:account2) { create(:account, name: 'Account B') } + + before do + create(:platform_app_permissible, platform_app: platform_app, permissible: account1) + create(:platform_app_permissible, platform_app: platform_app, permissible: account2) + end + + it 'returns all permissible accounts' do + get '/platform/api/v1/accounts', headers: { api_access_token: platform_app.access_token.token }, as: :json + + expect(response).to have_http_status(:success) + json_response = response.parsed_body + expect(json_response.size).to eq(2) + expect(json_response.map { |acc| acc['name'] }).to include('Account A', 'Account B') + end + end + end + describe 'GET /platform/api/v1/accounts/{account_id}' do context 'when it is an unauthenticated platform app' do it 'returns unauthorized' do From ecd9cf0326e240bb648ae9bb8e46c1101bc6d617 Mon Sep 17 00:00:00 2001 From: Sivin Varghese <64252451+iamsivin@users.noreply.github.com> Date: Tue, 12 Aug 2025 02:46:48 +0530 Subject: [PATCH 2/6] fix: RTL issues in new conversation form (#12163) # Pull Request Template ## Description This PR fixes RTL alignment issues in the new conversation form, removes the unused [`form-checkbox`](https://github.com/chatwoot/chatwoot/pull/12151#discussion_r2266333315) class name and drops the `app-rtl--wrapper` class, which was previously used for RTL detection in `rtl.scss` (removed earlier) Fixes https://linear.app/chatwoot/issue/CW-5410/rtl-issues ## Type of change - [x] Bug fix (non-breaking change which fixes an issue) ## How Has This Been Tested? ### Screenshots image image image ## Checklist: - [x] My code follows the style guidelines of this project - [x] I have performed a self-review of my code - [ ] I have commented on my code, particularly in hard-to-understand areas - [ ] I have made corresponding changes to the documentation - [x] My changes generate no new warnings - [ ] I have added tests that prove my fix is effective or that my feature works - [x] New and existing unit tests pass locally with my changes - [ ] Any dependent changes have been merged and published in downstream modules --- app/javascript/dashboard/App.vue | 1 - .../components/ActionButtons.vue | 2 +- .../components/AttachmentPreviews.vue | 2 +- .../components/InboxSelector.vue | 2 +- .../components/WhatsAppOptions.vue | 10 +++++++--- .../components/WhatsappTemplateParser.vue | 5 +++-- .../components-next/avatar/Avatar.vue | 2 +- .../assistant/EditAssistantForm.vue | 13 ++----------- .../settings/AssistantBasicSettingsForm.vue | 18 +++--------------- .../components-next/sidebar/SidebarGroup.vue | 4 ++-- .../components-next/taginput/TagInput.vue | 2 +- 11 files changed, 22 insertions(+), 39 deletions(-) diff --git a/app/javascript/dashboard/App.vue b/app/javascript/dashboard/App.vue index 0fbb20ea9..8da7e7476 100644 --- a/app/javascript/dashboard/App.vue +++ b/app/javascript/dashboard/App.vue @@ -137,7 +137,6 @@ export default { v-if="!authUIFlags.isFetching && !accountUIFlags.isFetchingItem" id="app" class="flex flex-col w-full h-screen min-h-0" - :class="{ 'app-rtl--wrapper': isRTL }" :dir="isRTL ? 'rtl' : 'ltr'" > diff --git a/app/javascript/dashboard/components-next/NewConversation/components/ActionButtons.vue b/app/javascript/dashboard/components-next/NewConversation/components/ActionButtons.vue index 90cb67c4f..a686a8d16 100644 --- a/app/javascript/dashboard/components-next/NewConversation/components/ActionButtons.vue +++ b/app/javascript/dashboard/components-next/NewConversation/components/ActionButtons.vue @@ -170,7 +170,7 @@ useKeyboardEvents(keyboardEvents); /> diff --git a/app/javascript/dashboard/components-next/NewConversation/components/AttachmentPreviews.vue b/app/javascript/dashboard/components-next/NewConversation/components/AttachmentPreviews.vue index fe57d19c4..a546fe0df 100644 --- a/app/javascript/dashboard/components-next/NewConversation/components/AttachmentPreviews.vue +++ b/app/javascript/dashboard/components-next/NewConversation/components/AttachmentPreviews.vue @@ -57,7 +57,7 @@ const removeAttachment = id => { variant="ghost" icon="i-lucide-trash" color="slate" - class="absolute top-1 right-1 !w-5 !h-5 transition-opacity duration-150 ease-in-out opacity-0 group-hover/image:opacity-100" + class="absolute top-1 ltr:right-1 rtl:left-1 !w-5 !h-5 transition-opacity duration-150 ease-in-out opacity-0 group-hover/image:opacity-100" @click="removeAttachment(attachment.resource.id)" /> diff --git a/app/javascript/dashboard/components-next/NewConversation/components/InboxSelector.vue b/app/javascript/dashboard/components-next/NewConversation/components/InboxSelector.vue index 7794d5bdd..3cafacb21 100644 --- a/app/javascript/dashboard/components-next/NewConversation/components/InboxSelector.vue +++ b/app/javascript/dashboard/components-next/NewConversation/components/InboxSelector.vue @@ -83,7 +83,7 @@ const targetInboxLabel = computed(() => { diff --git a/app/javascript/dashboard/components-next/NewConversation/components/WhatsAppOptions.vue b/app/javascript/dashboard/components-next/NewConversation/components/WhatsAppOptions.vue index 3980c6b30..124612ad3 100644 --- a/app/javascript/dashboard/components-next/NewConversation/components/WhatsAppOptions.vue +++ b/app/javascript/dashboard/components-next/NewConversation/components/WhatsAppOptions.vue @@ -2,6 +2,7 @@ import { computed, ref } from 'vue'; import { useI18n } from 'vue-i18n'; +import Icon from 'dashboard/components-next/icon/Icon.vue'; import Button from 'dashboard/components-next/button/Button.vue'; import WhatsappTemplateParser from './WhatsappTemplateParser.vue'; @@ -84,10 +85,13 @@ const handleSendMessage = template => { />
- + { 'COMPOSE_NEW_CONVERSATION.FORM.WHATSAPP_OPTIONS.SEARCH_PLACEHOLDER' ) " - class="w-full h-8 py-2 pl-10 pr-2 text-sm reset-base outline-none border-none rounded-lg bg-n-alpha-black2 dark:bg-n-solid-1 text-n-slate-12" + class="w-full h-8 py-2 ltr:pl-10 rtl:pr-10 ltr:pr-2 rtl:pl-2 text-sm reset-base outline-none border-none rounded-lg bg-n-alpha-black2 dark:bg-n-solid-1 text-n-slate-12" />
{