feat: Add a loader till the dashboard app is loaded (#5814)

Co-authored-by: Pranav Raj S <pranav@chatwoot.com>
Co-authored-by: Sivin Varghese <64252451+iamsivin@users.noreply.github.com>
This commit is contained in:
Fayaz Ahmed
2022-11-09 23:36:09 +05:30
committed by GitHub
parent 7352b928da
commit 47c90e2085
3 changed files with 27 additions and 3 deletions

View File

@@ -5,6 +5,11 @@
:key="index" :key="index"
class="dashboard-app--list" class="dashboard-app--list"
> >
<loading-state
v-if="iframeLoading"
:message="$t('DASHBOARD_APPS.LOADING_MESSAGE')"
class="dashboard-app_loading-container"
/>
<iframe <iframe
v-if="configItem.type === 'frame' && configItem.url" v-if="configItem.type === 'frame' && configItem.url"
:id="`dashboard-app--frame-${index}`" :id="`dashboard-app--frame-${index}`"
@@ -16,7 +21,11 @@
</template> </template>
<script> <script>
import LoadingState from 'dashboard/components/widgets/LoadingState';
export default { export default {
components: {
LoadingState,
},
props: { props: {
config: { config: {
type: Array, type: Array,
@@ -27,6 +36,11 @@ export default {
default: () => ({}), default: () => ({}),
}, },
}, },
data() {
return {
iframeLoading: true,
};
},
computed: { computed: {
dashboardAppContext() { dashboardAppContext() {
return { return {
@@ -57,6 +71,7 @@ export default {
); );
const eventData = { event: 'appContext', data: this.dashboardAppContext }; const eventData = { event: 'appContext', data: this.dashboardAppContext };
frameElement.contentWindow.postMessage(JSON.stringify(eventData), '*'); frameElement.contentWindow.postMessage(JSON.stringify(eventData), '*');
this.iframeLoading = false;
}, },
}, },
}; };
@@ -73,4 +88,11 @@ export default {
.dashboard-app--list iframe { .dashboard-app--list iframe {
border: 0; border: 0;
} }
.dashboard-app_loading-container {
display: flex;
align-items: center;
justify-content: center;
height: 100%;
width: 100%;
}
</style> </style>

View File

@@ -42,7 +42,7 @@
</div> </div>
<dashboard-app-frame <dashboard-app-frame
v-else v-else
:key="currentChat.id" :key="currentChat.id + '-' + activeIndex"
:config="dashboardApps[activeIndex - 1].content" :config="dashboardApps[activeIndex - 1].content"
:current-chat="currentChat" :current-chat="currentChat"
/> />

View File

@@ -122,7 +122,6 @@
"GO_TO_SETTINGS_ACCOUNT": "Go to Account Settings", "GO_TO_SETTINGS_ACCOUNT": "Go to Account Settings",
"GO_TO_SETTINGS_PROFILE": "Go to Profile Settings", "GO_TO_SETTINGS_PROFILE": "Go to Profile Settings",
"GO_TO_NOTIFICATIONS": "Go to Notifications", "GO_TO_NOTIFICATIONS": "Go to Notifications",
"ADD_LABELS_TO_CONVERSATION": "Add label to the conversation", "ADD_LABELS_TO_CONVERSATION": "Add label to the conversation",
"ASSIGN_AN_AGENT": "Assign an agent", "ASSIGN_AN_AGENT": "Assign an agent",
"ASSIGN_A_TEAM": "Assign a team", "ASSIGN_A_TEAM": "Assign a team",
@@ -137,5 +136,8 @@
"UNTIL_NEXT_WEEK": "Until next week", "UNTIL_NEXT_WEEK": "Until next week",
"UNTIL_TOMORROW": "Until tomorrow" "UNTIL_TOMORROW": "Until tomorrow"
} }
},
"DASHBOARD_APPS": {
"LOADING_MESSAGE": "Loading Dashboard App..."
} }
} }