Skip to content

Commit 1c948ba

Browse files
committed
fix hide delete message for agent
1 parent 33d308a commit 1c948ba

3 files changed

Lines changed: 18 additions & 2 deletions

File tree

app/javascript/dashboard/components-next/Editor/Editor.vue

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ const slots = useSlots();
2828
2929
const isFocused = ref(false);
3030
31-
const characterCount = computed(() => props.modelValue.length);
31+
const characterCount = computed(() => props.modelValue?.length);
3232
3333
const messageClass = computed(() => {
3434
switch (props.messageType) {

app/javascript/dashboard/components-next/message/Message.vue

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ import { useTrack } from 'dashboard/composables';
66
import { emitter } from 'shared/helpers/mitt';
77
import { useI18n } from 'vue-i18n';
88
import { useRoute } from 'vue-router';
9+
import { useStore } from 'vuex';
910
import { LocalStorage } from 'shared/helpers/localStorage';
1011
import { ACCOUNT_EVENTS } from 'dashboard/helper/AnalyticsHelper/events';
1112
import { LOCAL_STORAGE_KEYS } from 'dashboard/constants/localStorage';
@@ -335,10 +336,24 @@ const payloadForContextMenu = computed(() => {
335336
};
336337
});
337338
339+
const store = useStore();
340+
const currentRole = computed(() => store.getters.getCurrentRole);
341+
const accountId = computed(() => store.getters.getCurrentAccountId);
342+
const isFeatureEnabledonAccount = computed(
343+
() => store.getters['accounts/isFeatureEnabledonAccount']
344+
);
345+
338346
const contextMenuEnabledOptions = computed(() => {
339347
const hasText = !!props.content;
340348
const hasAttachments = !!(props.attachments && props.attachments.length > 0);
341349
350+
const hideDeleteMessageForAgents =
351+
currentRole.value !== 'administrator' &&
352+
isFeatureEnabledonAccount.value(
353+
accountId.value,
354+
'hide_delete_message_for_agent'
355+
);
356+
342357
const isOutgoing = props.messageType === MESSAGE_TYPES.OUTGOING;
343358
const isFailedOrProcessing =
344359
props.status === MESSAGE_STATUS.FAILED ||
@@ -347,6 +362,7 @@ const contextMenuEnabledOptions = computed(() => {
347362
return {
348363
copy: hasText,
349364
delete:
365+
!hideDeleteMessageForAgents &&
350366
(hasText || hasAttachments) &&
351367
!isFailedOrProcessing &&
352368
!isMessageDeleted.value,

app/javascript/dashboard/components/widgets/WootWriter/Editor.vue

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -109,7 +109,7 @@ const createState = (
109109
enabledMenuOptions = []
110110
) => {
111111
return EditorState.create({
112-
doc: new MessageMarkdownTransformer(messageSchema).parse(content),
112+
doc: new MessageMarkdownTransformer(messageSchema).parse(content || ''),
113113
plugins: buildEditor({
114114
schema: messageSchema,
115115
placeholder,

0 commit comments

Comments
 (0)