refactor: added data sharing configs to confighandler
This commit is contained in:
@@ -54,6 +54,11 @@ export type Config = {
|
|||||||
mailer_from_address: string;
|
mailer_from_address: string;
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
|
dataSharingConfigs: {
|
||||||
|
name: string;
|
||||||
|
enabled: boolean;
|
||||||
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
type UpdatedConfigs = {
|
type UpdatedConfigs = {
|
||||||
@@ -86,6 +91,7 @@ export function useConfigHandler(updatedConfigs?: Config) {
|
|||||||
'GITHUB_CLIENT_SECRET',
|
'GITHUB_CLIENT_SECRET',
|
||||||
'MAILER_SMTP_URL',
|
'MAILER_SMTP_URL',
|
||||||
'MAILER_ADDRESS_FROM',
|
'MAILER_ADDRESS_FROM',
|
||||||
|
'ALLOW_ANALYTICS_COLLECTION',
|
||||||
] as InfraConfigEnum[],
|
] as InfraConfigEnum[],
|
||||||
},
|
},
|
||||||
(x) => x.infraConfigs
|
(x) => x.infraConfigs
|
||||||
@@ -164,6 +170,15 @@ export function useConfigHandler(updatedConfigs?: Config) {
|
|||||||
?.value ?? '',
|
?.value ?? '',
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
dataSharingConfigs: {
|
||||||
|
name: 'data_sharing',
|
||||||
|
enabled:
|
||||||
|
infraConfigs.value.find(
|
||||||
|
(x) => x.name === 'ALLOW_ANALYTICS_COLLECTION'
|
||||||
|
)?.value === 'true'
|
||||||
|
? true
|
||||||
|
: false,
|
||||||
|
},
|
||||||
};
|
};
|
||||||
|
|
||||||
// Cloning the current configs to working configs
|
// Cloning the current configs to working configs
|
||||||
@@ -254,6 +269,17 @@ 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;
|
||||||
|
|||||||
Reference in New Issue
Block a user