fix(sh-admin): saving changes to server configurations post a failed attempt will require a page reload in dashboard (#4081)

* fix: resolved an issue with server restart component

* refactor: early return if any mutation fails when initiating server restart

* fix: ensure further attempts go through after a failed reset configs action

---------

Co-authored-by: jamesgeorge007 <jamesgeorge998001@gmail.com>
This commit is contained in:
Joel Jacob Stephen
2024-06-03 14:31:44 +05:30
committed by GitHub
parent bece13e6b0
commit b601a2f55f
4 changed files with 29 additions and 14 deletions

View File

@@ -17,7 +17,6 @@ declare module '@vue/runtime-core' {
HoppButtonPrimary: typeof import('@hoppscotch/ui')['HoppButtonPrimary'] HoppButtonPrimary: typeof import('@hoppscotch/ui')['HoppButtonPrimary']
HoppButtonSecondary: typeof import('@hoppscotch/ui')['HoppButtonSecondary'] HoppButtonSecondary: typeof import('@hoppscotch/ui')['HoppButtonSecondary']
HoppSmartAnchor: typeof import('@hoppscotch/ui')['HoppSmartAnchor'] HoppSmartAnchor: typeof import('@hoppscotch/ui')['HoppSmartAnchor']
HoppSmartAutoComplete: typeof import('@hoppscotch/ui')['HoppSmartAutoComplete']
HoppSmartConfirmModal: typeof import('@hoppscotch/ui')['HoppSmartConfirmModal'] HoppSmartConfirmModal: typeof import('@hoppscotch/ui')['HoppSmartConfirmModal']
HoppSmartInput: typeof import('@hoppscotch/ui')['HoppSmartInput'] HoppSmartInput: typeof import('@hoppscotch/ui')['HoppSmartInput']
HoppSmartItem: typeof import('@hoppscotch/ui')['HoppSmartItem'] HoppSmartItem: typeof import('@hoppscotch/ui')['HoppSmartItem']
@@ -26,14 +25,9 @@ declare module '@vue/runtime-core' {
HoppSmartPicture: typeof import('@hoppscotch/ui')['HoppSmartPicture'] HoppSmartPicture: typeof import('@hoppscotch/ui')['HoppSmartPicture']
HoppSmartSpinner: typeof import('@hoppscotch/ui')['HoppSmartSpinner'] HoppSmartSpinner: typeof import('@hoppscotch/ui')['HoppSmartSpinner']
HoppSmartTab: typeof import('@hoppscotch/ui')['HoppSmartTab'] HoppSmartTab: typeof import('@hoppscotch/ui')['HoppSmartTab']
HoppSmartTable: typeof import('@hoppscotch/ui')['HoppSmartTable']
HoppSmartTabs: typeof import('@hoppscotch/ui')['HoppSmartTabs'] HoppSmartTabs: typeof import('@hoppscotch/ui')['HoppSmartTabs']
HoppSmartToggle: typeof import('@hoppscotch/ui')['HoppSmartToggle'] HoppSmartToggle: typeof import('@hoppscotch/ui')['HoppSmartToggle']
IconLucideArrowLeft: typeof import('~icons/lucide/arrow-left')['default']
IconLucideChevronDown: typeof import('~icons/lucide/chevron-down')['default']
IconLucideInbox: typeof import('~icons/lucide/inbox')['default'] IconLucideInbox: typeof import('~icons/lucide/inbox')['default']
IconLucideSearch: typeof import('~icons/lucide/search')['default']
IconLucideUser: typeof import('~icons/lucide/user')['default']
SettingsAuthProvider: typeof import('./components/settings/AuthProvider.vue')['default'] SettingsAuthProvider: typeof import('./components/settings/AuthProvider.vue')['default']
SettingsConfigurations: typeof import('./components/settings/Configurations.vue')['default'] SettingsConfigurations: typeof import('./components/settings/Configurations.vue')['default']
SettingsDataSharing: typeof import('./components/settings/DataSharing.vue')['default'] SettingsDataSharing: typeof import('./components/settings/DataSharing.vue')['default']

View File

@@ -24,7 +24,11 @@
</div> </div>
</div> </div>
<SettingsServerRestart v-if="resetInfraConfigs" :reset="resetInfraConfigs" /> <SettingsServerRestart
v-if="resetInfraConfigs"
:reset="resetInfraConfigs"
@mutation-failure="resetInfraConfigs = false"
/>
<HoppSmartConfirmModal <HoppSmartConfirmModal
:show="resetModal" :show="resetModal"

View File

@@ -39,6 +39,10 @@ const props = withDefaults(
} }
); );
const emit = defineEmits<{
(e: 'mutationFailure'): void;
}>();
// Mutations to update or reset server configurations and audit logs // Mutations to update or reset server configurations and audit logs
const resetInfraConfigsMutation = useMutation(ResetInfraConfigsDocument); const resetInfraConfigsMutation = useMutation(ResetInfraConfigsDocument);
const updateInfraConfigsMutation = useMutation(UpdateInfraConfigsDocument); const updateInfraConfigsMutation = useMutation(UpdateInfraConfigsDocument);
@@ -73,28 +77,40 @@ const startCountdown = () => {
}, 1000); }, 1000);
}; };
const triggerComponentUnMount = () => emit('mutationFailure');
// Call relevant mutations on component mount and initiate server restart // Call relevant mutations on component mount and initiate server restart
onMounted(async () => { onMounted(async () => {
let success = true;
if (props.reset) { if (props.reset) {
success = await resetInfraConfigs(resetInfraConfigsMutation); const resetInfraConfigsResult = await resetInfraConfigs(
if (!success) return; resetInfraConfigsMutation
);
if (!resetInfraConfigsResult) {
return triggerComponentUnMount();
}
} else { } else {
const infraResult = await updateInfraConfigs(updateInfraConfigsMutation); const infraResult = await updateInfraConfigs(updateInfraConfigsMutation);
if (!infraResult) return; if (!infraResult) {
return triggerComponentUnMount();
}
const authResult = await updateAuthProvider( const authResult = await updateAuthProvider(
updateAllowedAuthProviderMutation updateAllowedAuthProviderMutation
); );
if (!authResult) return;
if (!authResult) {
return triggerComponentUnMount();
}
const dataSharingResult = await updateDataSharingConfigs( const dataSharingResult = await updateDataSharingConfigs(
toggleDataSharingMutation toggleDataSharingMutation
); );
if (!dataSharingResult) return; if (!dataSharingResult) {
return triggerComponentUnMount();
}
} }
restart.value = true; restart.value = true;

View File

@@ -37,6 +37,7 @@
<SettingsServerRestart <SettingsServerRestart
v-if="initiateServerRestart" v-if="initiateServerRestart"
:workingConfigs="workingConfigs" :workingConfigs="workingConfigs"
@mutation-failure="initiateServerRestart = false"
/> />
<HoppSmartConfirmModal <HoppSmartConfirmModal