Skip to content

Commit

Permalink
refactor(sh-admin): improved handling of server configurations in adm…
Browse files Browse the repository at this point in the history
…in dashboard (#3971)

Co-authored-by: jamesgeorge007 <jamesgeorge998001@gmail.com>
  • Loading branch information
JoelJacobStephen and jamesgeorge007 committed May 6, 2024
1 parent eecc3db commit 9424807
Show file tree
Hide file tree
Showing 9 changed files with 303 additions and 279 deletions.
3 changes: 2 additions & 1 deletion packages/hoppscotch-sh-admin/locales/en.json
Expand Up @@ -52,7 +52,8 @@
"title": "Server is restarting"
},
"save_changes": "Save Changes",
"title": "Configurations"
"title": "Configurations",
"update_failure": "Failed to update server configurations"
},
"data_sharing": {
"description": "Share anonymous data usage to improve Hoppscotch",
Expand Down
Expand Up @@ -69,18 +69,18 @@
import { useVModel } from '@vueuse/core';
import { reactive } from 'vue';
import { useI18n } from '~/composables/i18n';
import { Config, SsoAuthProviders } from '~/composables/useConfigHandler';
import { ServerConfigs, SsoAuthProviders } from '~/helpers/configs';
import IconEye from '~icons/lucide/eye';
import IconEyeOff from '~icons/lucide/eye-off';
const t = useI18n();
const props = defineProps<{
config: Config;
config: ServerConfigs;
}>();
const emit = defineEmits<{
(e: 'update:config', v: Config): void;
(e: 'update:config', v: ServerConfigs): void;
}>();
const workingConfigs = useVModel(props, 'config', emit);
Expand All @@ -93,7 +93,7 @@ const capitalize = (text: string) =>
type ProviderFieldKeys = keyof ProviderFields;
type ProviderFields = {
[Field in keyof Config['providers'][SsoAuthProviders]['fields']]: boolean;
[Field in keyof ServerConfigs['providers'][SsoAuthProviders]['fields']]: boolean;
} & Partial<{ tenant: boolean }>;
type ProviderFieldMetadata = {
Expand Down
Expand Up @@ -9,14 +9,14 @@

<script setup lang="ts">
import { useVModel } from '@vueuse/core';
import { Config } from '~/composables/useConfigHandler';
import { ServerConfigs } from '~/helpers/configs';
const props = defineProps<{
config: Config;
config: ServerConfigs;
}>();
const emit = defineEmits<{
(e: 'update:config', v: Config): void;
(e: 'update:config', v: ServerConfigs): void;
}>();
const workingConfigs = useVModel(props, 'config', emit);
Expand Down
Expand Up @@ -38,17 +38,17 @@
import { useVModel } from '@vueuse/core';
import { computed } from 'vue';
import { useI18n } from '~/composables/i18n';
import { Config } from '~/composables/useConfigHandler';
import { ServerConfigs } from '~/helpers/configs';
import IconShieldQuestion from '~icons/lucide/shield-question';
const t = useI18n();
const props = defineProps<{
config: Config;
config: ServerConfigs;
}>();
const emit = defineEmits<{
(e: 'update:config', v: Config): void;
(e: 'update:config', v: ServerConfigs): void;
}>();
const workingConfigs = useVModel(props, 'config', emit);
Expand Down
Expand Up @@ -17,20 +17,21 @@ import { useMutation } from '@urql/vue';
import { onMounted, ref } from 'vue';
import { useI18n } from '~/composables/i18n';
import { useToast } from '~/composables/toast';
import { Config, useConfigHandler } from '~/composables/useConfigHandler';
import { useConfigHandler } from '~/composables/useConfigHandler';
import {
EnableAndDisableSsoDocument,
ResetInfraConfigsDocument,
UpdateInfraConfigsDocument,
ToggleAnalyticsCollectionDocument,
UpdateInfraConfigsDocument,
} from '~/helpers/backend/graphql';
import { ServerConfigs } from '~/helpers/configs';
const t = useI18n();
const toast = useToast();
const props = withDefaults(
defineProps<{
workingConfigs?: Config;
workingConfigs?: ServerConfigs;
reset?: boolean;
}>(),
{
Expand Down
Expand Up @@ -58,18 +58,18 @@
import { useVModel } from '@vueuse/core';
import { computed, reactive } from 'vue';
import { useI18n } from '~/composables/i18n';
import { Config } from '~/composables/useConfigHandler';
import { ServerConfigs } from '~/helpers/configs';
import IconEye from '~icons/lucide/eye';
import IconEyeOff from '~icons/lucide/eye-off';
const t = useI18n();
const props = defineProps<{
config: Config;
config: ServerConfigs;
}>();
const emit = defineEmits<{
(e: 'update:config', v: Config): void;
(e: 'update:config', v: ServerConfigs): void;
}>();
const workingConfigs = useVModel(props, 'config', emit);
Expand All @@ -87,7 +87,7 @@ const smtpConfigs = computed({
// Mask sensitive fields
type Field = {
name: string;
key: keyof Config['mailConfigs']['fields'];
key: keyof ServerConfigs['mailConfigs']['fields'];
};
const smtpConfigFields = reactive<Field[]>([
Expand All @@ -100,10 +100,10 @@ const maskState = reactive<Record<string, boolean>>({
mailer_from_address: true,
});
const toggleMask = (fieldKey: keyof Config['mailConfigs']['fields']) => {
const toggleMask = (fieldKey: keyof ServerConfigs['mailConfigs']['fields']) => {
maskState[fieldKey] = !maskState[fieldKey];
};
const isMasked = (fieldKey: keyof Config['mailConfigs']['fields']) =>
const isMasked = (fieldKey: keyof ServerConfigs['mailConfigs']['fields']) =>
maskState[fieldKey];
</script>

0 comments on commit 9424807

Please sign in to comment.