feat: add reauthorization banner for Facebook (#9553)

This commit is contained in:
Shivam Mishra
2024-05-30 09:41:04 +05:30
committed by GitHub
parent b53ce3fa79
commit 6c682a6869
7 changed files with 25 additions and 24 deletions

View File

@@ -65,11 +65,11 @@
</div> </div>
<span <span
v-if="warningIcon" v-if="warningIcon"
class="inline-flex rounded-sm mr-1 bg-slate-100" class="inline-flex mr-1 bg-red-50 dark:bg-red-900 p-0.5 rounded-sm"
> >
<fluent-icon <fluent-icon
v-tooltip.top-end="$t('SIDEBAR.FACEBOOK_REAUTHORIZE')" v-tooltip.top-end="$t('SIDEBAR.REAUTHORIZE')"
class="text-xxs" class="text-xxs text-red-500 dark:text-red-300"
:icon="warningIcon" :icon="warningIcon"
size="12" size="12"
/> />

View File

@@ -87,7 +87,8 @@ export const getInboxClassByType = (type, phoneNumber) => {
}; };
export const getInboxWarningIconClass = (type, reauthorizationRequired) => { export const getInboxWarningIconClass = (type, reauthorizationRequired) => {
if (type === INBOX_TYPES.FB && reauthorizationRequired) { const allowedInboxTypes = [INBOX_TYPES.FB, INBOX_TYPES.EMAIL];
if (allowedInboxTypes.includes(type) && reauthorizationRequired) {
return 'warning'; return 'warning';
} }
return ''; return '';

View File

@@ -274,7 +274,7 @@
"SLA": "SLA", "SLA": "SLA",
"BETA": "Beta", "BETA": "Beta",
"REPORTS_OVERVIEW": "Overview", "REPORTS_OVERVIEW": "Overview",
"FACEBOOK_REAUTHORIZE": "Your Facebook connection has expired, please reconnect your Facebook page to continue services", "REAUTHORIZE": "Your inbox connection has expired, please reconnect\n to continue receiving and sending messages",
"HELP_CENTER": { "HELP_CENTER": {
"TITLE": "Help Center", "TITLE": "Help Center",
"ALL_ARTICLES": "All Articles", "ALL_ARTICLES": "All Articles",

View File

@@ -22,6 +22,7 @@
</setting-intro-banner> </setting-intro-banner>
<microsoft-reauthorize v-if="microsoftUnauthorized" :inbox="inbox" /> <microsoft-reauthorize v-if="microsoftUnauthorized" :inbox="inbox" />
<facebook-reauthorize v-if="facebookUnauthorized" :inbox="inbox" />
<div v-if="selectedTabKey === 'inbox_settings'" class="mx-8"> <div v-if="selectedTabKey === 'inbox_settings'" class="mx-8">
<settings-section <settings-section
@@ -399,7 +400,6 @@
@click="updateInbox" @click="updateInbox"
/> />
</settings-section> </settings-section>
<facebook-reauthorize v-if="isAFacebookInbox" :inbox-id="inbox.id" />
</div> </div>
<div v-if="selectedTabKey === 'collaborators'" class="mx-8"> <div v-if="selectedTabKey === 'collaborators'" class="mx-8">
@@ -619,7 +619,10 @@ export default {
return false; return false;
}, },
microsoftUnauthorized() { microsoftUnauthorized() {
return this.inbox.microsoft_reauthorization; return this.isAMicrosoftInbox && this.inbox.reauthorization_required;
},
facebookUnauthorized() {
return this.isAFacebookInbox && this.inbox.reauthorization_required;
}, },
}, },
watch: { watch: {

View File

@@ -1,38 +1,32 @@
<template> <template>
<settings-section <inbox-reconnection-required class="mx-8 mt-5" @reauthorize="tryFBlogin" />
:title="$t('INBOX_MGMT.FACEBOOK_REAUTHORIZE.TITLE')"
:sub-title="$t('INBOX_MGMT.FACEBOOK_REAUTHORIZE.SUBTITLE')"
>
<a class="fb--login" href="#" @click="tryFBlogin">
<img
src="~dashboard/assets/images/channels/facebook_login.png"
alt="Facebook-logo"
/>
</a>
</settings-section>
</template> </template>
<script> <script>
/* global FB */ /* global FB */
import SettingsSection from '../../../../../components/SettingsSection.vue'; import InboxReconnectionRequired from '../components/InboxReconnectionRequired';
import alertMixin from 'shared/mixins/alertMixin'; import alertMixin from 'shared/mixins/alertMixin';
export default { export default {
components: { components: {
SettingsSection, InboxReconnectionRequired,
}, },
mixins: [alertMixin], mixins: [alertMixin],
props: { props: {
inboxId: { inbox: {
type: Number, type: Object,
required: true, required: true,
}, },
}, },
computed: {
inboxId() {
return this.inbox.id;
},
},
mounted() { mounted() {
this.initFB(); this.initFB();
this.loadFBsdk(); this.loadFBsdk();
}, },
methods: { methods: {
initFB() { initFB() {
if (window.fbSDKLoaded === undefined) { if (window.fbSDKLoaded === undefined) {

View File

@@ -44,6 +44,9 @@ export default {
whatsAppAPIProvider() { whatsAppAPIProvider() {
return this.inbox.provider || ''; return this.inbox.provider || '';
}, },
isAMicrosoftInbox() {
return this.isAnEmailChannel && this.inbox.provider === 'microsoft';
},
isAPIInbox() { isAPIInbox() {
return this.channelType === INBOX_TYPES.API; return this.channelType === INBOX_TYPES.API;
}, },

View File

@@ -74,7 +74,7 @@ if resource.email?
json.imap_enable_ssl resource.channel.try(:imap_enable_ssl) json.imap_enable_ssl resource.channel.try(:imap_enable_ssl)
if resource.channel.try(:microsoft?) if resource.channel.try(:microsoft?)
json.microsoft_reauthorization resource.channel.try(:provider_config).empty? || resource.channel.try(:reauthorization_required?) json.reauthorization_required resource.channel.try(:provider_config).empty? || resource.channel.try(:reauthorization_required?)
end end
end end