Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(releases): reverting releases #8008

Merged
merged 26 commits into from
Dec 14, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
26 commits
Select commit Hold shift + click to select a range
17b795c
feat: showing documents in archived and published releases
jordanl17 Dec 9, 2024
aeae150
refactor: removing check for existing document in published
jordanl17 Dec 10, 2024
14859fe
feat: showing revert release button on published releases
jordanl17 Dec 10, 2024
dcd91d1
feat: supporting reverting of changed documents
jordanl17 Dec 10, 2024
cb2ffbd
feat: reverting unpublishes created documents
jordanl17 Dec 10, 2024
e8cb191
fix: resolving issue where doc wasn't being repopulated in unpublish …
jordanl17 Dec 10, 2024
e33559b
chore: adding i18n
jordanl17 Dec 10, 2024
a7b8dcb
refactor: separating hook
jordanl17 Dec 10, 2024
927c4be
chore: telemetry for reverting release
jordanl17 Dec 11, 2024
1740fbf
refactor: tidy to useAdjacent (check back here for before state)
jordanl17 Dec 11, 2024
426928f
refactor: optimistic fetch of revert states that carries into the han…
jordanl17 Dec 11, 2024
8ce775d
refactor: types for useAdjacentTransactions
jordanl17 Dec 11, 2024
9da8252
refactor: post pub transactions separated hook; separate component fo…
jordanl17 Dec 12, 2024
852ae2c
refactor: revert dialog handle the revert operation
jordanl17 Dec 12, 2024
d19b248
refactor: simplified hook for adjacent transactions
jordanl17 Dec 12, 2024
d73d702
test: testing usePostPublishTransactions
jordanl17 Dec 12, 2024
54a90f6
refactor: revert becomes an operation; testing for hooks and operations
jordanl17 Dec 12, 2024
cf416b6
test: resolving test types
jordanl17 Dec 12, 2024
8d281f5
chore: updating copy
jordanl17 Dec 12, 2024
cc88fc8
fix: type on mock
jordanl17 Dec 12, 2024
61681e8
fix: import path
jordanl17 Dec 12, 2024
9f0808b
refactor: comment tidy
jordanl17 Dec 12, 2024
959a533
refactor: immediate instead of immediately
jordanl17 Dec 12, 2024
f1e9de4
test: mocking promise.withResolvers; using inside useDocumentRevertSt…
jordanl17 Dec 12, 2024
44dedc7
test: fixing test due to update with type of revert
jordanl17 Dec 12, 2024
5a2a17a
refactor: removing undefined return type from getTransLogs when no do…
jordanl17 Dec 13, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,13 @@ export interface OriginInfo {
origin: 'structure' | 'release-plugin'
}

export interface RevertInfo {
/**
* determined whether reverting a release created a new staged release, or immediately reverted
*/
revertType: 'immediate' | 'staged'
}

