chore: merge hoppscotch/staging into self-hosted/main

This commit is contained in:
Andrew Bastin
2023-04-07 03:16:27 +05:30
8 changed files with 114 additions and 100 deletions

View File

@@ -98,8 +98,8 @@ declare module '@vue/runtime-core' {
HttpTestResultReport: typeof import('./components/http/TestResultReport.vue')['default'] HttpTestResultReport: typeof import('./components/http/TestResultReport.vue')['default']
HttpTests: typeof import('./components/http/Tests.vue')['default'] HttpTests: typeof import('./components/http/Tests.vue')['default']
HttpURLEncodedParams: typeof import('./components/http/URLEncodedParams.vue')['default'] HttpURLEncodedParams: typeof import('./components/http/URLEncodedParams.vue')['default']
IconLucideAlertTriangle: typeof import('~icons/lucide/alert-triangle')['default']
IconLucideArrowLeft: typeof import('~icons/lucide/arrow-left')['default'] IconLucideArrowLeft: typeof import('~icons/lucide/arrow-left')['default']
IconLucideBrush: typeof import('~icons/lucide/brush')['default']
IconLucideCheckCircle: typeof import('~icons/lucide/check-circle')['default'] IconLucideCheckCircle: typeof import('~icons/lucide/check-circle')['default']
IconLucideChevronRight: typeof import('~icons/lucide/chevron-right')['default'] IconLucideChevronRight: typeof import('~icons/lucide/chevron-right')['default']
IconLucideGlobe: typeof import('~icons/lucide/globe')['default'] IconLucideGlobe: typeof import('~icons/lucide/globe')['default']
@@ -108,7 +108,6 @@ declare module '@vue/runtime-core' {
IconLucideInfo: typeof import('~icons/lucide/info')['default'] IconLucideInfo: typeof import('~icons/lucide/info')['default']
IconLucideLayers: typeof import('~icons/lucide/layers')['default'] IconLucideLayers: typeof import('~icons/lucide/layers')['default']
IconLucideMinus: typeof import('~icons/lucide/minus')['default'] IconLucideMinus: typeof import('~icons/lucide/minus')['default']
IconLucideRss: typeof import('~icons/lucide/rss')['default']
IconLucideSearch: typeof import('~icons/lucide/search')['default'] IconLucideSearch: typeof import('~icons/lucide/search')['default']
IconLucideUser: typeof import('~icons/lucide/user')['default'] IconLucideUser: typeof import('~icons/lucide/user')['default']
IconLucideUsers: typeof import('~icons/lucide/users')['default'] IconLucideUsers: typeof import('~icons/lucide/users')['default']

View File

@@ -234,6 +234,7 @@ import {
getFoldersByPath, getFoldersByPath,
resolveSaveContextOnCollectionReorder, resolveSaveContextOnCollectionReorder,
updateSaveContextForAffectedRequests, updateSaveContextForAffectedRequests,
resetTeamRequestsContext,
} from "~/helpers/collection/collection" } from "~/helpers/collection/collection"
import { currentReorderingStatus$ } from "~/newstore/reordering" import { currentReorderingStatus$ } from "~/newstore/reordering"
@@ -990,10 +991,10 @@ const removeCollection = (id: string) => {
* since folder is treated as collection in the BE. * since folder is treated as collection in the BE.
* @param collectionID - ID of the collection or folder to be deleted. * @param collectionID - ID of the collection or folder to be deleted.
*/ */
const removeTeamCollectionOrFolder = (collectionID: string) => { const removeTeamCollectionOrFolder = async (collectionID: string) => {
modalLoadingState.value = true modalLoadingState.value = true
pipe( await pipe(
deleteCollection(collectionID), deleteCollection(collectionID),
TE.match( TE.match(
(err: GQLError<string>) => { (err: GQLError<string>) => {
@@ -1047,7 +1048,9 @@ const onRemoveCollection = () => {
emit("select", null) emit("select", null)
} }
removeTeamCollectionOrFolder(collectionID) removeTeamCollectionOrFolder(collectionID).then(() => {
resetTeamRequestsContext()
})
} }
} }
@@ -1099,7 +1102,9 @@ const onRemoveFolder = () => {
emit("select", null) emit("select", null)
} }
removeTeamCollectionOrFolder(collectionID) removeTeamCollectionOrFolder(collectionID).then(() => {
resetTeamRequestsContext()
})
} }
} }

View File

@@ -255,15 +255,6 @@ watch(
} }
) )
watch(
() => environmentType.value.selectedTeam,
(newTeam) => {
if (newTeam) {
adapter.changeTeamID(newTeam.id)
}
}
)
const switchToMyEnvironments = () => { const switchToMyEnvironments = () => {
environmentType.value.selectedTeam = undefined environmentType.value.selectedTeam = undefined
updateEnvironmentType("my-environments") updateEnvironmentType("my-environments")
@@ -282,17 +273,10 @@ const updateEnvironmentType = (newEnvironmentType: EnvironmentType) => {
} }
watch( watch(
() => environmentType.value.selectedTeam?.id, () => environmentType.value.selectedTeam,
(newTeamID) => { (newTeam) => {
adapter.changeTeamID(newTeamID) if (newTeam) {
} adapter.changeTeamID(newTeam.id)
)
watch(
() => currentUser.value,
(newValue) => {
if (!newValue) {
switchToMyEnvironments()
} }
} }
) )
@@ -320,6 +304,15 @@ watch(
} }
) )
watch(
() => currentUser.value,
(newValue) => {
if (!newValue) {
switchToMyEnvironments()
}
}
)
const showModalDetails = ref(false) const showModalDetails = ref(false)
const action = ref<"new" | "edit">("edit") const action = ref<"new" | "edit">("edit")
const editingEnvironmentIndex = ref<"Global" | null>(null) const editingEnvironmentIndex = ref<"Global" | null>(null)

View File

