Compare commits
14 Commits
fix/action
...
fix/shared
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
b5e7577024 | ||
|
|
9bd7961c15 | ||
|
|
4f74cd8f89 | ||
|
|
cf4ecd326e | ||
|
|
2ed43f03e1 | ||
|
|
1ac518ef87 | ||
|
|
7db7b9b068 | ||
|
|
3d25ef48d1 | ||
|
|
4f138beb8a | ||
|
|
3d7a76bced | ||
|
|
74359ea74e | ||
|
|
a694d3f7eb | ||
|
|
58a9514b67 | ||
|
|
a75bfa9d9e |
@@ -676,9 +676,16 @@ export const INFRA_CONFIG_RESET_FAILED = 'infra_config/reset_failed' as const;
|
|||||||
*/
|
*/
|
||||||
export const INFRA_CONFIG_INVALID_INPUT = 'infra_config/invalid_input' 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
|
* Error message for when the database table does not exist
|
||||||
* (InfraConfigService)
|
* (InfraConfigService)
|
||||||
*/
|
*/
|
||||||
export const DATABASE_TABLE_NOT_EXIST =
|
export const DATABASE_TABLE_NOT_EXIST =
|
||||||
'Database migration not performed. Please check the FAQ for assistance: https://docs.hoppscotch.io/support/getting-started/faq';
|
'Database migration not found. Please check the documentation for assistance: https://docs.hoppscotch.io/documentation/self-host/community-edition/install-and-build#running-migrations';
|
||||||
|
|||||||
@@ -15,11 +15,13 @@ import {
|
|||||||
INFRA_CONFIG_NOT_LISTED,
|
INFRA_CONFIG_NOT_LISTED,
|
||||||
INFRA_CONFIG_RESET_FAILED,
|
INFRA_CONFIG_RESET_FAILED,
|
||||||
INFRA_CONFIG_UPDATE_FAILED,
|
INFRA_CONFIG_UPDATE_FAILED,
|
||||||
|
INFRA_CONFIG_SERVICE_NOT_CONFIGURED,
|
||||||
} from 'src/errors';
|
} from 'src/errors';
|
||||||
import { throwErr, validateEmail, validateSMTPUrl } from 'src/utils';
|
import { throwErr, validateEmail, validateSMTPUrl } from 'src/utils';
|
||||||
import { ConfigService } from '@nestjs/config';
|
import { ConfigService } from '@nestjs/config';
|
||||||
import { ServiceStatus, stopApp } from './helper';
|
import { ServiceStatus, stopApp } from './helper';
|
||||||
import { EnableAndDisableSSOArgs, InfraConfigArgs } from './input-args';
|
import { EnableAndDisableSSOArgs, InfraConfigArgs } from './input-args';
|
||||||
|
import { AuthProvider } from 'src/auth/helper';
|
||||||
|
|
||||||
@Injectable()
|
@Injectable()
|
||||||
export class InfraConfigService implements OnModuleInit {
|
export class InfraConfigService implements OnModuleInit {
|
||||||
@@ -124,7 +126,7 @@ export class InfraConfigService implements OnModuleInit {
|
|||||||
cast(dbInfraConfig: DBInfraConfig) {
|
cast(dbInfraConfig: DBInfraConfig) {
|
||||||
return <InfraConfig>{
|
return <InfraConfig>{
|
||||||
name: dbInfraConfig.name,
|
name: dbInfraConfig.name,
|
||||||
value: dbInfraConfig.value,
|
value: dbInfraConfig.value ?? '',
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -182,6 +184,38 @@ 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
|
* Enable or Disable SSO for login/signup
|
||||||
* @param provider Auth Provider to enable or disable
|
* @param provider Auth Provider to enable or disable
|
||||||
@@ -195,15 +229,21 @@ export class InfraConfigService implements OnModuleInit {
|
|||||||
|
|
||||||
let updatedAuthProviders = allowedAuthProviders;
|
let updatedAuthProviders = allowedAuthProviders;
|
||||||
|
|
||||||
providerInfo.forEach(({ provider, status }) => {
|
for (let i = 0; i < providerInfo.length; i++) {
|
||||||
|
const { provider, status } = providerInfo[i];
|
||||||
|
|
||||||
if (status === ServiceStatus.ENABLE) {
|
if (status === ServiceStatus.ENABLE) {
|
||||||
|
const isConfigured = this.isServiceConfigured(provider);
|
||||||
|
if (!isConfigured) {
|
||||||
|
throwErr(INFRA_CONFIG_SERVICE_NOT_CONFIGURED);
|
||||||
|
}
|
||||||
updatedAuthProviders.push(provider);
|
updatedAuthProviders.push(provider);
|
||||||
} else if (status === ServiceStatus.DISABLE) {
|
} else if (status === ServiceStatus.DISABLE) {
|
||||||
updatedAuthProviders = updatedAuthProviders.filter(
|
updatedAuthProviders = updatedAuthProviders.filter(
|
||||||
(p) => p !== provider,
|
(p) => p !== provider,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
});
|
}
|
||||||
|
|
||||||
updatedAuthProviders = [...new Set(updatedAuthProviders)];
|
updatedAuthProviders = [...new Set(updatedAuthProviders)];
|
||||||
|
|
||||||
@@ -286,6 +326,9 @@ export class InfraConfigService implements OnModuleInit {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Validate the values of the InfraConfigs
|
||||||
|
*/
|
||||||
validateEnvValues(
|
validateEnvValues(
|
||||||
infraConfigs: {
|
infraConfigs: {
|
||||||
name: InfraConfigEnumForClient | InfraConfigEnum;
|
name: InfraConfigEnumForClient | InfraConfigEnum;
|
||||||
@@ -302,6 +345,24 @@ export class InfraConfigService implements OnModuleInit {
|
|||||||
const isValidEmail = validateEmail(infraConfigs[i].value);
|
const isValidEmail = validateEmail(infraConfigs[i].value);
|
||||||
if (!isValidEmail) return E.left(INFRA_CONFIG_INVALID_INPUT);
|
if (!isValidEmail) return E.left(INFRA_CONFIG_INVALID_INPUT);
|
||||||
break;
|
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:
|
default:
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -121,7 +121,7 @@
|
|||||||
"generate_token": "Generate Token",
|
"generate_token": "Generate Token",
|
||||||
"graphql_headers": "Authorization Headers are sent as part of the payload to connection_init",
|
"graphql_headers": "Authorization Headers are sent as part of the payload to connection_init",
|
||||||
"include_in_url": "Include in URL",
|
"include_in_url": "Include in URL",
|
||||||
"inherited_from": "Inherited from {auth} from Parent Collection {collection} ",
|
"inherited_from": "Inherited {auth} from parent collection {collection} ",
|
||||||
"learn": "Learn how",
|
"learn": "Learn how",
|
||||||
"oauth": {
|
"oauth": {
|
||||||
"redirect_auth_server_returned_error": "Auth Server returned an error state",
|
"redirect_auth_server_returned_error": "Auth Server returned an error state",
|
||||||
@@ -295,6 +295,7 @@
|
|||||||
"incorrect_email": "Incorrect email",
|
"incorrect_email": "Incorrect email",
|
||||||
"invalid_link": "Invalid link",
|
"invalid_link": "Invalid link",
|
||||||
"invalid_link_description": "The link you clicked is invalid or expired.",
|
"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_parsing_failed": "Invalid JSON",
|
||||||
"json_prettify_invalid_body": "Couldn't prettify an invalid body, solve json syntax errors and try again",
|
"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.",
|
"network_error": "There seems to be a network error. Please try again.",
|
||||||
@@ -313,10 +314,12 @@
|
|||||||
"export": {
|
"export": {
|
||||||
"as_json": "Export as JSON",
|
"as_json": "Export as JSON",
|
||||||
"create_secret_gist": "Create secret Gist",
|
"create_secret_gist": "Create secret Gist",
|
||||||
|
"create_secret_gist_tooltip_text": "Export as secret Gist",
|
||||||
"failed": "Something went wrong while exporting",
|
"failed": "Something went wrong while exporting",
|
||||||
"gist_created": "Gist created",
|
"secret_gist_success": "Successfully exported as secret Gist",
|
||||||
"require_github": "Login with GitHub to create secret gist",
|
"require_github": "Login with GitHub to create secret gist",
|
||||||
"title": "Export"
|
"title": "Export",
|
||||||
|
"success": "Successfully exported"
|
||||||
},
|
},
|
||||||
"filter": {
|
"filter": {
|
||||||
"all": "All",
|
"all": "All",
|
||||||
|
|||||||
@@ -9,7 +9,10 @@
|
|||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script setup lang="ts">
|
<script setup lang="ts">
|
||||||
|
import { HoppCollection } from "@hoppscotch/data"
|
||||||
import * as E from "fp-ts/Either"
|
import * as E from "fp-ts/Either"
|
||||||
|
import { PropType, computed, ref } from "vue"
|
||||||
|
|
||||||
import { FileSource } from "~/helpers/import-export/import/import-sources/FileSource"
|
import { FileSource } from "~/helpers/import-export/import/import-sources/FileSource"
|
||||||
import { UrlSource } from "~/helpers/import-export/import/import-sources/UrlSource"
|
import { UrlSource } from "~/helpers/import-export/import/import-sources/UrlSource"
|
||||||
|
|
||||||
@@ -24,11 +27,9 @@ import {
|
|||||||
} from "~/helpers/import-export/import/importers"
|
} from "~/helpers/import-export/import/importers"
|
||||||
|
|
||||||
import { defineStep } from "~/composables/step-components"
|
import { defineStep } from "~/composables/step-components"
|
||||||
import { PropType, computed, ref } from "vue"
|
|
||||||
|
|
||||||
import { useI18n } from "~/composables/i18n"
|
import { useI18n } from "~/composables/i18n"
|
||||||
import { useToast } from "~/composables/toast"
|
import { useToast } from "~/composables/toast"
|
||||||
import { HoppCollection } from "@hoppscotch/data"
|
|
||||||
import { appendRESTCollections, restCollections$ } from "~/newstore/collections"
|
import { appendRESTCollections, restCollections$ } from "~/newstore/collections"
|
||||||
import MyCollectionImport from "~/components/importExport/ImportExportSteps/MyCollectionImport.vue"
|
import MyCollectionImport from "~/components/importExport/ImportExportSteps/MyCollectionImport.vue"
|
||||||
import { GetMyTeamsQuery } from "~/helpers/backend/graphql"
|
import { GetMyTeamsQuery } from "~/helpers/backend/graphql"
|
||||||
@@ -48,7 +49,7 @@ import { getTeamCollectionJSON } from "~/helpers/backend/helpers"
|
|||||||
import { platform } from "~/platform"
|
import { platform } from "~/platform"
|
||||||
|
|
||||||
import { initializeDownloadCollection } from "~/helpers/import-export/export"
|
import { initializeDownloadCollection } from "~/helpers/import-export/export"
|
||||||
import { collectionsGistExporter } from "~/helpers/import-export/export/gistExport"
|
import { gistExporter } from "~/helpers/import-export/export/gist"
|
||||||
import { myCollectionsExporter } from "~/helpers/import-export/export/myCollections"
|
import { myCollectionsExporter } from "~/helpers/import-export/export/myCollections"
|
||||||
import { teamCollectionsExporter } from "~/helpers/import-export/export/teamCollections"
|
import { teamCollectionsExporter } from "~/helpers/import-export/export/teamCollections"
|
||||||
|
|
||||||
@@ -83,6 +84,8 @@ const currentUser = useReadonlyStream(
|
|||||||
platform.auth.getCurrentUser()
|
platform.auth.getCurrentUser()
|
||||||
)
|
)
|
||||||
|
|
||||||
|
const myCollections = useReadonlyStream(restCollections$, [])
|
||||||
|
|
||||||
const showImportFailedError = () => {
|
const showImportFailedError = () => {
|
||||||
toast.error(t("import.failed"))
|
toast.error(t("import.failed"))
|
||||||
}
|
}
|
||||||
@@ -468,8 +471,13 @@ const HoppGistCollectionsExporter: ImporterOrExporter = {
|
|||||||
icon: IconGithub,
|
icon: IconGithub,
|
||||||
disabled: !currentUser.value
|
disabled: !currentUser.value
|
||||||
? true
|
? true
|
||||||
: currentUser.value.provider !== "github.com",
|
: currentUser.value?.provider !== "github.com",
|
||||||
title: t("export.create_secret_gist"),
|
title:
|
||||||
|
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
||||||
|
// @ts-ignore
|
||||||
|
currentUser?.value?.provider === "github.com"
|
||||||
|
? "export.create_secret_gist_tooltip_text"
|
||||||
|
: "export.require_github",
|
||||||
applicableTo: ["personal-workspace", "team-workspace"],
|
applicableTo: ["personal-workspace", "team-workspace"],
|
||||||
isLoading: isHoppGistCollectionExporterInProgress,
|
isLoading: isHoppGistCollectionExporterInProgress,
|
||||||
},
|
},
|
||||||
@@ -486,13 +494,27 @@ const HoppGistCollectionsExporter: ImporterOrExporter = {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (E.isRight(collectionJSON)) {
|
if (E.isRight(collectionJSON)) {
|
||||||
collectionsGistExporter(collectionJSON.right, accessToken)
|
if (!JSON.parse(collectionJSON.right).length) {
|
||||||
|
isHoppGistCollectionExporterInProgress.value = false
|
||||||
|
return toast.error(t("error.no_collections_to_export"))
|
||||||
|
}
|
||||||
|
|
||||||
|
const res = await gistExporter(collectionJSON.right, accessToken)
|
||||||
|
|
||||||
|
if (E.isLeft(res)) {
|
||||||
|
toast.error(t("export.failed"))
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
toast.success(t("export.secret_gist_success"))
|
||||||
|
|
||||||
platform.analytics?.logEvent({
|
platform.analytics?.logEvent({
|
||||||
type: "HOPP_EXPORT_COLLECTION",
|
type: "HOPP_EXPORT_COLLECTION",
|
||||||
exporter: "gist",
|
exporter: "gist",
|
||||||
platform: "rest",
|
platform: "rest",
|
||||||
})
|
})
|
||||||
|
|
||||||
|
platform.io.openExternalLink(res.right)
|
||||||
}
|
}
|
||||||
|
|
||||||
isHoppGistCollectionExporterInProgress.value = false
|
isHoppGistCollectionExporterInProgress.value = false
|
||||||
@@ -560,8 +582,6 @@ const selectedTeamID = computed(() => {
|
|||||||
: undefined
|
: undefined
|
||||||
})
|
})
|
||||||
|
|
||||||
const myCollections = useReadonlyStream(restCollections$, [])
|
|
||||||
|
|
||||||
const getCollectionJSON = async () => {
|
const getCollectionJSON = async () => {
|
||||||
if (
|
if (
|
||||||
props.collectionsType.type === "team-collections" &&
|
props.collectionsType.type === "team-collections" &&
|
||||||
|
|||||||
@@ -33,6 +33,7 @@
|
|||||||
@select="onSelect"
|
@select="onSelect"
|
||||||
@update-team="updateTeam"
|
@update-team="updateTeam"
|
||||||
@update-collection-type="updateCollectionType"
|
@update-collection-type="updateCollectionType"
|
||||||
|
@set-team-collection-adapter="teamCollectionAdapter = $event"
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
@@ -86,6 +87,7 @@ import { platform } from "~/platform"
|
|||||||
import { useService } from "dioc/vue"
|
import { useService } from "dioc/vue"
|
||||||
import { RESTTabService } from "~/services/tab/rest"
|
import { RESTTabService } from "~/services/tab/rest"
|
||||||
import { GQLTabService } from "~/services/tab/graphql"
|
import { GQLTabService } from "~/services/tab/graphql"
|
||||||
|
import TeamCollectionAdapter from "~/helpers/teams/TeamCollectionAdapter"
|
||||||
|
|
||||||
const t = useI18n()
|
const t = useI18n()
|
||||||
const toast = useToast()
|
const toast = useToast()
|
||||||
@@ -93,6 +95,8 @@ const toast = useToast()
|
|||||||
const RESTTabs = useService(RESTTabService)
|
const RESTTabs = useService(RESTTabService)
|
||||||
const GQLTabs = useService(GQLTabService)
|
const GQLTabs = useService(GQLTabService)
|
||||||
|
|
||||||
|
const teamCollectionAdapter = ref<TeamCollectionAdapter>()
|
||||||
|
|
||||||
type SelectedTeam = GetMyTeamsQuery["myTeams"][number] | undefined
|
type SelectedTeam = GetMyTeamsQuery["myTeams"][number] | undefined
|
||||||
|
|
||||||
type CollectionType =
|
type CollectionType =
|
||||||
@@ -380,7 +384,6 @@ const saveRequestAs = async () => {
|
|||||||
platform: "rest",
|
platform: "rest",
|
||||||
workspaceType: "team",
|
workspaceType: "team",
|
||||||
})
|
})
|
||||||
|
|
||||||
pipe(
|
pipe(
|
||||||
updateTeamRequest(picked.value.requestID, data),
|
updateTeamRequest(picked.value.requestID, data),
|
||||||
TE.match(
|
TE.match(
|
||||||
@@ -388,7 +391,31 @@ const saveRequestAs = async () => {
|
|||||||
toast.error(`${getErrorMessage(err)}`)
|
toast.error(`${getErrorMessage(err)}`)
|
||||||
modalLoadingState.value = false
|
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
|
modalLoadingState.value = false
|
||||||
requestSaved()
|
requestSaved()
|
||||||
}
|
}
|
||||||
@@ -516,6 +543,18 @@ const updateTeamCollectionOrFolder = (
|
|||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (teamCollectionAdapter.value) {
|
||||||
|
const { auth, headers } =
|
||||||
|
teamCollectionAdapter.value.cascadeParentCollectionForHeaderAuth(
|
||||||
|
createRequestInCollection.collection.id
|
||||||
|
)
|
||||||
|
|
||||||
|
RESTTabs.currentActiveTab.value.document.inheritedProperties = {
|
||||||
|
auth,
|
||||||
|
headers,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
modalLoadingState.value = false
|
modalLoadingState.value = false
|
||||||
requestSaved()
|
requestSaved()
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -9,15 +9,16 @@
|
|||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script setup lang="ts">
|
<script setup lang="ts">
|
||||||
|
import { HoppCollection } from "@hoppscotch/data"
|
||||||
|
import * as E from "fp-ts/Either"
|
||||||
|
import { ref } from "vue"
|
||||||
|
|
||||||
import { useI18n } from "~/composables/i18n"
|
import { useI18n } from "~/composables/i18n"
|
||||||
import { useToast } from "~/composables/toast"
|
import { useToast } from "~/composables/toast"
|
||||||
import { HoppCollection } from "@hoppscotch/data"
|
|
||||||
import { ImporterOrExporter } from "~/components/importExport/types"
|
import { ImporterOrExporter } from "~/components/importExport/types"
|
||||||
import { FileSource } from "~/helpers/import-export/import/import-sources/FileSource"
|
import { FileSource } from "~/helpers/import-export/import/import-sources/FileSource"
|
||||||
import { GistSource } from "~/helpers/import-export/import/import-sources/GistSource"
|
import { GistSource } from "~/helpers/import-export/import/import-sources/GistSource"
|
||||||
|
|
||||||
import * as E from "fp-ts/Either"
|
|
||||||
|
|
||||||
import IconFolderPlus from "~icons/lucide/folder-plus"
|
import IconFolderPlus from "~icons/lucide/folder-plus"
|
||||||
import IconUser from "~icons/lucide/user"
|
import IconUser from "~icons/lucide/user"
|
||||||
import { initializeDownloadCollection } from "~/helpers/import-export/export"
|
import { initializeDownloadCollection } from "~/helpers/import-export/export"
|
||||||
@@ -30,7 +31,7 @@ import {
|
|||||||
} from "~/newstore/collections"
|
} from "~/newstore/collections"
|
||||||
import { hoppGqlCollectionsImporter } from "~/helpers/import-export/import/hoppGql"
|
import { hoppGqlCollectionsImporter } from "~/helpers/import-export/import/hoppGql"
|
||||||
import { gqlCollectionsExporter } from "~/helpers/import-export/export/gqlCollections"
|
import { gqlCollectionsExporter } from "~/helpers/import-export/export/gqlCollections"
|
||||||
import { gqlCollectionsGistExporter } from "~/helpers/import-export/export/gqlCollectionsGistExporter"
|
import { gistExporter } from "~/helpers/import-export/export/gist"
|
||||||
import { computed } from "vue"
|
import { computed } from "vue"
|
||||||
import { hoppGQLImporter } from "~/helpers/import-export/import/hopp"
|
import { hoppGQLImporter } from "~/helpers/import-export/import/hopp"
|
||||||
|
|
||||||
@@ -42,6 +43,10 @@ const currentUser = useReadonlyStream(
|
|||||||
platform.auth.getCurrentUser()
|
platform.auth.getCurrentUser()
|
||||||
)
|
)
|
||||||
|
|
||||||
|
const gqlCollections = useReadonlyStream(graphqlCollections$, [])
|
||||||
|
|
||||||
|
const isGqlCollectionGistExportInProgress = ref(false)
|
||||||
|
|
||||||
const GqlCollectionsHoppImporter: ImporterOrExporter = {
|
const GqlCollectionsHoppImporter: ImporterOrExporter = {
|
||||||
metadata: {
|
metadata: {
|
||||||
id: "import.from_json",
|
id: "import.from_json",
|
||||||
@@ -119,8 +124,6 @@ const GqlCollectionsGistImporter: ImporterOrExporter = {
|
|||||||
}),
|
}),
|
||||||
}
|
}
|
||||||
|
|
||||||
const gqlCollections = useReadonlyStream(graphqlCollections$, [])
|
|
||||||
|
|
||||||
const GqlCollectionsHoppExporter: ImporterOrExporter = {
|
const GqlCollectionsHoppExporter: ImporterOrExporter = {
|
||||||
metadata: {
|
metadata: {
|
||||||
id: "export.as_json",
|
id: "export.as_json",
|
||||||
@@ -159,29 +162,35 @@ const GqlCollectionsGistExporter: ImporterOrExporter = {
|
|||||||
metadata: {
|
metadata: {
|
||||||
id: "export.as_gist",
|
id: "export.as_gist",
|
||||||
name: "export.create_secret_gist",
|
name: "export.create_secret_gist",
|
||||||
title: !currentUser
|
title:
|
||||||
? "export.require_github"
|
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
||||||
: // eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
// @ts-ignore
|
||||||
// @ts-ignore
|
currentUser?.value?.provider === "github.com"
|
||||||
currentUser.provider !== "github.com"
|
? "export.create_secret_gist_tooltip_text"
|
||||||
? `export.require_github`
|
: "export.require_github",
|
||||||
: "export.create_secret_gist",
|
|
||||||
icon: IconUser,
|
icon: IconUser,
|
||||||
disabled: !currentUser.value
|
disabled: !currentUser.value
|
||||||
? true
|
? true
|
||||||
: currentUser.value.provider !== "github.com",
|
: currentUser.value?.provider !== "github.com",
|
||||||
applicableTo: ["personal-workspace"],
|
applicableTo: ["personal-workspace"],
|
||||||
|
isLoading: isGqlCollectionGistExportInProgress,
|
||||||
},
|
},
|
||||||
action: async () => {
|
action: async () => {
|
||||||
|
if (!gqlCollections.value.length) {
|
||||||
|
return toast.error(t("error.no_collections_to_export"))
|
||||||
|
}
|
||||||
|
|
||||||
if (!currentUser.value) {
|
if (!currentUser.value) {
|
||||||
toast.error(t("profile.no_permission"))
|
toast.error(t("profile.no_permission"))
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
isGqlCollectionGistExportInProgress.value = true
|
||||||
|
|
||||||
const accessToken = currentUser.value?.accessToken
|
const accessToken = currentUser.value?.accessToken
|
||||||
|
|
||||||
if (accessToken) {
|
if (accessToken) {
|
||||||
const res = await gqlCollectionsGistExporter(
|
const res = await gistExporter(
|
||||||
JSON.stringify(gqlCollections.value),
|
JSON.stringify(gqlCollections.value),
|
||||||
accessToken
|
accessToken
|
||||||
)
|
)
|
||||||
@@ -191,7 +200,7 @@ const GqlCollectionsGistExporter: ImporterOrExporter = {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
toast.success(t("export.success"))
|
toast.success(t("export.secret_gist_success"))
|
||||||
|
|
||||||
platform.analytics?.logEvent({
|
platform.analytics?.logEvent({
|
||||||
type: "HOPP_EXPORT_COLLECTION",
|
type: "HOPP_EXPORT_COLLECTION",
|
||||||
@@ -201,6 +210,8 @@ const GqlCollectionsGistExporter: ImporterOrExporter = {
|
|||||||
|
|
||||||
platform.io.openExternalLink(res.right)
|
platform.io.openExternalLink(res.right)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
isGqlCollectionGistExportInProgress.value = false
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -262,6 +262,7 @@ const emit = defineEmits<{
|
|||||||
(event: "select", payload: Picked | null): void
|
(event: "select", payload: Picked | null): void
|
||||||
(event: "update-team", team: SelectedTeam): void
|
(event: "update-team", team: SelectedTeam): void
|
||||||
(event: "update-collection-type", type: CollectionType["type"]): void
|
(event: "update-collection-type", type: CollectionType["type"]): void
|
||||||
|
(event: "set-team-collection-adapter", adapter: TeamCollectionAdapter): void
|
||||||
}>()
|
}>()
|
||||||
|
|
||||||
type SelectedTeam = GetMyTeamsQuery["myTeams"][number] | undefined
|
type SelectedTeam = GetMyTeamsQuery["myTeams"][number] | undefined
|
||||||
@@ -354,6 +355,7 @@ watch(
|
|||||||
(newTeam) => {
|
(newTeam) => {
|
||||||
if (newTeam) {
|
if (newTeam) {
|
||||||
teamCollectionAdapter.changeTeamID(newTeam.id)
|
teamCollectionAdapter.changeTeamID(newTeam.id)
|
||||||
|
emit("set-team-collection-adapter", teamCollectionAdapter)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
|
|||||||
@@ -9,15 +9,17 @@
|
|||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script setup lang="ts">
|
<script setup lang="ts">
|
||||||
|
import { Environment } from "@hoppscotch/data"
|
||||||
|
import * as E from "fp-ts/Either"
|
||||||
|
import { ref } from "vue"
|
||||||
|
|
||||||
import { useI18n } from "~/composables/i18n"
|
import { useI18n } from "~/composables/i18n"
|
||||||
import { useToast } from "~/composables/toast"
|
import { useToast } from "~/composables/toast"
|
||||||
import { Environment } from "@hoppscotch/data"
|
|
||||||
import { ImporterOrExporter } from "~/components/importExport/types"
|
import { ImporterOrExporter } from "~/components/importExport/types"
|
||||||
import { FileSource } from "~/helpers/import-export/import/import-sources/FileSource"
|
import { FileSource } from "~/helpers/import-export/import/import-sources/FileSource"
|
||||||
import { GistSource } from "~/helpers/import-export/import/import-sources/GistSource"
|
import { GistSource } from "~/helpers/import-export/import/import-sources/GistSource"
|
||||||
import { hoppEnvImporter } from "~/helpers/import-export/import/hoppEnv"
|
import { hoppEnvImporter } from "~/helpers/import-export/import/hoppEnv"
|
||||||
|
|
||||||
import * as E from "fp-ts/Either"
|
|
||||||
import {
|
import {
|
||||||
appendEnvironments,
|
appendEnvironments,
|
||||||
addGlobalEnvVariable,
|
addGlobalEnvVariable,
|
||||||
@@ -39,7 +41,7 @@ import { initializeDownloadCollection } from "~/helpers/import-export/export"
|
|||||||
import { computed } from "vue"
|
import { computed } from "vue"
|
||||||
import { useReadonlyStream } from "~/composables/stream"
|
import { useReadonlyStream } from "~/composables/stream"
|
||||||
import { environmentsExporter } from "~/helpers/import-export/export/environments"
|
import { environmentsExporter } from "~/helpers/import-export/export/environments"
|
||||||
import { environmentsGistExporter } from "~/helpers/import-export/export/environmentsGistExport"
|
import { gistExporter } from "~/helpers/import-export/export/gist"
|
||||||
import { platform } from "~/platform"
|
import { platform } from "~/platform"
|
||||||
|
|
||||||
const t = useI18n()
|
const t = useI18n()
|
||||||
@@ -58,6 +60,8 @@ const currentUser = useReadonlyStream(
|
|||||||
platform.auth.getCurrentUser()
|
platform.auth.getCurrentUser()
|
||||||
)
|
)
|
||||||
|
|
||||||
|
const isEnvironmentGistExportInProgress = ref(false)
|
||||||
|
|
||||||
const isTeamEnvironment = computed(() => {
|
const isTeamEnvironment = computed(() => {
|
||||||
return props.environmentType === "TEAM_ENV"
|
return props.environmentType === "TEAM_ENV"
|
||||||
})
|
})
|
||||||
@@ -262,35 +266,44 @@ const HoppEnvironmentsGistExporter: ImporterOrExporter = {
|
|||||||
title:
|
title:
|
||||||
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
||||||
// @ts-ignore
|
// @ts-ignore
|
||||||
currentUser?.provider === "github.com"
|
currentUser?.value?.provider === "github.com"
|
||||||
? "export.create_secret_gist"
|
? "export.create_secret_gist_tooltip_text"
|
||||||
: "export.require_github",
|
: "export.require_github",
|
||||||
icon: IconUser,
|
icon: IconUser,
|
||||||
disabled: !currentUser.value
|
disabled: !currentUser.value
|
||||||
? true
|
? true
|
||||||
: currentUser.value.provider !== "github.com",
|
: currentUser.value?.provider !== "github.com",
|
||||||
applicableTo: ["personal-workspace", "team-workspace"],
|
applicableTo: ["personal-workspace", "team-workspace"],
|
||||||
|
isLoading: isEnvironmentGistExportInProgress,
|
||||||
},
|
},
|
||||||
action: async () => {
|
action: async () => {
|
||||||
|
if (!environmentJson.value.length) {
|
||||||
|
return toast.error(t("error.no_environments_to_export"))
|
||||||
|
}
|
||||||
|
|
||||||
if (!currentUser.value) {
|
if (!currentUser.value) {
|
||||||
toast.error(t("profile.no_permission"))
|
toast.error(t("profile.no_permission"))
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
isEnvironmentGistExportInProgress.value = true
|
||||||
|
|
||||||
const accessToken = currentUser.value?.accessToken
|
const accessToken = currentUser.value?.accessToken
|
||||||
|
|
||||||
if (accessToken) {
|
if (accessToken) {
|
||||||
const res = await environmentsGistExporter(
|
const res = await gistExporter(
|
||||||
JSON.stringify(environmentJson.value),
|
JSON.stringify(environmentJson.value),
|
||||||
accessToken
|
accessToken,
|
||||||
|
"hoppscotch-environment.json"
|
||||||
)
|
)
|
||||||
|
|
||||||
if (E.isLeft(res)) {
|
if (E.isLeft(res)) {
|
||||||
toast.error(t("export.failed"))
|
toast.error(t("export.failed"))
|
||||||
|
isEnvironmentGistExportInProgress.value = false
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
toast.success(t("export.success"))
|
toast.success(t("export.secret_gist_success"))
|
||||||
|
|
||||||
platform.analytics?.logEvent({
|
platform.analytics?.logEvent({
|
||||||
type: "HOPP_EXPORT_ENVIRONMENT",
|
type: "HOPP_EXPORT_ENVIRONMENT",
|
||||||
@@ -299,6 +312,8 @@ const HoppEnvironmentsGistExporter: ImporterOrExporter = {
|
|||||||
|
|
||||||
platform.io.openExternalLink(res.right)
|
platform.io.openExternalLink(res.right)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
isEnvironmentGistExportInProgress.value = false
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -140,7 +140,10 @@ const runQuery = async (
|
|||||||
const runVariables = clone(request.value.variables)
|
const runVariables = clone(request.value.variables)
|
||||||
const runAuth =
|
const runAuth =
|
||||||
request.value.auth.authType === "inherit" && request.value.auth.authActive
|
request.value.auth.authType === "inherit" && request.value.auth.authActive
|
||||||
? clone(tabs.currentActiveTab.value.document.inheritedProperties?.auth)
|
? clone(
|
||||||
|
tabs.currentActiveTab.value.document.inheritedProperties?.auth
|
||||||
|
.inheritedAuth
|
||||||
|
)
|
||||||
: clone(request.value.auth)
|
: clone(request.value.auth)
|
||||||
|
|
||||||
const inheritedHeaders =
|
const inheritedHeaders =
|
||||||
|
|||||||
@@ -21,7 +21,7 @@
|
|||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
<div class="flex flex-col">
|
<div class="flex flex-col">
|
||||||
<div v-if="loading" class="flex flex-col items-center justify-center">
|
<div v-if="loading" class="flex flex-col items-center justify-center p-4">
|
||||||
<HoppSmartSpinner class="mb-4" />
|
<HoppSmartSpinner class="mb-4" />
|
||||||
<span class="text-secondaryLight">{{ t("state.loading") }}</span>
|
<span class="text-secondaryLight">{{ t("state.loading") }}</span>
|
||||||
</div>
|
</div>
|
||||||
@@ -451,7 +451,7 @@ const getErrorMessage = (err: GQLError<string>) => {
|
|||||||
}
|
}
|
||||||
switch (err.error) {
|
switch (err.error) {
|
||||||
case "shortcode/not_found":
|
case "shortcode/not_found":
|
||||||
return t("shared_request.not_found")
|
return t("shared_requests.not_found")
|
||||||
default:
|
default:
|
||||||
return t("error.something_went_wrong")
|
return t("error.something_went_wrong")
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -2,5 +2,6 @@ mutation UpdateRequest($data: UpdateTeamRequestInput!, $requestID: ID!) {
|
|||||||
updateRequest(data: $data, requestID: $requestID) {
|
updateRequest(data: $data, requestID: $requestID) {
|
||||||
id
|
id
|
||||||
title
|
title
|
||||||
|
collectionID
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -27,7 +27,7 @@ export const getDefaultGQLRequest = (): HoppGQLRequest => ({
|
|||||||
}`,
|
}`,
|
||||||
query: DEFAULT_QUERY,
|
query: DEFAULT_QUERY,
|
||||||
auth: {
|
auth: {
|
||||||
authType: "inherit",
|
authType: "none",
|
||||||
authActive: true,
|
authActive: true,
|
||||||
},
|
},
|
||||||
})
|
})
|
||||||
|
|||||||
@@ -1,18 +0,0 @@
|
|||||||
import * as E from "fp-ts/Either"
|
|
||||||
import { createGist } from "~/helpers/gist"
|
|
||||||
|
|
||||||
export const environmentsGistExporter = async (
|
|
||||||
environmentsJSON: string,
|
|
||||||
accessToken: string
|
|
||||||
) => {
|
|
||||||
const res = await createGist(
|
|
||||||
environmentsJSON,
|
|
||||||
"hoppscotch-collections.json",
|
|
||||||
accessToken
|
|
||||||
)()
|
|
||||||
|
|
||||||
if (E.isLeft(res)) {
|
|
||||||
return E.left(res.left)
|
|
||||||
}
|
|
||||||
return E.right(res.right.data.html_url as string)
|
|
||||||
}
|
|
||||||
@@ -0,0 +1,19 @@
|
|||||||
|
import * as E from "fp-ts/Either"
|
||||||
|
import { createGist } from "~/helpers/gist"
|
||||||
|
|
||||||
|
export const gistExporter = async (
|
||||||
|
JSONFileContents: string,
|
||||||
|
accessToken: string,
|
||||||
|
fileName = "hoppscotch-collections.json"
|
||||||
|
) => {
|
||||||
|
if (!accessToken) {
|
||||||
|
return E.left("Invalid User")
|
||||||
|
}
|
||||||
|
|
||||||
|
const res = await createGist(JSONFileContents, fileName, accessToken)()
|
||||||
|
|
||||||
|
if (E.isLeft(res)) {
|
||||||
|
return E.left(res.left)
|
||||||
|
}
|
||||||
|
return E.right(res.right.data.html_url as string)
|
||||||
|
}
|
||||||
@@ -1,22 +0,0 @@
|
|||||||
import { createGist } from "~/helpers/gist"
|
|
||||||
import * as E from "fp-ts/Either"
|
|
||||||
|
|
||||||
export const collectionsGistExporter = async (
|
|
||||||
collectionJSON: string,
|
|
||||||
accessToken: string
|
|
||||||
) => {
|
|
||||||
if (!accessToken) {
|
|
||||||
return E.left("Invalid User")
|
|
||||||
}
|
|
||||||
|
|
||||||
const res = await createGist(
|
|
||||||
collectionJSON,
|
|
||||||
"hoppscotch-collections.json",
|
|
||||||
accessToken
|
|
||||||
)()
|
|
||||||
|
|
||||||
if (E.isLeft(res)) {
|
|
||||||
return E.left(res.left)
|
|
||||||
}
|
|
||||||
return E.right(true)
|
|
||||||
}
|
|
||||||
@@ -1,18 +0,0 @@
|
|||||||
import * as E from "fp-ts/Either"
|
|
||||||
import { createGist } from "~/helpers/gist"
|
|
||||||
|
|
||||||
export const gqlCollectionsGistExporter = async (
|
|
||||||
gqlCollectionsJSON: string,
|
|
||||||
accessToken: string
|
|
||||||
) => {
|
|
||||||
const res = await createGist(
|
|
||||||
gqlCollectionsJSON,
|
|
||||||
"hoppscotch-collections.json",
|
|
||||||
accessToken
|
|
||||||
)()
|
|
||||||
|
|
||||||
if (E.isLeft(res)) {
|
|
||||||
return E.left(res.left)
|
|
||||||
}
|
|
||||||
return E.right(res.right.data.html_url as string)
|
|
||||||
}
|
|
||||||
@@ -156,6 +156,7 @@ export default class ShortcodeListAdapter {
|
|||||||
const [shortcodeCreated$, shortcodeCreatedSub] = runAuthOnlyGQLSubscription(
|
const [shortcodeCreated$, shortcodeCreatedSub] = runAuthOnlyGQLSubscription(
|
||||||
{
|
{
|
||||||
query: ShortcodeCreatedDocument,
|
query: ShortcodeCreatedDocument,
|
||||||
|
variables: {},
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
|
|
||||||
@@ -172,6 +173,7 @@ export default class ShortcodeListAdapter {
|
|||||||
const [shortcodeRevoked$, shortcodeRevokedSub] = runAuthOnlyGQLSubscription(
|
const [shortcodeRevoked$, shortcodeRevokedSub] = runAuthOnlyGQLSubscription(
|
||||||
{
|
{
|
||||||
query: ShortcodeDeletedDocument,
|
query: ShortcodeDeletedDocument,
|
||||||
|
variables: {},
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
|
|
||||||
@@ -188,6 +190,7 @@ export default class ShortcodeListAdapter {
|
|||||||
const [shortcodeUpdated$, shortcodeUpdatedSub] = runAuthOnlyGQLSubscription(
|
const [shortcodeUpdated$, shortcodeUpdatedSub] = runAuthOnlyGQLSubscription(
|
||||||
{
|
{
|
||||||
query: ShortcodeUpdatedDocument,
|
query: ShortcodeUpdatedDocument,
|
||||||
|
variables: {},
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|||||||
@@ -1034,6 +1034,11 @@ 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) {
|
public cascadeParentCollectionForHeaderAuth(folderPath: string) {
|
||||||
let auth: HoppInheritedProperty["auth"] = {
|
let auth: HoppInheritedProperty["auth"] = {
|
||||||
parentID: folderPath ?? "",
|
parentID: folderPath ?? "",
|
||||||
@@ -1089,7 +1094,10 @@ export default class NewTeamCollectionAdapter {
|
|||||||
const parentFolderAuth = data.auth
|
const parentFolderAuth = data.auth
|
||||||
const parentFolderHeaders = data.headers
|
const parentFolderHeaders = data.headers
|
||||||
|
|
||||||
if (parentFolderAuth?.authType === "inherit" && path.length === 1) {
|
if (
|
||||||
|
parentFolderAuth?.authType === "inherit" &&
|
||||||
|
[...path.slice(0, i + 1)].length === 1
|
||||||
|
) {
|
||||||
auth = {
|
auth = {
|
||||||
parentID: [...path.slice(0, i + 1)].join("/"),
|
parentID: [...path.slice(0, i + 1)].join("/"),
|
||||||
parentName: parentFolder.title,
|
parentName: parentFolder.title,
|
||||||
|
|||||||
@@ -4,6 +4,7 @@ import {
|
|||||||
HoppRESTRequest,
|
HoppRESTRequest,
|
||||||
HoppCollection,
|
HoppCollection,
|
||||||
makeCollection,
|
makeCollection,
|
||||||
|
HoppGQLAuth,
|
||||||
} from "@hoppscotch/data"
|
} from "@hoppscotch/data"
|
||||||
import DispatchingStore, { defineDispatchers } from "./DispatchingStore"
|
import DispatchingStore, { defineDispatchers } from "./DispatchingStore"
|
||||||
import { cloneDeep } from "lodash-es"
|
import { cloneDeep } from "lodash-es"
|
||||||
@@ -11,6 +12,9 @@ import { resolveSaveContextOnRequestReorder } from "~/helpers/collection/request
|
|||||||
import { getService } from "~/modules/dioc"
|
import { getService } from "~/modules/dioc"
|
||||||
import { RESTTabService } from "~/services/tab/rest"
|
import { RESTTabService } from "~/services/tab/rest"
|
||||||
import { HoppInheritedProperty } from "~/helpers/types/HoppInheritedProperties"
|
import { HoppInheritedProperty } from "~/helpers/types/HoppInheritedProperties"
|
||||||
|
import { HoppRESTAuth } from "@hoppscotch/data"
|
||||||
|
import { HoppRESTHeaders } from "@hoppscotch/data"
|
||||||
|
import { HoppGQLHeader } from "~/helpers/graphql"
|
||||||
|
|
||||||
const defaultRESTCollectionState = {
|
const defaultRESTCollectionState = {
|
||||||
state: [
|
state: [
|
||||||
@@ -63,6 +67,12 @@ export function navigateToFolderWithIndexPath(
|
|||||||
return target !== undefined ? target : null
|
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(
|
export function cascadeParentCollectionForHeaderAuth(
|
||||||
folderPath: string | undefined,
|
folderPath: string | undefined,
|
||||||
type: "rest" | "graphql"
|
type: "rest" | "graphql"
|
||||||
@@ -103,10 +113,16 @@ export function cascadeParentCollectionForHeaderAuth(
|
|||||||
return { auth, headers }
|
return { auth, headers }
|
||||||
}
|
}
|
||||||
|
|
||||||
const parentFolderAuth = parentFolder.auth
|
const parentFolderAuth = parentFolder.auth as HoppRESTAuth | HoppGQLAuth
|
||||||
const parentFolderHeaders = parentFolder.headers
|
const parentFolderHeaders = parentFolder.headers as
|
||||||
|
| HoppRESTHeaders
|
||||||
|
| HoppGQLHeader[]
|
||||||
|
|
||||||
// check if the parent folder has authType 'inherit' and if it is the root folder
|
// check if the parent folder has authType 'inherit' and if it is the root folder
|
||||||
if (parentFolderAuth?.authType === "inherit" && path.length === 1) {
|
if (
|
||||||
|
parentFolderAuth?.authType === "inherit" &&
|
||||||
|
[...path.slice(0, i + 1)].length === 1
|
||||||
|
) {
|
||||||
auth = {
|
auth = {
|
||||||
parentID: [...path.slice(0, i + 1)].join("/"),
|
parentID: [...path.slice(0, i + 1)].join("/"),
|
||||||
parentName: parentFolder.name,
|
parentName: parentFolder.name,
|
||||||
|
|||||||
@@ -1,11 +1,58 @@
|
|||||||
<template>
|
<template>
|
||||||
<div class="flex flex-col flex-1 w-full">
|
<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>
|
||||||
<Embeds
|
<Embeds
|
||||||
v-if="tab"
|
v-else-if="!invalidLink && tab"
|
||||||
v-model:modelTab="tab"
|
v-model:modelTab="tab"
|
||||||
:properties="properties"
|
:properties="properties"
|
||||||
:shared-request-i-d="sharedRequestID"
|
: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>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
@@ -28,6 +75,9 @@ import {
|
|||||||
import { HoppTab } from "~/services/tab"
|
import { HoppTab } from "~/services/tab"
|
||||||
import { HoppRESTDocument } from "~/helpers/rest/document"
|
import { HoppRESTDocument } from "~/helpers/rest/document"
|
||||||
import { applySetting } from "~/newstore/settings"
|
import { applySetting } from "~/newstore/settings"
|
||||||
|
import { useI18n } from "~/composables/i18n"
|
||||||
|
|
||||||
|
const t = useI18n()
|
||||||
|
|
||||||
const route = useRoute()
|
const route = useRoute()
|
||||||
|
|
||||||
|
|||||||
@@ -244,9 +244,13 @@ export class PersistenceService extends Service {
|
|||||||
private setupSettingsPersistence() {
|
private setupSettingsPersistence() {
|
||||||
const settingsKey = "settings"
|
const settingsKey = "settings"
|
||||||
let settingsData = JSON.parse(
|
let settingsData = JSON.parse(
|
||||||
window.localStorage.getItem(settingsKey) || "{}"
|
window.localStorage.getItem(settingsKey) ?? "null"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
if (!settingsData) {
|
||||||
|
settingsData = getDefaultSettings()
|
||||||
|
}
|
||||||
|
|
||||||
// Validate data read from localStorage
|
// Validate data read from localStorage
|
||||||
const result = SETTINGS_SCHEMA.safeParse(settingsData)
|
const result = SETTINGS_SCHEMA.safeParse(settingsData)
|
||||||
if (result.success) {
|
if (result.success) {
|
||||||
|
|||||||
@@ -36,7 +36,7 @@ const SettingsDefSchema = z.object({
|
|||||||
httpUser: z.boolean(),
|
httpUser: z.boolean(),
|
||||||
httpPassword: z.boolean(),
|
httpPassword: z.boolean(),
|
||||||
bearerToken: z.boolean(),
|
bearerToken: z.boolean(),
|
||||||
oauth2Token: z.boolean(),
|
oauth2Token: z.optional(z.boolean()),
|
||||||
}),
|
}),
|
||||||
THEME_COLOR: ThemeColorSchema,
|
THEME_COLOR: ThemeColorSchema,
|
||||||
BG_COLOR: BgColorSchema,
|
BG_COLOR: BgColorSchema,
|
||||||
@@ -103,13 +103,10 @@ export const LOCAL_STATE_SCHEMA = z.union([
|
|||||||
.strict(),
|
.strict(),
|
||||||
])
|
])
|
||||||
|
|
||||||
export const SETTINGS_SCHEMA = z.union([
|
export const SETTINGS_SCHEMA = SettingsDefSchema.extend({
|
||||||
z.object({}).strict(),
|
EXTENSIONS_ENABLED: z.optional(z.boolean()),
|
||||||
SettingsDefSchema.extend({
|
PROXY_ENABLED: z.optional(z.boolean()),
|
||||||
EXTENSIONS_ENABLED: z.optional(z.boolean()),
|
})
|
||||||
PROXY_ENABLED: z.optional(z.boolean()),
|
|
||||||
}),
|
|
||||||
])
|
|
||||||
|
|
||||||
export const REST_HISTORY_ENTRY_SCHEMA = z
|
export const REST_HISTORY_ENTRY_SCHEMA = z
|
||||||
.object({
|
.object({
|
||||||
@@ -208,7 +205,7 @@ export const MQTT_REQUEST_SCHEMA = z.nullable(
|
|||||||
z
|
z
|
||||||
.object({
|
.object({
|
||||||
endpoint: z.string(),
|
endpoint: z.string(),
|
||||||
clientID: z.string(),
|
clientID: z.optional(z.string()),
|
||||||
})
|
})
|
||||||
.strict()
|
.strict()
|
||||||
)
|
)
|
||||||
|
|||||||
Reference in New Issue
Block a user