Merge branch 'develop' into feat/add_read_replica_support
This commit is contained in:
@@ -71,7 +71,7 @@ gem 'barnes'
|
||||
##--- gems for authentication & authorization ---##
|
||||
gem 'devise', '>= 4.9.4'
|
||||
gem 'devise-secure_password', git: 'https://github.com/chatwoot/devise-secure_password', branch: 'chatwoot'
|
||||
gem 'devise_token_auth'
|
||||
gem 'devise_token_auth', '>= 1.2.3'
|
||||
# authorization
|
||||
gem 'jwt'
|
||||
gem 'pundit'
|
||||
@@ -166,7 +166,7 @@ gem 'audited', '~> 5.4', '>= 5.4.1'
|
||||
# need for google auth
|
||||
gem 'omniauth', '>= 2.1.2'
|
||||
gem 'omniauth-google-oauth2', '>= 1.1.2'
|
||||
gem 'omniauth-rails_csrf_protection', '~> 1.0'
|
||||
gem 'omniauth-rails_csrf_protection', '~> 1.0', '>= 1.0.2'
|
||||
|
||||
## Gems for reponse bot
|
||||
# adds cosine similarity to postgres using vector extension
|
||||
|
||||
+14
-14
@@ -148,7 +148,7 @@ GEM
|
||||
barnes (0.0.9)
|
||||
multi_json (~> 1)
|
||||
statsd-ruby (~> 1.1)
|
||||
base64 (0.1.1)
|
||||
base64 (0.2.0)
|
||||
bcrypt (3.1.20)
|
||||
bigdecimal (3.1.7)
|
||||
bindex (0.8.1)
|
||||
@@ -200,10 +200,10 @@ GEM
|
||||
railties (>= 4.1.0)
|
||||
responders
|
||||
warden (~> 1.2.3)
|
||||
devise_token_auth (1.2.1)
|
||||
devise_token_auth (1.2.3)
|
||||
bcrypt (~> 3.0)
|
||||
devise (> 3.5.2, < 5)
|
||||
rails (>= 4.2.0, < 7.1)
|
||||
rails (>= 4.2.0, < 7.2)
|
||||
diff-lcs (1.5.0)
|
||||
digest-crc (0.6.4)
|
||||
rake (>= 12.0.0, < 14.0.0)
|
||||
@@ -369,7 +369,7 @@ GEM
|
||||
mini_mime (>= 1.0.0)
|
||||
multi_xml (>= 0.5.2)
|
||||
httpclient (2.8.3)
|
||||
i18n (1.14.4)
|
||||
i18n (1.14.5)
|
||||
concurrent-ruby (~> 1.0)
|
||||
image_processing (1.12.2)
|
||||
mini_magick (>= 4.9.5, < 5)
|
||||
@@ -474,7 +474,7 @@ GEM
|
||||
uri
|
||||
net-http-persistent (4.0.2)
|
||||
connection_pool (~> 2.2)
|
||||
net-imap (0.4.10)
|
||||
net-imap (0.4.11)
|
||||
date
|
||||
net-protocol
|
||||
net-pop (0.1.2)
|
||||
@@ -489,15 +489,15 @@ GEM
|
||||
sidekiq
|
||||
newrelic_rpm (9.6.0)
|
||||
base64
|
||||
nio4r (2.7.1)
|
||||
nokogiri (1.16.4)
|
||||
nio4r (2.7.3)
|
||||
nokogiri (1.16.5)
|
||||
mini_portile2 (~> 2.8.2)
|
||||
racc (~> 1.4)
|
||||
nokogiri (1.16.4-arm64-darwin)
|
||||
nokogiri (1.16.5-arm64-darwin)
|
||||
racc (~> 1.4)
|
||||
nokogiri (1.16.4-x86_64-darwin)
|
||||
nokogiri (1.16.5-x86_64-darwin)
|
||||
racc (~> 1.4)
|
||||
nokogiri (1.16.4-x86_64-linux)
|
||||
nokogiri (1.16.5-x86_64-linux)
|
||||
racc (~> 1.4)
|
||||
oauth (1.1.0)
|
||||
oauth-tty (~> 1.0, >= 1.0.1)
|
||||
@@ -524,7 +524,7 @@ GEM
|
||||
omniauth-oauth2 (1.8.0)
|
||||
oauth2 (>= 1.4, < 3)
|
||||
omniauth (~> 2.0)
|
||||
omniauth-rails_csrf_protection (1.0.1)
|
||||
omniauth-rails_csrf_protection (1.0.2)
|
||||
actionpack (>= 4.2)
|
||||
omniauth (~> 2.0)
|
||||
openssl (3.1.0)
|
||||
@@ -819,7 +819,7 @@ GEM
|
||||
working_hours (1.4.1)
|
||||
activesupport (>= 3.2)
|
||||
tzinfo
|
||||
zeitwerk (2.6.13)
|
||||
zeitwerk (2.6.14)
|
||||
|
||||
PLATFORMS
|
||||
arm64-darwin-20
|
||||
@@ -860,7 +860,7 @@ DEPENDENCIES
|
||||
debug (~> 1.8)
|
||||
devise (>= 4.9.4)
|
||||
devise-secure_password!
|
||||
devise_token_auth
|
||||
devise_token_auth (>= 1.2.3)
|
||||
dotenv-rails
|
||||
down
|
||||
elastic-apm
|
||||
@@ -904,7 +904,7 @@ DEPENDENCIES
|
||||
omniauth (>= 2.1.2)
|
||||
omniauth-google-oauth2 (>= 1.1.2)
|
||||
omniauth-oauth2
|
||||
omniauth-rails_csrf_protection (~> 1.0)
|
||||
omniauth-rails_csrf_protection (~> 1.0, >= 1.0.2)
|
||||
pg
|
||||
pg_search
|
||||
pgvector
|
||||
|
||||
@@ -55,7 +55,7 @@
|
||||
"plan": "heroku-redis:mini"
|
||||
},
|
||||
{
|
||||
"plan": "heroku-postgresql:mini"
|
||||
"plan": "heroku-postgresql:essential-0"
|
||||
}
|
||||
],
|
||||
"stack": "heroku-20",
|
||||
|
||||
@@ -19,9 +19,9 @@ class ContactInboxWithContactBuilder
|
||||
|
||||
ActiveRecord::Base.transaction(requires_new: true) do
|
||||
build_contact_with_contact_inbox
|
||||
update_contact_avatar(@contact) unless @contact.avatar.attached?
|
||||
@contact_inbox
|
||||
end
|
||||
update_contact_avatar(@contact) unless @contact.avatar.attached?
|
||||
@contact_inbox
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
@@ -21,6 +21,6 @@ class Api::V1::Accounts::BulkActionsController < Api::V1::Accounts::BaseControll
|
||||
end
|
||||
|
||||
def permitted_params
|
||||
params.permit(:type, ids: [], fields: [:status, :assignee_id, :team_id], labels: [add: [], remove: []])
|
||||
params.permit(:type, :snoozed_until, ids: [], fields: [:status, :assignee_id, :team_id], labels: [add: [], remove: []])
|
||||
end
|
||||
end
|
||||
|
||||
@@ -46,7 +46,8 @@ class Api::V1::Accounts::ContactsController < Api::V1::Accounts::BaseController
|
||||
|
||||
def export
|
||||
column_names = params['column_names']
|
||||
Account::ContactsExportJob.perform_later(Current.account.id, column_names, Current.user.email)
|
||||
filter_params = { :payload => params.permit!['payload'], :label => params.permit!['label'] }
|
||||
Account::ContactsExportJob.perform_later(Current.account.id, Current.user.id, column_names, filter_params)
|
||||
head :ok, message: I18n.t('errors.contacts.export.success')
|
||||
end
|
||||
|
||||
@@ -61,7 +62,7 @@ class Api::V1::Accounts::ContactsController < Api::V1::Accounts::BaseController
|
||||
def show; end
|
||||
|
||||
def filter
|
||||
result = ::Contacts::FilterService.new(params.permit!, current_user).perform
|
||||
result = ::Contacts::FilterService.new(Current.account, Current.user, params.permit!).perform
|
||||
contacts = result[:contacts]
|
||||
@contacts_count = result[:count]
|
||||
@contacts = fetch_contacts(contacts)
|
||||
|
||||
@@ -77,8 +77,8 @@ class ContactAPI extends ApiClient {
|
||||
return axios.delete(`${this.url}/${contactId}/avatar`);
|
||||
}
|
||||
|
||||
exportContacts() {
|
||||
return axios.get(`${this.url}/export`);
|
||||
exportContacts(queryPayload) {
|
||||
return axios.post(`${this.url}/export`, queryPayload);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -288,7 +288,6 @@ export default {
|
||||
foldersQuery: {},
|
||||
showAddFoldersModal: false,
|
||||
showDeleteFoldersModal: false,
|
||||
selectedConversations: [],
|
||||
selectedInboxes: [],
|
||||
isContextMenuOpen: false,
|
||||
appliedFilter: [],
|
||||
@@ -329,6 +328,7 @@ export default {
|
||||
inboxesList: 'inboxes/getInboxes',
|
||||
campaigns: 'campaigns/getAllCampaigns',
|
||||
labels: 'labels/getLabels',
|
||||
selectedConversations: 'bulkActions/getSelectedConversationIds',
|
||||
}),
|
||||
hasAppliedFilters() {
|
||||
return this.appliedFilters.length !== 0;
|
||||
@@ -799,7 +799,7 @@ export default {
|
||||
});
|
||||
},
|
||||
resetBulkActions() {
|
||||
this.selectedConversations = [];
|
||||
this.$store.dispatch('bulkActions/clearSelectedConversationIds');
|
||||
this.selectedInboxes = [];
|
||||
},
|
||||
onBasicFilterChange(value, type) {
|
||||
@@ -830,12 +830,16 @@ export default {
|
||||
return this.selectedConversations.includes(id);
|
||||
},
|
||||
selectConversation(conversationId, inboxId) {
|
||||
this.selectedConversations.push(conversationId);
|
||||
this.$store.dispatch(
|
||||
'bulkActions/setSelectedConversationIds',
|
||||
conversationId
|
||||
);
|
||||
this.selectedInboxes.push(inboxId);
|
||||
},
|
||||
deSelectConversation(conversationId, inboxId) {
|
||||
this.selectedConversations = this.selectedConversations.filter(
|
||||
item => item !== conversationId
|
||||
this.$store.dispatch(
|
||||
'bulkActions/removeSelectedConversationIds',
|
||||
conversationId
|
||||
);
|
||||
this.selectedInboxes = this.selectedInboxes.filter(
|
||||
item => item !== inboxId
|
||||
@@ -843,7 +847,10 @@ export default {
|
||||
},
|
||||
selectAllConversations(check) {
|
||||
if (check) {
|
||||
this.selectedConversations = this.conversationList.map(item => item.id);
|
||||
this.$store.dispatch(
|
||||
'bulkActions/setSelectedConversationIds',
|
||||
this.conversationList.map(item => item.id)
|
||||
);
|
||||
this.selectedInboxes = this.conversationList.map(item => item.inbox_id);
|
||||
} else {
|
||||
this.resetBulkActions();
|
||||
@@ -859,7 +866,7 @@ export default {
|
||||
assignee_id: agent.id,
|
||||
},
|
||||
});
|
||||
this.selectedConversations = [];
|
||||
this.$store.dispatch('bulkActions/clearSelectedConversationIds');
|
||||
if (conversationId) {
|
||||
this.showAlert(
|
||||
this.$t(
|
||||
@@ -957,7 +964,7 @@ export default {
|
||||
add: labels,
|
||||
},
|
||||
});
|
||||
this.selectedConversations = [];
|
||||
this.$store.dispatch('bulkActions/clearSelectedConversationIds');
|
||||
if (conversationId) {
|
||||
this.showAlert(
|
||||
this.$t(
|
||||
@@ -984,13 +991,13 @@ export default {
|
||||
team_id: team.id,
|
||||
},
|
||||
});
|
||||
this.selectedConversations = [];
|
||||
this.$store.dispatch('bulkActions/clearSelectedConversationIds');
|
||||
this.showAlert(this.$t('BULK_ACTION.TEAMS.ASSIGN_SUCCESFUL'));
|
||||
} catch (err) {
|
||||
this.showAlert(this.$t('BULK_ACTION.TEAMS.ASSIGN_FAILED'));
|
||||
}
|
||||
},
|
||||
async onUpdateConversations(status) {
|
||||
async onUpdateConversations(status, snoozedUntil) {
|
||||
try {
|
||||
await this.$store.dispatch('bulkActions/process', {
|
||||
type: 'Conversation',
|
||||
@@ -998,8 +1005,9 @@ export default {
|
||||
fields: {
|
||||
status,
|
||||
},
|
||||
snoozed_until: snoozedUntil,
|
||||
});
|
||||
this.selectedConversations = [];
|
||||
this.$store.dispatch('bulkActions/clearSelectedConversationIds');
|
||||
this.showAlert(this.$t('BULK_ACTION.UPDATE.UPDATE_SUCCESFUL'));
|
||||
} catch (err) {
|
||||
this.showAlert(this.$t('BULK_ACTION.UPDATE.UPDATE_FAILED'));
|
||||
|
||||
@@ -5,6 +5,7 @@
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import getUuid from 'widget/helpers/uuid';
|
||||
import 'video.js/dist/video-js.css';
|
||||
import 'videojs-record/dist/css/videojs.record.css';
|
||||
|
||||
@@ -28,9 +29,25 @@ import OpusRecorderEngine from 'videojs-record/dist/plugins/videojs.record.opus-
|
||||
|
||||
import { format, addSeconds } from 'date-fns';
|
||||
import { AUDIO_FORMATS } from 'shared/constants/messages';
|
||||
import { convertWavToMp3 } from './utils/mp3ConversionUtils';
|
||||
|
||||
WaveSurfer.microphone = MicrophonePlugin;
|
||||
|
||||
const RECORDER_CONFIG = {
|
||||
[AUDIO_FORMATS.WAV]: {
|
||||
audioMimeType: 'audio/wav',
|
||||
audioWorkerURL: waveWorker,
|
||||
},
|
||||
[AUDIO_FORMATS.MP3]: {
|
||||
audioMimeType: 'audio/wav',
|
||||
audioWorkerURL: waveWorker,
|
||||
},
|
||||
[AUDIO_FORMATS.OGG]: {
|
||||
audioMimeType: 'audio/ogg',
|
||||
audioWorkerURL: encoderWorker,
|
||||
},
|
||||
};
|
||||
|
||||
export default {
|
||||
name: 'WootAudioRecorder',
|
||||
mixins: [alertMixin],
|
||||
@@ -39,6 +56,10 @@ export default {
|
||||
type: String,
|
||||
default: AUDIO_FORMATS.WAV,
|
||||
},
|
||||
isAWhatsAppChannel: {
|
||||
type: Boolean,
|
||||
default: false,
|
||||
},
|
||||
},
|
||||
data() {
|
||||
return {
|
||||
@@ -88,14 +109,7 @@ export default {
|
||||
audioSampleRate: 48000,
|
||||
audioBitRate: 128,
|
||||
audioEngine: 'opus-recorder',
|
||||
...(this.audioRecordFormat === AUDIO_FORMATS.WAV && {
|
||||
audioMimeType: 'audio/wav',
|
||||
audioWorkerURL: waveWorker,
|
||||
}),
|
||||
...(this.audioRecordFormat === AUDIO_FORMATS.OGG && {
|
||||
audioMimeType: 'audio/ogg',
|
||||
audioWorkerURL: encoderWorker,
|
||||
}),
|
||||
...RECORDER_CONFIG[this.audioRecordFormat],
|
||||
},
|
||||
},
|
||||
},
|
||||
@@ -133,7 +147,11 @@ export default {
|
||||
methods: {
|
||||
deviceReady() {
|
||||
if (this.player.record().engine instanceof OpusRecorderEngine) {
|
||||
if (this.audioRecordFormat === AUDIO_FORMATS.WAV) {
|
||||
if (
|
||||
[AUDIO_FORMATS.WAV, AUDIO_FORMATS.MP3].includes(
|
||||
this.audioRecordFormat
|
||||
)
|
||||
) {
|
||||
this.player.record().engine.audioType = 'audio/wav';
|
||||
}
|
||||
}
|
||||
@@ -145,12 +163,16 @@ export default {
|
||||
stopRecord() {
|
||||
this.fireStateRecorderChanged('stopped');
|
||||
},
|
||||
finishRecord() {
|
||||
const file = new File(
|
||||
[this.player.recordedData],
|
||||
this.player.recordedData.name,
|
||||
{ type: this.player.recordedData.type }
|
||||
);
|
||||
async finishRecord() {
|
||||
let recordedContent = this.player.recordedData;
|
||||
let fileName = this.player.recordedData.name;
|
||||
let type = this.player.recordedData.type;
|
||||
if (this.audioRecordFormat === AUDIO_FORMATS.MP3) {
|
||||
recordedContent = await convertWavToMp3(this.player.recordedData);
|
||||
fileName = `${getUuid()}.mp3`;
|
||||
type = AUDIO_FORMATS.MP3;
|
||||
}
|
||||
const file = new File([recordedContent], fileName, { type });
|
||||
this.fireRecorderBlob(file);
|
||||
},
|
||||
progressRecord() {
|
||||
@@ -231,11 +253,13 @@ export default {
|
||||
@apply bg-transparent max-h-60 min-h-[3rem] pt-4 px-0 pb-0 resize-none;
|
||||
}
|
||||
}
|
||||
|
||||
// Added to override the default text and bg style to support dark and light mode.
|
||||
.video-js .vjs-control-bar,
|
||||
.vjs-record.video-js .vjs-control.vjs-record-indicator:before {
|
||||
@apply text-slate-600 dark:text-slate-200 bg-transparent dark:bg-transparent;
|
||||
}
|
||||
|
||||
// Added to fix div overlays the screen and takes over the button clicks
|
||||
// https://github.com/collab-project/videojs-record/issues/688
|
||||
// https://github.com/collab-project/videojs-record/pull/709
|
||||
|
||||
@@ -0,0 +1,53 @@
|
||||
import lamejs from 'lamejs';
|
||||
/**
|
||||
* Encodes a mono channel audio stream to MP3 format.
|
||||
* @param {number} channels - Number of audio channels.
|
||||
* @param {number} sampleRate - Sample rate in Hz.
|
||||
* @param {Int16Array} samples - Audio samples to be encoded.
|
||||
* @returns {Blob} - The MP3 encoded audio as a Blob.
|
||||
*/
|
||||
export const encodeToMP3 = (channels, sampleRate, samples) => {
|
||||
const outputBuffer = [];
|
||||
const encoder = new lamejs.Mp3Encoder(channels, sampleRate, 128);
|
||||
const maxSamplesPerFrame = 1152;
|
||||
|
||||
for (let offset = 0; offset < samples.length; offset += maxSamplesPerFrame) {
|
||||
const sliceEnd = Math.min(offset + maxSamplesPerFrame, samples.length);
|
||||
const sampleSlice = samples.subarray(offset, sliceEnd);
|
||||
const mp3Buffer = encoder.encodeBuffer(sampleSlice);
|
||||
|
||||
if (mp3Buffer.length > 0) {
|
||||
outputBuffer.push(new Int8Array(mp3Buffer));
|
||||
}
|
||||
}
|
||||
|
||||
const remainingData = encoder.flush();
|
||||
if (remainingData.length > 0) {
|
||||
outputBuffer.push(new Int8Array(remainingData));
|
||||
}
|
||||
|
||||
return new Blob(outputBuffer, { type: 'audio/mp3' });
|
||||
};
|
||||
|
||||
/**
|
||||
* Converts a WAV audio Blob to an MP3 format Blob.
|
||||
* @param {Blob} blob - The audio data in WAV format as a Blob.
|
||||
* @returns {Promise<Blob>} - A Blob containing the MP3 encoded audio.
|
||||
*/
|
||||
export const convertWavToMp3 = async blob => {
|
||||
try {
|
||||
const audioBuffer = await blob.arrayBuffer();
|
||||
const wavHeader = lamejs.WavHeader.readHeader(new DataView(audioBuffer));
|
||||
const samples = new Int16Array(
|
||||
audioBuffer,
|
||||
wavHeader.dataOffset,
|
||||
wavHeader.dataLen / 2
|
||||
);
|
||||
|
||||
return encodeToMP3(wavHeader.channels, wavHeader.sampleRate, samples);
|
||||
} catch (error) {
|
||||
// eslint-disable-next-line
|
||||
console.log('Failed to convert WAV to MP3:', error);
|
||||
throw new Error('Conversion from WAV to MP3 failed.');
|
||||
}
|
||||
};
|
||||
@@ -501,11 +501,10 @@ export default {
|
||||
return `draft-${this.conversationIdByRoute}-${this.replyType}`;
|
||||
},
|
||||
audioRecordFormat() {
|
||||
if (
|
||||
this.isAWhatsAppChannel ||
|
||||
this.isAPIInbox ||
|
||||
this.isATelegramChannel
|
||||
) {
|
||||
if (this.isAWhatsAppChannel || this.isATelegramChannel) {
|
||||
return AUDIO_FORMATS.MP3;
|
||||
}
|
||||
if (this.isAPIInbox) {
|
||||
return AUDIO_FORMATS.OGG;
|
||||
}
|
||||
return AUDIO_FORMATS.WAV;
|
||||
@@ -1253,6 +1252,7 @@ export default {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
.send-button {
|
||||
@apply mb-0;
|
||||
}
|
||||
@@ -1277,6 +1277,7 @@ export default {
|
||||
|
||||
.emoji-dialog--rtl {
|
||||
@apply left-[unset] -right-80;
|
||||
|
||||
&::before {
|
||||
transform: rotate(90deg);
|
||||
filter: drop-shadow(0px 4px 4px rgba(0, 0, 0, 0.08));
|
||||
|
||||
+61
-2
@@ -95,20 +95,40 @@
|
||||
<div v-if="allConversationsSelected" class="bulk-action__alert">
|
||||
{{ $t('BULK_ACTION.ALL_CONVERSATIONS_SELECTED_ALERT') }}
|
||||
</div>
|
||||
<woot-modal
|
||||
:show.sync="showCustomTimeSnoozeModal"
|
||||
:on-close="hideCustomSnoozeModal"
|
||||
>
|
||||
<custom-snooze-modal
|
||||
@close="hideCustomSnoozeModal"
|
||||
@choose-time="customSnoozeTime"
|
||||
/>
|
||||
</woot-modal>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import { getUnixTime } from 'date-fns';
|
||||
import { findSnoozeTime } from 'dashboard/helper/snoozeHelpers';
|
||||
import wootConstants from 'dashboard/constants/globals';
|
||||
import {
|
||||
CMD_BULK_ACTION_SNOOZE_CONVERSATION,
|
||||
CMD_BULK_ACTION_REOPEN_CONVERSATION,
|
||||
CMD_BULK_ACTION_RESOLVE_CONVERSATION,
|
||||
} from 'dashboard/routes/dashboard/commands/commandBarBusEvents';
|
||||
|
||||
import AgentSelector from './AgentSelector.vue';
|
||||
import UpdateActions from './UpdateActions.vue';
|
||||
import LabelActions from './LabelActions.vue';
|
||||
import TeamActions from './TeamActions.vue';
|
||||
import CustomSnoozeModal from 'dashboard/components/CustomSnoozeModal.vue';
|
||||
export default {
|
||||
components: {
|
||||
AgentSelector,
|
||||
UpdateActions,
|
||||
LabelActions,
|
||||
TeamActions,
|
||||
CustomSnoozeModal,
|
||||
},
|
||||
props: {
|
||||
conversations: {
|
||||
@@ -143,17 +163,56 @@ export default {
|
||||
showLabelActions: false,
|
||||
showTeamsList: false,
|
||||
popoverPositions: {},
|
||||
showCustomTimeSnoozeModal: false,
|
||||
};
|
||||
},
|
||||
mounted() {
|
||||
bus.$on(CMD_BULK_ACTION_SNOOZE_CONVERSATION, this.onCmdSnoozeConversation);
|
||||
bus.$on(CMD_BULK_ACTION_REOPEN_CONVERSATION, this.onCmdReopenConversation);
|
||||
bus.$on(
|
||||
CMD_BULK_ACTION_RESOLVE_CONVERSATION,
|
||||
this.onCmdResolveConversation
|
||||
);
|
||||
},
|
||||
destroyed() {
|
||||
bus.$off(CMD_BULK_ACTION_SNOOZE_CONVERSATION, this.onCmdSnoozeConversation);
|
||||
bus.$off(CMD_BULK_ACTION_REOPEN_CONVERSATION, this.onCmdReopenConversation);
|
||||
bus.$off(
|
||||
CMD_BULK_ACTION_RESOLVE_CONVERSATION,
|
||||
this.onCmdResolveConversation
|
||||
);
|
||||
},
|
||||
methods: {
|
||||
onCmdSnoozeConversation(snoozeType) {
|
||||
if (snoozeType === wootConstants.SNOOZE_OPTIONS.UNTIL_CUSTOM_TIME) {
|
||||
this.showCustomTimeSnoozeModal = true;
|
||||
} else {
|
||||
this.updateConversations('snoozed', findSnoozeTime(snoozeType) || null);
|
||||
}
|
||||
},
|
||||
onCmdReopenConversation() {
|
||||
this.updateConversations('open', null);
|
||||
},
|
||||
onCmdResolveConversation() {
|
||||
this.updateConversations('resolved', null);
|
||||
},
|
||||
customSnoozeTime(customSnoozedTime) {
|
||||
this.showCustomTimeSnoozeModal = false;
|
||||
if (customSnoozedTime) {
|
||||
this.updateConversations('snoozed', getUnixTime(customSnoozedTime));
|
||||
}
|
||||
},
|
||||
hideCustomSnoozeModal() {
|
||||
this.showCustomTimeSnoozeModal = false;
|
||||
},
|
||||
selectAll(e) {
|
||||
this.$emit('select-all-conversations', e.target.checked);
|
||||
},
|
||||
submit(agent) {
|
||||
this.$emit('assign-agent', agent);
|
||||
},
|
||||
updateConversations(status) {
|
||||
this.$emit('update-conversations', status);
|
||||
updateConversations(status, snoozedUntil) {
|
||||
this.$emit('update-conversations', status, snoozedUntil);
|
||||
},
|
||||
assignLabels(labels) {
|
||||
this.$emit('assign-labels', labels);
|
||||
|
||||
+93
-118
@@ -1,12 +1,98 @@
|
||||
<script setup>
|
||||
import { useI18n } from 'dashboard/composables/useI18n';
|
||||
import { ref } from 'vue';
|
||||
|
||||
import WootDropdownItem from 'shared/components/ui/dropdown/DropdownItem.vue';
|
||||
import WootDropdownMenu from 'shared/components/ui/dropdown/DropdownMenu.vue';
|
||||
|
||||
const { t } = useI18n();
|
||||
|
||||
const emits = defineEmits(['update', 'close']);
|
||||
|
||||
const props = defineProps({
|
||||
selectedInboxes: {
|
||||
type: Array,
|
||||
default: () => [],
|
||||
},
|
||||
conversationCount: {
|
||||
type: Number,
|
||||
default: 0,
|
||||
},
|
||||
showResolve: {
|
||||
type: Boolean,
|
||||
default: true,
|
||||
},
|
||||
showReopen: {
|
||||
type: Boolean,
|
||||
default: true,
|
||||
},
|
||||
showSnooze: {
|
||||
type: Boolean,
|
||||
default: true,
|
||||
},
|
||||
});
|
||||
|
||||
const actions = ref([
|
||||
{ icon: 'checkmark', key: 'resolved' },
|
||||
{ icon: 'arrow-redo', key: 'open' },
|
||||
{ icon: 'send-clock', key: 'snoozed' },
|
||||
]);
|
||||
|
||||
const updateConversations = key => {
|
||||
if (key === 'snoozed') {
|
||||
// If the user clicks on the snooze option from the bulk action change status dropdown.
|
||||
// Open the snooze option for bulk action in the cmd bar.
|
||||
const ninja = document.querySelector('ninja-keys');
|
||||
ninja?.open({ parent: 'bulk_action_snooze_conversation' });
|
||||
} else {
|
||||
emits('update', key);
|
||||
}
|
||||
};
|
||||
|
||||
const onClose = () => {
|
||||
emits('close');
|
||||
};
|
||||
|
||||
const showAction = key => {
|
||||
const actionsMap = {
|
||||
resolved: props.showResolve,
|
||||
open: props.showReopen,
|
||||
snoozed: props.showSnooze,
|
||||
};
|
||||
return actionsMap[key] || false;
|
||||
};
|
||||
|
||||
const actionLabel = key => {
|
||||
const labelsMap = {
|
||||
resolved: t('CONVERSATION.HEADER.RESOLVE_ACTION'),
|
||||
open: t('CONVERSATION.HEADER.REOPEN_ACTION'),
|
||||
snoozed: t('BULK_ACTION.UPDATE.SNOOZE_UNTIL'),
|
||||
};
|
||||
return labelsMap[key] || '';
|
||||
};
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<div v-on-clickaway="onClose" class="actions-container">
|
||||
<div class="triangle">
|
||||
<div
|
||||
v-on-clickaway="onClose"
|
||||
class="absolute right-2 top-12 origin-top-right w-auto z-20 bg-white dark:bg-slate-800 rounded-lg border border-solid border-slate-50 dark:border-slate-700 shadow-md"
|
||||
>
|
||||
<div
|
||||
class="right-[var(--triangle-position)] block z-10 absolute text-left -top-3"
|
||||
>
|
||||
<svg height="12" viewBox="0 0 24 12" width="24">
|
||||
<path d="M20 12l-8-8-12 12" fill-rule="evenodd" stroke-width="1px" />
|
||||
<path
|
||||
d="M20 12l-8-8-12 12"
|
||||
fill-rule="evenodd"
|
||||
stroke-width="1px"
|
||||
class="fill-white dark:fill-slate-800 stroke-slate-50 dark:stroke-slate-600/50"
|
||||
/>
|
||||
</svg>
|
||||
</div>
|
||||
<div class="header flex items-center justify-between">
|
||||
<span>{{ $t('BULK_ACTION.UPDATE.CHANGE_STATUS') }}</span>
|
||||
<div class="p-2.5 flex gap-1 items-center justify-between">
|
||||
<span class="text-sm font-medium text-slate-600 dark:text-slate-100">
|
||||
{{ $t('BULK_ACTION.UPDATE.CHANGE_STATUS') }}
|
||||
</span>
|
||||
<woot-button
|
||||
size="tiny"
|
||||
variant="clear"
|
||||
@@ -15,8 +101,8 @@
|
||||
@click="onClose"
|
||||
/>
|
||||
</div>
|
||||
<div class="container">
|
||||
<woot-dropdown-menu>
|
||||
<div class="px-2.5 pt-0 pb-2.5">
|
||||
<woot-dropdown-menu class="m-0 list-none">
|
||||
<template v-for="action in actions">
|
||||
<woot-dropdown-item v-if="showAction(action.key)" :key="action.key">
|
||||
<woot-button
|
||||
@@ -34,114 +120,3 @@
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import WootDropdownItem from 'shared/components/ui/dropdown/DropdownItem.vue';
|
||||
import WootDropdownMenu from 'shared/components/ui/dropdown/DropdownMenu.vue';
|
||||
|
||||
export default {
|
||||
components: {
|
||||
WootDropdownItem,
|
||||
WootDropdownMenu,
|
||||
},
|
||||
props: {
|
||||
selectedInboxes: {
|
||||
type: Array,
|
||||
default: () => [],
|
||||
},
|
||||
conversationCount: {
|
||||
type: Number,
|
||||
default: 0,
|
||||
},
|
||||
showResolve: {
|
||||
type: Boolean,
|
||||
default: true,
|
||||
},
|
||||
showReopen: {
|
||||
type: Boolean,
|
||||
default: true,
|
||||
},
|
||||
showSnooze: {
|
||||
type: Boolean,
|
||||
default: true,
|
||||
},
|
||||
},
|
||||
data() {
|
||||
return {
|
||||
query: '',
|
||||
selectedAction: null,
|
||||
actions: [
|
||||
{
|
||||
icon: 'checkmark',
|
||||
key: 'resolved',
|
||||
},
|
||||
{
|
||||
icon: 'arrow-redo',
|
||||
key: 'open',
|
||||
},
|
||||
{
|
||||
icon: 'send-clock',
|
||||
key: 'snoozed',
|
||||
},
|
||||
],
|
||||
};
|
||||
},
|
||||
methods: {
|
||||
updateConversations(key) {
|
||||
this.$emit('update', key);
|
||||
},
|
||||
goBack() {
|
||||
this.selectedAgent = null;
|
||||
},
|
||||
onClose() {
|
||||
this.$emit('close');
|
||||
},
|
||||
showAction(key) {
|
||||
const actionsMap = {
|
||||
resolved: this.showResolve,
|
||||
open: this.showReopen,
|
||||
snoozed: this.showSnooze,
|
||||
};
|
||||
return actionsMap[key] || false;
|
||||
},
|
||||
actionLabel(key) {
|
||||
const labelsMap = {
|
||||
resolved: this.$t('CONVERSATION.HEADER.RESOLVE_ACTION'),
|
||||
open: this.$t('CONVERSATION.HEADER.REOPEN_ACTION'),
|
||||
snoozed: this.$t('BULK_ACTION.UPDATE.SNOOZE_UNTIL_NEXT_REPLY'),
|
||||
};
|
||||
return labelsMap[key] || '';
|
||||
},
|
||||
},
|
||||
};
|
||||
</script>
|
||||
|
||||
<style scoped lang="scss">
|
||||
.actions-container {
|
||||
@apply absolute right-2 top-12 origin-top-right w-auto z-20 bg-white dark:bg-slate-800 rounded-lg border border-solid border-slate-50 dark:border-slate-700 shadow-md;
|
||||
|
||||
.header {
|
||||
@apply p-2.5;
|
||||
|
||||
span {
|
||||
@apply text-sm font-medium;
|
||||
}
|
||||
}
|
||||
.container {
|
||||
@apply px-2.5 pt-0 pb-2.5;
|
||||
}
|
||||
|
||||
.triangle {
|
||||
right: var(--triangle-position);
|
||||
@apply block z-10 absolute text-left -top-3;
|
||||
|
||||
svg path {
|
||||
@apply fill-white dark:fill-slate-800 stroke-slate-50 dark:stroke-slate-600/50;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
ul {
|
||||
@apply m-0 list-none;
|
||||
}
|
||||
</style>
|
||||
|
||||
@@ -17,7 +17,7 @@
|
||||
"AGENT_LIST_LOADING": "Loading agents",
|
||||
"UPDATE": {
|
||||
"CHANGE_STATUS": "Change status",
|
||||
"SNOOZE_UNTIL_NEXT_REPLY": "Snooze until next reply.",
|
||||
"SNOOZE_UNTIL": "Snooze",
|
||||
"UPDATE_SUCCESFUL": "Conversation status updated successfully.",
|
||||
"UPDATE_FAILED": "Failed to update conversations. Please try again."
|
||||
},
|
||||
|
||||
@@ -84,6 +84,7 @@
|
||||
"CONFIRM": {
|
||||
"TITLE": "Export Contacts",
|
||||
"MESSAGE": "Are you sure you want to export all contacts?",
|
||||
"FILTERED_MESSAGE": "Are you sure you want to export all the filtered contacts?",
|
||||
"YES": "Yes, Export",
|
||||
"NO": "No, Cancel"
|
||||
}
|
||||
|
||||
@@ -107,6 +107,7 @@
|
||||
"GENERAL": "General",
|
||||
"REPORTS": "Reports",
|
||||
"CONVERSATION": "Conversation",
|
||||
"BULK_ACTIONS": "Bulk Actions",
|
||||
"CHANGE_ASSIGNEE": "Change Assignee",
|
||||
"CHANGE_PRIORITY": "Change Priority",
|
||||
"CHANGE_TEAM": "Change Team",
|
||||
|
||||
@@ -0,0 +1,151 @@
|
||||
import { mapGetters } from 'vuex';
|
||||
import wootConstants from 'dashboard/constants/globals';
|
||||
|
||||
import {
|
||||
CMD_BULK_ACTION_SNOOZE_CONVERSATION,
|
||||
CMD_BULK_ACTION_REOPEN_CONVERSATION,
|
||||
CMD_BULK_ACTION_RESOLVE_CONVERSATION,
|
||||
} from './commandBarBusEvents';
|
||||
import {
|
||||
ICON_SNOOZE_CONVERSATION,
|
||||
ICON_REOPEN_CONVERSATION,
|
||||
ICON_RESOLVE_CONVERSATION,
|
||||
} from './CommandBarIcons';
|
||||
|
||||
const SNOOZE_OPTIONS = wootConstants.SNOOZE_OPTIONS;
|
||||
|
||||
export const SNOOZE_CONVERSATION_BULK_ACTIONS = [
|
||||
{
|
||||
id: 'bulk_action_snooze_conversation',
|
||||
title: 'COMMAND_BAR.COMMANDS.SNOOZE_CONVERSATION',
|
||||
section: 'COMMAND_BAR.SECTIONS.BULK_ACTIONS',
|
||||
icon: ICON_SNOOZE_CONVERSATION,
|
||||
children: Object.values(SNOOZE_OPTIONS),
|
||||
},
|
||||
|
||||
{
|
||||
id: SNOOZE_OPTIONS.UNTIL_NEXT_REPLY,
|
||||
title: 'COMMAND_BAR.COMMANDS.UNTIL_NEXT_REPLY',
|
||||
parent: 'bulk_action_snooze_conversation',
|
||||
section: 'COMMAND_BAR.SECTIONS.BULK_ACTIONS',
|
||||
icon: ICON_SNOOZE_CONVERSATION,
|
||||
handler: () =>
|
||||
bus.$emit(
|
||||
CMD_BULK_ACTION_SNOOZE_CONVERSATION,
|
||||
SNOOZE_OPTIONS.UNTIL_NEXT_REPLY
|
||||
),
|
||||
},
|
||||
{
|
||||
id: SNOOZE_OPTIONS.AN_HOUR_FROM_NOW,
|
||||
title: 'COMMAND_BAR.COMMANDS.AN_HOUR_FROM_NOW',
|
||||
parent: 'bulk_action_snooze_conversation',
|
||||
section: 'COMMAND_BAR.SECTIONS.BULK_ACTIONS',
|
||||
icon: ICON_SNOOZE_CONVERSATION,
|
||||
handler: () =>
|
||||
bus.$emit(
|
||||
CMD_BULK_ACTION_SNOOZE_CONVERSATION,
|
||||
SNOOZE_OPTIONS.AN_HOUR_FROM_NOW
|
||||
),
|
||||
},
|
||||
{
|
||||
id: SNOOZE_OPTIONS.UNTIL_TOMORROW,
|
||||
title: 'COMMAND_BAR.COMMANDS.UNTIL_TOMORROW',
|
||||
section: 'COMMAND_BAR.SECTIONS.BULK_ACTIONS',
|
||||
parent: 'bulk_action_snooze_conversation',
|
||||
icon: ICON_SNOOZE_CONVERSATION,
|
||||
handler: () =>
|
||||
bus.$emit(
|
||||
CMD_BULK_ACTION_SNOOZE_CONVERSATION,
|
||||
SNOOZE_OPTIONS.UNTIL_TOMORROW
|
||||
),
|
||||
},
|
||||
{
|
||||
id: SNOOZE_OPTIONS.UNTIL_NEXT_WEEK,
|
||||
title: 'COMMAND_BAR.COMMANDS.UNTIL_NEXT_WEEK',
|
||||
section: 'COMMAND_BAR.SECTIONS.BULK_ACTIONS',
|
||||
parent: 'bulk_action_snooze_conversation',
|
||||
icon: ICON_SNOOZE_CONVERSATION,
|
||||
handler: () =>
|
||||
bus.$emit(
|
||||
CMD_BULK_ACTION_SNOOZE_CONVERSATION,
|
||||
SNOOZE_OPTIONS.UNTIL_NEXT_WEEK
|
||||
),
|
||||
},
|
||||
{
|
||||
id: SNOOZE_OPTIONS.UNTIL_NEXT_MONTH,
|
||||
title: 'COMMAND_BAR.COMMANDS.UNTIL_NEXT_MONTH',
|
||||
section: 'COMMAND_BAR.SECTIONS.BULK_ACTIONS',
|
||||
parent: 'bulk_action_snooze_conversation',
|
||||
icon: ICON_SNOOZE_CONVERSATION,
|
||||
handler: () =>
|
||||
bus.$emit(
|
||||
CMD_BULK_ACTION_SNOOZE_CONVERSATION,
|
||||
SNOOZE_OPTIONS.UNTIL_NEXT_MONTH
|
||||
),
|
||||
},
|
||||
{
|
||||
id: SNOOZE_OPTIONS.UNTIL_CUSTOM_TIME,
|
||||
title: 'COMMAND_BAR.COMMANDS.CUSTOM',
|
||||
section: 'COMMAND_BAR.SECTIONS.BULK_ACTIONS',
|
||||
parent: 'bulk_action_snooze_conversation',
|
||||
icon: ICON_SNOOZE_CONVERSATION,
|
||||
handler: () =>
|
||||
bus.$emit(
|
||||
CMD_BULK_ACTION_SNOOZE_CONVERSATION,
|
||||
SNOOZE_OPTIONS.UNTIL_CUSTOM_TIME
|
||||
),
|
||||
},
|
||||
];
|
||||
|
||||
export const RESOLVED_CONVERSATION_BULK_ACTIONS = [
|
||||
{
|
||||
id: 'bulk_action_reopen_conversation',
|
||||
title: 'COMMAND_BAR.COMMANDS.REOPEN_CONVERSATION',
|
||||
section: 'COMMAND_BAR.SECTIONS.BULK_ACTIONS',
|
||||
icon: ICON_REOPEN_CONVERSATION,
|
||||
handler: () => bus.$emit(CMD_BULK_ACTION_REOPEN_CONVERSATION),
|
||||
},
|
||||
];
|
||||
|
||||
export const OPEN_CONVERSATION_BULK_ACTIONS = [
|
||||
{
|
||||
id: 'bulk_action_resolve_conversation',
|
||||
title: 'COMMAND_BAR.COMMANDS.RESOLVE_CONVERSATION',
|
||||
section: 'COMMAND_BAR.SECTIONS.BULK_ACTIONS',
|
||||
icon: ICON_RESOLVE_CONVERSATION,
|
||||
handler: () => bus.$emit(CMD_BULK_ACTION_RESOLVE_CONVERSATION),
|
||||
},
|
||||
];
|
||||
|
||||
export default {
|
||||
computed: {
|
||||
...mapGetters({
|
||||
selectedConversations: 'bulkActions/getSelectedConversationIds',
|
||||
}),
|
||||
bulkActionsHotKeys() {
|
||||
let actions = [];
|
||||
if (this.selectedConversations.length > 0) {
|
||||
actions = [
|
||||
...SNOOZE_CONVERSATION_BULK_ACTIONS,
|
||||
...RESOLVED_CONVERSATION_BULK_ACTIONS,
|
||||
...OPEN_CONVERSATION_BULK_ACTIONS,
|
||||
];
|
||||
}
|
||||
return this.prepareActions(actions);
|
||||
},
|
||||
},
|
||||
watch: {
|
||||
selectedConversations() {
|
||||
this.setCommandbarData();
|
||||
},
|
||||
},
|
||||
methods: {
|
||||
prepareActions(actions) {
|
||||
return actions.map(action => ({
|
||||
...action,
|
||||
title: this.$t(action.title),
|
||||
section: this.$t(action.section),
|
||||
}));
|
||||
},
|
||||
},
|
||||
};
|
||||
@@ -16,5 +16,13 @@ export const CMD_RESOLVE_CONVERSATION = 'CMD_RESOLVE_CONVERSATION';
|
||||
export const CMD_SNOOZE_CONVERSATION = 'CMD_SNOOZE_CONVERSATION';
|
||||
export const CMD_AI_ASSIST = 'CMD_AI_ASSIST';
|
||||
|
||||
// Bulk Actions
|
||||
export const CMD_BULK_ACTION_SNOOZE_CONVERSATION =
|
||||
'CMD_BULK_ACTION_SNOOZE_CONVERSATION';
|
||||
export const CMD_BULK_ACTION_REOPEN_CONVERSATION =
|
||||
'CMD_BULK_ACTION_REOPEN_CONVERSATION';
|
||||
export const CMD_BULK_ACTION_RESOLVE_CONVERSATION =
|
||||
'CMD_BULK_ACTION_RESOLVE_CONVERSATION';
|
||||
|
||||
// Inbox Commands (Notifications)
|
||||
export const CMD_SNOOZE_NOTIFICATION = 'CMD_SNOOZE_NOTIFICATION';
|
||||
|
||||
@@ -12,6 +12,7 @@
|
||||
<script>
|
||||
import 'ninja-keys';
|
||||
import conversationHotKeysMixin from './conversationHotKeys';
|
||||
import bulkActionsHotKeysMixin from './bulkActionsHotKeys';
|
||||
import inboxHotKeysMixin from './inboxHotKeys';
|
||||
import goToCommandHotKeys from './goToCommandHotKeys';
|
||||
import appearanceHotKeys from './appearanceHotKeys';
|
||||
@@ -26,6 +27,7 @@ export default {
|
||||
adminMixin,
|
||||
agentMixin,
|
||||
conversationHotKeysMixin,
|
||||
bulkActionsHotKeysMixin,
|
||||
inboxHotKeysMixin,
|
||||
conversationLabelMixin,
|
||||
conversationTeamMixin,
|
||||
@@ -46,6 +48,7 @@ export default {
|
||||
return [
|
||||
...this.inboxHotKeys,
|
||||
...this.conversationHotKeys,
|
||||
...this.bulkActionsHotKeys,
|
||||
...this.goToCommandHotKeys,
|
||||
...this.goToAppearanceHotKeys,
|
||||
];
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
<template>
|
||||
<div class="w-full flex flex-row">
|
||||
<div class="flex flex-row w-full">
|
||||
<div class="flex flex-col h-full" :class="wrapClass">
|
||||
<contacts-header
|
||||
:search-query="searchQuery"
|
||||
@@ -391,8 +391,19 @@ export default {
|
||||
this.fetchContacts(this.pageParameter);
|
||||
},
|
||||
onExportSubmit() {
|
||||
let query = { payload: [] };
|
||||
|
||||
if (this.hasActiveSegments) {
|
||||
query = this.activeSegment.query;
|
||||
} else if (this.hasAppliedFilters) {
|
||||
query = filterQueryGenerator(this.getAppliedContactFilters);
|
||||
}
|
||||
|
||||
try {
|
||||
this.$store.dispatch('contacts/export');
|
||||
this.$store.dispatch('contacts/export', {
|
||||
...query,
|
||||
label: this.label,
|
||||
});
|
||||
this.showAlert(this.$t('EXPORT_CONTACTS.SUCCESS_MESSAGE'));
|
||||
} catch (error) {
|
||||
this.showAlert(
|
||||
|
||||
@@ -1,12 +1,12 @@
|
||||
<template>
|
||||
<header
|
||||
class="bg-white dark:bg-slate-900 border-b border-slate-50 dark:border-slate-800"
|
||||
class="bg-white border-b dark:bg-slate-900 border-slate-50 dark:border-slate-800"
|
||||
>
|
||||
<div class="flex justify-between w-full py-2 px-4">
|
||||
<div class="flex justify-between w-full px-4 py-2">
|
||||
<div class="flex items-center justify-center max-w-full min-w-[6.25rem]">
|
||||
<woot-sidemenu-icon />
|
||||
<h1
|
||||
class="m-0 text-xl text-slate-900 dark:text-slate-100 overflow-hidden whitespace-nowrap text-ellipsis my-0 mx-2"
|
||||
class="m-0 mx-2 my-0 overflow-hidden text-xl text-slate-900 dark:text-slate-100 whitespace-nowrap text-ellipsis"
|
||||
>
|
||||
{{ headerTitle }}
|
||||
</h1>
|
||||
@@ -18,7 +18,7 @@
|
||||
<div class="flex items-center absolute h-full left-2.5">
|
||||
<fluent-icon
|
||||
icon="search"
|
||||
class="h-5 leading-9 text-sm text-slate-700 dark:text-slate-200"
|
||||
class="h-5 text-sm leading-9 text-slate-700 dark:text-slate-200"
|
||||
/>
|
||||
</div>
|
||||
<input
|
||||
@@ -59,7 +59,7 @@
|
||||
<div v-if="!hasActiveSegments" class="relative">
|
||||
<div
|
||||
v-if="hasAppliedFilters"
|
||||
class="absolute h-2 w-2 top-1 right-3 bg-slate-500 dark:bg-slate-500 rounded-full"
|
||||
class="absolute w-2 h-2 rounded-full top-1 right-3 bg-slate-500 dark:bg-slate-500"
|
||||
/>
|
||||
<woot-button
|
||||
class="clear"
|
||||
@@ -116,7 +116,7 @@
|
||||
<woot-confirm-modal
|
||||
ref="confirmExportContactsDialog"
|
||||
:title="$t('EXPORT_CONTACTS.CONFIRM.TITLE')"
|
||||
:description="$t('EXPORT_CONTACTS.CONFIRM.MESSAGE')"
|
||||
:description="exportDescription"
|
||||
:confirm-label="$t('EXPORT_CONTACTS.CONFIRM.YES')"
|
||||
:cancel-label="$t('EXPORT_CONTACTS.CONFIRM.NO')"
|
||||
/>
|
||||
@@ -162,6 +162,11 @@ export default {
|
||||
hasActiveSegments() {
|
||||
return this.segmentsId !== 0;
|
||||
},
|
||||
exportDescription() {
|
||||
return this.hasAppliedFilters
|
||||
? this.$t('EXPORT_CONTACTS.CONFIRM.FILTERED_MESSAGE')
|
||||
: this.$t('EXPORT_CONTACTS.CONFIRM.MESSAGE');
|
||||
},
|
||||
},
|
||||
methods: {
|
||||
onToggleSegmentsModal() {
|
||||
|
||||
+3
-1
@@ -111,7 +111,9 @@ export default {
|
||||
},
|
||||
});
|
||||
} catch (error) {
|
||||
this.showAlert(this.$t('INBOX_MGMT.ADD.WHATSAPP.API.ERROR_MESSAGE'));
|
||||
this.showAlert(
|
||||
error.message || this.$t('INBOX_MGMT.ADD.WHATSAPP.API.ERROR_MESSAGE')
|
||||
);
|
||||
}
|
||||
},
|
||||
},
|
||||
|
||||
@@ -155,7 +155,9 @@ export default {
|
||||
},
|
||||
});
|
||||
} catch (error) {
|
||||
this.showAlert(this.$t('INBOX_MGMT.ADD.WHATSAPP.API.ERROR_MESSAGE'));
|
||||
this.showAlert(
|
||||
error.message || this.$t('INBOX_MGMT.ADD.WHATSAPP.API.ERROR_MESSAGE')
|
||||
);
|
||||
}
|
||||
},
|
||||
},
|
||||
|
||||
@@ -86,7 +86,8 @@ export default {
|
||||
});
|
||||
} catch (error) {
|
||||
this.showAlert(
|
||||
this.$t('INBOX_MGMT.ADD.TELEGRAM_CHANNEL.API.ERROR_MESSAGE')
|
||||
error.message ||
|
||||
this.$t('INBOX_MGMT.ADD.TELEGRAM_CHANNEL.API.ERROR_MESSAGE')
|
||||
);
|
||||
}
|
||||
},
|
||||
|
||||
@@ -16,9 +16,6 @@
|
||||
<option value="twilio">
|
||||
{{ $t('INBOX_MGMT.ADD.WHATSAPP.PROVIDERS.TWILIO') }}
|
||||
</option>
|
||||
<option value="360dialog">
|
||||
{{ $t('INBOX_MGMT.ADD.WHATSAPP.PROVIDERS.360_DIALOG') }}
|
||||
</option>
|
||||
</select>
|
||||
</label>
|
||||
</div>
|
||||
|
||||
@@ -2,15 +2,15 @@
|
||||
<tr>
|
||||
<td>{{ macro.name }}</td>
|
||||
<td>
|
||||
<div class="avatar-container">
|
||||
<thumbnail :username="macro.created_by.name" size="24px" />
|
||||
<span>{{ macro.created_by.name }}</span>
|
||||
<div v-if="macro.created_by" class="avatar-container">
|
||||
<thumbnail :username="createdByName" size="24px" />
|
||||
<span>{{ createdByName }}</span>
|
||||
</div>
|
||||
</td>
|
||||
<td>
|
||||
<div class="avatar-container">
|
||||
<thumbnail :username="macro.updated_by.name" size="24px" />
|
||||
<span>{{ macro.updated_by.name }}</span>
|
||||
<div v-if="macro.updated_by" class="avatar-container">
|
||||
<thumbnail :username="updatedByName" size="24px" />
|
||||
<span>{{ updatedByName }}</span>
|
||||
</div>
|
||||
</td>
|
||||
<td>{{ visibilityLabel }}</td>
|
||||
@@ -53,6 +53,14 @@ export default {
|
||||
},
|
||||
},
|
||||
computed: {
|
||||
createdByName() {
|
||||
const createdBy = this.macro.created_by;
|
||||
return createdBy.available_name ?? createdBy.email ?? '';
|
||||
},
|
||||
updatedByName() {
|
||||
const updatedBy = this.macro.updated_by;
|
||||
return updatedBy.available_name ?? updatedBy.email ?? '';
|
||||
},
|
||||
visibilityLabel() {
|
||||
return this.macro.visibility === 'global'
|
||||
? this.$t('MACROS.EDITOR.VISIBILITY.GLOBAL.LABEL')
|
||||
|
||||
@@ -38,7 +38,7 @@ const signature = ref(props.messageSignature);
|
||||
const emit = defineEmits(['update-signature']);
|
||||
|
||||
watch(
|
||||
() => props.messageSignature,
|
||||
() => props.messageSignature ?? '',
|
||||
newValue => {
|
||||
signature.value = newValue;
|
||||
}
|
||||
|
||||
@@ -2,6 +2,7 @@ import types from '../mutation-types';
|
||||
import BulkActionsAPI from '../../api/bulkActions';
|
||||
|
||||
export const state = {
|
||||
selectedConversationIds: [],
|
||||
uiFlags: {
|
||||
isUpdating: false,
|
||||
},
|
||||
@@ -11,6 +12,9 @@ export const getters = {
|
||||
getUIFlags(_state) {
|
||||
return _state.uiFlags;
|
||||
},
|
||||
getSelectedConversationIds(_state) {
|
||||
return _state.selectedConversationIds;
|
||||
},
|
||||
};
|
||||
|
||||
export const actions = {
|
||||
@@ -24,6 +28,15 @@ export const actions = {
|
||||
commit(types.SET_BULK_ACTIONS_FLAG, { isUpdating: false });
|
||||
}
|
||||
},
|
||||
setSelectedConversationIds({ commit }, id) {
|
||||
commit(types.SET_SELECTED_CONVERSATION_IDS, id);
|
||||
},
|
||||
removeSelectedConversationIds({ commit }, id) {
|
||||
commit(types.REMOVE_SELECTED_CONVERSATION_IDS, id);
|
||||
},
|
||||
clearSelectedConversationIds({ commit }) {
|
||||
commit(types.CLEAR_SELECTED_CONVERSATION_IDS);
|
||||
},
|
||||
};
|
||||
|
||||
export const mutations = {
|
||||
@@ -33,6 +46,23 @@ export const mutations = {
|
||||
...data,
|
||||
};
|
||||
},
|
||||
[types.SET_SELECTED_CONVERSATION_IDS](_state, ids) {
|
||||
// Check if ids is an array, if not, convert it to an array
|
||||
const idsArray = Array.isArray(ids) ? ids : [ids];
|
||||
|
||||
// Concatenate the new IDs ensuring no duplicates
|
||||
_state.selectedConversationIds = [
|
||||
...new Set([..._state.selectedConversationIds, ...idsArray]),
|
||||
];
|
||||
},
|
||||
[types.REMOVE_SELECTED_CONVERSATION_IDS](_state, id) {
|
||||
_state.selectedConversationIds = _state.selectedConversationIds.filter(
|
||||
item => item !== id
|
||||
);
|
||||
},
|
||||
[types.CLEAR_SELECTED_CONVERSATION_IDS](_state) {
|
||||
_state.selectedConversationIds = [];
|
||||
},
|
||||
};
|
||||
|
||||
export default {
|
||||
|
||||
@@ -138,9 +138,10 @@ export const actions = {
|
||||
}
|
||||
},
|
||||
|
||||
export: async ({ commit }) => {
|
||||
export: async ({ commit }, { payload, label }) => {
|
||||
try {
|
||||
await ContactAPI.exportContacts();
|
||||
await ContactAPI.exportContacts({ payload, label });
|
||||
|
||||
commit(types.SET_CONTACT_UI_FLAG, { isCreating: false });
|
||||
} catch (error) {
|
||||
commit(types.SET_CONTACT_UI_FLAG, { isCreating: false });
|
||||
|
||||
@@ -25,4 +25,28 @@ describe('#actions', () => {
|
||||
]);
|
||||
});
|
||||
});
|
||||
describe('#setSelectedConversationIds', () => {
|
||||
it('sends correct actions if API is success', async () => {
|
||||
await actions.setSelectedConversationIds({ commit }, payload.ids);
|
||||
expect(commit.mock.calls).toEqual([
|
||||
[types.default.SET_SELECTED_CONVERSATION_IDS, payload.ids],
|
||||
]);
|
||||
});
|
||||
});
|
||||
describe('#removeSelectedConversationIds', () => {
|
||||
it('sends correct actions if API is success', async () => {
|
||||
await actions.removeSelectedConversationIds({ commit }, payload.ids);
|
||||
expect(commit.mock.calls).toEqual([
|
||||
[types.default.REMOVE_SELECTED_CONVERSATION_IDS, payload.ids],
|
||||
]);
|
||||
});
|
||||
});
|
||||
describe('#clearSelectedConversationIds', () => {
|
||||
it('sends correct actions if API is success', async () => {
|
||||
await actions.clearSelectedConversationIds({ commit });
|
||||
expect(commit.mock.calls).toEqual([
|
||||
[types.default.CLEAR_SELECTED_CONVERSATION_IDS],
|
||||
]);
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
@@ -11,4 +11,10 @@ describe('#getters', () => {
|
||||
isUpdating: false,
|
||||
});
|
||||
});
|
||||
it('getSelectedConversationIds', () => {
|
||||
const state = {
|
||||
selectedConversationIds: [1, 2, 3],
|
||||
};
|
||||
expect(getters.getSelectedConversationIds(state)).toEqual([1, 2, 3]);
|
||||
});
|
||||
});
|
||||
|
||||
@@ -9,4 +9,25 @@ describe('#mutations', () => {
|
||||
expect(state.uiFlags.isUpdating).toEqual(true);
|
||||
});
|
||||
});
|
||||
describe('#setSelectedConversationIds', () => {
|
||||
it('set selected conversation ids', () => {
|
||||
const state = { selectedConversationIds: [] };
|
||||
mutations[types.SET_SELECTED_CONVERSATION_IDS](state, [1, 2, 3]);
|
||||
expect(state.selectedConversationIds).toEqual([1, 2, 3]);
|
||||
});
|
||||
});
|
||||
describe('#removeSelectedConversationIds', () => {
|
||||
it('remove selected conversation ids', () => {
|
||||
const state = { selectedConversationIds: [1, 2, 3] };
|
||||
mutations[types.REMOVE_SELECTED_CONVERSATION_IDS](state, 1);
|
||||
expect(state.selectedConversationIds).toEqual([2, 3]);
|
||||
});
|
||||
});
|
||||
describe('#clearSelectedConversationIds', () => {
|
||||
it('clear selected conversation ids', () => {
|
||||
const state = { selectedConversationIds: [1, 2, 3] };
|
||||
mutations[types.CLEAR_SELECTED_CONVERSATION_IDS](state);
|
||||
expect(state.selectedConversationIds).toEqual([]);
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
@@ -160,6 +160,9 @@ export default {
|
||||
SET_CONVERSATION_LABELS_UI_FLAG: 'SET_CONVERSATION_LABELS_UI_FLAG',
|
||||
SET_CONVERSATION_LABELS: 'SET_CONVERSATION_LABELS',
|
||||
SET_BULK_CONVERSATION_LABELS: 'SET_BULK_CONVERSATION_LABELS',
|
||||
SET_SELECTED_CONVERSATION_IDS: 'SET_SELECTED_CONVERSATION_IDS',
|
||||
CLEAR_SELECTED_CONVERSATION_IDS: 'CLEAR_SELECTED_CONVERSATION_IDS',
|
||||
REMOVE_SELECTED_CONVERSATION_IDS: 'REMOVE_SELECTED_CONVERSATION_IDS',
|
||||
|
||||
// Reports
|
||||
SET_ACCOUNT_REPORTS: 'SET_ACCOUNT_REPORTS',
|
||||
|
||||
@@ -5,8 +5,10 @@ import Vue from 'vue';
|
||||
import { InitializationHelpers } from '../portal/portalHelpers';
|
||||
import VueDOMPurifyHTML from 'vue-dompurify-html';
|
||||
import { domPurifyConfig } from '../shared/helpers/HTMLSanitizer';
|
||||
import { directive as onClickaway } from 'vue-clickaway';
|
||||
|
||||
Vue.use(VueDOMPurifyHTML, domPurifyConfig);
|
||||
Vue.directive('on-clickaway', onClickaway);
|
||||
|
||||
Rails.start();
|
||||
Turbolinks.start();
|
||||
|
||||
@@ -10,14 +10,37 @@ import {
|
||||
getUserCookieName,
|
||||
hasUserKeys,
|
||||
} from '../sdk/cookieHelpers';
|
||||
import { addClasses, removeClasses } from '../sdk/DOMHelpers';
|
||||
import {
|
||||
addClasses,
|
||||
removeClasses,
|
||||
restoreWidgetInDOM,
|
||||
} from '../sdk/DOMHelpers';
|
||||
import { setCookieWithDomain } from '../sdk/cookieHelpers';
|
||||
import { SDK_SET_BUBBLE_VISIBILITY } from 'shared/constants/sharedFrameEvents';
|
||||
|
||||
const runSDK = ({ baseUrl, websiteToken }) => {
|
||||
if (window.$chatwoot) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (window.Turbo) {
|
||||
// if this is a Rails Turbo app
|
||||
document.addEventListener('turbo:before-render', event =>
|
||||
restoreWidgetInDOM(event.detail.newBody)
|
||||
);
|
||||
}
|
||||
|
||||
if (window.Turbolinks) {
|
||||
document.addEventListener('turbolinks:before-render', event => {
|
||||
restoreWidgetInDOM(event.data.newBody);
|
||||
});
|
||||
}
|
||||
|
||||
// if this is an astro app
|
||||
document.addEventListener('astro:before-swap', event =>
|
||||
restoreWidgetInDOM(event.newDocument.body)
|
||||
);
|
||||
|
||||
const chatwootSettings = window.chatwootSettings || {};
|
||||
let locale = chatwootSettings.locale;
|
||||
let baseDomain = chatwootSettings.baseDomain;
|
||||
|
||||
@@ -12,12 +12,15 @@ import {
|
||||
isPhoneNumberValidWithDialCode,
|
||||
} from 'shared/helpers/Validators';
|
||||
import router from '../widget/router';
|
||||
import { directive as onClickaway } from 'vue-clickaway';
|
||||
|
||||
import { domPurifyConfig } from '../shared/helpers/HTMLSanitizer';
|
||||
const PhoneInput = () => import('../widget/components/Form/PhoneInput');
|
||||
|
||||
Vue.use(VueI18n);
|
||||
Vue.use(Vuelidate);
|
||||
Vue.use(VueDOMPurifyHTML, domPurifyConfig);
|
||||
Vue.directive('on-clickaway', onClickaway);
|
||||
|
||||
const i18nConfig = new VueI18n({
|
||||
locale: 'en',
|
||||
|
||||
@@ -4,6 +4,7 @@ import Vue from 'vue';
|
||||
import PublicArticleSearch from './components/PublicArticleSearch.vue';
|
||||
import TableOfContents from './components/TableOfContents.vue';
|
||||
import { initializeTheme } from './portalThemeHelper.js';
|
||||
import { directive as onClickaway } from 'vue-clickaway';
|
||||
|
||||
export const getHeadingsfromTheArticle = () => {
|
||||
const rows = [];
|
||||
@@ -80,6 +81,9 @@ export const InitializationHelpers = {
|
||||
if (isSearchContainerAvailable) {
|
||||
new Vue({
|
||||
components: { PublicArticleSearch },
|
||||
directives: {
|
||||
'on-clickaway': onClickaway,
|
||||
},
|
||||
template: '<PublicArticleSearch />',
|
||||
}).$mount('#search-wrap');
|
||||
}
|
||||
|
||||
@@ -4,9 +4,28 @@ import { IFrameHelper } from './IFrameHelper';
|
||||
export const loadCSS = () => {
|
||||
const css = document.createElement('style');
|
||||
css.innerHTML = `${SDK_CSS}`;
|
||||
css.id = 'cw-widget-styles';
|
||||
document.body.appendChild(css);
|
||||
};
|
||||
|
||||
// This is a method specific to Turbo
|
||||
// The body replacing strategy removes Chatwoot styles
|
||||
// as well as the widget, this help us get it back
|
||||
export const restoreElement = (id, newBody) => {
|
||||
const element = document.getElementById(id);
|
||||
const newElement = newBody.querySelector(`#${id}`);
|
||||
|
||||
if (element && !newElement) {
|
||||
newBody.appendChild(element);
|
||||
}
|
||||
};
|
||||
|
||||
export const restoreWidgetInDOM = newBody => {
|
||||
restoreElement('cw-bubble-holder', newBody);
|
||||
restoreElement('cw-widget-holder', newBody);
|
||||
restoreElement('cw-widget-styles', newBody);
|
||||
};
|
||||
|
||||
export const addClasses = (elm, classes) => {
|
||||
elm.classList.add(...classes.split(' '));
|
||||
};
|
||||
|
||||
@@ -78,6 +78,7 @@ export const IFrameHelper = {
|
||||
}
|
||||
|
||||
addClasses(widgetHolder, holderClassName);
|
||||
widgetHolder.id = 'cw-widget-holder';
|
||||
widgetHolder.appendChild(iframe);
|
||||
body.appendChild(widgetHolder);
|
||||
IFrameHelper.initPostMessageCommunication();
|
||||
|
||||
@@ -61,6 +61,7 @@ export const createBubbleHolder = hideMessageBubble => {
|
||||
addClasses(bubbleHolder, 'woot-hidden');
|
||||
}
|
||||
addClasses(bubbleHolder, 'woot--bubble-holder');
|
||||
bubbleHolder.id = 'cw-bubble-holder';
|
||||
body.appendChild(bubbleHolder);
|
||||
};
|
||||
|
||||
|
||||
@@ -98,6 +98,7 @@ export const CSAT_RATINGS = [
|
||||
export const AUDIO_FORMATS = {
|
||||
WEBM: 'audio/webm',
|
||||
OGG: 'audio/ogg',
|
||||
MP3: 'audio/mp3',
|
||||
WAV: 'audio/wav',
|
||||
};
|
||||
|
||||
|
||||
@@ -26,7 +26,7 @@
|
||||
</button>
|
||||
</template>
|
||||
<script setup>
|
||||
import { computed, defineProps, useAttrs } from 'vue';
|
||||
import { computed, useAttrs } from 'vue';
|
||||
|
||||
const props = defineProps({
|
||||
variant: {
|
||||
|
||||
@@ -9,7 +9,7 @@
|
||||
</template>
|
||||
|
||||
<script setup>
|
||||
import { defineProps, defineEmits, computed } from 'vue';
|
||||
import { computed } from 'vue';
|
||||
|
||||
const props = defineProps({
|
||||
isChecked: {
|
||||
|
||||
@@ -1,21 +1,21 @@
|
||||
<template>
|
||||
<main
|
||||
class="flex flex-col bg-woot-25 min-h-screen w-full py-20 sm:px-6 lg:px-8 dark:bg-slate-900"
|
||||
class="flex flex-col w-full min-h-screen py-20 bg-woot-25 sm:px-6 lg:px-8 dark:bg-slate-900"
|
||||
>
|
||||
<section class="max-w-5xl mx-auto">
|
||||
<img
|
||||
:src="globalConfig.logo"
|
||||
:alt="globalConfig.installationName"
|
||||
class="mx-auto h-8 w-auto block dark:hidden"
|
||||
class="block w-auto h-8 mx-auto dark:hidden"
|
||||
/>
|
||||
<img
|
||||
v-if="globalConfig.logoDark"
|
||||
:src="globalConfig.logoDark"
|
||||
:alt="globalConfig.installationName"
|
||||
class="mx-auto h-8 w-auto hidden dark:block"
|
||||
class="hidden w-auto h-8 mx-auto dark:block"
|
||||
/>
|
||||
<h2
|
||||
class="mt-6 text-center text-3xl font-medium text-slate-900 dark:text-woot-50"
|
||||
class="mt-6 text-3xl font-medium text-center text-slate-900 dark:text-woot-50"
|
||||
>
|
||||
{{
|
||||
useInstallationName($t('LOGIN.TITLE'), globalConfig.installationName)
|
||||
@@ -23,10 +23,10 @@
|
||||
</h2>
|
||||
<p
|
||||
v-if="showSignupLink"
|
||||
class="mt-3 text-center text-sm text-slate-600 dark:text-slate-400"
|
||||
class="mt-3 text-sm text-center text-slate-600 dark:text-slate-400"
|
||||
>
|
||||
{{ $t('COMMON.OR') }}
|
||||
<router-link to="auth/signup" class="text-link lowercase">
|
||||
<router-link to="auth/signup" class="lowercase text-link">
|
||||
{{ $t('LOGIN.CREATE_NEW_ACCOUNT') }}
|
||||
</router-link>
|
||||
</p>
|
||||
@@ -68,7 +68,7 @@
|
||||
<p v-if="!globalConfig.disableUserProfileUpdate">
|
||||
<router-link
|
||||
to="auth/reset/password"
|
||||
class="text-link text-sm"
|
||||
class="text-sm text-link"
|
||||
tabindex="4"
|
||||
>
|
||||
{{ $t('LOGIN.FORGOT_PASSWORD') }}
|
||||
@@ -165,7 +165,7 @@ export default {
|
||||
const message = ERROR_MESSAGES[this.authError] ?? 'LOGIN.API.UNAUTH';
|
||||
this.showAlert(this.$t(message));
|
||||
// wait for idle state
|
||||
window.requestIdleCallback(() => {
|
||||
this.requestIdleCallbackPolyfill(() => {
|
||||
// Remove the error query param from the url
|
||||
const { query } = this.$route;
|
||||
this.$router.replace({ query: { ...query, error: undefined } });
|
||||
@@ -173,6 +173,19 @@ export default {
|
||||
}
|
||||
},
|
||||
methods: {
|
||||
// TODO: Remove this when Safari gets wider support
|
||||
// Ref: https://caniuse.com/requestidlecallback
|
||||
//
|
||||
requestIdleCallbackPolyfill(callback) {
|
||||
if (window.requestIdleCallback) {
|
||||
window.requestIdleCallback(callback);
|
||||
} else {
|
||||
// Fallback for safari
|
||||
// Using a delay of 0 allows the callback to be executed asynchronously
|
||||
// in the next available event loop iteration, similar to requestIdleCallback
|
||||
setTimeout(callback, 0);
|
||||
}
|
||||
},
|
||||
showAlert(message) {
|
||||
// Reset loading, current selected agent
|
||||
this.loginApi.showLoading = false;
|
||||
|
||||
@@ -39,6 +39,9 @@
|
||||
v-on-clickaway="closeDropdown"
|
||||
:class="dropdownBackgroundClass"
|
||||
class="country-dropdown h-48 overflow-y-auto z-10 absolute top-12 px-0 pt-0 pl-1 pr-1 pb-1 rounded shadow-lg"
|
||||
@keydown.up="moveSelectionUp"
|
||||
@keydown.down="moveSelectionDown"
|
||||
@keydown.enter="onSelect"
|
||||
>
|
||||
<div class="sticky top-0" :class="dropdownBackgroundClass">
|
||||
<input
|
||||
@@ -85,7 +88,6 @@
|
||||
<script>
|
||||
import countries from 'shared/constants/countries.js';
|
||||
import FluentIcon from 'shared/components/FluentIcon/Index.vue';
|
||||
import mentionSelectionKeyboardMixin from 'dashboard/components/widgets/mentions/mentionSelectionKeyboardMixin.js';
|
||||
import FormulateInputMixin from '@braid/vue-formulate/src/FormulateInputMixin';
|
||||
import darkModeMixin from 'widget/mixins/darkModeMixin';
|
||||
|
||||
@@ -93,7 +95,7 @@ export default {
|
||||
components: {
|
||||
FluentIcon,
|
||||
},
|
||||
mixins: [mentionSelectionKeyboardMixin, FormulateInputMixin, darkModeMixin],
|
||||
mixins: [FormulateInputMixin, darkModeMixin],
|
||||
props: {
|
||||
placeholder: {
|
||||
type: String,
|
||||
@@ -185,6 +187,14 @@ export default {
|
||||
);
|
||||
},
|
||||
},
|
||||
watch: {
|
||||
items(newItems) {
|
||||
if (newItems.length < this.selectedIndex + 1) {
|
||||
// Reset the selected index to 0 if the new items length is less than the selected index.
|
||||
this.selectedIndex = 0;
|
||||
}
|
||||
},
|
||||
},
|
||||
methods: {
|
||||
setContextValue(code) {
|
||||
// This function is used to set the context value.
|
||||
@@ -235,7 +245,26 @@ export default {
|
||||
this.scrollToFocusedOrActiveItem(this.focusedOrActiveItem('focus'));
|
||||
});
|
||||
},
|
||||
adjustSelection(direction) {
|
||||
if (!this.showDropdown) return;
|
||||
const maxIndex = this.items.length - 1;
|
||||
if (direction === 'up') {
|
||||
this.selectedIndex =
|
||||
this.selectedIndex <= 0 ? maxIndex : this.selectedIndex - 1;
|
||||
} else if (direction === 'down') {
|
||||
this.selectedIndex =
|
||||
this.selectedIndex >= maxIndex ? 0 : this.selectedIndex + 1;
|
||||
}
|
||||
this.adjustScroll();
|
||||
},
|
||||
moveSelectionUp() {
|
||||
this.adjustSelection('up');
|
||||
},
|
||||
moveSelectionDown() {
|
||||
this.adjustSelection('down');
|
||||
},
|
||||
onSelect() {
|
||||
if (!this.showDropdown || this.selectedIndex === -1) return;
|
||||
this.onSelectCountry(this.items[this.selectedIndex]);
|
||||
},
|
||||
scrollToFocusedOrActiveItem(item) {
|
||||
|
||||
@@ -1,44 +1,62 @@
|
||||
class Account::ContactsExportJob < ApplicationJob
|
||||
queue_as :low
|
||||
|
||||
def perform(account_id, column_names, email_to)
|
||||
account = Account.find(account_id)
|
||||
headers = valid_headers(column_names)
|
||||
generate_csv(account, headers)
|
||||
file_url = account_contact_export_url(account)
|
||||
def perform(account_id, user_id, column_names, params)
|
||||
@account = Account.find(account_id)
|
||||
@params = params
|
||||
@account_user = @account.users.find(user_id)
|
||||
|
||||
AdministratorNotifications::ChannelNotificationsMailer.with(account: account).contact_export_complete(file_url, email_to)&.deliver_later
|
||||
headers = valid_headers(column_names)
|
||||
generate_csv(headers)
|
||||
send_mail
|
||||
end
|
||||
|
||||
def generate_csv(account, headers)
|
||||
private
|
||||
|
||||
def generate_csv(headers)
|
||||
csv_data = CSV.generate do |csv|
|
||||
csv << headers
|
||||
account.contacts.each do |contact|
|
||||
contacts.each do |contact|
|
||||
csv << headers.map { |header| contact.send(header) }
|
||||
end
|
||||
end
|
||||
|
||||
attach_export_file(account, csv_data)
|
||||
attach_export_file(csv_data)
|
||||
end
|
||||
|
||||
def contacts
|
||||
if @params.present? && @params[:payload].present? && @params[:payload].any?
|
||||
result = ::Contacts::FilterService.new(@account, @account_user, @params).perform
|
||||
result[:contacts]
|
||||
elsif @params[:label].present?
|
||||
@account.contacts.resolved_contacts.tagged_with(@params[:label], any: true)
|
||||
else
|
||||
@account.contacts.resolved_contacts
|
||||
end
|
||||
end
|
||||
|
||||
def valid_headers(column_names)
|
||||
columns = (column_names.presence || default_columns)
|
||||
headers = columns.map { |column| column if Contact.column_names.include?(column) }
|
||||
headers.compact
|
||||
(column_names.presence || default_columns) & Contact.column_names
|
||||
end
|
||||
|
||||
def attach_export_file(account, csv_data)
|
||||
def attach_export_file(csv_data)
|
||||
return if csv_data.blank?
|
||||
|
||||
account.contacts_export.attach(
|
||||
@account.contacts_export.attach(
|
||||
io: StringIO.new(csv_data),
|
||||
filename: "#{account.name}_#{account.id}_contacts.csv",
|
||||
filename: "#{@account.name}_#{@account.id}_contacts.csv",
|
||||
content_type: 'text/csv'
|
||||
)
|
||||
end
|
||||
|
||||
def account_contact_export_url(account)
|
||||
Rails.application.routes.url_helpers.rails_blob_url(account.contacts_export)
|
||||
def send_mail
|
||||
file_url = account_contact_export_url
|
||||
mailer = AdministratorNotifications::ChannelNotificationsMailer.with(account: @account)
|
||||
mailer.contact_export_complete(file_url, @account_user.email)&.deliver_later
|
||||
end
|
||||
|
||||
def account_contact_export_url
|
||||
Rails.application.routes.url_helpers.rails_blob_url(@account.contacts_export)
|
||||
end
|
||||
|
||||
def default_columns
|
||||
|
||||
@@ -1,4 +1,6 @@
|
||||
class BulkActionsJob < ApplicationJob
|
||||
include DateRangeHelper
|
||||
|
||||
queue_as :medium
|
||||
attr_accessor :records
|
||||
|
||||
@@ -23,6 +25,7 @@ class BulkActionsJob < ApplicationJob
|
||||
params = available_params(@params)
|
||||
records.each do |conversation|
|
||||
bulk_add_labels(conversation)
|
||||
bulk_snoozed_until(conversation)
|
||||
conversation.update(params) if params
|
||||
end
|
||||
end
|
||||
@@ -43,6 +46,10 @@ class BulkActionsJob < ApplicationJob
|
||||
conversation.add_labels(@params[:labels][:add]) if @params[:labels] && @params[:labels][:add]
|
||||
end
|
||||
|
||||
def bulk_snoozed_until(conversation)
|
||||
conversation.snoozed_until = parse_date_time(@params[:snoozed_until].to_s) if @params[:snoozed_until]
|
||||
end
|
||||
|
||||
def remove_labels(conversation)
|
||||
return unless @params[:labels] && @params[:labels][:remove]
|
||||
|
||||
|
||||
@@ -36,6 +36,9 @@ class Inboxes::FetchImapEmailsJob < MutexApplicationJob
|
||||
inbound_emails.map do |inbound_mail|
|
||||
process_mail(inbound_mail, channel)
|
||||
end
|
||||
rescue OAuth2::Error => e
|
||||
Rails.logger.error "Error for email channel - #{channel.inbox.id} : #{e.message}"
|
||||
channel.authorization_error!
|
||||
end
|
||||
|
||||
def process_mail(inbound_mail, channel)
|
||||
|
||||
@@ -3,6 +3,13 @@ class ParticipationListener < BaseListener
|
||||
|
||||
def assignee_changed(event)
|
||||
conversation, _account = extract_conversation_and_account(event)
|
||||
conversation.conversation_participants.find_or_create_by!(user_id: conversation.assignee_id) if conversation.assignee_id.present?
|
||||
return if conversation.assignee_id.blank?
|
||||
|
||||
conversation.conversation_participants.find_or_create_by!(user_id: conversation.assignee_id)
|
||||
# We have observed race conditions triggering these errors
|
||||
# example: Assignment happening via automation, while auto assignment is also configured.
|
||||
rescue ActiveRecord::RecordNotUnique, ActiveRecord::RecordInvalid
|
||||
Rails.logger.warn "Failed to create conversation participant for account #{conversation.account.id} " \
|
||||
": user #{conversation.assignee_id} : conversation #{conversation.id}"
|
||||
end
|
||||
end
|
||||
|
||||
@@ -12,6 +12,9 @@ class Imap::ImapMailbox
|
||||
# prevent loop from chatwoot notification emails
|
||||
return if notification_email_from_chatwoot?
|
||||
|
||||
# Stop processing if email format doesn't match Chatwoot supported mail format
|
||||
return unless email_from_valid_email?
|
||||
|
||||
ActiveRecord::Base.transaction do
|
||||
find_or_create_contact
|
||||
find_or_create_conversation
|
||||
@@ -34,6 +37,18 @@ class Imap::ImapMailbox
|
||||
@processed_mail = MailPresenter.new(@inbound_mail, @account)
|
||||
end
|
||||
|
||||
def email_from_valid_email?
|
||||
Rails.logger.info("Processing Email from: #{@processed_mail.original_sender} : inbox #{@inbox.id}")
|
||||
|
||||
# validate email with Devise.email_regexp
|
||||
if Devise.email_regexp.match?(@processed_mail.original_sender)
|
||||
true
|
||||
else
|
||||
Rails.logger.error("Email from: #{@processed_mail.original_sender} : inbox #{@inbox.id} is invalid")
|
||||
false
|
||||
end
|
||||
end
|
||||
|
||||
def find_conversation_by_in_reply_to
|
||||
return if in_reply_to.blank?
|
||||
|
||||
|
||||
@@ -32,7 +32,7 @@ module AssignmentHandler
|
||||
ASSIGNEE_CHANGED => -> { saved_change_to_assignee_id? },
|
||||
TEAM_CHANGED => -> { saved_change_to_team_id? }
|
||||
}.each do |event, condition|
|
||||
condition.call && dispatcher_dispatch(event)
|
||||
condition.call && dispatcher_dispatch(event, previous_changes)
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
@@ -25,6 +25,7 @@
|
||||
# Indexes
|
||||
#
|
||||
# index_contacts_on_account_id (account_id)
|
||||
# index_contacts_on_account_id_and_last_activity_at (account_id,last_activity_at DESC NULLS LAST)
|
||||
# index_contacts_on_blocked (blocked)
|
||||
# index_contacts_on_lower_email_account_id (lower((email)::text), account_id)
|
||||
# index_contacts_on_name_email_phone_number_identifier (name,email,phone_number,identifier) USING gin
|
||||
|
||||
@@ -41,7 +41,6 @@
|
||||
# index_conversations_on_first_reply_created_at (first_reply_created_at)
|
||||
# index_conversations_on_id_and_account_id (account_id,id)
|
||||
# index_conversations_on_inbox_id (inbox_id)
|
||||
# index_conversations_on_last_activity_at (last_activity_at)
|
||||
# index_conversations_on_priority (priority)
|
||||
# index_conversations_on_status_and_account_id (status,account_id)
|
||||
# index_conversations_on_status_and_priority (status,priority)
|
||||
|
||||
@@ -1,6 +1,13 @@
|
||||
class Contacts::FilterService < FilterService
|
||||
ATTRIBUTE_MODEL = 'contact_attribute'.freeze
|
||||
|
||||
def initialize(account, user, params)
|
||||
@account = account
|
||||
# TODO: Change the order of arguments in FilterService maybe?
|
||||
# account, user, params makes more sense
|
||||
super(params, user)
|
||||
end
|
||||
|
||||
def perform
|
||||
@contacts = query_builder(@filters['contacts'])
|
||||
|
||||
@@ -21,8 +28,9 @@ class Contacts::FilterService < FilterService
|
||||
end
|
||||
end
|
||||
|
||||
# TODO: @account.contacts.resolved_contacts ? to stay consistant with the behavior in ui
|
||||
def base_relation
|
||||
Current.account.contacts
|
||||
@account.contacts
|
||||
end
|
||||
|
||||
def filter_config
|
||||
|
||||
@@ -1,2 +1,3 @@
|
||||
json.partial! 'api/v1/models/account', formats: [:json], resource: @account
|
||||
json.latest_chatwoot_version @latest_chatwoot_version
|
||||
json.partial! 'enterprise/api/v1/accounts/partials/account', account: @account if ChatwootApp.enterprise?
|
||||
|
||||
@@ -135,8 +135,13 @@
|
||||
description: 'The Chatwoot Inbox HMAC Key for Contact Support in Cloud'
|
||||
locked: false
|
||||
- name: CHATWOOT_CLOUD_PLANS
|
||||
display_title: 'Cloud Plans'
|
||||
value:
|
||||
description: 'Config to store stripe plans for cloud'
|
||||
- name: CHATWOOT_CLOUD_PLAN_FEATURES
|
||||
display_title: 'Planwise Features List'
|
||||
value:
|
||||
description: 'Config to features and their associated plans'
|
||||
- name: DEPLOYMENT_ENV
|
||||
value: self-hosted
|
||||
description: 'The deployment environment of the installation, to differentiate between Chatwoot cloud and self-hosted'
|
||||
|
||||
+1
-1
@@ -125,7 +125,7 @@ Rails.application.routes.draw do
|
||||
get :search
|
||||
post :filter
|
||||
post :import
|
||||
get :export
|
||||
post :export
|
||||
end
|
||||
member do
|
||||
get :contactable_inboxes
|
||||
|
||||
@@ -0,0 +1,11 @@
|
||||
class IndexImprovementsConversationsContacts < ActiveRecord::Migration[7.0]
|
||||
disable_ddl_transaction!
|
||||
|
||||
def change
|
||||
remove_index :conversations, :last_activity_at
|
||||
add_index :contacts, [:account_id, :last_activity_at],
|
||||
order: { last_activity_at: 'DESC NULLS LAST' },
|
||||
algorithm: :concurrently,
|
||||
name: 'index_contacts_on_account_id_and_last_activity_at'
|
||||
end
|
||||
end
|
||||
+2
-2
@@ -10,7 +10,7 @@
|
||||
#
|
||||
# It's strongly recommended that you check this file into your version control system.
|
||||
|
||||
ActiveRecord::Schema[7.0].define(version: 2024_04_15_210313) do
|
||||
ActiveRecord::Schema[7.0].define(version: 2024_05_15_201632) do
|
||||
# These are extensions that must be enabled in order to support this database
|
||||
enable_extension "pg_stat_statements"
|
||||
enable_extension "pg_trgm"
|
||||
@@ -426,6 +426,7 @@ ActiveRecord::Schema[7.0].define(version: 2024_04_15_210313) do
|
||||
t.boolean "blocked", default: false, null: false
|
||||
t.index "lower((email)::text), account_id", name: "index_contacts_on_lower_email_account_id"
|
||||
t.index ["account_id", "email", "phone_number", "identifier"], name: "index_contacts_on_nonempty_fields", where: "(((email)::text <> ''::text) OR ((phone_number)::text <> ''::text) OR ((identifier)::text <> ''::text))"
|
||||
t.index ["account_id", "last_activity_at"], name: "index_contacts_on_account_id_and_last_activity_at", order: { last_activity_at: "DESC NULLS LAST" }
|
||||
t.index ["account_id"], name: "index_contacts_on_account_id"
|
||||
t.index ["account_id"], name: "index_resolved_contact_account_id", where: "(((email)::text <> ''::text) OR ((phone_number)::text <> ''::text) OR ((identifier)::text <> ''::text))"
|
||||
t.index ["blocked"], name: "index_contacts_on_blocked"
|
||||
@@ -483,7 +484,6 @@ ActiveRecord::Schema[7.0].define(version: 2024_04_15_210313) do
|
||||
t.index ["contact_inbox_id"], name: "index_conversations_on_contact_inbox_id"
|
||||
t.index ["first_reply_created_at"], name: "index_conversations_on_first_reply_created_at"
|
||||
t.index ["inbox_id"], name: "index_conversations_on_inbox_id"
|
||||
t.index ["last_activity_at"], name: "index_conversations_on_last_activity_at"
|
||||
t.index ["priority"], name: "index_conversations_on_priority"
|
||||
t.index ["status", "account_id"], name: "index_conversations_on_status_and_account_id"
|
||||
t.index ["status", "priority"], name: "index_conversations_on_status_and_priority"
|
||||
|
||||
@@ -6,8 +6,19 @@ module Enterprise::Account
|
||||
}
|
||||
end
|
||||
|
||||
def subscribed_features
|
||||
plan_features = InstallationConfig.find_by(name: 'CHATWOOT_CLOUD_PLAN_FEATURES')&.value
|
||||
return [] if plan_features.blank?
|
||||
|
||||
plan_features[plan_name]
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
def plan_name
|
||||
custom_attributes['plan_name']
|
||||
end
|
||||
|
||||
def agent_limits
|
||||
subscribed_quantity = custom_attributes['subscribed_quantity']
|
||||
subscribed_quantity || get_limits(:agents)
|
||||
|
||||
@@ -66,7 +66,7 @@ module Enterprise::Concerns::Article
|
||||
{ role: 'user', content: "title: #{title} \n description: #{description} \n content: #{content}" }
|
||||
]
|
||||
headers = { 'Content-Type' => 'application/json', 'Authorization' => "Bearer #{ENV.fetch('OPENAI_API_KEY', nil)}" }
|
||||
body = { model: 'gpt-4-turbo', messages: messages, response_format: { type: 'json_object' } }.to_json
|
||||
body = { model: 'gpt-4o', messages: messages, response_format: { type: 'json_object' } }.to_json
|
||||
Rails.logger.info "Requesting Chat GPT with body: #{body}"
|
||||
response = HTTParty.post('https://api.openai.com/v1/chat/completions', headers: headers, body: body)
|
||||
Rails.logger.info "Chat GPT response: #{response.body}"
|
||||
|
||||
@@ -5,8 +5,7 @@ class Internal::ReconcilePlanConfigService
|
||||
|
||||
create_premium_config_reset_warning if premium_config_reset_required?
|
||||
|
||||
# We will have this enabled in the future
|
||||
# reconcile_premium_config
|
||||
reconcile_premium_config
|
||||
reconcile_premium_features
|
||||
end
|
||||
|
||||
|
||||
@@ -0,0 +1 @@
|
||||
json.subscribed_features @account.subscribed_features
|
||||
@@ -4,7 +4,7 @@ class ChatGpt
|
||||
end
|
||||
|
||||
def initialize(context_sections = '')
|
||||
@model = 'gpt-4-0125-preview'
|
||||
@model = 'gpt-4o'
|
||||
@messages = [system_message(context_sections)]
|
||||
end
|
||||
|
||||
|
||||
@@ -13,7 +13,7 @@ namespace :ip_lookup do
|
||||
Rails.logger.info '[rake ip_lookup:setup] Fetch GeoLite2-City database'
|
||||
|
||||
begin
|
||||
base_url = 'https://download.maxmind.com/app/geoip_download'
|
||||
base_url = ENV.fetch('IP_LOOKUP_BASE_URL', 'https://download.maxmind.com/app/geoip_download')
|
||||
source_file = Down.download(
|
||||
"#{base_url}?edition_id=GeoLite2-City&suffix=tar.gz&license_key=#{ip_lookup_api_key}"
|
||||
)
|
||||
|
||||
+2
-1
@@ -32,7 +32,7 @@
|
||||
"dependencies": {
|
||||
"@braid/vue-formulate": "^2.5.2",
|
||||
"@chatwoot/prosemirror-schema": "1.0.5",
|
||||
"@chatwoot/utils": "^0.0.24",
|
||||
"@chatwoot/utils": "^0.0.25",
|
||||
"@hcaptcha/vue-hcaptcha": "^0.3.2",
|
||||
"@june-so/analytics-next": "^2.0.0",
|
||||
"@radix-ui/colors": "^1.0.1",
|
||||
@@ -62,6 +62,7 @@
|
||||
"idb": "^7.1.1",
|
||||
"ionicons": "~2.0.1",
|
||||
"js-cookie": "^3.0.5",
|
||||
"lamejs": "1.2.0",
|
||||
"libphonenumber-js": "^1.10.24",
|
||||
"markdown-it": "^13.0.2",
|
||||
"markdown-it-link-attributes": "^4.0.1",
|
||||
|
||||
@@ -2,6 +2,16 @@ require 'rails_helper'
|
||||
|
||||
RSpec.describe 'Contacts API', type: :request do
|
||||
let(:account) { create(:account) }
|
||||
let(:email_filter) do
|
||||
{
|
||||
attribute_key: 'email',
|
||||
filter_operator: 'contains',
|
||||
values: 'looped',
|
||||
query_operator: 'and',
|
||||
attribute_model: 'standard',
|
||||
custom_attribute_type: ''
|
||||
}
|
||||
end
|
||||
|
||||
describe 'GET /api/v1/accounts/{account.id}/contacts' do
|
||||
context 'when it is an unauthenticated user' do
|
||||
@@ -87,6 +97,8 @@ RSpec.describe 'Contacts API', type: :request do
|
||||
|
||||
expect(response).to have_http_status(:success)
|
||||
response_body = response.parsed_body
|
||||
# TODO: this spec has been flaky for a while, so adding a debug statement to see the response
|
||||
Rails.logger.info(response_body)
|
||||
expect(response_body['payload'].first['email']).to eq(contact.email)
|
||||
expect(response_body['payload'].first['id']).to eq(contact.id)
|
||||
expect(response_body['payload'].last['email']).to eq(contact_4.email)
|
||||
@@ -175,7 +187,7 @@ RSpec.describe 'Contacts API', type: :request do
|
||||
describe 'POST /api/v1/accounts/{account.id}/contacts/export' do
|
||||
context 'when it is an unauthenticated user' do
|
||||
it 'returns unauthorized' do
|
||||
get "/api/v1/accounts/#{account.id}/contacts/export"
|
||||
post "/api/v1/accounts/#{account.id}/contacts/export"
|
||||
|
||||
expect(response).to have_http_status(:unauthorized)
|
||||
end
|
||||
@@ -185,9 +197,9 @@ RSpec.describe 'Contacts API', type: :request do
|
||||
let(:agent) { create(:user, account: account, role: :agent) }
|
||||
|
||||
it 'returns unauthorized' do
|
||||
get "/api/v1/accounts/#{account.id}/contacts/export",
|
||||
headers: agent.create_new_auth_token,
|
||||
as: :json
|
||||
post "/api/v1/accounts/#{account.id}/contacts/export",
|
||||
headers: agent.create_new_auth_token,
|
||||
as: :json
|
||||
|
||||
expect(response).to have_http_status(:unauthorized)
|
||||
end
|
||||
@@ -197,21 +209,35 @@ RSpec.describe 'Contacts API', type: :request do
|
||||
let(:admin) { create(:user, account: account, role: :administrator) }
|
||||
|
||||
it 'enqueues a contact export job' do
|
||||
expect(Account::ContactsExportJob).to receive(:perform_later).with(account.id, nil, admin.email).once
|
||||
expect(Account::ContactsExportJob).to receive(:perform_later).with(account.id, admin.id, nil, { :payload => nil, :label => nil }).once
|
||||
|
||||
get "/api/v1/accounts/#{account.id}/contacts/export",
|
||||
headers: admin.create_new_auth_token,
|
||||
params: { column_names: nil }
|
||||
post "/api/v1/accounts/#{account.id}/contacts/export",
|
||||
headers: admin.create_new_auth_token
|
||||
|
||||
expect(response).to have_http_status(:success)
|
||||
end
|
||||
|
||||
it 'enqueues a contact export job with sent_columns' do
|
||||
expect(Account::ContactsExportJob).to receive(:perform_later).with(account.id, %w[phone_number email], admin.email).once
|
||||
expect(Account::ContactsExportJob).to receive(:perform_later).with(account.id, admin.id, %w[phone_number email],
|
||||
{ :payload => nil, :label => nil }).once
|
||||
|
||||
get "/api/v1/accounts/#{account.id}/contacts/export",
|
||||
headers: admin.create_new_auth_token,
|
||||
params: { column_names: %w[phone_number email] }
|
||||
post "/api/v1/accounts/#{account.id}/contacts/export",
|
||||
headers: admin.create_new_auth_token,
|
||||
params: { column_names: %w[phone_number email] }
|
||||
|
||||
expect(response).to have_http_status(:success)
|
||||
end
|
||||
|
||||
it 'enqueues a contact export job with payload' do
|
||||
expect(Account::ContactsExportJob).to receive(:perform_later).with(account.id, admin.id, nil,
|
||||
{
|
||||
:payload => [ActionController::Parameters.new(email_filter).permit!],
|
||||
:label => nil
|
||||
}).once
|
||||
|
||||
post "/api/v1/accounts/#{account.id}/contacts/export",
|
||||
headers: admin.create_new_auth_token,
|
||||
params: { payload: [email_filter] }
|
||||
|
||||
expect(response).to have_http_status(:success)
|
||||
end
|
||||
|
||||
@@ -91,4 +91,45 @@ RSpec.describe Account do
|
||||
)
|
||||
end
|
||||
end
|
||||
|
||||
describe 'subscribed_features' do
|
||||
let(:account) { create(:account) }
|
||||
let(:plan_features) do
|
||||
{
|
||||
'hacker' => %w[feature1 feature2],
|
||||
'startups' => %w[feature1 feature2 feature3 feature4]
|
||||
}
|
||||
end
|
||||
|
||||
before do
|
||||
InstallationConfig.where(name: 'CHATWOOT_CLOUD_PLAN_FEATURES').first_or_create(value: plan_features)
|
||||
end
|
||||
|
||||
context 'when plan_name is hacker' do
|
||||
it 'returns the features for the hacker plan' do
|
||||
account.custom_attributes = { 'plan_name': 'hacker' }
|
||||
account.save!
|
||||
|
||||
expect(account.subscribed_features).to eq(%w[feature1 feature2])
|
||||
end
|
||||
end
|
||||
|
||||
context 'when plan_name is startups' do
|
||||
it 'returns the features for the startups plan' do
|
||||
account.custom_attributes = { 'plan_name': 'startups' }
|
||||
account.save!
|
||||
|
||||
expect(account.subscribed_features).to eq(%w[feature1 feature2 feature3 feature4])
|
||||
end
|
||||
end
|
||||
|
||||
context 'when plan_features is blank' do
|
||||
it 'returns an empty array' do
|
||||
account.custom_attributes = {}
|
||||
account.save!
|
||||
|
||||
expect(account.subscribed_features).to be_nil
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
@@ -34,15 +34,13 @@ RSpec.describe Internal::ReconcilePlanConfigService do
|
||||
expect(Redis::Alfred.get(Redis::Alfred::CHATWOOT_INSTALLATION_CONFIG_RESET_WARNING)).to be_nil
|
||||
end
|
||||
|
||||
# To be enabled in the future when method is uncommented
|
||||
|
||||
# it 'updates the premium configs to default' do
|
||||
# create(:installation_config, name: 'INSTALLATION_NAME', value: 'custom-name')
|
||||
# create(:installation_config, name: 'LOGO', value: '/custom-path/logo.svg')
|
||||
# service.perform
|
||||
# expect(InstallationConfig.find_by(name: 'INSTALLATION_NAME').value).to eq('Chatwoot')
|
||||
# expect(InstallationConfig.find_by(name: 'LOGO').value).to eq('/brand-assets/logo.svg')
|
||||
# end
|
||||
it 'updates the premium configs to default' do
|
||||
create(:installation_config, name: 'INSTALLATION_NAME', value: 'custom-name')
|
||||
create(:installation_config, name: 'LOGO', value: '/custom-path/logo.svg')
|
||||
service.perform
|
||||
expect(InstallationConfig.find_by(name: 'INSTALLATION_NAME').value).to eq('Chatwoot')
|
||||
expect(InstallationConfig.find_by(name: 'LOGO').value).to eq('/brand-assets/logo.svg')
|
||||
end
|
||||
end
|
||||
|
||||
context 'when pricing plan is not community' do
|
||||
|
||||
@@ -3,7 +3,43 @@ require 'rails_helper'
|
||||
RSpec.describe Account::ContactsExportJob do
|
||||
subject(:job) { described_class.perform_later }
|
||||
|
||||
let!(:account) { create(:account) }
|
||||
let(:account) { create(:account) }
|
||||
let(:user) { create(:user, account: account, email: 'account-user-test@test.com') }
|
||||
let(:label) { create(:label, title: 'spec-billing', maccount: account) }
|
||||
|
||||
let(:email_filter) do
|
||||
{
|
||||
:attribute_key => 'email',
|
||||
:filter_operator => 'contains',
|
||||
:values => 'looped',
|
||||
:query_operator => 'and',
|
||||
:attribute_model => 'standard',
|
||||
:custom_attribute_type => ''
|
||||
}
|
||||
end
|
||||
|
||||
let(:city_filter) do
|
||||
{
|
||||
:attribute_key => 'country_code',
|
||||
:filter_operator => 'equal_to',
|
||||
:values => ['India'],
|
||||
:query_operator => 'and',
|
||||
:attribute_model => 'standard',
|
||||
:custom_attribute_type => ''
|
||||
}
|
||||
end
|
||||
|
||||
let(:single_filter) do
|
||||
{
|
||||
:payload => [email_filter.merge(:query_operator => nil)]
|
||||
}
|
||||
end
|
||||
|
||||
let(:multiple_filters) do
|
||||
{
|
||||
:payload => [city_filter, email_filter.merge(:query_operator => nil)]
|
||||
}
|
||||
end
|
||||
|
||||
it 'enqueues the job' do
|
||||
expect { job }.to have_enqueued_job(described_class)
|
||||
@@ -13,8 +49,11 @@ RSpec.describe Account::ContactsExportJob do
|
||||
context 'when export_contacts' do
|
||||
before do
|
||||
create(:contact, account: account, phone_number: '+910808080818', email: 'test1@text.example')
|
||||
8.times do
|
||||
create(:contact, account: account)
|
||||
4.times do |i|
|
||||
create(:contact, account: account, email: "looped-#{i + 3}@text.example.com")
|
||||
end
|
||||
4.times do |i|
|
||||
create(:contact, account: account, additional_attributes: { :country_code => 'India' }, email: "looped-#{i + 10}@text.example.com")
|
||||
end
|
||||
create(:contact, account: account, phone_number: '+910808080808', email: 'test2@text.example')
|
||||
end
|
||||
@@ -24,17 +63,17 @@ RSpec.describe Account::ContactsExportJob do
|
||||
allow(AdministratorNotifications::ChannelNotificationsMailer).to receive(:with).with(account: account).and_return(mailer)
|
||||
allow(mailer).to receive(:contact_export_complete)
|
||||
|
||||
described_class.perform_now(account.id, [], 'test@test.com')
|
||||
described_class.perform_now(account.id, user.id, [], {})
|
||||
|
||||
file_url = Rails.application.routes.url_helpers.rails_blob_url(account.contacts_export)
|
||||
|
||||
expect(account.contacts_export).to be_present
|
||||
expect(file_url).to be_present
|
||||
expect(mailer).to have_received(:contact_export_complete).with(file_url, 'test@test.com')
|
||||
expect(mailer).to have_received(:contact_export_complete).with(file_url, user.email)
|
||||
end
|
||||
|
||||
it 'generates valid data export file' do
|
||||
described_class.perform_now(account.id, [], 'test@test.com')
|
||||
described_class.perform_now(account.id, user.id, %w[id name email phone_number column_not_present], {})
|
||||
|
||||
csv_data = CSV.parse(account.contacts_export.download, headers: true)
|
||||
emails = csv_data.pluck('email')
|
||||
@@ -45,5 +84,46 @@ RSpec.describe Account::ContactsExportJob do
|
||||
expect(emails).to include('test1@text.example', 'test2@text.example')
|
||||
expect(phone_numbers).to include('+910808080818', '+910808080808')
|
||||
end
|
||||
|
||||
it 'returns all resolved contacts as results when filter is not prvoided' do
|
||||
create(:contact, account: account, email: nil, phone_number: nil)
|
||||
described_class.perform_now(account.id, user.id, %w[id name email column_not_present], {})
|
||||
csv_data = CSV.parse(account.contacts_export.download, headers: true)
|
||||
expect(csv_data.length).to eq(account.contacts.resolved_contacts.count)
|
||||
end
|
||||
|
||||
it 'returns resolved contacts filtered if labels are provided' do
|
||||
# Adding label to a resolved contact
|
||||
Contact.last.add_labels(['spec-billing'])
|
||||
contact = create(:contact, account: account, email: nil, phone_number: nil)
|
||||
contact.add_labels(['spec-billing'])
|
||||
described_class.perform_now(account.id, user.id, [], { :payload => nil, :label => 'spec-billing' })
|
||||
csv_data = CSV.parse(account.contacts_export.download, headers: true)
|
||||
# since there is only 1 resolved contact with 'spec-billing' label
|
||||
expect(csv_data.length).to eq(1)
|
||||
end
|
||||
|
||||
# TODO: This returns unresolved contacts as well since filter service returns the same
|
||||
# Change this when we make changes to filter service and ensure only resolved contacts are returned
|
||||
it 'returns filtered data which inclues unresolved contacts when filter is provided' do
|
||||
create(:contact, account: account, email: nil, phone_number: nil, additional_attributes: { :country_code => 'India' })
|
||||
described_class.perform_now(account.id, user.id, [], { :payload => [city_filter.merge(:query_operator => nil)] }.with_indifferent_access)
|
||||
csv_data = CSV.parse(account.contacts_export.download, headers: true)
|
||||
expect(csv_data.length).to eq(5)
|
||||
end
|
||||
|
||||
it 'returns filtered data when multiple filters are provided' do
|
||||
described_class.perform_now(account.id, user.id, [], multiple_filters.with_indifferent_access)
|
||||
csv_data = CSV.parse(account.contacts_export.download, headers: true)
|
||||
# since there are only 4 contacts with 'looped' in email and 'India' as country_code
|
||||
expect(csv_data.length).to eq(4)
|
||||
end
|
||||
|
||||
it 'returns filtered data when a single filter is provided' do
|
||||
described_class.perform_now(account.id, user.id, [], single_filter.with_indifferent_access)
|
||||
csv_data = CSV.parse(account.contacts_export.download, headers: true)
|
||||
# since there are only 8 contacts with 'looped' in email
|
||||
expect(csv_data.length).to eq(8)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
@@ -65,5 +65,21 @@ RSpec.describe BulkActionsJob do
|
||||
expect(Conversation.second.assignee_id).to eq(agent.id)
|
||||
expect(Conversation.third.assignee_id).to eq(agent.id)
|
||||
end
|
||||
|
||||
it 'bulk updates the snoozed_until' do
|
||||
params = {
|
||||
type: 'Conversation',
|
||||
fields: { status: 'snoozed', snoozed_until: Time.zone.now },
|
||||
ids: Conversation.first(3).pluck(:display_id)
|
||||
}
|
||||
|
||||
expect(Conversation.first.snoozed_until).to be_nil
|
||||
|
||||
described_class.perform_now(account: account, params: params, user: agent)
|
||||
|
||||
expect(Conversation.first.snoozed_until).to be_present
|
||||
expect(Conversation.second.snoozed_until).to be_present
|
||||
expect(Conversation.third.snoozed_until).to be_present
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
@@ -69,6 +69,24 @@ RSpec.describe Inboxes::FetchImapEmailsJob do
|
||||
end
|
||||
end
|
||||
|
||||
context 'when IMAP OAuth errors out' do
|
||||
it 'marks the connection as requiring authorization' do
|
||||
error_response = double
|
||||
oauth_error = OAuth2::Error.new(error_response)
|
||||
|
||||
allow(Imap::MicrosoftFetchEmailService).to receive(:new)
|
||||
.with(channel: microsoft_imap_email_channel, interval: 1)
|
||||
.and_raise(oauth_error)
|
||||
|
||||
allow(Redis::Alfred).to receive(:incr)
|
||||
|
||||
expect(Redis::Alfred).to receive(:incr)
|
||||
.with("AUTHORIZATION_ERROR_COUNT:channel_email:#{microsoft_imap_email_channel.id}")
|
||||
|
||||
described_class.perform_now(microsoft_imap_email_channel)
|
||||
end
|
||||
end
|
||||
|
||||
context 'when the fetch service returns the email objects' do
|
||||
let(:inbound_mail) { create_inbound_email_from_fixture('welcome.eml').mail }
|
||||
let(:mailbox) { double }
|
||||
|
||||
@@ -9,8 +9,6 @@ describe ParticipationListener do
|
||||
|
||||
before do
|
||||
create(:inbox_member, inbox: inbox, user: agent)
|
||||
Current.user = nil
|
||||
Current.account = nil
|
||||
end
|
||||
|
||||
describe '#assignee_changed' do
|
||||
@@ -22,5 +20,19 @@ describe ParticipationListener do
|
||||
listener.assignee_changed(event)
|
||||
expect(conversation.conversation_participants.map(&:user_id)).to include(agent.id)
|
||||
end
|
||||
|
||||
it 'does not fail if the conversation participant already exists' do
|
||||
conversation.conversation_participants.create!(user: agent)
|
||||
expect { listener.assignee_changed(event) }.not_to raise_error
|
||||
end
|
||||
|
||||
it 'logs a debug message if participant save fails due to a race condition' do
|
||||
allow(Rails.logger).to receive(:warn)
|
||||
allow(conversation).to receive(:conversation_participants).and_return(double)
|
||||
allow(conversation.conversation_participants).to receive(:find_or_create_by!).and_raise(ActiveRecord::RecordNotUnique)
|
||||
expect { listener.assignee_changed(event) }.not_to raise_error
|
||||
expect(Rails.logger).to have_received(:warn).with('Failed to create conversation participant for account ' \
|
||||
"#{account.id} : user #{agent.id} : conversation #{conversation.id}")
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
@@ -54,6 +54,16 @@ RSpec.describe Imap::ImapMailbox do
|
||||
end
|
||||
end
|
||||
|
||||
context 'when a new email with invalid from' do
|
||||
let(:inbound_mail) { create_inbound_email_from_mail(from: 'invalidemail', to: 'imap@gmail.com', subject: 'Hello!') }
|
||||
|
||||
it 'does not create a new conversation' do
|
||||
allow(Rails.logger).to receive(:error)
|
||||
class_instance.process(inbound_mail.mail, channel)
|
||||
expect(Rails.logger).to have_received(:error).with("Email from: invalidemail : inbox #{inbox.id} is invalid")
|
||||
end
|
||||
end
|
||||
|
||||
context 'when a reply for existing email conversation' do
|
||||
let(:prev_conversation) { create(:conversation, account: account, inbox: channel.inbox, assignee: agent) }
|
||||
let(:reply_mail) do
|
||||
|
||||
@@ -156,7 +156,7 @@ RSpec.describe Conversation do
|
||||
changed_attributes: nil, performed_by: nil)
|
||||
expect(Rails.configuration.dispatcher).to have_received(:dispatch)
|
||||
.with(described_class::ASSIGNEE_CHANGED, kind_of(Time), conversation: conversation, notifiable_assignee_change: true,
|
||||
changed_attributes: nil, performed_by: nil)
|
||||
changed_attributes: changed_attributes, performed_by: nil)
|
||||
expect(Rails.configuration.dispatcher).to have_received(:dispatch)
|
||||
.with(described_class::CONVERSATION_UPDATED, kind_of(Time), conversation: conversation, notifiable_assignee_change: true,
|
||||
changed_attributes: changed_attributes, performed_by: nil)
|
||||
|
||||
@@ -16,7 +16,6 @@ describe Contacts::FilterService do
|
||||
create(:inbox_member, user: second_user, inbox: inbox)
|
||||
create(:conversation, account: account, inbox: inbox, assignee: first_user, contact: en_contact)
|
||||
create(:conversation, account: account, inbox: inbox, contact: el_contact)
|
||||
Current.account = account
|
||||
|
||||
create(:custom_attribute_definition,
|
||||
attribute_key: 'contact_additional_information',
|
||||
@@ -59,7 +58,7 @@ describe Contacts::FilterService do
|
||||
}.with_indifferent_access
|
||||
]
|
||||
|
||||
result = filter_service.new(params, first_user).perform
|
||||
result = filter_service.new(account, first_user, params).perform
|
||||
expect(result[:count]).to be 1
|
||||
expect(result[:contacts].length).to be 1
|
||||
expect(result[:contacts].first.name).to eq(en_contact.name)
|
||||
@@ -71,7 +70,7 @@ describe Contacts::FilterService do
|
||||
blocked_contact = create(:contact, account: account, blocked: true)
|
||||
params = { payload: [{ attribute_key: 'blocked', filter_operator: 'equal_to', values: ['true'],
|
||||
query_operator: nil }.with_indifferent_access] }
|
||||
result = filter_service.new(params, first_user).perform
|
||||
result = filter_service.new(account, first_user, params).perform
|
||||
expect(result[:count]).to be 1
|
||||
expect(result[:contacts].first.id).to eq(blocked_contact.id)
|
||||
end
|
||||
@@ -79,7 +78,7 @@ describe Contacts::FilterService do
|
||||
it 'filter contacts by not_blocked' do
|
||||
params = { payload: [{ attribute_key: 'blocked', filter_operator: 'equal_to', values: [false],
|
||||
query_operator: nil }.with_indifferent_access] }
|
||||
result = filter_service.new(params, first_user).perform
|
||||
result = filter_service.new(account, first_user, params).perform
|
||||
# existing contacts are not blocked
|
||||
expect(result[:count]).to be 3
|
||||
end
|
||||
@@ -96,7 +95,7 @@ describe Contacts::FilterService do
|
||||
}.with_indifferent_access
|
||||
]
|
||||
|
||||
result = filter_service.new(params, first_user).perform
|
||||
result = filter_service.new(account, first_user, params).perform
|
||||
expect(result[:contacts].length).to be 2
|
||||
expect(result[:contacts].first.label_list).to include('support')
|
||||
expect(result[:contacts].last.label_list).to include('support')
|
||||
@@ -112,7 +111,7 @@ describe Contacts::FilterService do
|
||||
}.with_indifferent_access
|
||||
]
|
||||
|
||||
result = filter_service.new(params, first_user).perform
|
||||
result = filter_service.new(account, first_user, params).perform
|
||||
expect(result[:contacts].length).to be 1
|
||||
expect(result[:contacts].first.id).to eq el_contact.id
|
||||
end
|
||||
@@ -127,7 +126,7 @@ describe Contacts::FilterService do
|
||||
}.with_indifferent_access
|
||||
]
|
||||
|
||||
result = filter_service.new(params, first_user).perform
|
||||
result = filter_service.new(account, first_user, params).perform
|
||||
expect(result[:contacts].length).to be 2
|
||||
expect(result[:contacts].first.label_list).to include('support')
|
||||
expect(result[:contacts].last.label_list).to include('support')
|
||||
@@ -143,7 +142,7 @@ describe Contacts::FilterService do
|
||||
}.with_indifferent_access
|
||||
]
|
||||
|
||||
result = filter_service.new(params, first_user).perform
|
||||
result = filter_service.new(account, first_user, params).perform
|
||||
expect(result[:contacts].length).to be 1
|
||||
expect(result[:contacts].first.id).to eq el_contact.id
|
||||
end
|
||||
@@ -180,7 +179,7 @@ describe Contacts::FilterService do
|
||||
'test custom data'
|
||||
).count
|
||||
|
||||
result = filter_service.new(params, first_user).perform
|
||||
result = filter_service.new(account, first_user, params).perform
|
||||
expect(result[:contacts].length).to be expected_count
|
||||
expect(result[:contacts].first.id).to eq(el_contact.id)
|
||||
end
|
||||
@@ -197,7 +196,7 @@ describe Contacts::FilterService do
|
||||
|
||||
expected_count = Contact.where('last_activity_at < ?', (Time.zone.today - 2.days)).count
|
||||
|
||||
result = filter_service.new(params, first_user).perform
|
||||
result = filter_service.new(account, first_user, params).perform
|
||||
expect(result[:contacts].length).to be expected_count
|
||||
expect(result[:contacts].pluck(:id)).to include(el_contact.id)
|
||||
expect(result[:contacts].pluck(:id)).to include(cs_contact.id)
|
||||
@@ -219,7 +218,7 @@ describe Contacts::FilterService do
|
||||
|
||||
it 'filter contacts by additional_attributes' do
|
||||
params[:payload] = payload
|
||||
result = filter_service.new(params, first_user).perform
|
||||
result = filter_service.new(account, first_user, params).perform
|
||||
expect(result[:count]).to be 1
|
||||
expect(result[:contacts].first.id).to eq(en_contact.id)
|
||||
end
|
||||
@@ -247,7 +246,7 @@ describe Contacts::FilterService do
|
||||
query_operator: nil
|
||||
}.with_indifferent_access
|
||||
]
|
||||
result = filter_service.new(params, first_user).perform
|
||||
result = filter_service.new(account, first_user, params).perform
|
||||
expect(result[:contacts].length).to be 1
|
||||
expect(result[:contacts].first.id).to eq(cs_contact.id)
|
||||
end
|
||||
@@ -273,7 +272,7 @@ describe Contacts::FilterService do
|
||||
query_operator: nil
|
||||
}.with_indifferent_access
|
||||
]
|
||||
result = filter_service.new(params, first_user).perform
|
||||
result = filter_service.new(account, first_user, params).perform
|
||||
expect(result[:contacts].length).to be 1
|
||||
expect(result[:contacts].first.id).to eq(el_contact.id)
|
||||
end
|
||||
@@ -294,7 +293,7 @@ describe Contacts::FilterService do
|
||||
query_operator: nil
|
||||
}.with_indifferent_access
|
||||
]
|
||||
result = filter_service.new(params, first_user).perform
|
||||
result = filter_service.new(account, first_user, params).perform
|
||||
expected_count = Contact.where("created_at < ? AND custom_attributes->>'customer_type' = ?", Date.tomorrow, 'platinum').count
|
||||
|
||||
expect(result[:contacts].length).to be expected_count
|
||||
|
||||
@@ -3177,10 +3177,10 @@
|
||||
prosemirror-utils "^0.9.6"
|
||||
prosemirror-view "^1.17.2"
|
||||
|
||||
"@chatwoot/utils@^0.0.24":
|
||||
version "0.0.24"
|
||||
resolved "https://registry.yarnpkg.com/@chatwoot/utils/-/utils-0.0.24.tgz#584e26b7fba2a8b23c049cc555497d0f35a5aebd"
|
||||
integrity sha512-TEPA1LxrCfEVFYZvBj3bckn2sEljStriiZttF6lu3j1rdNn2tysqK9IwYcRBHS4nyfleRMG4kSFrqD653t3YfA==
|
||||
"@chatwoot/utils@^0.0.25":
|
||||
version "0.0.25"
|
||||
resolved "https://registry.yarnpkg.com/@chatwoot/utils/-/utils-0.0.25.tgz#7657286baa1ef833789f934991df63c4a9716595"
|
||||
integrity sha512-2bGfRewHu0Bra47vHwJa3SdZ0VqXK/2q2ampcc6TT3z8ojSfZqpfMdb+1RKJ/Q1tQEYn/0rJTdWtLDRjePF92A==
|
||||
dependencies:
|
||||
date-fns "^2.29.1"
|
||||
|
||||
@@ -14062,6 +14062,13 @@ klona@^2.0.4:
|
||||
resolved "https://registry.yarnpkg.com/klona/-/klona-2.0.4.tgz#7bb1e3affb0cb8624547ef7e8f6708ea2e39dfc0"
|
||||
integrity sha512-ZRbnvdg/NxqzC7L9Uyqzf4psi1OM4Cuc+sJAkQPjO6XkQIJTNbfK2Rsmbw8fx1p2mkZdp2FZYo2+LwXYY/uwIA==
|
||||
|
||||
lamejs@1.2.0:
|
||||
version "1.2.0"
|
||||
resolved "https://registry.yarnpkg.com/lamejs/-/lamejs-1.2.0.tgz#0259f83db4666141a7b671b8caa6369d95177d08"
|
||||
integrity sha512-xEYvsB2sZ9jIccqfUQpQEBdB6UYQDG/ta2xQkH7oEpENb0JHFJii965WVF8ErUMdZzoe7EdIruz1WpICdhZ9Pw==
|
||||
dependencies:
|
||||
use-strict "1.0.1"
|
||||
|
||||
language-subtag-registry@~0.3.2:
|
||||
version "0.3.21"
|
||||
resolved "https://registry.yarnpkg.com/language-subtag-registry/-/language-subtag-registry-0.3.21.tgz#04ac218bea46f04cb039084602c6da9e788dd45a"
|
||||
@@ -20289,6 +20296,11 @@ urlpattern-polyfill@^6.0.2:
|
||||
dependencies:
|
||||
braces "^3.0.2"
|
||||
|
||||
use-strict@1.0.1:
|
||||
version "1.0.1"
|
||||
resolved "https://registry.yarnpkg.com/use-strict/-/use-strict-1.0.1.tgz#0bb80d94f49a4a05192b84a8c7d34e95f1a7e3a0"
|
||||
integrity sha512-IeiWvvEXfW5ltKVMkxq6FvNf2LojMKvB2OCeja6+ct24S1XOmQw2dGr2JyndwACWAGJva9B7yPHwAmeA9QCqAQ==
|
||||
|
||||
use@^3.1.0:
|
||||
version "3.1.1"
|
||||
resolved "https://registry.yarnpkg.com/use/-/use-3.1.1.tgz#d50c8cac79a19fbc20f2911f56eb973f4e10070f"
|
||||
|
||||
Reference in New Issue
Block a user