diff --git a/packages/tokens-studio-for-figma/cypress/e2e/branches.cy.js b/packages/tokens-studio-for-figma/cypress/e2e/branches.cy.js index 53fae23f77..ae630091b0 100644 --- a/packages/tokens-studio-for-figma/cypress/e2e/branches.cy.js +++ b/packages/tokens-studio-for-figma/cypress/e2e/branches.cy.js @@ -1,13 +1,11 @@ -import { - StorageProviderType -} from '@/constants/StorageProviderType'; +import { AVAILABLE_PROVIDERS } from '@sync-providers/constants'; import { UpdateMode } from '@/constants/UpdateMode'; import MockEnv from '../support/mockEnv' import { fillTokenForm } from './helpers/utils'; describe('Branch switcher', () => { const provider = { - provider: StorageProviderType.GITHUB, + provider: AVAILABLE_PROVIDERS.GITHUB, id: '122/figma-tokens', secret: '456', name: 'dummy 2', @@ -157,4 +155,4 @@ describe('Branch switcher', () => { cy.get('[data-testid=push-dialog-button-push-changes]').click(); cy.get('[data-testid=push-dialog-success-heading]').should('have.length', 1); }); -}); \ No newline at end of file +}); diff --git a/packages/tokens-studio-for-figma/cypress/e2e/inspector.cy.js b/packages/tokens-studio-for-figma/cypress/e2e/inspector.cy.js index c1dbd736c1..b6057670bf 100644 --- a/packages/tokens-studio-for-figma/cypress/e2e/inspector.cy.js +++ b/packages/tokens-studio-for-figma/cypress/e2e/inspector.cy.js @@ -1,6 +1,4 @@ -import { - StorageProviderType -} from '@/constants/StorageProviderType'; +import { AVAILABLE_PROVIDERS } from '@sync-providers/constants'; import { UpdateMode } from '@/constants/UpdateMode'; import MockEnv from '../support/mockEnv'; @@ -28,7 +26,7 @@ describe('Inspector tokens', () => { updateRemote: true, updateStyles: true, }, - storageType: { provider: StorageProviderType.LOCAL }, + storageType: { provider: AVAILABLE_PROVIDERS.LOCAL }, user: { figmaId: 'figma:1234', userId: 'uid:1234', @@ -253,4 +251,4 @@ describe('Inspector tokens', () => { cy.contains('opacity.50').should('not.exist'); cy.contains('opacity.100'); }); -}); \ No newline at end of file +}); diff --git a/packages/tokens-studio-for-figma/cypress/e2e/manage-themes.cy.js b/packages/tokens-studio-for-figma/cypress/e2e/manage-themes.cy.js index 3825ebdca0..433cc39bb6 100644 --- a/packages/tokens-studio-for-figma/cypress/e2e/manage-themes.cy.js +++ b/packages/tokens-studio-for-figma/cypress/e2e/manage-themes.cy.js @@ -1,6 +1,4 @@ -import { - StorageProviderType -} from '@/constants/StorageProviderType'; +import { AVAILABLE_PROVIDERS } from '@sync-providers/constants'; import { UpdateMode } from '@/constants/UpdateMode'; import MockEnv from '../support/mockEnv'; @@ -33,7 +31,7 @@ describe('TokenListing', () => { updateRemote: true, updateStyles: true, }, - storageType: { provider: StorageProviderType.LOCAL }, + storageType: { provider: AVAILABLE_PROVIDERS.LOCAL }, user: { figmaId: 'figma:1234', userId: 'uid:1234', diff --git a/packages/tokens-studio-for-figma/cypress/e2e/startup.cy.js b/packages/tokens-studio-for-figma/cypress/e2e/startup.cy.js index 8e43e5dda7..3066fc761e 100644 --- a/packages/tokens-studio-for-figma/cypress/e2e/startup.cy.js +++ b/packages/tokens-studio-for-figma/cypress/e2e/startup.cy.js @@ -1,6 +1,4 @@ -import { - StorageProviderType -} from '@/constants/StorageProviderType'; +import { AVAILABLE_PROVIDERS } from '@sync-providers/constants'; import { TokenTypes } from '@/constants/TokenTypes'; @@ -29,7 +27,7 @@ describe('Loads application', () => { updateRemote: true, updateStyles: true, }, - storageType: { provider: StorageProviderType.LOCAL }, + storageType: { provider: AVAILABLE_PROVIDERS.LOCAL }, user: { figmaId: 'figma:1234', userId: 'uid:1234', diff --git a/packages/tokens-studio-for-figma/cypress/e2e/themes.cy.js b/packages/tokens-studio-for-figma/cypress/e2e/themes.cy.js index 93b990da37..c97434db5b 100644 --- a/packages/tokens-studio-for-figma/cypress/e2e/themes.cy.js +++ b/packages/tokens-studio-for-figma/cypress/e2e/themes.cy.js @@ -1,6 +1,4 @@ -import { - StorageProviderType -} from '@/constants/StorageProviderType'; +import { AVAILABLE_PROVIDERS } from '@sync-providers/constants'; import { UpdateMode } from '@/constants/UpdateMode'; import MockEnv from '../support/mockEnv'; @@ -27,7 +25,7 @@ describe('Themes', () => { updateRemote: true, updateStyles: true, }, - storageType: { provider: StorageProviderType.LOCAL }, + storageType: { provider: AVAILABLE_PROVIDERS.LOCAL }, user: { figmaId: 'figma:1234', userId: 'uid:1234', @@ -121,4 +119,4 @@ describe('Themes', () => { cy.get('[data-testid="button-manage-themes-modal-delete-theme"]').click(); cy.get('[data-testid="singlethemeentry"]').should('have.length', 0) }); -}); \ No newline at end of file +}); diff --git a/packages/tokens-studio-for-figma/cypress/e2e/tokens.cy.js b/packages/tokens-studio-for-figma/cypress/e2e/tokens.cy.js index 3124392644..f65c620107 100644 --- a/packages/tokens-studio-for-figma/cypress/e2e/tokens.cy.js +++ b/packages/tokens-studio-for-figma/cypress/e2e/tokens.cy.js @@ -1,6 +1,4 @@ -import { - StorageProviderType -} from '@/constants/StorageProviderType'; +import { AVAILABLE_PROVIDERS } from '@sync-providers/constants'; import { UpdateMode } from '@/constants/UpdateMode'; import MockEnv from '../support/mockEnv'; import { fillTokenForm, fillInputNth, fillValueInput, fillInput } from './helpers/utils'; @@ -28,7 +26,7 @@ describe('TokenListing', () => { updateRemote: true, updateStyles: true, }, - storageType: { provider: StorageProviderType.LOCAL }, + storageType: { provider: AVAILABLE_PROVIDERS.LOCAL }, user: { figmaId: 'figma:1234', userId: 'uid:1234', @@ -464,7 +462,7 @@ describe('TokenListing', () => { cy.get('span:contains("minWidth")').parent().should('be.visible'); cy.get('span:contains("minWidth")').parent().click(); cy.get('[data-testid="composition-token-dropdown"]').click(); - + cy.get('body').type('{esc}'); diff --git a/packages/tokens-studio-for-figma/src/app/components/AppContainer/__tests__/AppContainerIntegration.test.tsx b/packages/tokens-studio-for-figma/src/app/components/AppContainer/__tests__/AppContainerIntegration.test.tsx index bdf4c3bfb3..451980fe6c 100644 --- a/packages/tokens-studio-for-figma/src/app/components/AppContainer/__tests__/AppContainerIntegration.test.tsx +++ b/packages/tokens-studio-for-figma/src/app/components/AppContainer/__tests__/AppContainerIntegration.test.tsx @@ -1,7 +1,8 @@ import React from 'react'; import { Provider } from 'react-redux'; +import type { StorageProviderType } from '@sync-providers/types'; +import { AVAILABLE_PROVIDERS } from '@sync-providers/constants'; import { Entitlements } from '@/app/store/models/userState'; -import { StorageProviderType } from '@/constants/StorageProviderType'; import { TokenSetStatus } from '@/constants/TokenSetStatus'; import { TokenTypes } from '@/constants/TokenTypes'; import { @@ -86,7 +87,7 @@ const mockValues: Record = { }; const mockGithubStoragetype: StorageType = { - provider: StorageProviderType.GITHUB, + provider: AVAILABLE_PROVIDERS.GITHUB as StorageProviderType.GITHUB, id: 'github', internalId: 'github', name: 'Github', @@ -96,7 +97,7 @@ const mockGithubStoragetype: StorageType = { const mockGithubApiProviders: StorageTypeCredentials[] = [ { - provider: StorageProviderType.GITHUB, + provider: AVAILABLE_PROVIDERS.GITHUB as StorageProviderType.GITHUB, id: 'github', internalId: 'github', name: 'Github', @@ -128,7 +129,7 @@ const mockStartupParams: Omit = { localApiProviders: [], settings: mockSettings, storageType: { - provider: StorageProviderType.LOCAL, + provider: AVAILABLE_PROVIDERS.LOCAL as StorageProviderType.LOCAL, }, user: mockUser, localTokenData: { @@ -405,7 +406,7 @@ describe('AppContainer (integration)', () => { checkForChanges: false, }, storageType: { - provider: StorageProviderType.GITHUB, + provider: AVAILABLE_PROVIDERS.GITHUB, branch: 'main', filePath: 'data/tokens.json', id: 'github', diff --git a/packages/tokens-studio-for-figma/src/app/components/AppContainer/startupProcessSteps/__tests__/pullTokensFactory.test.ts b/packages/tokens-studio-for-figma/src/app/components/AppContainer/startupProcessSteps/__tests__/pullTokensFactory.test.ts index 820b45b414..2209849a64 100644 --- a/packages/tokens-studio-for-figma/src/app/components/AppContainer/startupProcessSteps/__tests__/pullTokensFactory.test.ts +++ b/packages/tokens-studio-for-figma/src/app/components/AppContainer/startupProcessSteps/__tests__/pullTokensFactory.test.ts @@ -1,4 +1,5 @@ -import { StorageProviderType } from '@/constants/StorageProviderType'; +import type { StorageProviderType } from '@sync-providers/types'; +import { AVAILABLE_PROVIDERS } from '@sync-providers/constants'; import { createMockStore } from '../../../../../../tests/config/setupTest'; import type { StartupMessage } from '@/types/AsyncMessages'; import { TokenTypes } from '@/constants/TokenTypes'; @@ -21,7 +22,7 @@ describe('pullTokensFactory', () => { id: 'github', internalId: 'github', name: 'Github', - provider: StorageProviderType.GITHUB, + provider: AVAILABLE_PROVIDERS.GITHUB as StorageProviderType.GITHUB, branch: 'main', filePath: 'data/tokens.json', }; @@ -39,7 +40,7 @@ describe('pullTokensFactory', () => { const mockStore = createMockStore({ uiState: { storageType: { - provider: StorageProviderType.LOCAL, + provider: AVAILABLE_PROVIDERS.LOCAL as StorageProviderType.LOCAL, }, }, }); @@ -83,7 +84,7 @@ describe('pullTokensFactory', () => { const mockStore = createMockStore({ uiState: { storageType: { - provider: StorageProviderType.LOCAL, + provider: AVAILABLE_PROVIDERS.LOCAL as StorageProviderType.LOCAL, }, }, }); diff --git a/packages/tokens-studio-for-figma/src/app/components/AppContainer/startupProcessSteps/__tests__/saveStorageInformationFactory.test.ts b/packages/tokens-studio-for-figma/src/app/components/AppContainer/startupProcessSteps/__tests__/saveStorageInformationFactory.test.ts index 74ce684a37..f7817c8649 100644 --- a/packages/tokens-studio-for-figma/src/app/components/AppContainer/startupProcessSteps/__tests__/saveStorageInformationFactory.test.ts +++ b/packages/tokens-studio-for-figma/src/app/components/AppContainer/startupProcessSteps/__tests__/saveStorageInformationFactory.test.ts @@ -1,4 +1,4 @@ -import { StorageProviderType } from '@/constants/StorageProviderType'; +import { AVAILABLE_PROVIDERS } from '@sync-providers/constants'; import { StartupMessage } from '@/types/AsyncMessages'; import { createMockStore } from '../../../../../../tests/config/setupTest'; import { saveStorageInformationFactory } from '../saveStorageInformationFactory'; @@ -7,10 +7,10 @@ describe('saveStorageInformationFactory', () => { it('should work', async () => { const mockStore = createMockStore({}); const mockParams = { - storageType: StorageProviderType.GITHUB, + storageType: AVAILABLE_PROVIDERS.GITHUB, localApiProviders: [ { - provider: StorageProviderType.GITHUB, + provider: AVAILABLE_PROVIDERS.GITHUB, }, ], } as unknown as StartupMessage; @@ -23,7 +23,7 @@ describe('saveStorageInformationFactory', () => { expect(mockSetStorageFn).toBeCalledTimes(1); expect(mockSetStorageFn).toBeCalledWith({ - provider: StorageProviderType.GITHUB, + provider: AVAILABLE_PROVIDERS.GITHUB, }); expect(mockStore.getState().uiState.apiProviders).toEqual(mockParams.localApiProviders); }); diff --git a/packages/tokens-studio-for-figma/src/app/components/AppContainer/startupProcessSteps/pullTokensFactory.ts b/packages/tokens-studio-for-figma/src/app/components/AppContainer/startupProcessSteps/pullTokensFactory.ts index 31c3ebfab3..d74f859c10 100644 --- a/packages/tokens-studio-for-figma/src/app/components/AppContainer/startupProcessSteps/pullTokensFactory.ts +++ b/packages/tokens-studio-for-figma/src/app/components/AppContainer/startupProcessSteps/pullTokensFactory.ts @@ -1,12 +1,12 @@ import * as Sentry from '@sentry/react'; import type { LDFlagSet } from 'launchdarkly-js-client-sdk'; import { Store } from 'redux'; +import { AVAILABLE_PROVIDERS } from '@sync-providers/constants'; import { INTERNAL_THEMES_NO_GROUP } from '../../../../constants/InternalTokenGroup'; import type { StartupMessage } from '@/types/AsyncMessages'; import type { Dispatch, RootState } from '@/app/store'; import { Tabs } from '@/constants/Tabs'; import { storageTypeSelector } from '@/selectors'; -import { StorageProviderType } from '@/constants/StorageProviderType'; import useConfirm from '@/app/hooks/useConfirm'; import isSameCredentials from '@/utils/isSameCredentials'; import { track } from '@/utils/analytics'; @@ -37,15 +37,15 @@ export function pullTokensFactory( const state = store.getState(); const storageType = storageTypeSelector(state); const isRemoteStorage = [ - StorageProviderType.ADO, - StorageProviderType.GITHUB, - StorageProviderType.GITLAB, - StorageProviderType.BITBUCKET, - StorageProviderType.JSONBIN, - StorageProviderType.GENERIC_VERSIONED_STORAGE, - StorageProviderType.URL, - StorageProviderType.SUPERNOVA, - StorageProviderType.TOKENS_STUDIO, + AVAILABLE_PROVIDERS.ADO, + AVAILABLE_PROVIDERS.GITHUB, + AVAILABLE_PROVIDERS.GITLAB, + AVAILABLE_PROVIDERS.BITBUCKET, + AVAILABLE_PROVIDERS.JSONBIN, + AVAILABLE_PROVIDERS.GENERIC_VERSIONED_STORAGE, + AVAILABLE_PROVIDERS.URL, + AVAILABLE_PROVIDERS.SUPERNOVA, + AVAILABLE_PROVIDERS.TOKENS_STUDIO, ].includes(storageType.provider); if (isRemoteStorage) { @@ -63,10 +63,10 @@ export function pullTokensFactory( } if ( - matchingSet.provider === StorageProviderType.GITHUB - || matchingSet.provider === StorageProviderType.GITLAB - || matchingSet.provider === StorageProviderType.ADO - || matchingSet.provider === StorageProviderType.BITBUCKET + matchingSet.provider === AVAILABLE_PROVIDERS.GITHUB + || matchingSet.provider === AVAILABLE_PROVIDERS.GITLAB + || matchingSet.provider === AVAILABLE_PROVIDERS.ADO + || matchingSet.provider === AVAILABLE_PROVIDERS.BITBUCKET ) { const branches = await useRemoteTokensResult.fetchBranches(matchingSet); if (branches) dispatch.branchState.setBranches(branches); @@ -136,7 +136,7 @@ export function pullTokensFactory( if ( !checkForChanges || ( - (storageType && storageType.provider !== StorageProviderType.LOCAL) + (storageType && storageType.provider !== AVAILABLE_PROVIDERS.LOCAL) && checkForChanges && (!await askUserIfRecoverLocalChanges()) ) ) { diff --git a/packages/tokens-studio-for-figma/src/app/components/ConvertToDTCGModal.tsx b/packages/tokens-studio-for-figma/src/app/components/ConvertToDTCGModal.tsx index 5ad1a41eba..8d5a3509d5 100644 --- a/packages/tokens-studio-for-figma/src/app/components/ConvertToDTCGModal.tsx +++ b/packages/tokens-studio-for-figma/src/app/components/ConvertToDTCGModal.tsx @@ -4,6 +4,7 @@ import { import React from 'react'; import { useDispatch, useSelector } from 'react-redux'; import { useTranslation } from 'react-i18next'; +import { AVAILABLE_PROVIDERS } from '@sync-providers/constants'; import Modal from './Modal'; import { Dispatch } from '../store'; import { TokenFormatOptions } from '@/plugin/TokenFormatStoreClass'; @@ -15,7 +16,6 @@ import useRemoteTokens from '../store/remoteTokens'; import w3cConvertImage from '@/app/assets/hints/w3cformat.png'; import legacyConvertImage from '@/app/assets/hints/legacyformat.png'; import { storageTypeSelector } from '@/selectors'; -import { StorageProviderType } from '@/constants/StorageProviderType'; export function ConvertToDTCGModal() { const dispatch = useDispatch(); @@ -35,7 +35,7 @@ export function ConvertToDTCGModal() { const handleConvert = React.useCallback(() => { dispatch.tokenState.setTokenFormat(isDTCG ? TokenFormatOptions.Legacy : TokenFormatOptions.DTCG); dispatch.uiState.setShowConvertTokenFormatModal(false); - if (storageType.provider === StorageProviderType.LOCAL) return; + if (storageType.provider === AVAILABLE_PROVIDERS.LOCAL) return; pushTokens({ overrides: isDTCG ? { branch: 'w3c-dtcg-conversion-revert', @@ -47,7 +47,7 @@ export function ConvertToDTCGModal() { }); }, [dispatch, pushTokens, isDTCG, storageType]); - const hasRemoteChanges = hasChanges && storageType.provider !== StorageProviderType.LOCAL; + const hasRemoteChanges = hasChanges && storageType.provider !== AVAILABLE_PROVIDERS.LOCAL; return ( diff --git a/packages/tokens-studio-for-figma/src/app/components/Footer.test.tsx b/packages/tokens-studio-for-figma/src/app/components/Footer.test.tsx index 3dd1428ab3..044f8d4d80 100644 --- a/packages/tokens-studio-for-figma/src/app/components/Footer.test.tsx +++ b/packages/tokens-studio-for-figma/src/app/components/Footer.test.tsx @@ -1,9 +1,9 @@ import React from 'react'; +import { AVAILABLE_PROVIDERS } from '@sync-providers/constants'; import { render, waitFor } from '../../../tests/config/setupTest'; import { store } from '../store'; import Footer from './Footer'; import * as pjs from '../../../package.json'; -import { StorageProviderType } from '@/constants/StorageProviderType'; describe('Footer', () => { it('displays current version number', () => { @@ -13,7 +13,7 @@ describe('Footer', () => { it('shows branch selector for users on a free plan', () => { const { getByText } = render(