fix: Use team conversationURL in team section (#1921)

Fixes: #1917
This commit is contained in:
Pranav Raj S 2021-03-16 19:44:50 +05:30 committed by GitHub
parent e44e9fc025
commit 54d578676b
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
5 changed files with 33 additions and 13 deletions

View file

@ -25,6 +25,7 @@
v-for="chat in conversationList" v-for="chat in conversationList"
:key="chat.id" :key="chat.id"
:active-label="label" :active-label="label"
:team-id="teamId"
:chat="chat" :chat="chat"
/> />
@ -76,14 +77,14 @@ export default {
type: [String, Number], type: [String, Number],
default: 0, default: 0,
}, },
teamId: {
type: [String, Number],
default: 0,
},
label: { label: {
type: String, type: String,
default: '', default: '',
}, },
activeTeam: {
type: Object,
default: () => {},
},
}, },
data() { data() {
return { return {
@ -132,7 +133,7 @@ export default {
status: this.activeStatus, status: this.activeStatus,
page: this.currentPage + 1, page: this.currentPage + 1,
labels: this.label ? [this.label] : undefined, labels: this.label ? [this.label] : undefined,
teamId: this.activeTeam.name ? this.activeTeam.id : undefined, teamId: this.teamId ? this.teamId : undefined,
}; };
}, },
pageTitle() { pageTitle() {
@ -168,6 +169,12 @@ export default {
return labels.includes(this.label); return labels.includes(this.label);
}); });
}, },
activeTeam() {
if (this.teamId) {
return this.$store.getters['teams/getTeam'](this.teamId);
}
return {};
},
}, },
watch: { watch: {
activeTeam() { activeTeam() {

View file

@ -85,6 +85,10 @@ export default {
type: Boolean, type: Boolean,
default: false, default: false,
}, },
teamId: {
type: [String, Number],
default: 0,
},
}, },
computed: { computed: {
@ -171,6 +175,7 @@ export default {
activeInbox, activeInbox,
id: chat.id, id: chat.id,
label: this.activeLabel, label: this.activeLabel,
teamId: this.teamId,
}); });
router.push({ path: frontendURL(path) }); router.push({ path: frontendURL(path) });
}, },

View file

@ -5,13 +5,22 @@ export const frontendURL = (path, params) => {
return `/app/${path}${stringifiedParams}`; return `/app/${path}${stringifiedParams}`;
}; };
export const conversationUrl = ({ accountId, activeInbox, id, label }) => { export const conversationUrl = ({
accountId,
activeInbox,
id,
label,
teamId,
}) => {
if (activeInbox) { if (activeInbox) {
return `accounts/${accountId}/inbox/${activeInbox}/conversations/${id}`; return `accounts/${accountId}/inbox/${activeInbox}/conversations/${id}`;
} }
if (label) { if (label) {
return `accounts/${accountId}/label/${label}/conversations/${id}`; return `accounts/${accountId}/label/${label}/conversations/${id}`;
} }
if (teamId) {
return `accounts/${accountId}/team/${teamId}/conversations/${id}`;
}
return `accounts/${accountId}/conversations/${id}`; return `accounts/${accountId}/conversations/${id}`;
}; };

View file

@ -21,6 +21,11 @@ describe('#URL Helpers', () => {
conversationUrl({ accountId: 1, label: 'customer-support', id: 1 }) conversationUrl({ accountId: 1, label: 'customer-support', id: 1 })
).toBe('accounts/1/label/customer-support/conversations/1'); ).toBe('accounts/1/label/customer-support/conversations/1');
}); });
it('should return correct conversation URL if team Id is available', () => {
expect(conversationUrl({ accountId: 1, teamId: 1, id: 1 })).toBe(
'accounts/1/team/1/conversations/1'
);
});
}); });
describe('frontendURL', () => { describe('frontendURL', () => {

View file

@ -3,7 +3,7 @@
<chat-list <chat-list
:conversation-inbox="inboxId" :conversation-inbox="inboxId"
:label="label" :label="label"
:active-team="activeTeam" :team-id="teamId"
@conversation-load="onConversationLoad" @conversation-load="onConversationLoad"
> >
<pop-over-search /> <pop-over-search />
@ -68,12 +68,6 @@ export default {
} }
return false; return false;
}, },
activeTeam() {
if (this.teamId) {
return this.$store.getters['teams/getTeam'](this.teamId);
}
return {};
},
}, },
mounted() { mounted() {