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

Allow duplicate group names while validating no duplicate tokens #2827

Merged
merged 7 commits into from
Jun 16, 2024

Conversation

macintoshhelper
Copy link
Contributor

@macintoshhelper macintoshhelper commented Jun 7, 2024

Why does this PR exist?

Fixes #2778

What does this pull request do?

Testing this change

Import this JSON

{
  "buttons123": {
    "default": {
      "value": "#0fa",
      "type": "color"
    },
    "primary": {
      "value": "#0af",
      "type": "color"
    },
    "secondary": {
      "value": "#a0f",
      "type": "color"
    },
    "superlongtokenname": {
      "value": "#0af",
      "type": "color"
    }
  },
  "buttons": {
    "default": {
      "value": "16",
      "type": "sizing"
    },
    "primary": {
      "value": "12",
      "type": "sizing"
    },
    "superlongtokenname": {
      "value": "16",
      "type": "sizing"
    }
  },
  "buttons2": {
    "value": "12",
    "type": "sizing"
  },
  "buttons3": {
    "test": {
      "value": "16",
      "type": "spacing"
    }
  }
}

Try to rename and duplicate the buttons123 group to buttons and buttons2. These should show error messages with the conflicting token(s).

Renaming/duplicating buttons123 to buttons3 should be allowed.

Additional Notes (if any)

Before

image image image

After

image image image image image image image

Copy link

changeset-bot bot commented Jun 7, 2024

⚠️ No Changeset found

Latest commit: 5c13993

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

Click here if you're a maintainer who wants to add a changeset to this PR

@six7
Copy link
Collaborator

six7 commented Jun 10, 2024

Tests failing here

(I'm not able to copy paste that JSON in, leads to errors)

Slight UX feedback on a different set of JSON that i used:

Try to rename the buttons group in the Colors type here to buttons.foo - This technically should be possible as the only tokens inside are tokens part of the current group:

{
  "buttons": {
    "foo": {
      "default": {
        "value": "#0fa",
        "type": "color"
      },
      "primary": {
        "value": "#0af",
        "type": "color"
      },
      "secondary": {
        "value": "#a0f",
        "type": "color"
      },
      "superlongtokenname": {
        "value": "#0af",
        "type": "color"
      }
    },
    "default": {
      "value": "16",
      "type": "sizing"
    }
  },
  "primary": {
    "value": "12",
    "type": "sizing"
  },
  "superlongtokenname": {
    "value": "16",
    "type": "sizing"
  }
}

Copy link
Collaborator

@six7 six7 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just some comments on the translation strings as well as test names, but all are nits. Feel free to merge once that is in!

@@ -95,7 +95,24 @@
},
"duplicate": "Duplicate",
"rename": "Rename",
"renameGroupError": "There's an existing token or group with that name",
"renameGroupModal": {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can you add the translations to these for all the other languages?

const newName = 'buttons3';
expect(validateRenameGroupName(tokens2[activeTokenSet], type, oldName, newName)).toEqual(null);
});
// FIXME: Test is disabled, as this should not be a blocking issue. If there is just one of each incorrect values, it is still giving the correct error/overlapping token
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

should we remove this then?

const newName = 'buttons.foo';
expect(validateDuplicateGroupName(tokens, selectedTokenSets, activeTokenSet, type, oldName, newName)).toEqual(null);
});
it('prevent overlapping token name with group name', () => {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can you start all with should... ? that feels easier to read (it should prevent overlapping..)

@six7
Copy link
Collaborator

six7 commented Jun 16, 2024

I'll merge this in - can you add the comments of mine in a follow-up PR?

@six7 six7 merged commit 1070ab1 into release-139 Jun 16, 2024
7 of 8 checks passed
@six7 six7 deleted the fix/2778-error-on-group-collision branch June 16, 2024 11:12
@six7 six7 added the 2.0-rc8 label Jun 16, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants