fix(common): use fallback ref ID for mock server creation with legacy collections (#5536)
Co-authored-by: jamesgeorge007 <25279263+jamesgeorge007@users.noreply.github.com>
This commit is contained in:
parent
e607f9db24
commit
a573db5937
5 changed files with 14 additions and 38 deletions
|
|
@ -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).id
|
||||
|
||||
return getMockServerStatus(collectionId || "")
|
||||
|
|
|
|||
|
|
@ -1083,7 +1083,7 @@ const createMockServer = (payload: {
|
|||
}) => {
|
||||
// Import the mock server store dynamically to avoid circular dependencies
|
||||
import("~/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 ID
|
||||
if (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
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -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 future
|
||||
const hasMockServer = mockServers.value.some(
|
||||
(server) => server.collectionID === collectionId
|
||||
)
|
||||
|
|
|
|||
|
|
@ -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,
|
||||
|
|
|
|||
|
|
@ -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?: LimitsPlatformDef
|
||||
infra?: InfraPlatformDef
|
||||
|
|
|
|||
Loading…
Reference in a new issue