chore: Improve macros stability (#5700)
Co-authored-by: Pranav Raj S <pranav@chatwoot.com>
This commit is contained in:
parent
c3ec1d4f8a
commit
06e2219110
8 changed files with 55 additions and 32 deletions
|
@ -150,7 +150,7 @@ export default {
|
||||||
},
|
},
|
||||||
actionInputStyles() {
|
actionInputStyles() {
|
||||||
return {
|
return {
|
||||||
error: this.v.action_params.$dirty && this.v.action_params.$error,
|
'has-error': this.v.action_params.$dirty && this.v.action_params.$error,
|
||||||
'is-a-macro': this.isMacro,
|
'is-a-macro': this.isMacro,
|
||||||
};
|
};
|
||||||
},
|
},
|
||||||
|
@ -187,7 +187,7 @@ export default {
|
||||||
margin-bottom: 0;
|
margin-bottom: 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
.filter.error {
|
.filter.has-error {
|
||||||
background: var(--r-50);
|
background: var(--r-50);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -113,5 +113,6 @@ input[type='file'] {
|
||||||
overflow: hidden;
|
overflow: hidden;
|
||||||
text-overflow: ellipsis;
|
text-overflow: ellipsis;
|
||||||
width: 100%;
|
width: 100%;
|
||||||
|
margin-bottom: 0;
|
||||||
}
|
}
|
||||||
</style>
|
</style>
|
||||||
|
|
|
@ -116,10 +116,10 @@ describe('uiSettingsMixin', () => {
|
||||||
const wrapper = shallowMount(Component, { store, localVue });
|
const wrapper = shallowMount(Component, { store, localVue });
|
||||||
expect(wrapper.vm.conversationSidebarItemsOrder).toEqual([
|
expect(wrapper.vm.conversationSidebarItemsOrder).toEqual([
|
||||||
{ name: 'conversation_actions' },
|
{ name: 'conversation_actions' },
|
||||||
|
{ name: 'macros' },
|
||||||
{ name: 'conversation_info' },
|
{ name: 'conversation_info' },
|
||||||
{ name: 'contact_attributes' },
|
{ name: 'contact_attributes' },
|
||||||
{ name: 'previous_conversation' },
|
{ name: 'previous_conversation' },
|
||||||
{ name: 'macros' },
|
|
||||||
]);
|
]);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
|
@ -16,7 +16,6 @@
|
||||||
import MacroForm from './MacroForm';
|
import MacroForm from './MacroForm';
|
||||||
import { MACRO_ACTION_TYPES } from './constants';
|
import { MACRO_ACTION_TYPES } from './constants';
|
||||||
import { mapGetters } from 'vuex';
|
import { mapGetters } from 'vuex';
|
||||||
import { emptyMacro } from './macroHelper';
|
|
||||||
import actionQueryGenerator from 'dashboard/helper/actionQueryGenerator.js';
|
import actionQueryGenerator from 'dashboard/helper/actionQueryGenerator.js';
|
||||||
import alertMixin from 'shared/mixins/alertMixin';
|
import alertMixin from 'shared/mixins/alertMixin';
|
||||||
import macrosMixin from 'dashboard/mixins/macrosMixin';
|
import macrosMixin from 'dashboard/mixins/macrosMixin';
|
||||||
|
@ -107,7 +106,16 @@ export default {
|
||||||
},
|
},
|
||||||
initNewMacro() {
|
initNewMacro() {
|
||||||
this.mode = 'CREATE';
|
this.mode = 'CREATE';
|
||||||
this.macro = emptyMacro;
|
this.macro = {
|
||||||
|
name: '',
|
||||||
|
actions: [
|
||||||
|
{
|
||||||
|
action_name: 'assign_team',
|
||||||
|
action_params: [],
|
||||||
|
},
|
||||||
|
],
|
||||||
|
visibility: 'global',
|
||||||
|
};
|
||||||
},
|
},
|
||||||
async saveMacro(macro) {
|
async saveMacro(macro) {
|
||||||
try {
|
try {
|
||||||
|
|
|
@ -47,6 +47,12 @@ export default {
|
||||||
};
|
};
|
||||||
},
|
},
|
||||||
watch: {
|
watch: {
|
||||||
|
$route: {
|
||||||
|
handler() {
|
||||||
|
this.resetValidation();
|
||||||
|
},
|
||||||
|
immediate: true,
|
||||||
|
},
|
||||||
macroData: {
|
macroData: {
|
||||||
handler() {
|
handler() {
|
||||||
this.macro = this.macroData;
|
this.macro = this.macroData;
|
||||||
|
@ -79,9 +85,6 @@ export default {
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
mounted() {
|
|
||||||
this.$v.$reset();
|
|
||||||
},
|
|
||||||
methods: {
|
methods: {
|
||||||
updateName(value) {
|
updateName(value) {
|
||||||
this.macro.name = value;
|
this.macro.name = value;
|
||||||
|
@ -104,8 +107,12 @@ export default {
|
||||||
this.$emit('submit', this.macro);
|
this.$emit('submit', this.macro);
|
||||||
},
|
},
|
||||||
resetNode(index) {
|
resetNode(index) {
|
||||||
|
this.$v.macro.actions.$each[index].$reset();
|
||||||
this.macro.actions[index].action_params = [];
|
this.macro.actions[index].action_params = [];
|
||||||
},
|
},
|
||||||
|
resetValidation() {
|
||||||
|
this.$v.$reset();
|
||||||
|
},
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
</script>
|
</script>
|
||||||
|
|
|
@ -8,8 +8,6 @@
|
||||||
tag="div"
|
tag="div"
|
||||||
class="macros__nodes-draggable"
|
class="macros__nodes-draggable"
|
||||||
handle=".macros__node-drag-handle"
|
handle=".macros__node-drag-handle"
|
||||||
@start="dragging = true"
|
|
||||||
@end="dragging = false"
|
|
||||||
>
|
>
|
||||||
<div v-for="(action, i) in actionData" :key="i" class="macro__node">
|
<div v-for="(action, i) in actionData" :key="i" class="macro__node">
|
||||||
<macro-node
|
<macro-node
|
||||||
|
@ -53,11 +51,6 @@ export default {
|
||||||
default: () => [],
|
default: () => [],
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
data() {
|
|
||||||
return {
|
|
||||||
dragging: false,
|
|
||||||
};
|
|
||||||
},
|
|
||||||
computed: {
|
computed: {
|
||||||
actionData: {
|
actionData: {
|
||||||
get() {
|
get() {
|
||||||
|
|
|
@ -10,7 +10,7 @@
|
||||||
@input="onUpdateName($event)"
|
@input="onUpdateName($event)"
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
<div>
|
<div class="macros__form-visibility-container">
|
||||||
<p class="title">{{ $t('MACROS.EDITOR.VISIBILITY.LABEL') }}</p>
|
<p class="title">{{ $t('MACROS.EDITOR.VISIBILITY.LABEL') }}</p>
|
||||||
<div class="macros__form-visibility">
|
<div class="macros__form-visibility">
|
||||||
<button
|
<button
|
||||||
|
@ -110,7 +110,9 @@ export default {
|
||||||
.macros__submit-button {
|
.macros__submit-button {
|
||||||
margin-top: auto;
|
margin-top: auto;
|
||||||
}
|
}
|
||||||
|
.macros__form-visibility-container {
|
||||||
|
margin-top: var(--space-small);
|
||||||
|
}
|
||||||
.macros__form-visibility {
|
.macros__form-visibility {
|
||||||
display: grid;
|
display: grid;
|
||||||
grid-template-columns: repeat(2, minmax(0, 1fr));
|
grid-template-columns: repeat(2, minmax(0, 1fr));
|
||||||
|
@ -129,20 +131,6 @@ export default {
|
||||||
border: 1px solid var(--w-300);
|
border: 1px solid var(--w-300);
|
||||||
}
|
}
|
||||||
|
|
||||||
.subtitle {
|
|
||||||
font-size: var(--font-size-mini);
|
|
||||||
color: var(--s-500);
|
|
||||||
}
|
|
||||||
|
|
||||||
.title {
|
|
||||||
display: block;
|
|
||||||
margin: 0;
|
|
||||||
font-size: var(--font-size-small);
|
|
||||||
font-weight: var(--font-weight-medium);
|
|
||||||
line-height: 1.8;
|
|
||||||
color: var(--color-body);
|
|
||||||
}
|
|
||||||
|
|
||||||
.visibility-check {
|
.visibility-check {
|
||||||
position: absolute;
|
position: absolute;
|
||||||
color: var(--w-500);
|
color: var(--w-500);
|
||||||
|
@ -152,6 +140,20 @@ export default {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.subtitle {
|
||||||
|
font-size: var(--font-size-mini);
|
||||||
|
color: var(--s-500);
|
||||||
|
}
|
||||||
|
|
||||||
|
.title {
|
||||||
|
display: block;
|
||||||
|
margin: 0;
|
||||||
|
font-size: var(--font-size-small);
|
||||||
|
font-weight: var(--font-weight-medium);
|
||||||
|
line-height: 1.8;
|
||||||
|
color: var(--color-body);
|
||||||
|
}
|
||||||
|
|
||||||
.macros__info-panel {
|
.macros__info-panel {
|
||||||
margin-top: var(--space-small);
|
margin-top: var(--space-small);
|
||||||
display: flex;
|
display: flex;
|
||||||
|
@ -164,11 +166,18 @@ export default {
|
||||||
}
|
}
|
||||||
p {
|
p {
|
||||||
margin-left: var(--space-small);
|
margin-left: var(--space-small);
|
||||||
|
margin-bottom: 0;
|
||||||
color: var(--s-600);
|
color: var(--s-600);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
::v-deep input[type='text'] {
|
::v-deep input[type='text'] {
|
||||||
margin-bottom: var(--space-small);
|
margin-bottom: 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
::v-deep .error {
|
||||||
|
.message {
|
||||||
|
margin-bottom: 0;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
</style>
|
</style>
|
||||||
|
|
|
@ -58,6 +58,7 @@ describe('#actions', () => {
|
||||||
id: 1,
|
id: 1,
|
||||||
messages: [],
|
messages: [],
|
||||||
meta: { sender: { id: 1, name: 'john-doe' } },
|
meta: { sender: { id: 1, name: 'john-doe' } },
|
||||||
|
labels: ['support'],
|
||||||
};
|
};
|
||||||
actions.updateConversation(
|
actions.updateConversation(
|
||||||
{ commit, rootState: { route: { name: 'home' } }, dispatch },
|
{ commit, rootState: { route: { name: 'home' } }, dispatch },
|
||||||
|
@ -67,6 +68,10 @@ describe('#actions', () => {
|
||||||
[types.UPDATE_CONVERSATION, conversation],
|
[types.UPDATE_CONVERSATION, conversation],
|
||||||
]);
|
]);
|
||||||
expect(dispatch.mock.calls).toEqual([
|
expect(dispatch.mock.calls).toEqual([
|
||||||
|
[
|
||||||
|
'conversationLabels/setConversationLabel',
|
||||||
|
{ id: 1, data: ['support'] },
|
||||||
|
],
|
||||||
[
|
[
|
||||||
'contacts/setContact',
|
'contacts/setContact',
|
||||||
{
|
{
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue