Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refactor(sh-admin): improved handling of server configurations in admin dashboard #3971

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
15 commits
Select commit Hold shift + click to select a range
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
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>