Open-Source API Development Ecosystem • https://hoppscotch.io • Offline, On-Prem & Cloud • Web, Desktop & CLI • Open-Source Alternative to Postman, Insomnia
TypeScript apiapi-clientapi-restapi-testingdeveloper-toolsgraphqlhttphttp-clientpwarestrest-apispatestingtesting-toolstoolsvuevuejswebsocket
fix(common): use fallback ref ID for mock server creation with legacy collections (#5536)
Anwarul Islama573db593751
diff --git a/packages/hoppscotch-common/src/components/collections/Collection.vue b/packages/hoppscotch-common/src/components/collections/Collection.vueindex b72456731..f3ff9f4fa 100644--- a/packages/hoppscotch-common/src/components/collections/Collection.vue+++ b/packages/hoppscotch-common/src/components/collections/Collection.vue@@ -473,7 +473,8 @@ const mockServerStatus = computed(() => {const collectionId =props.collectionsType === "my-collections"- ? (props.data as HoppCollection).id+ ? ((props.data as HoppCollection).id ??+ (props.data as HoppCollection)._ref_id): (props.data as TeamCollection).idreturn getMockServerStatus(collectionId || "")diff --git a/packages/hoppscotch-common/src/components/collections/index.vue b/packages/hoppscotch-common/src/components/collections/index.vueindex 93080b363..4390a4172 100644--- a/packages/hoppscotch-common/src/components/collections/index.vue+++ b/packages/hoppscotch-common/src/components/collections/index.vue@@ -1083,7 +1083,7 @@ const createMockServer = (payload: {}) => {// Import the mock server store dynamically to avoid circular dependenciesimport("~/newstore/mockServers").then(({ showCreateMockServerModal$ }) => {- let collectionID = payload.collection.id ?? undefined+ let collectionID = payload.collection.id ?? payload.collection._ref_id// If this is a child collection (folder), we need to get the root collection IDif (payload.collectionIndex.includes("/")) {@@ -1091,7 +1091,7 @@ const createMockServer = (payload: {const rootIndex = payload.collectionIndex.split("/")[0]const rootCollection = myCollections.value[parseInt(rootIndex)]if (rootCollection) {- collectionID = rootCollection.id ?? undefined+ collectionID = rootCollection.id ?? rootCollection._ref_id}}diff --git a/packages/hoppscotch-common/src/components/mockServer/CreateMockServer.vue b/packages/hoppscotch-common/src/components/mockServer/CreateMockServer.vueindex 345c1ecd1..032d2b56b 100644--- a/packages/hoppscotch-common/src/components/mockServer/CreateMockServer.vue+++ b/packages/hoppscotch-common/src/components/mockServer/CreateMockServer.vue@@ -386,7 +386,10 @@ const isExistingMockServer = computed(() => !!existingMockServer.value)// Collection options for the selector (only root collections)const collectionOptions = computed(() => {return availableCollections.value.map((collection) => {- const collectionId = collection.id+ const collectionId =+ currentWorkspace.value.type === "team"+ ? collection.id+ : (collection.id ?? collection._ref_id) // TODO: fix this fallback logic for personal workspaces in the futureconst hasMockServer = mockServers.value.some((server) => server.collectionID === collectionId)diff --git a/packages/hoppscotch-common/src/composables/mockServerVisibility.ts b/packages/hoppscotch-common/src/composables/mockServerVisibility.tsindex 02a835121..63d53ff56 100644--- a/packages/hoppscotch-common/src/composables/mockServerVisibility.ts+++ b/packages/hoppscotch-common/src/composables/mockServerVisibility.ts@@ -1,43 +1,21 @@import { computed } from "vue"+import { useSetting } from "~/composables/settings"-import { platform } from "~/platform"-import { useService } from "dioc/vue"-import { WorkspaceService } from "~/services/workspace.service"/**- * Composable to determine mock server visibility based on experimental flags and platform configuration+ * Composable to determine mock server visibility based on experimental flags*/export function useMockServerVisibility() {const ENABLE_EXPERIMENTAL_MOCK_SERVERS = useSetting("ENABLE_EXPERIMENTAL_MOCK_SERVERS")- const workspaceService = useService(WorkspaceService)-/**- * Check if mock servers should be visible based on experimental flag and platform configuration+ * Check if mock servers should be visible based on experimental flag*/- const isMockServerVisible = computed(() => {- // First check if experimental mock servers are enabled- if (!ENABLE_EXPERIMENTAL_MOCK_SERVERS.value) {- return false- }-- // Check if platform disables mock servers in personal workspaces- const disableInPersonalWorkspace =- platform.platformFeatureFlags.disableMockServerInPersonalWorkspace ??- false-- // If platform disables mock servers in personal workspaces and current workspace is personal, hide mock servers- if (- disableInPersonalWorkspace &&- workspaceService.currentWorkspace.value.type === "personal"- ) {- return false- }-- return true- })+ const isMockServerVisible = computed(+ () => ENABLE_EXPERIMENTAL_MOCK_SERVERS.value+ )return {isMockServerVisible,diff --git a/packages/hoppscotch-common/src/platform/index.ts b/packages/hoppscotch-common/src/platform/index.tsindex 5aec2f81d..cec460c44 100644--- a/packages/hoppscotch-common/src/platform/index.ts+++ b/packages/hoppscotch-common/src/platform/index.ts@@ -66,12 +66,6 @@ export type PlatformDef = {* Whether to show the A/B testing workspace switcher click login flow or not*/workspaceSwitcherLogin?: Ref<boolean>-- /**- * Whether to disable mock servers in personal workspaces- * If a value is not given, then the value is assumed to be false- */- disableMockServerInPersonalWorkspace?: boolean}limits?: LimitsPlatformDefinfra?: InfraPlatformDef