@@ -125,14 +125,14 @@ import { useColorMode } from "~/composables/theming"
import IconPlus from "~icons/lucide/plus" import IconPlus from "~icons/lucide/plus"
import IconArchive from "~icons/lucide/archive" import IconArchive from "~icons/lucide/archive"
import IconHelpCircle from "~icons/lucide/help-circle" import IconHelpCircle from "~icons/lucide/help-circle"
import { Team } from "~/helpers/backend/graphql"
import { defineActionHandler } from "~/helpers/actions" import { defineActionHandler } from "~/helpers/actions"
import { GetMyTeamsQuery } from "~/helpers/backend/graphql"
const t = useI18n() const t = useI18n()
const colorMode = useColorMode() const colorMode = useColorMode()
type SelectedTeam = Team | undefined type SelectedTeam = GetMyTeamsQuery["myTeams"][number] | undefined
const props = defineProps<{ const props = defineProps<{
team: SelectedTeam team: SelectedTeam

View File

@@ -1,6 +1,9 @@
import { HoppCollection, HoppRESTRequest } from "@hoppscotch/data" import { HoppCollection, HoppRESTRequest } from "@hoppscotch/data"
import { getTabsRefTo } from "../rest/tab" import { getTabsRefTo } from "../rest/tab"
import { getAffectedIndexes } from "./affectedIndex" import { getAffectedIndexes } from "./affectedIndex"
import { GetSingleRequestDocument } from "../backend/graphql"
import { runGQLQuery } from "../backend/GQLClient"
import * as E from "fp-ts/Either"
/** /**
* Resolve save context on reorder * Resolve save context on reorder
@@ -115,6 +118,33 @@ function resetSaveContextForAffectedRequests(folderPath: string) {
} }
} }
/**
* Reset save context to null if requests are deleted from the team collection or its folder
* only runs when collection or folder is deleted
*/
export async function resetTeamRequestsContext() {
const tabs = getTabsRefTo((tab) => {
return tab.document.saveContext?.originLocation === "team-collection"
})
for (const tab of tabs) {
if (tab.value.document.saveContext?.originLocation === "team-collection") {
const data = await runGQLQuery({
query: GetSingleRequestDocument,
variables: {
requestID: tab.value.document.saveContext?.requestID,
},
})
if (E.isRight(data) && data.right.request === null) {
tab.value.document.saveContext = null
tab.value.document.isDirty = true
}
}
}
}
export function getFoldersByPath( export function getFoldersByPath(
collections: HoppCollection<HoppRESTRequest>[], collections: HoppCollection<HoppRESTRequest>[],
path: string path: string

View File

@@ -45,6 +45,7 @@ export default class TeamEnvironmentAdapter {
this.teamEnvironmentCreated$ = null this.teamEnvironmentCreated$ = null
this.teamEnvironmentDeleted$ = null this.teamEnvironmentDeleted$ = null
this.teamEnvironmentUpdated$ = null this.teamEnvironmentUpdated$ = null
this.teamEnvironmentCreatedSub = null this.teamEnvironmentCreatedSub = null
this.teamEnvironmentDeletedSub = null this.teamEnvironmentDeletedSub = null
this.teamEnvironmentUpdatedSub = null this.teamEnvironmentUpdatedSub = null
@@ -56,6 +57,7 @@ export default class TeamEnvironmentAdapter {
this.teamEnvironmentCreated$?.unsubscribe() this.teamEnvironmentCreated$?.unsubscribe()
this.teamEnvironmentDeleted$?.unsubscribe() this.teamEnvironmentDeleted$?.unsubscribe()
this.teamEnvironmentUpdated$?.unsubscribe() this.teamEnvironmentUpdated$?.unsubscribe()
this.teamEnvironmentCreatedSub?.unsubscribe() this.teamEnvironmentCreatedSub?.unsubscribe()
this.teamEnvironmentDeletedSub?.unsubscribe() this.teamEnvironmentDeletedSub?.unsubscribe()
this.teamEnvironmentUpdatedSub?.unsubscribe() this.teamEnvironmentUpdatedSub?.unsubscribe()

View File

@@ -59,8 +59,8 @@
</div> </div>
</template> </template>
<script lang="ts"> <script setup lang="ts">
import { defineComponent, watch } from "vue" import { onMounted, ref, watch } from "vue"
import { useRoute, useRouter } from "vue-router" import { useRoute, useRouter } from "vue-router"
import * as E from "fp-ts/Either" import * as E from "fp-ts/Either"
import { safelyExtractRESTRequest } from "@hoppscotch/data" import { safelyExtractRESTRequest } from "@hoppscotch/data"
@@ -77,71 +77,56 @@ import IconRefreshCW from "~icons/lucide/refresh-cw"
import { createNewTab } from "~/helpers/rest/tab" import { createNewTab } from "~/helpers/rest/tab"
import { getDefaultRESTRequest } from "~/helpers/rest/default" import { getDefaultRESTRequest } from "~/helpers/rest/default"
export default defineComponent({ const route = useRoute()
setup() { const router = useRouter()
const route = useRoute()
const router = useRouter()
const t = useI18n() const t = useI18n()
const shortcodeDetails = useGQLQuery< const invalidLink = ref(false)
ResolveShortcodeQuery, const shortcodeID = ref("")
ResolveShortcodeQueryVariables,
""
>({
query: ResolveShortcodeDocument,
variables: {
code: route.params.id as string,
},
})
watch( const shortcodeDetails = useGQLQuery<
() => shortcodeDetails.data, ResolveShortcodeQuery,
() => { ResolveShortcodeQueryVariables,
if (shortcodeDetails.loading) return ""
>({
const data = shortcodeDetails.data query: ResolveShortcodeDocument,
variables: {
if (E.isRight(data)) { code: route.params.id.toString(),
const request: unknown = JSON.parse(
data.right.shortcode?.request as string
)
createNewTab({
request: safelyExtractRESTRequest(request, getDefaultRESTRequest()),
isDirty: false,
})
router.push({ path: "/" })
}
}
)
const reloadApplication = () => {
window.location.reload()
}
return {
E,
shortcodeDetails,
reloadApplication,
t,
route,
IconHome,
IconRefreshCW,
}
},
data() {
return {
invalidLink: false,
shortcodeID: "",
}
},
mounted() {
if (typeof this.route.params.id === "string") {
this.shortcodeID = this.route.params.id
}
this.invalidLink = !this.shortcodeID
}, },
}) })
watch(
() => shortcodeDetails.data,
() => addRequestToTab()
)
const addRequestToTab = () => {
if (shortcodeDetails.loading) return
const data = shortcodeDetails.data
if (E.isRight(data)) {
const request: unknown = JSON.parse(data.right.shortcode?.request as string)
createNewTab({
request: safelyExtractRESTRequest(request, getDefaultRESTRequest()),
isDirty: false,
})
router.push({ path: "/" })
}
}
const reloadApplication = () => {
window.location.reload()
}
onMounted(() => {
if (typeof route.params.id === "string") {
shortcodeID.value = route.params.id
shortcodeDetails.execute()
}
invalidLink.value = !shortcodeID.value
})
</script> </script>

16
pnpm-lock.yaml generated
View File

@@ -9215,7 +9215,7 @@ packages:
hasBin: true hasBin: true
/after@0.8.2: /after@0.8.2:
resolution: {integrity: sha512-QbJ0NTQ/I9DI3uSJA4cbexiwQeRAfjPScqIbSjUDd9TOrcg6pTkdgziesOqxBMBzit8vFCTwrP27t13vFOORRA==} resolution: {integrity: sha1-/ts5T58OAqqXaOcCvaI7UF+ufh8=}
dev: false dev: false
/agent-base@6.0.2: /agent-base@6.0.2:
@@ -9827,7 +9827,7 @@ packages:
resolution: {integrity: sha512-3oSeUO0TMV67hN1AmbXsK4yaqU7tjiHlbxRDZOpH0KW9+CeX4bRAaX0Anxt0tx2MrpRpWwQaPwIlISEJhYU5Pw==} resolution: {integrity: sha512-3oSeUO0TMV67hN1AmbXsK4yaqU7tjiHlbxRDZOpH0KW9+CeX4bRAaX0Anxt0tx2MrpRpWwQaPwIlISEJhYU5Pw==}
/base64-arraybuffer@0.1.4: /base64-arraybuffer@0.1.4:
resolution: {integrity: sha512-a1eIFi4R9ySrbiMuyTGx5e92uRH5tQY6kArNcFaKBUleIoLjdjBg7Zxm3Mqm3Kmkf27HLR/1fnxX9q8GQ7Iavg==} resolution: {integrity: sha1-mBjHngWbE1X5fgQooBfIOOkLqBI=}
engines: {node: '>= 0.6.0'} engines: {node: '>= 0.6.0'}
dev: false dev: false
@@ -10473,14 +10473,14 @@ packages:
dev: true dev: true
/component-bind@1.0.0: /component-bind@1.0.0:
resolution: {integrity: sha512-WZveuKPeKAG9qY+FkYDeADzdHyTYdIboXS59ixDeRJL5ZhxpqUnxSOwop4FQjMsiYm3/Or8cegVbpAHNA7pHxw==} resolution: {integrity: sha1-AMYIq33Nk4l8AAllGx06jh5zu9E=}
dev: false dev: false
/component-emitter@1.3.0: /component-emitter@1.3.0:
resolution: {integrity: sha512-Rd3se6QB+sO1TwqZjscQrurpEPIfO0/yYnSin6Q/rD3mOutHvUrCAhJub3r90uNb+SESBuE0QYoB90YdfatsRg==} resolution: {integrity: sha512-Rd3se6QB+sO1TwqZjscQrurpEPIfO0/yYnSin6Q/rD3mOutHvUrCAhJub3r90uNb+SESBuE0QYoB90YdfatsRg==}
/component-inherit@0.0.3: /component-inherit@0.0.3:
resolution: {integrity: sha512-w+LhYREhatpVqTESyGFg3NlP6Iu0kEKUHETY9GoZP/pQyW4mHFZuFWRUCIqVPZ36ueVLtoOEZaAqbCF2RDndaA==} resolution: {integrity: sha1-ZF/ErfWLcrZJ1crmUTVhnbJv8UM=}
dev: false dev: false
/concat-map@0.0.1: /concat-map@0.0.1:
@@ -13726,7 +13726,7 @@ packages:
dev: false dev: false
/has-cors@1.1.0: /has-cors@1.1.0:
resolution: {integrity: sha512-g5VNKdkFuUuVCP9gYfDJHjK2nqdQJ7aDLTnycnc2+RvsOQbuLdF5pm7vuE5J76SEBIQjs4kQY/BWq74JUmjbXA==} resolution: {integrity: sha1-XkdHk/fqmEPRu5nCPu9J/xJv/zk=}
dev: false dev: false
/has-flag@3.0.0: /has-flag@3.0.0:
@@ -14119,7 +14119,7 @@ packages:
engines: {node: '>=8'} engines: {node: '>=8'}
/indexof@0.0.1: /indexof@0.0.1:
resolution: {integrity: sha512-i0G7hLJ1z0DE8dsqJa2rycj9dBmNKgXBvotXtZYXakU9oivfB9Uj2ZBC27qqef2U58/ZLwalxa1X/RDCdkHtVg==} resolution: {integrity: sha1-gtwzbSMrkGIXnQWrMpOmYFn9Q10=}
dev: false dev: false
/inflight@1.0.6: /inflight@1.0.6:
@@ -19813,7 +19813,7 @@ packages:
dev: true dev: true
/to-array@0.1.4: /to-array@0.1.4:
resolution: {integrity: sha512-LhVdShQD/4Mk4zXNroIQZJC+Ap3zgLcDuwEdcmLv9CCO73NWockQDwyUnW/m8VX/EElfL6FcYx7EeutN4HJA6A==} resolution: {integrity: sha1-F+bBH3PdTz10zaek/zI46a2b+JA=}
dev: false dev: false
/to-fast-properties@2.0.0: /to-fast-properties@2.0.0:
@@ -22404,7 +22404,7 @@ packages:
dev: false dev: false
/yeast@0.1.2: /yeast@0.1.2:
resolution: {integrity: sha512-8HFIh676uyGYP6wP13R/j6OJ/1HwJ46snpvzE7aHAN3Ryqh2yX6Xox2B4CUmTwwOIzlG3Bs7ocsP5dZH/R1Qbg==} resolution: {integrity: sha1-AI4G2AlDIMNy28L47XagymyKxBk=}
dev: false dev: false
/yn@3.1.1: /yn@3.1.1: