From d9410ed404d2c979826a0bb6d5d2f98165e0ce8f Mon Sep 17 00:00:00 2001 From: Cody Olsen Date: Wed, 22 Jan 2025 09:52:09 +0100 Subject: [PATCH] fix(stega): remove `isDraft` search param --- src/csm/createEditUrl.ts | 5 +---- test/csm/createEditUrl.test.ts | 8 ++++---- test/csm/resolveEditUrl.test.ts | 6 +++--- 3 files changed, 8 insertions(+), 11 deletions(-) diff --git a/src/csm/createEditUrl.ts b/src/csm/createEditUrl.ts index 533b3779..98d697b7 100644 --- a/src/csm/createEditUrl.ts +++ b/src/csm/createEditUrl.ts @@ -1,4 +1,4 @@ -import {getPublishedId, getVersionFromId, isDraftId, isPublishedId, isVersionId} from './draftUtils' +import {getPublishedId, getVersionFromId, isPublishedId, isVersionId} from './draftUtils' import {jsonPathToStudioPath} from './jsonPath' import * as studioPath from './studioPath' import type {CreateEditUrlOptions, EditIntentUrl, StudioBaseUrl} from './types' @@ -62,9 +62,6 @@ export function createEditUrl(options: CreateEditUrlOptions): `${StudioBaseUrl}$ const versionId = getVersionFromId(_id)! searchParams.set('perspective', versionId) } - if (isDraftId(_id)) { - searchParams.set('isDraft', '') - } const segments = [baseUrl === '/' ? '' : baseUrl] if (workspace) { diff --git a/test/csm/createEditUrl.test.ts b/test/csm/createEditUrl.test.ts index 9bb98345..80fcebc9 100644 --- a/test/csm/createEditUrl.test.ts +++ b/test/csm/createEditUrl.test.ts @@ -17,25 +17,25 @@ const cases = [ context: {baseUrl, workspace, tool, id, type}, path: parseJsonPath("$['foo'][?(@._key=='section-1')][0]['baz'][?(@._key=='section-2')]"), expected: - 'https://test.sanity.studio/staging/intent/edit/mode=presentation;id=homepage;type=page;path=foo[_key=="section-1"][0].baz[_key=="section-2"];tool=content?baseUrl=https://test.sanity.studio&id=homepage&type=page&path=foo[_key=="section-1"][0].baz[_key=="section-2"]&workspace=staging&tool=content&isDraft=', + 'https://test.sanity.studio/staging/intent/edit/mode=presentation;id=homepage;type=page;path=foo[_key=="section-1"][0].baz[_key=="section-2"];tool=content?baseUrl=https://test.sanity.studio&id=homepage&type=page&path=foo[_key=="section-1"][0].baz[_key=="section-2"]&workspace=staging&tool=content', }, { context: {baseUrl: '/', id, type}, path: parseJsonPath("$['foo'][?(@._key=='section-1')][0]"), expected: - '/intent/edit/mode=presentation;id=homepage;type=page;path=foo[_key=="section-1"][0]?baseUrl=/&id=homepage&type=page&path=foo[_key=="section-1"][0]&isDraft=', + '/intent/edit/mode=presentation;id=homepage;type=page;path=foo[_key=="section-1"][0]?baseUrl=/&id=homepage&type=page&path=foo[_key=="section-1"][0]', }, { context: {baseUrl: '/', workspace, tool, id, type}, path: parseJsonPath("$['foo'][?(@._key=='section-1')][0]"), expected: - '/staging/intent/edit/mode=presentation;id=homepage;type=page;path=foo[_key=="section-1"][0];tool=content?baseUrl=/&id=homepage&type=page&path=foo[_key=="section-1"][0]&workspace=staging&tool=content&isDraft=', + '/staging/intent/edit/mode=presentation;id=homepage;type=page;path=foo[_key=="section-1"][0];tool=content?baseUrl=/&id=homepage&type=page&path=foo[_key=="section-1"][0]&workspace=staging&tool=content', }, { context: {baseUrl: '/', workspace, tool, id, type, projectId, dataset}, path: parseJsonPath("$['foo'][?(@._key=='section-1')][0]"), expected: - '/staging/intent/edit/mode=presentation;id=homepage;type=page;path=foo[_key=="section-1"][0];tool=content?baseUrl=/&id=homepage&type=page&path=foo[_key=="section-1"][0]&workspace=staging&tool=content&projectId=a1b2c3d4&dataset=production&isDraft=', + '/staging/intent/edit/mode=presentation;id=homepage;type=page;path=foo[_key=="section-1"][0];tool=content?baseUrl=/&id=homepage&type=page&path=foo[_key=="section-1"][0]&workspace=staging&tool=content&projectId=a1b2c3d4&dataset=production', }, { context: {baseUrl: '/', workspace, tool, id: getPublishedId(id), type, projectId, dataset}, diff --git a/test/csm/resolveEditUrl.test.ts b/test/csm/resolveEditUrl.test.ts index 59a466bb..0c420455 100644 --- a/test/csm/resolveEditUrl.test.ts +++ b/test/csm/resolveEditUrl.test.ts @@ -519,19 +519,19 @@ const cases = [ path: 'products[1].title', studioUrl: 'https://test.sanity.studio', expected: - 'https://test.sanity.studio/intent/edit/mode=presentation;id=807cc05c-8c4c-443a-a9c1-198fd3fd7b16;type=product;path=title?baseUrl=https://test.sanity.studio&id=807cc05c-8c4c-443a-a9c1-198fd3fd7b16&type=product&path=title&isDraft=', + 'https://test.sanity.studio/intent/edit/mode=presentation;id=807cc05c-8c4c-443a-a9c1-198fd3fd7b16;type=product;path=title?baseUrl=https://test.sanity.studio&id=807cc05c-8c4c-443a-a9c1-198fd3fd7b16&type=product&path=title', }, { path: 'products[1].media.alt', studioUrl: '/', expected: - '/intent/edit/mode=presentation;id=807cc05c-8c4c-443a-a9c1-198fd3fd7b16;type=product;path=media[_key=="55659c72ec46"].alt?baseUrl=/&id=807cc05c-8c4c-443a-a9c1-198fd3fd7b16&type=product&path=media[_key=="55659c72ec46"].alt&isDraft=', + '/intent/edit/mode=presentation;id=807cc05c-8c4c-443a-a9c1-198fd3fd7b16;type=product;path=media[_key=="55659c72ec46"].alt?baseUrl=/&id=807cc05c-8c4c-443a-a9c1-198fd3fd7b16&type=product&path=media[_key=="55659c72ec46"].alt', }, { path: 'products[1].description[0].children[0].text', studioUrl: '/', expected: - '/intent/edit/mode=presentation;id=807cc05c-8c4c-443a-a9c1-198fd3fd7b16;type=product;path=description[0].children[0].text?baseUrl=/&id=807cc05c-8c4c-443a-a9c1-198fd3fd7b16&type=product&path=description[0].children[0].text&isDraft=', + '/intent/edit/mode=presentation;id=807cc05c-8c4c-443a-a9c1-198fd3fd7b16;type=product;path=description[0].children[0].text?baseUrl=/&id=807cc05c-8c4c-443a-a9c1-198fd3fd7b16&type=product&path=description[0].children[0].text', }, { path: 'products[2].title',