Skip to content

Commit

Permalink
refactor: updated types and removing unnecessary exports
Browse files Browse the repository at this point in the history
  • Loading branch information
JoelJacobStephen committed Apr 30, 2024
1 parent 957a3ee commit 5b0b43a
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 16 deletions.
3 changes: 0 additions & 3 deletions packages/hoppscotch-sh-admin/src/components.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,16 +24,13 @@ declare module '@vue/runtime-core' {
HoppSmartLink: typeof import('@hoppscotch/ui')['HoppSmartLink']
HoppSmartModal: typeof import('@hoppscotch/ui')['HoppSmartModal']
HoppSmartPicture: typeof import('@hoppscotch/ui')['HoppSmartPicture']
HoppSmartPlaceholder: typeof import('@hoppscotch/ui')['HoppSmartPlaceholder']
HoppSmartSelectWrapper: typeof import('@hoppscotch/ui')['HoppSmartSelectWrapper']
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']
IconLucideHelpCircle: typeof import('~icons/lucide/help-circle')['default']
IconLucideInbox: typeof import('~icons/lucide/inbox')['default']
IconLucideSearch: typeof import('~icons/lucide/search')['default']
IconLucideUser: typeof import('~icons/lucide/user')['default']
Expand Down
20 changes: 8 additions & 12 deletions packages/hoppscotch-sh-admin/src/composables/useConfigHandler.ts
Original file line number Diff line number Diff line change
Expand Up @@ -157,40 +157,38 @@ export function useConfigHandler(updatedConfigs?: ServerConfigs) {
{
config: GOOGLE_CONFIGS,
enabled: updatedConfigs?.providers.google.enabled,
field: updatedConfigs?.providers.google.fields,
fields: updatedConfigs?.providers.google.fields,
},
{
config: GITHUB_CONFIGS,
enabled: updatedConfigs?.providers.github.enabled,
field: updatedConfigs?.providers.github.fields,
fields: updatedConfigs?.providers.github.fields,
},
{
config: MICROSOFT_CONFIGS,
enabled: updatedConfigs?.providers.microsoft.enabled,
field: updatedConfigs?.providers.microsoft.fields,
fields: updatedConfigs?.providers.microsoft.fields,
},
{
config: MAIL_CONFIGS,
enabled: updatedConfigs?.mailConfigs.enabled,
field: updatedConfigs?.mailConfigs.fields,
fields: updatedConfigs?.mailConfigs.fields,
},
];

// Push or filter the configs based on the enabled condition
const transformInfraConfigs = (workingConfigs: ConfigTransform[]) => {
let newConfigs: UpdatedConfigs[] = [];

workingConfigs.forEach(({ config, enabled, field }) => {
workingConfigs.forEach(({ config, enabled, fields }) => {
config.forEach(({ name, key }) => {
if (enabled && field) {
const value = typeof field === 'string' ? field : String(field[key]);
if (enabled && fields) {
const value =
typeof fields === 'string' ? fields : String(fields[key]);
newConfigs.push({ name, value });
} else {
newConfigs = newConfigs.filter((item) => item.name !== name);
}
});
});
newConfigs = newConfigs.filter((item) => item.name !== '');
return newConfigs;
};

Expand Down Expand Up @@ -286,8 +284,6 @@ export function useConfigHandler(updatedConfigs?: ServerConfigs) {
return {
currentConfigs,
workingConfigs,
updatedInfraConfigs,
updatedAllowedAuthProviders,
updateAuthProvider,
updateDataSharingConfigs,
updateInfraConfigs,
Expand Down
2 changes: 1 addition & 1 deletion packages/hoppscotch-sh-admin/src/helpers/configs.ts
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ export type UpdatedConfigs = {
export type ConfigTransform = {
config: Config[];
enabled?: boolean;
field?: Record<string, string | boolean> | string;
fields?: Record<string, string | boolean> | string;
};

export type ConfigSection = {
Expand Down

0 comments on commit 5b0b43a

Please sign in to comment.