feat: added new configs and mutations for data sharing in config handler and server restart
This commit is contained in:
@@ -22,6 +22,7 @@ import {
|
|||||||
EnableAndDisableSsoDocument,
|
EnableAndDisableSsoDocument,
|
||||||
ResetInfraConfigsDocument,
|
ResetInfraConfigsDocument,
|
||||||
UpdateInfraConfigsDocument,
|
UpdateInfraConfigsDocument,
|
||||||
|
ToggleAnalyticsCollectionDocument,
|
||||||
} from '~/helpers/backend/graphql';
|
} from '~/helpers/backend/graphql';
|
||||||
|
|
||||||
const t = useI18n();
|
const t = useI18n();
|
||||||
@@ -43,10 +44,17 @@ const updateInfraConfigsMutation = useMutation(UpdateInfraConfigsDocument);
|
|||||||
const updateAllowedAuthProviderMutation = useMutation(
|
const updateAllowedAuthProviderMutation = useMutation(
|
||||||
EnableAndDisableSsoDocument
|
EnableAndDisableSsoDocument
|
||||||
);
|
);
|
||||||
|
const toggleDataSharingMutation = useMutation(
|
||||||
|
ToggleAnalyticsCollectionDocument
|
||||||
|
);
|
||||||
|
|
||||||
// Mutation handlers
|
// Mutation handlers
|
||||||
const { updateInfraConfigs, updateAuthProvider, resetInfraConfigs } =
|
const {
|
||||||
useConfigHandler(props.workingConfigs);
|
updateInfraConfigs,
|
||||||
|
updateAuthProvider,
|
||||||
|
resetInfraConfigs,
|
||||||
|
updateDataSharingConfigs,
|
||||||
|
} = useConfigHandler(props.workingConfigs);
|
||||||
|
|
||||||
// Call relevant mutations on component mount and initiate server restart
|
// Call relevant mutations on component mount and initiate server restart
|
||||||
const duration = ref(30);
|
const duration = ref(30);
|
||||||
@@ -80,6 +88,12 @@ onMounted(async () => {
|
|||||||
updateAllowedAuthProviderMutation
|
updateAllowedAuthProviderMutation
|
||||||
);
|
);
|
||||||
if (!authResult) return;
|
if (!authResult) return;
|
||||||
|
|
||||||
|
const dataSharingReult = await updateDataSharingConfigs(
|
||||||
|
toggleDataSharingMutation
|
||||||
|
);
|
||||||
|
|
||||||
|
if (!dataSharingReult) return;
|
||||||
}
|
}
|
||||||
|
|
||||||
restart.value = true;
|
restart.value = true;
|
||||||
|
|||||||
@@ -12,6 +12,7 @@ import {
|
|||||||
UpdateInfraConfigsMutation,
|
UpdateInfraConfigsMutation,
|
||||||
ResetInfraConfigsMutation,
|
ResetInfraConfigsMutation,
|
||||||
EnableAndDisableSsoArgs,
|
EnableAndDisableSsoArgs,
|
||||||
|
ToggleAnalyticsCollectionMutation,
|
||||||
InfraConfigArgs,
|
InfraConfigArgs,
|
||||||
} from '~/helpers/backend/graphql';
|
} from '~/helpers/backend/graphql';
|
||||||
|
|
||||||
@@ -269,17 +270,6 @@ export function useConfigHandler(updatedConfigs?: Config) {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (updatedConfigs?.dataSharingConfigs.enabled) {
|
|
||||||
config.push({
|
|
||||||
name: 'ALLOW_ANALYTICS_COLLECTION',
|
|
||||||
value: updatedConfigs?.dataSharingConfigs.enabled ? 'true' : 'false',
|
|
||||||
});
|
|
||||||
} else {
|
|
||||||
config = config.filter(
|
|
||||||
(item) => item.name !== 'ALLOW_ANALYTICS_COLLECTION'
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
config = config.filter((item) => item.name !== '');
|
config = config.filter((item) => item.name !== '');
|
||||||
|
|
||||||
return config;
|
return config;
|
||||||
@@ -373,12 +363,31 @@ export function useConfigHandler(updatedConfigs?: Config) {
|
|||||||
return true;
|
return true;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
// Updating the data sharing configurations
|
||||||
|
const updateDataSharingConfigs = async (
|
||||||
|
toggleDataSharingMutation: UseMutationResponse<ToggleAnalyticsCollectionMutation>
|
||||||
|
) => {
|
||||||
|
const variables = {
|
||||||
|
status: updatedConfigs?.dataSharingConfigs.enabled ? 'ENABLE' : 'DISABLE',
|
||||||
|
};
|
||||||
|
|
||||||
|
const result = await toggleDataSharingMutation.executeMutation(variables);
|
||||||
|
|
||||||
|
if (result.error) {
|
||||||
|
toast.error(t('configs.data_sharing.update_failure'));
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
|
};
|
||||||
|
|
||||||
return {
|
return {
|
||||||
currentConfigs,
|
currentConfigs,
|
||||||
workingConfigs,
|
workingConfigs,
|
||||||
updatedInfraConfigs,
|
updatedInfraConfigs,
|
||||||
updatedAllowedAuthProviders,
|
updatedAllowedAuthProviders,
|
||||||
updateAuthProvider,
|
updateAuthProvider,
|
||||||
|
updateDataSharingConfigs,
|
||||||
updateInfraConfigs,
|
updateInfraConfigs,
|
||||||
resetInfraConfigs,
|
resetInfraConfigs,
|
||||||
fetchingInfraConfigs,
|
fetchingInfraConfigs,
|
||||||
|
|||||||
Reference in New Issue
Block a user