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

Update sdk to v2 #3207

Merged
merged 23 commits into from
Dec 18, 2024
Merged

Update sdk to v2 #3207

merged 23 commits into from
Dec 18, 2024

Conversation

roppazvan
Copy link
Collaborator

@roppazvan roppazvan commented Nov 22, 2024

Why does this PR exist?

This updates the studio sync provider to use the latest SDK version.

What does this pull request do?

Testing this change

Run graphql locally. Add the local endpoint in the plugin env variables.

Additional Notes (if any)

Screenshot 2024-11-22 at 17 19 02

Copy link

changeset-bot bot commented Nov 22, 2024

🦋 Changeset detected

Latest commit: 9a748e3

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 1 package
Name Type
@tokens-studio/figma-plugin Minor

Not sure what this means? Click here to learn what changesets are.

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

Copy link
Contributor

github-actions bot commented Nov 22, 2024

⤵️ 📦 ✨ The artifact was successfully created! Want to test it? Download it here 👀 🎁

Copy link

@github-advanced-security github-advanced-security bot left a comment

Choose a reason for hiding this comment

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

ESLint found more than 20 potential problems in the proposed changes. Check the Files changed tab for more details.

successCallback?.();
} catch (e) {
Sentry.captureException(e);
console.error('Error updating token set order in Tokens Studio', e);

Check warning

Code scanning / ESLint

disallow the use of `console`

Unexpected console statement.
successCallback?.();
} catch (e) {
Sentry.captureException(e);
console.error('Error creating theme group in Tokens Studio', e);

Check warning

Code scanning / ESLint

disallow the use of `console`

Unexpected console statement.
successCallback?.();
} catch (e) {
Sentry.captureException(e);
console.error('Error updating theme group in Tokens Studio', e);

Check warning

Code scanning / ESLint

disallow the use of `console`

Unexpected console statement.
successCallback?.();
} catch (e) {
Sentry.captureException(e);
console.error('Error deleting theme group in Tokens Studio', e);

Check warning

Code scanning / ESLint

disallow the use of `console`

Unexpected console statement.
@roppazvan roppazvan marked this pull request as ready for review November 28, 2024 14:32
@roppazvan roppazvan requested review from six7 and SorsOps November 28, 2024 14:33
@six7 six7 added the do not merge Not ready for merging yet label Dec 9, 2024
Copy link
Contributor

github-actions bot commented Dec 9, 2024

Commit SHA:8e3bc5ae9affbddb72787a2846501cfe2d5072c9

Test coverage results 🧪

Code coverage diff between base branch:main and head branch: update-sdk-to-v2 
Status File % Stmts % Branch % Funcs % Lines
🔴 total 67.08 (0.01) 57.85 (-0.09) 63.86 (-0.04) 67.45 (0.03)
🔴 packages/tokens-studio-for-figma/src/app/components/StorageItemForm/TokensStudioForm.tsx 1.81 (-2.95) 0 (0) 0 (0) 2.12 (-2.88)
🔴 packages/tokens-studio-for-figma/src/app/store/models/tokenState.tsx 76.44 (-0.54) 63.07 (-1.09) 84 (0.5) 76.51 (-0.24)
🟢 packages/tokens-studio-for-figma/src/app/store/models/reducers/tokenState/disconnectStyleFromTheme.ts 78.57 (1.65) 80 (5) 50 (0) 76.92 (1.92)
🟢 packages/tokens-studio-for-figma/src/app/store/providers/tokens-studio/tokensStudio.tsx 34.28 (5.71) 8.33 (8.33) 44.44 (6.94) 34.28 (5.71)
🔴 packages/tokens-studio-for-figma/src/app/store/utils/updateAliasesInState.ts 82.85 (-6.62) 70 (-30) 100 (0) 90 (0.53)
🟢 packages/tokens-studio-for-figma/src/storage/TokensStudioTokenStorage.ts 50.31 (2.87) 34.84 (-4.33) 52.17 (36.79) 51.28 (2.85)
🔴 packages/tokens-studio-for-figma/src/storage/tokensStudio/createTokenInTokensStudio.ts 85.71 (-14.29) 50 (-50) 100 (0) 85.71 (-14.29)
🟢 packages/tokens-studio-for-figma/src/storage/tokensStudio/createTokenSetInTokensStudio.ts 100 (0) 100 (25) 100 (0) 100 (0)
🟢 packages/tokens-studio-for-figma/src/storage/tokensStudio/deleteTokenSetFromTokensStudio.ts 100 (0) 100 (50) 100 (0) 100 (0)
✨ 🆕 packages/tokens-studio-for-figma/src/storage/tokensStudio/duplicateTokenInTokensStudio.ts 0 100 0 0
🟢 packages/tokens-studio-for-figma/src/storage/tokensStudio/updateTokenSetInTokensStudio.ts 100 (0) 100 (25) 100 (0) 100 (0)
✨ 🆕 packages/tokens-studio-for-figma/src/storage/tokensStudio/graphql/getOrgsQuery.ts 100 100 100 100
🔴 packages/tokens-studio-for-figma/src/storage/tokensStudio/updateThemeGroupsInTokensStudio/getThemeGroupsToUpdate.ts 100 (0) 75 (-8.33) 100 (0) 100 (0)
🔴 packages/tokens-studio-for-figma/src/storage/tokensStudio/updateThemeGroupsInTokensStudio/index.ts 83.33 (-5.37) 43.75 (-28.25) 100 (0) 83.33 (-5.19)
🔴 packages/tokens-studio-for-figma/src/storage/tokensStudio/updateThemeGroupsInTokensStudio/saveTheme.ts 91.42 (-5.35) 77.27 (-2.73) 100 (0) 91.17 (-4.83)
✨ 🆕 packages/tokens-studio-for-figma/src/utils/convert.ts 100 40 100 100
🔴 packages/tokens-studio-for-figma/src/utils/themeListToTree.ts 63.63 (0) 46.42 (0) 50 (0) 63.63 (-14.14)
🔴 packages/tokens-studio-for-figma/src/utils/tokenHelpers.ts 53.33 (0) 57.69 (0) 41.66 (0) 53.84 (-6.16)
packages/tokens-studio-for-figma/src/storage/tokensStudio/utils/tokensStudioToToken.ts 10.34 0 0 11.11

Copy link
Contributor

github-actions bot commented Dec 9, 2024

Commit SHA:8e3bc5ae9affbddb72787a2846501cfe2d5072c9
Current PR reduces the test coverage percentage by 1 for some tests

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.

It'd have been easier if formatting changes were not part of that PR. Also, it had gotten super big, it might have made sense to break it down in smaller PRs.

const fetchOrgData = React.useCallback(async () => {
try {
const client = create({
host: process.env.API_HOST || 'localhost:4200',
Copy link
Collaborator

Choose a reason for hiding this comment

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

Is this the Studio API? Lets change the name of the env variable then to Studio

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

changed

setOrgData(result.data.organizations.data as Organization[]);
}
} catch (error) {
setFetchOrgsError('Error fetching organization data. Please check your PAT.');
Copy link
Collaborator

Choose a reason for hiding this comment

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

Lets write the full name not PAT

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

sure

@@ -7,7 +7,7 @@ export function renameVariableNamesToThemes(state: TokenState, tokensToRename: T
return acc;
}, {});
const newThemes = state.themes.map((theme) => {
const updatedTokens = theme.$figmaVariableReferences;
const updatedTokens = { ...theme.$figmaVariableReferences };
Copy link
Collaborator

Choose a reason for hiding this comment

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

Why are we doing it that way?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

reverted this change as it was causing issues with tests.


expect(updatedTokens).toEqual(expectedTokens);
expect(newTokens).toEqual(expectedTokens);
Copy link
Collaborator

Choose a reason for hiding this comment

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

Is this on purpose?


expect(updatedTokens).toEqual(expectedTokens);
expect(newTokens).toEqual(expectedTokens);
Copy link
Collaborator

Choose a reason for hiding this comment

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

Is this on purpose? We used to check for updated tokens now were doing new tokens?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

just renamed it, but reverted back. updatedTokens is better.

acc.splice(parentIndex + childrenLength + 1, 0, {
isLeaf: true,
value: curr,
key: curr.id,
key: curr.name,
Copy link
Collaborator

Choose a reason for hiding this comment

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

Is this a fn just used by Studio?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

it's used by the manage themes modal

Copy link
Collaborator

Choose a reason for hiding this comment

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

i think same as before, name is not unique


export function getOverallConfig(themes: ThemeObject[], selectedThemes: string[]) {
return selectedThemes.reduce((acc, themeId) => {
const currentTheme = themes.find((theme) => theme.id === themeId);
const currentTheme = themes.find((theme) => theme.name === themeId);
Copy link
Collaborator

Choose a reason for hiding this comment

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

Why are we switching from id to name?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

this was done before we moved everything to postgres . The idea was that gitea would be name based. Most of the studio stuff is the same. everything is based on name, except project and org.

Copy link
Collaborator

Choose a reason for hiding this comment

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

@roppazvan i think we cannot compare name.. there could be multiple themes with the same name (under different groups), lets keep to id

@roppazvan roppazvan requested a review from six7 December 16, 2024 13:56
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.

approving code-side, @rbosker @keeganedwin can you do functional testing?

@keeganedwin
Copy link
Collaborator

approving code-side, @rbosker @keeganedwin can you do functional testing?
Test was successful. Was able to :

  • Choose Org
  • Choose Proj
  • Export styles & variables

@roppazvan roppazvan merged commit da1786c into main Dec 18, 2024
9 of 10 checks passed
@roppazvan roppazvan deleted the update-sdk-to-v2 branch December 18, 2024 11:46
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.

5 participants