Compare commits
5 Commits
fix/shared
...
pr/jamesge
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
75e2199cb5 | ||
|
|
dacecf3c17 | ||
|
|
ae57e7b5b5 | ||
|
|
e23bc2d864 | ||
|
|
2affb21d22 |
@@ -676,16 +676,9 @@ export const INFRA_CONFIG_RESET_FAILED = 'infra_config/reset_failed' as const;
|
||||
*/
|
||||
export const INFRA_CONFIG_INVALID_INPUT = 'infra_config/invalid_input' as const;
|
||||
|
||||
/**
|
||||
* Infra Config service (auth provider/mailer/audit logs) not configured
|
||||
* (InfraConfigService)
|
||||
*/
|
||||
export const INFRA_CONFIG_SERVICE_NOT_CONFIGURED =
|
||||
'infra_config/service_not_configured' as const;
|
||||
|
||||
/**
|
||||
* Error message for when the database table does not exist
|
||||
* (InfraConfigService)
|
||||
*/
|
||||
export const DATABASE_TABLE_NOT_EXIST =
|
||||
'Database migration not found. Please check the documentation for assistance: https://docs.hoppscotch.io/documentation/self-host/community-edition/install-and-build#running-migrations';
|
||||
'Database migration not performed. Please check the FAQ for assistance: https://docs.hoppscotch.io/support/getting-started/faq';
|
||||
|
||||
@@ -15,13 +15,11 @@ import {
|
||||
INFRA_CONFIG_NOT_LISTED,
|
||||
INFRA_CONFIG_RESET_FAILED,
|
||||
INFRA_CONFIG_UPDATE_FAILED,
|
||||
INFRA_CONFIG_SERVICE_NOT_CONFIGURED,
|
||||
} from 'src/errors';
|
||||
import { throwErr, validateEmail, validateSMTPUrl } from 'src/utils';
|
||||
import { ConfigService } from '@nestjs/config';
|
||||
import { ServiceStatus, stopApp } from './helper';
|
||||
import { EnableAndDisableSSOArgs, InfraConfigArgs } from './input-args';
|
||||
import { AuthProvider } from 'src/auth/helper';
|
||||
|
||||
@Injectable()
|
||||
export class InfraConfigService implements OnModuleInit {
|
||||
@@ -126,7 +124,7 @@ export class InfraConfigService implements OnModuleInit {
|
||||
cast(dbInfraConfig: DBInfraConfig) {
|
||||
return <InfraConfig>{
|
||||
name: dbInfraConfig.name,
|
||||
value: dbInfraConfig.value ?? '',
|
||||
value: dbInfraConfig.value,
|
||||
};
|
||||
}
|
||||
|
||||
@@ -184,38 +182,6 @@ export class InfraConfigService implements OnModuleInit {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Check if the service is configured or not
|
||||
* @param service Service can be Auth Provider, Mailer, Audit Log etc.
|
||||
* @returns Either true or false
|
||||
*/
|
||||
isServiceConfigured(service: AuthProvider) {
|
||||
switch (service) {
|
||||
case AuthProvider.GOOGLE:
|
||||
return (
|
||||
this.configService.get<string>('INFRA.GOOGLE_CLIENT_ID') &&
|
||||
this.configService.get<string>('INFRA.GOOGLE_CLIENT_SECRET')
|
||||
);
|
||||
case AuthProvider.GITHUB:
|
||||
return (
|
||||
this.configService.get<string>('INFRA.GITHUB_CLIENT_ID') &&
|
||||
!this.configService.get<string>('INFRA.GITHUB_CLIENT_SECRET')
|
||||
);
|
||||
case AuthProvider.MICROSOFT:
|
||||
return (
|
||||
this.configService.get<string>('INFRA.MICROSOFT_CLIENT_ID') &&
|
||||
!this.configService.get<string>('INFRA.MICROSOFT_CLIENT_SECRET')
|
||||
);
|
||||
case AuthProvider.EMAIL:
|
||||
return (
|
||||
this.configService.get<string>('INFRA.MAILER_SMTP_URL') &&
|
||||
this.configService.get<string>('INFRA.MAILER_ADDRESS_FROM')
|
||||
);
|
||||
default:
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Enable or Disable SSO for login/signup
|
||||
* @param provider Auth Provider to enable or disable
|
||||
@@ -229,21 +195,15 @@ export class InfraConfigService implements OnModuleInit {
|
||||
|
||||
let updatedAuthProviders = allowedAuthProviders;
|
||||
|
||||
for (let i = 0; i < providerInfo.length; i++) {
|
||||
const { provider, status } = providerInfo[i];
|
||||
|
||||
providerInfo.forEach(({ provider, status }) => {
|
||||
if (status === ServiceStatus.ENABLE) {
|
||||
const isConfigured = this.isServiceConfigured(provider);
|
||||
if (!isConfigured) {
|
||||
throwErr(INFRA_CONFIG_SERVICE_NOT_CONFIGURED);
|
||||
}
|
||||
updatedAuthProviders.push(provider);
|
||||
} else if (status === ServiceStatus.DISABLE) {
|
||||
updatedAuthProviders = updatedAuthProviders.filter(
|
||||
(p) => p !== provider,
|
||||
);
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
updatedAuthProviders = [...new Set(updatedAuthProviders)];
|
||||
|
||||
@@ -326,9 +286,6 @@ export class InfraConfigService implements OnModuleInit {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Validate the values of the InfraConfigs
|
||||
*/
|
||||
validateEnvValues(
|
||||
infraConfigs: {
|
||||
name: InfraConfigEnumForClient | InfraConfigEnum;
|
||||
@@ -345,24 +302,6 @@ export class InfraConfigService implements OnModuleInit {
|
||||
const isValidEmail = validateEmail(infraConfigs[i].value);
|
||||
if (!isValidEmail) return E.left(INFRA_CONFIG_INVALID_INPUT);
|
||||
break;
|
||||
case InfraConfigEnumForClient.GOOGLE_CLIENT_ID:
|
||||
if (!infraConfigs[i].value) return E.left(INFRA_CONFIG_INVALID_INPUT);
|
||||
break;
|
||||
case InfraConfigEnumForClient.GOOGLE_CLIENT_SECRET:
|
||||
if (!infraConfigs[i].value) return E.left(INFRA_CONFIG_INVALID_INPUT);
|
||||
break;
|
||||
case InfraConfigEnumForClient.GITHUB_CLIENT_ID:
|
||||
if (!infraConfigs[i].value) return E.left(INFRA_CONFIG_INVALID_INPUT);
|
||||
break;
|
||||
case InfraConfigEnumForClient.GITHUB_CLIENT_SECRET:
|
||||
if (!infraConfigs[i].value) return E.left(INFRA_CONFIG_INVALID_INPUT);
|
||||
break;
|
||||
case InfraConfigEnumForClient.MICROSOFT_CLIENT_ID:
|
||||
if (!infraConfigs[i].value) return E.left(INFRA_CONFIG_INVALID_INPUT);
|
||||
break;
|
||||
case InfraConfigEnumForClient.MICROSOFT_CLIENT_SECRET:
|
||||
if (!infraConfigs[i].value) return E.left(INFRA_CONFIG_INVALID_INPUT);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
@@ -121,7 +121,7 @@
|
||||
"generate_token": "Generate Token",
|
||||
"graphql_headers": "Authorization Headers are sent as part of the payload to connection_init",
|
||||
"include_in_url": "Include in URL",
|
||||
"inherited_from": "Inherited {auth} from parent collection {collection} ",
|
||||
"inherited_from": "Inherited from {auth} from Parent Collection {collection} ",
|
||||
"learn": "Learn how",
|
||||
"oauth": {
|
||||
"redirect_auth_server_returned_error": "Auth Server returned an error state",
|
||||
@@ -295,7 +295,6 @@
|
||||
"incorrect_email": "Incorrect email",
|
||||
"invalid_link": "Invalid link",
|
||||
"invalid_link_description": "The link you clicked is invalid or expired.",
|
||||
"invalid_embed_link": "The embed does not exist or is invalid.",
|
||||
"json_parsing_failed": "Invalid JSON",
|
||||
"json_prettify_invalid_body": "Couldn't prettify an invalid body, solve json syntax errors and try again",
|
||||
"network_error": "There seems to be a network error. Please try again.",
|
||||
|
||||
11
packages/hoppscotch-common/src/components.d.ts
vendored
11
packages/hoppscotch-common/src/components.d.ts
vendored
@@ -1,11 +1,11 @@
|
||||
/* eslint-disable */
|
||||
/* prettier-ignore */
|
||||
// @ts-nocheck
|
||||
// Generated by unplugin-vue-components
|
||||
// generated by unplugin-vue-components
|
||||
// We suggest you to commit this file into source control
|
||||
// Read more: https://github.com/vuejs/core/pull/3399
|
||||
import '@vue/runtime-core'
|
||||
|
||||
export {}
|
||||
|
||||
declare module 'vue' {
|
||||
declare module '@vue/runtime-core' {
|
||||
export interface GlobalComponents {
|
||||
AppActionHandler: typeof import('./components/app/ActionHandler.vue')['default']
|
||||
AppBanner: typeof import('./components/app/Banner.vue')['default']
|
||||
@@ -210,4 +210,5 @@ declare module 'vue' {
|
||||
WorkspaceCurrent: typeof import('./components/workspace/Current.vue')['default']
|
||||
WorkspaceSelector: typeof import('./components/workspace/Selector.vue')['default']
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -1,16 +1,15 @@
|
||||
<template>
|
||||
<Splitpanes
|
||||
class="smart-splitter"
|
||||
:rtl="SIDEBAR_ON_LEFT && mdAndLarger"
|
||||
:class="{
|
||||
'!flex-row-reverse': SIDEBAR_ON_LEFT && mdAndLarger,
|
||||
'smart-splitter': SIDEBAR && hasSidebar,
|
||||
'no-splitter': !(SIDEBAR && hasSidebar),
|
||||
}"
|
||||
:horizontal="!mdAndLarger"
|
||||
@resize="setPaneEvent($event, 'vertical')"
|
||||
>
|
||||
<Pane
|
||||
:size="SIDEBAR && hasSidebar ? PANE_MAIN_SIZE : 100"
|
||||
:size="PANE_MAIN_SIZE"
|
||||
min-size="65"
|
||||
class="flex flex-col !overflow-auto"
|
||||
>
|
||||
@@ -37,8 +36,9 @@
|
||||
</Splitpanes>
|
||||
</Pane>
|
||||
<Pane
|
||||
:size="SIDEBAR && hasSidebar ? PANE_SIDEBAR_SIZE : 0"
|
||||
:min-size="25"
|
||||
v-if="SIDEBAR && hasSidebar"
|
||||
:size="PANE_SIDEBAR_SIZE"
|
||||
min-size="25"
|
||||
class="flex flex-col !overflow-auto bg-primaryContrast"
|
||||
>
|
||||
<slot name="sidebar" />
|
||||
|
||||
@@ -33,7 +33,6 @@
|
||||
@select="onSelect"
|
||||
@update-team="updateTeam"
|
||||
@update-collection-type="updateCollectionType"
|
||||
@set-team-collection-adapter="teamCollectionAdapter = $event"
|
||||
/>
|
||||
</div>
|
||||
</template>
|
||||
@@ -87,7 +86,6 @@ import { platform } from "~/platform"
|
||||
import { useService } from "dioc/vue"
|
||||
import { RESTTabService } from "~/services/tab/rest"
|
||||
import { GQLTabService } from "~/services/tab/graphql"
|
||||
import TeamCollectionAdapter from "~/helpers/teams/TeamCollectionAdapter"
|
||||
|
||||
const t = useI18n()
|
||||
const toast = useToast()
|
||||
@@ -95,8 +93,6 @@ const toast = useToast()
|
||||
const RESTTabs = useService(RESTTabService)
|
||||
const GQLTabs = useService(GQLTabService)
|
||||
|
||||
const teamCollectionAdapter = ref<TeamCollectionAdapter>()
|
||||
|
||||
type SelectedTeam = GetMyTeamsQuery["myTeams"][number] | undefined
|
||||
|
||||
type CollectionType =
|
||||
@@ -384,6 +380,7 @@ const saveRequestAs = async () => {
|
||||
platform: "rest",
|
||||
workspaceType: "team",
|
||||
})
|
||||
|
||||
pipe(
|
||||
updateTeamRequest(picked.value.requestID, data),
|
||||
TE.match(
|
||||
@@ -391,31 +388,7 @@ const saveRequestAs = async () => {
|
||||
toast.error(`${getErrorMessage(err)}`)
|
||||
modalLoadingState.value = false
|
||||
},
|
||||
(result) => {
|
||||
const { updateRequest } = result
|
||||
|
||||
RESTTabs.currentActiveTab.value.document = {
|
||||
request: requestUpdated,
|
||||
isDirty: false,
|
||||
saveContext: {
|
||||
originLocation: "team-collection",
|
||||
requestID: updateRequest.id,
|
||||
collectionID: updateRequest.collectionID,
|
||||
},
|
||||
}
|
||||
|
||||
if (teamCollectionAdapter.value) {
|
||||
const { auth, headers } =
|
||||
teamCollectionAdapter.value.cascadeParentCollectionForHeaderAuth(
|
||||
updateRequest.collectionID
|
||||
)
|
||||
|
||||
RESTTabs.currentActiveTab.value.document.inheritedProperties = {
|
||||
auth,
|
||||
headers,
|
||||
}
|
||||
}
|
||||
|
||||
() => {
|
||||
modalLoadingState.value = false
|
||||
requestSaved()
|
||||
}
|
||||
@@ -543,18 +516,6 @@ const updateTeamCollectionOrFolder = (
|
||||
},
|
||||
}
|
||||
|
||||
if (teamCollectionAdapter.value) {
|
||||
const { auth, headers } =
|
||||
teamCollectionAdapter.value.cascadeParentCollectionForHeaderAuth(
|
||||
createRequestInCollection.collection.id
|
||||
)
|
||||
|
||||
RESTTabs.currentActiveTab.value.document.inheritedProperties = {
|
||||
auth,
|
||||
headers,
|
||||
}
|
||||
}
|
||||
|
||||
modalLoadingState.value = false
|
||||
requestSaved()
|
||||
}
|
||||
|
||||
@@ -262,7 +262,6 @@ const emit = defineEmits<{
|
||||
(event: "select", payload: Picked | null): void
|
||||
(event: "update-team", team: SelectedTeam): void
|
||||
(event: "update-collection-type", type: CollectionType["type"]): void
|
||||
(event: "set-team-collection-adapter", adapter: TeamCollectionAdapter): void
|
||||
}>()
|
||||
|
||||
type SelectedTeam = GetMyTeamsQuery["myTeams"][number] | undefined
|
||||
@@ -355,7 +354,6 @@ watch(
|
||||
(newTeam) => {
|
||||
if (newTeam) {
|
||||
teamCollectionAdapter.changeTeamID(newTeam.id)
|
||||
emit("set-team-collection-adapter", teamCollectionAdapter)
|
||||
}
|
||||
}
|
||||
)
|
||||
|
||||
@@ -140,10 +140,7 @@ const runQuery = async (
|
||||
const runVariables = clone(request.value.variables)
|
||||
const runAuth =
|
||||
request.value.auth.authType === "inherit" && request.value.auth.authActive
|
||||
? clone(
|
||||
tabs.currentActiveTab.value.document.inheritedProperties?.auth
|
||||
.inheritedAuth
|
||||
)
|
||||
? clone(tabs.currentActiveTab.value.document.inheritedProperties?.auth)
|
||||
: clone(request.value.auth)
|
||||
|
||||
const inheritedHeaders =
|
||||
|
||||
@@ -21,7 +21,7 @@
|
||||
/>
|
||||
</div>
|
||||
<div class="flex flex-col">
|
||||
<div v-if="loading" class="flex flex-col items-center justify-center p-4">
|
||||
<div v-if="loading" class="flex flex-col items-center justify-center">
|
||||
<HoppSmartSpinner class="mb-4" />
|
||||
<span class="text-secondaryLight">{{ t("state.loading") }}</span>
|
||||
</div>
|
||||
@@ -451,7 +451,7 @@ const getErrorMessage = (err: GQLError<string>) => {
|
||||
}
|
||||
switch (err.error) {
|
||||
case "shortcode/not_found":
|
||||
return t("shared_requests.not_found")
|
||||
return t("shared_request.not_found")
|
||||
default:
|
||||
return t("error.something_went_wrong")
|
||||
}
|
||||
|
||||
@@ -2,6 +2,5 @@ mutation UpdateRequest($data: UpdateTeamRequestInput!, $requestID: ID!) {
|
||||
updateRequest(data: $data, requestID: $requestID) {
|
||||
id
|
||||
title
|
||||
collectionID
|
||||
}
|
||||
}
|
||||
|
||||
@@ -27,7 +27,7 @@ export const getDefaultGQLRequest = (): HoppGQLRequest => ({
|
||||
}`,
|
||||
query: DEFAULT_QUERY,
|
||||
auth: {
|
||||
authType: "none",
|
||||
authType: "inherit",
|
||||
authActive: true,
|
||||
},
|
||||
})
|
||||
|
||||
@@ -156,7 +156,6 @@ export default class ShortcodeListAdapter {
|
||||
const [shortcodeCreated$, shortcodeCreatedSub] = runAuthOnlyGQLSubscription(
|
||||
{
|
||||
query: ShortcodeCreatedDocument,
|
||||
variables: {},
|
||||
}
|
||||
)
|
||||
|
||||
@@ -173,7 +172,6 @@ export default class ShortcodeListAdapter {
|
||||
const [shortcodeRevoked$, shortcodeRevokedSub] = runAuthOnlyGQLSubscription(
|
||||
{
|
||||
query: ShortcodeDeletedDocument,
|
||||
variables: {},
|
||||
}
|
||||
)
|
||||
|
||||
@@ -190,7 +188,6 @@ export default class ShortcodeListAdapter {
|
||||
const [shortcodeUpdated$, shortcodeUpdatedSub] = runAuthOnlyGQLSubscription(
|
||||
{
|
||||
query: ShortcodeUpdatedDocument,
|
||||
variables: {},
|
||||
}
|
||||
)
|
||||
|
||||
|
||||
@@ -1034,11 +1034,6 @@ export default class NewTeamCollectionAdapter {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Used to obtain the inherited auth and headers for a given folder path, used for both REST and GraphQL team collections
|
||||
* @param folderPath the path of the folder to cascade the auth from
|
||||
* @returns the inherited auth and headers for the given folder path
|
||||
*/
|
||||
public cascadeParentCollectionForHeaderAuth(folderPath: string) {
|
||||
let auth: HoppInheritedProperty["auth"] = {
|
||||
parentID: folderPath ?? "",
|
||||
@@ -1094,10 +1089,7 @@ export default class NewTeamCollectionAdapter {
|
||||
const parentFolderAuth = data.auth
|
||||
const parentFolderHeaders = data.headers
|
||||
|
||||
if (
|
||||
parentFolderAuth?.authType === "inherit" &&
|
||||
[...path.slice(0, i + 1)].length === 1
|
||||
) {
|
||||
if (parentFolderAuth?.authType === "inherit" && path.length === 1) {
|
||||
auth = {
|
||||
parentID: [...path.slice(0, i + 1)].join("/"),
|
||||
parentName: parentFolder.title,
|
||||
|
||||
@@ -4,7 +4,6 @@ import {
|
||||
HoppRESTRequest,
|
||||
HoppCollection,
|
||||
makeCollection,
|
||||
HoppGQLAuth,
|
||||
} from "@hoppscotch/data"
|
||||
import DispatchingStore, { defineDispatchers } from "./DispatchingStore"
|
||||
import { cloneDeep } from "lodash-es"
|
||||
@@ -12,9 +11,6 @@ import { resolveSaveContextOnRequestReorder } from "~/helpers/collection/request
|
||||
import { getService } from "~/modules/dioc"
|
||||
import { RESTTabService } from "~/services/tab/rest"
|
||||
import { HoppInheritedProperty } from "~/helpers/types/HoppInheritedProperties"
|
||||
import { HoppRESTAuth } from "@hoppscotch/data"
|
||||
import { HoppRESTHeaders } from "@hoppscotch/data"
|
||||
import { HoppGQLHeader } from "~/helpers/graphql"
|
||||
|
||||
const defaultRESTCollectionState = {
|
||||
state: [
|
||||
@@ -67,12 +63,6 @@ export function navigateToFolderWithIndexPath(
|
||||
return target !== undefined ? target : null
|
||||
}
|
||||
|
||||
/**
|
||||
* Used to obtain the inherited auth and headers for a given folder path, used for both REST and GraphQL personal collections
|
||||
* @param folderPath the path of the folder to cascade the auth from
|
||||
* @param type the type of collection
|
||||
* @returns the inherited auth and headers for the given folder path
|
||||
*/
|
||||
export function cascadeParentCollectionForHeaderAuth(
|
||||
folderPath: string | undefined,
|
||||
type: "rest" | "graphql"
|
||||
@@ -113,16 +103,10 @@ export function cascadeParentCollectionForHeaderAuth(
|
||||
return { auth, headers }
|
||||
}
|
||||
|
||||
const parentFolderAuth = parentFolder.auth as HoppRESTAuth | HoppGQLAuth
|
||||
const parentFolderHeaders = parentFolder.headers as
|
||||
| HoppRESTHeaders
|
||||
| HoppGQLHeader[]
|
||||
|
||||
const parentFolderAuth = parentFolder.auth
|
||||
const parentFolderHeaders = parentFolder.headers
|
||||
// check if the parent folder has authType 'inherit' and if it is the root folder
|
||||
if (
|
||||
parentFolderAuth?.authType === "inherit" &&
|
||||
[...path.slice(0, i + 1)].length === 1
|
||||
) {
|
||||
if (parentFolderAuth?.authType === "inherit" && path.length === 1) {
|
||||
auth = {
|
||||
parentID: [...path.slice(0, i + 1)].join("/"),
|
||||
parentName: parentFolder.name,
|
||||
|
||||
@@ -1,58 +1,11 @@
|
||||
<template>
|
||||
<div class="flex flex-col justify-center">
|
||||
<div
|
||||
v-if="invalidLink"
|
||||
class="flex flex-1 flex-col items-center justify-center p-8"
|
||||
>
|
||||
<icon-lucide-alert-triangle class="svg-icons mb-2 opacity-75" />
|
||||
<h1 class="heading text-center">
|
||||
{{ t("error.invalid_link") }}
|
||||
</h1>
|
||||
<p class="mt-2 text-center">
|
||||
{{ t("error.invalid_embed_link") }}
|
||||
</p>
|
||||
</div>
|
||||
<div class="flex flex-col flex-1 w-full">
|
||||
<Embeds
|
||||
v-else-if="!invalidLink && tab"
|
||||
v-if="tab"
|
||||
v-model:modelTab="tab"
|
||||
:properties="properties"
|
||||
:shared-request-i-d="sharedRequestID"
|
||||
/>
|
||||
<div v-else class="flex flex-1 flex-col items-center justify-center p-4">
|
||||
<div
|
||||
v-if="sharedRequestDetails.loading"
|
||||
class="flex flex-1 flex-col items-center justify-center p-4"
|
||||
>
|
||||
<HoppSmartSpinner />
|
||||
</div>
|
||||
<div v-else>
|
||||
<div
|
||||
v-if="
|
||||
!sharedRequestDetails.loading && E.isLeft(sharedRequestDetails.data)
|
||||
"
|
||||
class="flex flex-col items-center p-4"
|
||||
>
|
||||
<icon-lucide-alert-triangle class="svg-icons mb-2 opacity-75" />
|
||||
<h1 class="heading text-center">
|
||||
{{ t("error.invalid_link") }}
|
||||
</h1>
|
||||
<p class="mt-2 text-center">
|
||||
{{ t("error.invalid_embed_link") }}
|
||||
</p>
|
||||
</div>
|
||||
<div
|
||||
v-if="
|
||||
!sharedRequestDetails.loading &&
|
||||
E.isRight(sharedRequestDetails.data)
|
||||
"
|
||||
class="flex flex-1 flex-col items-center justify-center p-4"
|
||||
>
|
||||
<h1 class="heading">
|
||||
{{ t("state.loading") }}
|
||||
</h1>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
@@ -75,9 +28,6 @@ import {
|
||||
import { HoppTab } from "~/services/tab"
|
||||
import { HoppRESTDocument } from "~/helpers/rest/document"
|
||||
import { applySetting } from "~/newstore/settings"
|
||||
import { useI18n } from "~/composables/i18n"
|
||||
|
||||
const t = useI18n()
|
||||
|
||||
const route = useRoute()
|
||||
|
||||
|
||||
@@ -244,13 +244,9 @@ export class PersistenceService extends Service {
|
||||
private setupSettingsPersistence() {
|
||||
const settingsKey = "settings"
|
||||
let settingsData = JSON.parse(
|
||||
window.localStorage.getItem(settingsKey) ?? "null"
|
||||
window.localStorage.getItem(settingsKey) || "{}"
|
||||
)
|
||||
|
||||
if (!settingsData) {
|
||||
settingsData = getDefaultSettings()
|
||||
}
|
||||
|
||||
// Validate data read from localStorage
|
||||
const result = SETTINGS_SCHEMA.safeParse(settingsData)
|
||||
if (result.success) {
|
||||
|
||||
@@ -36,7 +36,7 @@ const SettingsDefSchema = z.object({
|
||||
httpUser: z.boolean(),
|
||||
httpPassword: z.boolean(),
|
||||
bearerToken: z.boolean(),
|
||||
oauth2Token: z.optional(z.boolean()),
|
||||
oauth2Token: z.boolean(),
|
||||
}),
|
||||
THEME_COLOR: ThemeColorSchema,
|
||||
BG_COLOR: BgColorSchema,
|
||||
@@ -103,10 +103,13 @@ export const LOCAL_STATE_SCHEMA = z.union([
|
||||
.strict(),
|
||||
])
|
||||
|
||||
export const SETTINGS_SCHEMA = SettingsDefSchema.extend({
|
||||
EXTENSIONS_ENABLED: z.optional(z.boolean()),
|
||||
PROXY_ENABLED: z.optional(z.boolean()),
|
||||
})
|
||||
export const SETTINGS_SCHEMA = z.union([
|
||||
z.object({}).strict(),
|
||||
SettingsDefSchema.extend({
|
||||
EXTENSIONS_ENABLED: z.optional(z.boolean()),
|
||||
PROXY_ENABLED: z.optional(z.boolean()),
|
||||
}),
|
||||
])
|
||||
|
||||
export const REST_HISTORY_ENTRY_SCHEMA = z
|
||||
.object({
|
||||
@@ -205,7 +208,7 @@ export const MQTT_REQUEST_SCHEMA = z.nullable(
|
||||
z
|
||||
.object({
|
||||
endpoint: z.string(),
|
||||
clientID: z.optional(z.string()),
|
||||
clientID: z.string(),
|
||||
})
|
||||
.strict()
|
||||
)
|
||||
|
||||
@@ -1,8 +0,0 @@
|
||||
const config = {
|
||||
plugins: {
|
||||
tailwindcss: {},
|
||||
autoprefixer: {},
|
||||
},
|
||||
}
|
||||
|
||||
module.exports = config
|
||||
Reference in New Issue
Block a user