/**
* When a document (version) is successfully added to a release
* @internal
Expand Down Expand Up @@ -101,3 +108,12 @@ export const UnarchivedRelease = defineEvent({
version: 1,
description: 'User unarchived a release',
})

/** When a release is successfully reverted
* @internal
*/
export const RevertRelease = defineEvent<RevertInfo>({
name: 'Revert release',
jordanl17 marked this conversation as resolved.
Show resolved Hide resolved
version: 1,
description: 'User reverted a release',
})
44 changes: 38 additions & 6 deletions packages/sanity/src/core/releases/i18n/resources.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@ const releasesLocaleStrings = {
'action.archived': 'Archived',
/** Action text for comparing document versions */
'action.compare-versions': 'Compare versions',
/** Action text for reverting a release by creating a new release */
'action.create-revert-release': 'Stage in new release',
/** Action text for deleting a release */
'action.delete-release': 'Delete release',
/** Action text for editing a release */
Expand All @@ -32,8 +34,12 @@ const releasesLocaleStrings = {
'action.publish-all-documents': 'Publish all documents',
/** Text for the review changes button in release tool */
'action.review': 'Review changes',
/** Action text for reverting a release */
'action.revert': 'Revert release',
/** Text for the summary button in release tool */
'actions.summary': 'Summary',
/** Action text for reverting a release immediately without staging changes */
'action.immediate-revert-release': 'Revert now',
/** Label for unarchiving a release */
'action.unarchive': 'Unarchive release',
/** Header for the dialog confirming the archive of a release */
Expand Down Expand Up @@ -185,6 +191,29 @@ const releasesLocaleStrings = {
/** Label for when documents in release have validation errors */
'publish-dialog.validation.error': 'Some documents have validation errors',

/** Description for the review changes button in release tool */
'review.description': 'Add documents to this release to review changes',
/** Text for when a document is edited */
'review.edited': 'Edited <RelativeTime/>',
/** Description for the dialog confirming the revert of a release with multiple documents */
'revert-dialog.confirm-revert-description_one':
'This will revert {{releaseDocumentsLength}} document version.',
/** Description for the dialog confirming the revert of a release with multiple documents */
'revert-dialog.confirm-revert-description_other':
'This will revert {{releaseDocumentsLength}} document versions.',
/** Title for the dialog confirming the revert of a release */
'revert-dialog.confirm-revert.title': "Are you sure you want to revert the '{{title}}' release?",
/** Checkbox label to confirm whether to create a staged release for revert or immediately revert */
'revert-dialog.confirm-revert.stage-revert-checkbox-label':
'Stage revert actions in a new release',
/** Warning card text for when immediately revert a release with history */
'revert-dialog.confirm-revert.warning-card':
'Changes were made to documents in this release after they were published. Reverting will overwrite these changes.',
/** Title of a reverted release */
'revert-release.title': 'Reverting "{{title}}"',
/** Description of a reverted release */
'revert-release.description': 'Revert changes to document versions in "{{title}}".',

/** Title o unschedule release dialog */
'schedule-button.tooltip': 'Are you sure you want to unschedule the release?',

Expand All @@ -204,7 +233,7 @@ const releasesLocaleStrings = {
"The '<strong>{{title}}</strong>' release and its document will be published on the selected date.",
/** Description for the dialog confirming the publish of a release with multiple documents */
'schedule-dialog.confirm-description_other':
'The <strong>{{title}}</strong> release and its {{count}} document versions will be scheduled for publishing.',
'The <strong>{{title}}</strong> release and its {{count}} document versions will be scheduled for publishing.',

/** Description for the confirm button for scheduling a release */
'schedule-dialog.confirm-button': 'Yes, schedule for publishing',
Expand All @@ -218,11 +247,6 @@ const releasesLocaleStrings = {
'unschedule-dialog.confirm-description':
'The release will no longer be published on the scheduled date',

/** Description for the review changes button in release tool */
'review.description': 'Add documents to this release to review changes',
/** Text for when a document is edited */
'review.edited': 'Edited <RelativeTime/>',

/** Placeholder for search of documents in a release */
'search-documents-placeholder': 'Search documents',
/** Text for when the release was created */
Expand Down Expand Up @@ -282,6 +306,14 @@ const releasesLocaleStrings = {
'toast.unschedule.success': "The '<strong>{{title}}</strong>' release was unscheduled.",
/** Text for tooltip when a release has been scheduled */
'type-picker.tooltip.scheduled': 'The release is scheduled, unschedule it to change type',
/** Text for toast when release failed to revert */
'toast.revert.error': 'Failed to revert release: {{error}}',
/** Text for toast when release has been reverted immediately */
'toast.immediate-revert.success': "The '{{title}}' release was successfully reverted",
/** Text for toast when release has reverted release successfully staged */
'toast.revert-stage.success': "Revert release for '{{title}}' was successfully created. <Link/>",
/** Link text for toast link to the generated revert release */
'toast.revert-stage.success-link': 'View revert release',

/** Title for the dialog confirming the unpublish of a release */
'unpublish-dialog.header': 'Are you sure you want to unpublish this document when releasing?',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ export const createReleaseOperationsStoreReturn: Mocked<ReleaseOperationsStore>
unschedule: vi.fn(),
updateRelease: vi.fn(),
deleteRelease: vi.fn(),
revertRelease: vi.fn(),
unpublishVersion: vi.fn(),
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ export const useReleaseOperationsMockReturn: Mocked<ReleaseOperationsStore> = {
unschedule: vi.fn(),
updateRelease: vi.fn(),
deleteRelease: vi.fn(),
revertRelease: vi.fn(),
unpublishVersion: vi.fn(),
}

Expand Down
Loading
Loading