chore: Add a redirect link to the conversation in success toast message (#3711)
When creating a conversation from the contacts tab now we can go directly to the conversation by clicking the link in the success message Co-authored-by: Pranav Raj S <pranav@chatwoot.com>
This commit is contained in:
parent
359caf754c
commit
cab5a3e53b
9 changed files with 40 additions and 11 deletions
|
@ -15,7 +15,7 @@
|
||||||
@include shadow;
|
@include shadow;
|
||||||
background-color: $woot-snackbar-bg;
|
background-color: $woot-snackbar-bg;
|
||||||
border-radius: $space-smaller;
|
border-radius: $space-smaller;
|
||||||
display: inline-block;
|
display: inline-flex;
|
||||||
margin-bottom: $space-small;
|
margin-bottom: $space-small;
|
||||||
max-width: 40rem;
|
max-width: 40rem;
|
||||||
min-height: 3rem;
|
min-height: 3rem;
|
||||||
|
|
|
@ -4,6 +4,11 @@
|
||||||
<div class="ui-snackbar-text">
|
<div class="ui-snackbar-text">
|
||||||
{{ message }}
|
{{ message }}
|
||||||
</div>
|
</div>
|
||||||
|
<div v-if="action" class="ui-snackbar-action">
|
||||||
|
<router-link v-if="action.type == 'link'" :to="action.to">
|
||||||
|
{{ action.message }}
|
||||||
|
</router-link>
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
|
@ -12,6 +17,10 @@
|
||||||
export default {
|
export default {
|
||||||
props: {
|
props: {
|
||||||
message: { type: String, default: '' },
|
message: { type: String, default: '' },
|
||||||
|
action: {
|
||||||
|
type: Object,
|
||||||
|
default: () => {},
|
||||||
|
},
|
||||||
showButton: Boolean,
|
showButton: Boolean,
|
||||||
duration: {
|
duration: {
|
||||||
type: [String, Number],
|
type: [String, Number],
|
||||||
|
|
|
@ -4,6 +4,7 @@
|
||||||
v-for="snackMessage in snackMessages"
|
v-for="snackMessage in snackMessages"
|
||||||
:key="snackMessage.key"
|
:key="snackMessage.key"
|
||||||
:message="snackMessage.message"
|
:message="snackMessage.message"
|
||||||
|
:action="snackMessage.action"
|
||||||
/>
|
/>
|
||||||
</transition-group>
|
</transition-group>
|
||||||
</template>
|
</template>
|
||||||
|
@ -35,8 +36,12 @@ export default {
|
||||||
bus.$off('newToastMessage', this.onNewToastMessage);
|
bus.$off('newToastMessage', this.onNewToastMessage);
|
||||||
},
|
},
|
||||||
methods: {
|
methods: {
|
||||||
onNewToastMessage(message) {
|
onNewToastMessage(message, action) {
|
||||||
this.snackMessages.push({ key: new Date().getTime(), message });
|
this.snackMessages.push({
|
||||||
|
key: new Date().getTime(),
|
||||||
|
message,
|
||||||
|
action,
|
||||||
|
});
|
||||||
window.setTimeout(() => {
|
window.setTimeout(() => {
|
||||||
this.snackMessages.splice(0, 1);
|
this.snackMessages.splice(0, 1);
|
||||||
}, this.duration);
|
}, this.duration);
|
||||||
|
|
|
@ -84,7 +84,8 @@ describe('MoveActions', () => {
|
||||||
|
|
||||||
expect(window.bus.$emit).toBeCalledWith(
|
expect(window.bus.$emit).toBeCalledWith(
|
||||||
'newToastMessage',
|
'newToastMessage',
|
||||||
'This conversation is muted for 6 hours'
|
'This conversation is muted for 6 hours',
|
||||||
|
undefined
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
@ -109,7 +110,8 @@ describe('MoveActions', () => {
|
||||||
|
|
||||||
expect(window.bus.$emit).toBeCalledWith(
|
expect(window.bus.$emit).toBeCalledWith(
|
||||||
'newToastMessage',
|
'newToastMessage',
|
||||||
'This conversation is unmuted'
|
'This conversation is unmuted',
|
||||||
|
undefined
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
|
@ -169,6 +169,7 @@
|
||||||
"SUBMIT": "Send message",
|
"SUBMIT": "Send message",
|
||||||
"CANCEL": "Cancel",
|
"CANCEL": "Cancel",
|
||||||
"SUCCESS_MESSAGE": "Message sent!",
|
"SUCCESS_MESSAGE": "Message sent!",
|
||||||
|
"GO_TO_CONVERSATION": "View",
|
||||||
"ERROR_MESSAGE": "Couldn't send! try again"
|
"ERROR_MESSAGE": "Couldn't send! try again"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
|
@ -174,7 +174,6 @@ export default {
|
||||||
onSuccess() {
|
onSuccess() {
|
||||||
this.$emit('success');
|
this.$emit('success');
|
||||||
},
|
},
|
||||||
|
|
||||||
async handleSubmit() {
|
async handleSubmit() {
|
||||||
this.$v.$touch();
|
this.$v.$touch();
|
||||||
if (this.$v.$invalid) {
|
if (this.$v.$invalid) {
|
||||||
|
@ -182,9 +181,17 @@ export default {
|
||||||
}
|
}
|
||||||
try {
|
try {
|
||||||
const payload = this.getNewConversation;
|
const payload = this.getNewConversation;
|
||||||
await this.onSubmit(payload);
|
const data = await this.onSubmit(payload);
|
||||||
|
const action = {
|
||||||
|
type: 'link',
|
||||||
|
to: `/app/accounts/${data.account_id}/conversations/${data.id}`,
|
||||||
|
message: this.$t('NEW_CONVERSATION.FORM.GO_TO_CONVERSATION'),
|
||||||
|
};
|
||||||
this.onSuccess();
|
this.onSuccess();
|
||||||
this.showAlert(this.$t('NEW_CONVERSATION.FORM.SUCCESS_MESSAGE'));
|
this.showAlert(
|
||||||
|
this.$t('NEW_CONVERSATION.FORM.SUCCESS_MESSAGE'),
|
||||||
|
action
|
||||||
|
);
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
if (error instanceof ExceptionWithMessage) {
|
if (error instanceof ExceptionWithMessage) {
|
||||||
this.showAlert(error.data);
|
this.showAlert(error.data);
|
||||||
|
|
|
@ -49,7 +49,11 @@ export default {
|
||||||
this.$emit('cancel');
|
this.$emit('cancel');
|
||||||
},
|
},
|
||||||
async onSubmit(contactItem) {
|
async onSubmit(contactItem) {
|
||||||
await this.$store.dispatch('contactConversations/create', contactItem);
|
const data = await this.$store.dispatch(
|
||||||
|
'contactConversations/create',
|
||||||
|
contactItem
|
||||||
|
);
|
||||||
|
return data;
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
|
|
@ -39,6 +39,7 @@ export const actions = {
|
||||||
id: contactId,
|
id: contactId,
|
||||||
data,
|
data,
|
||||||
});
|
});
|
||||||
|
return data;
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
throw new Error(error);
|
throw new Error(error);
|
||||||
} finally {
|
} finally {
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
export default {
|
export default {
|
||||||
methods: {
|
methods: {
|
||||||
showAlert(message) {
|
showAlert(message, action) {
|
||||||
bus.$emit('newToastMessage', message);
|
bus.$emit('newToastMessage', message, action);
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
|
Loading…
Reference in a new issue