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:
committed by
GitHub
parent
bece13e6b0
commit
b601a2f55f
@@ -17,7 +17,6 @@ declare module '@vue/runtime-core' {
|
||||
HoppButtonPrimary: typeof import('@hoppscotch/ui')['HoppButtonPrimary']
|
||||
HoppButtonSecondary: typeof import('@hoppscotch/ui')['HoppButtonSecondary']
|
||||
HoppSmartAnchor: typeof import('@hoppscotch/ui')['HoppSmartAnchor']
|
||||
HoppSmartAutoComplete: typeof import('@hoppscotch/ui')['HoppSmartAutoComplete']
|
||||
HoppSmartConfirmModal: typeof import('@hoppscotch/ui')['HoppSmartConfirmModal']
|
||||
HoppSmartInput: typeof import('@hoppscotch/ui')['HoppSmartInput']
|
||||
HoppSmartItem: typeof import('@hoppscotch/ui')['HoppSmartItem']
|
||||
@@ -26,14 +25,9 @@ declare module '@vue/runtime-core' {
|
||||
HoppSmartPicture: typeof import('@hoppscotch/ui')['HoppSmartPicture']
|
||||
HoppSmartSpinner: typeof import('@hoppscotch/ui')['HoppSmartSpinner']
|
||||
HoppSmartTab: typeof import('@hoppscotch/ui')['HoppSmartTab']
|
||||
HoppSmartTable: typeof import('@hoppscotch/ui')['HoppSmartTable']
|
||||
HoppSmartTabs: typeof import('@hoppscotch/ui')['HoppSmartTabs']
|
||||
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']
|
||||
IconLucideSearch: typeof import('~icons/lucide/search')['default']
|
||||
IconLucideUser: typeof import('~icons/lucide/user')['default']
|
||||
SettingsAuthProvider: typeof import('./components/settings/AuthProvider.vue')['default']
|
||||
SettingsConfigurations: typeof import('./components/settings/Configurations.vue')['default']
|
||||
SettingsDataSharing: typeof import('./components/settings/DataSharing.vue')['default']
|
||||
|
||||
@@ -24,7 +24,11 @@
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<SettingsServerRestart v-if="resetInfraConfigs" :reset="resetInfraConfigs" />
|
||||
<SettingsServerRestart
|
||||
v-if="resetInfraConfigs"
|
||||
:reset="resetInfraConfigs"
|
||||
@mutation-failure="resetInfraConfigs = false"
|
||||
/>
|
||||
|
||||
<HoppSmartConfirmModal
|
||||
:show="resetModal"
|
||||
|
||||
@@ -39,6 +39,10 @@ const props = withDefaults(
|
||||
}
|
||||
);
|
||||
|
||||
const emit = defineEmits<{
|
||||
(e: 'mutationFailure'): void;
|
||||
}>();
|
||||
|
||||
// Mutations to update or reset server configurations and audit logs
|
||||
const resetInfraConfigsMutation = useMutation(ResetInfraConfigsDocument);
|
||||
const updateInfraConfigsMutation = useMutation(UpdateInfraConfigsDocument);
|
||||
@@ -73,28 +77,40 @@ const startCountdown = () => {
|
||||
}, 1000);
|
||||
};
|
||||
|
||||
const triggerComponentUnMount = () => emit('mutationFailure');
|
||||
|
||||
// Call relevant mutations on component mount and initiate server restart
|
||||
onMounted(async () => {
|
||||
let success = true;
|
||||
|
||||
if (props.reset) {
|
||||
success = await resetInfraConfigs(resetInfraConfigsMutation);
|
||||
if (!success) return;
|
||||
const resetInfraConfigsResult = await resetInfraConfigs(
|
||||
resetInfraConfigsMutation
|
||||
);
|
||||
|
||||
if (!resetInfraConfigsResult) {
|
||||
return triggerComponentUnMount();
|
||||
}
|
||||
} else {
|
||||
const infraResult = await updateInfraConfigs(updateInfraConfigsMutation);
|
||||
|
||||
if (!infraResult) return;
|
||||
if (!infraResult) {
|
||||
return triggerComponentUnMount();
|
||||
}
|
||||
|
||||
const authResult = await updateAuthProvider(
|
||||
updateAllowedAuthProviderMutation
|
||||
);
|
||||
if (!authResult) return;
|
||||
|
||||
if (!authResult) {
|
||||
return triggerComponentUnMount();
|
||||
}
|
||||
|
||||
const dataSharingResult = await updateDataSharingConfigs(
|
||||
toggleDataSharingMutation
|
||||
);
|
||||
|
||||
if (!dataSharingResult) return;
|
||||
if (!dataSharingResult) {
|
||||
return triggerComponentUnMount();
|
||||
}
|
||||
}
|
||||
|
||||
restart.value = true;
|
||||
|
||||
@@ -37,6 +37,7 @@
|
||||
<SettingsServerRestart
|
||||
v-if="initiateServerRestart"
|
||||
:workingConfigs="workingConfigs"
|
||||
@mutation-failure="initiateServerRestart = false"
|
||||
/>
|
||||
|
||||
<HoppSmartConfirmModal
|
||||
|
||||
Reference in New Issue
Block a user