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: enable raw JSON editor mode for collection links #990

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

dcshzj
Copy link
Contributor

@dcshzj dcshzj commented Jan 15, 2025

Problem

The raw JSON editor mode is not available for collection links, which adds ops load to engineers when migrators need to change tags (e.g. for REACH).

Solution

Breaking Changes

  • Yes - this PR contains breaking changes
  • No - this PR is backwards compatible

Features:

  • Extended the existing raw JSON editor mode to the collection links editor. This involved:
    • Small refactor of ActivateRawJsonEditorMode.tsx to allow the consumer to determine the action to take after a successful activation (removed the dependency on the EditorStateDrawer context).
    • Refactored RawJsonEditorModeStateDrawer.tsx by extracting out the UI from the business logic, so that the UI can be reused by the LinkEditorDrawer.
    • Extended LinkEditorDrawer to handle two states - root and rawJsonEditor states. Also split the existing page state into a saved and preview version, so that the raw JSON editor can discard changes to revert back to the original saved state.

Bug fixes:

  • The ref attribute in the link preview was hard-coded, so it could be misleading when users hover over the link. Have updated it to use the value provided by the user.

Notes:

  • It is NOT possible to change the title using the raw JSON editor mode. This is not something I'm tackling now, since the title change needs to be done in a separate flow.
  • It is also not possible to edit something on the link editor first, then go into the raw JSON editor mode and see those changes reflected. I was thinking if we want this behaviour, then we may have to handle 3 page states which makes this feature overly complicated (since it is only used by migrators), so opted to keep things simple.

Before & After Screenshots

Screen.Recording.2025-01-15.at.11.50.29.mov

Tests

  • Navigate to any collection link in a collection inside Studio.
  • Press the special sequence to activate the raw JSON editor mode.
  • Make changes to the category and/or year of the collection link item and verify that the changes are reflected on the preview on the right (provided the schema is valid).
  • Save the changes made, verify that you should be able to save.
  • Refresh the page, verify that the changes you made persist.

@dcshzj dcshzj requested a review from a team as a code owner January 15, 2025 03:54
@datadog-opengovsg
Copy link

datadog-opengovsg bot commented Jan 15, 2025

Datadog Report

Branch report: feat/link-json-editor
Commit report: 7e389f2
Test service: isomer-studio

✅ 0 Failed, 257 Passed, 36 Skipped, 49.39s Total Time
➡️ Test Sessions change in coverage: 1 no change

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant