From 85420dd49cb120e4e160aed7d9a9293fd31a9527 Mon Sep 17 00:00:00 2001 From: SorsOps <80043879+SorsOps@users.noreply.github.com> Date: Sat, 18 May 2024 18:06:52 +0200 Subject: [PATCH 1/6] Add sonarqube integration (#2771) --- .github/workflows/{techdocs.yml => merge.yml} | 30 ++++++++++++++++++- sonar-project.properties | 1 + 2 files changed, 30 insertions(+), 1 deletion(-) rename .github/workflows/{techdocs.yml => merge.yml} (63%) create mode 100644 sonar-project.properties diff --git a/.github/workflows/techdocs.yml b/.github/workflows/merge.yml similarity index 63% rename from .github/workflows/techdocs.yml rename to .github/workflows/merge.yml index 9ad3076df..9509decc7 100644 --- a/.github/workflows/techdocs.yml +++ b/.github/workflows/merge.yml @@ -1,4 +1,4 @@ -name: Techdocs +name: Merge on: push: @@ -12,6 +12,34 @@ permissions: contents: write jobs: + analysis: + name: Analyze + runs-on: ubuntu-latest + permissions: + contents: read + pages: write + id-token: write + steps: + - uses: actions/checkout@v4 + with: + fetch-depth: 0 # Shallow clones should be disabled for a better relevancy of analysis + - name: Import Secrets + id: secrets + uses: hashicorp/vault-action@v2 + with: + url: ${{ vars.VAULT_URL }} + role: sonarqube + method: jwt + namespace: admin + secrets: | + secret/data/cicd/sonarqube/global SONAR_TOKEN |SONAR_TOKEN ; + secret/data/cicd/sonarqube/global SONAR_HOST_URL | SONAR_HOST_URL; + - uses: sonarsource/sonarqube-scan-action@master + env: + SONAR_TOKEN: ${{ steps.secrets.outputs.SONAR_TOKEN }} + SONAR_HOST_URL: ${{ steps.secrets.outputs.SONAR_HOST_URL }} + + techdocs: name: Techdocs runs-on: ubuntu-latest diff --git a/sonar-project.properties b/sonar-project.properties new file mode 100644 index 000000000..4397a4b82 --- /dev/null +++ b/sonar-project.properties @@ -0,0 +1 @@ +sonar.projectKey=tokens-studio_figma-plugin_0900c296-9153-4298-8372-5e3be33e480e \ No newline at end of file From c790f039ef5727981733550fb2e1fb50b22b3070 Mon Sep 17 00:00:00 2001 From: Luke Finch Date: Mon, 10 Jun 2024 12:45:13 +0100 Subject: [PATCH 2/6] move providers to modal --- .../src/app/components/SyncSettings.tsx | 202 ++++++++++++++++++ 1 file changed, 202 insertions(+) create mode 100644 packages/tokens-studio-for-figma/src/app/components/SyncSettings.tsx diff --git a/packages/tokens-studio-for-figma/src/app/components/SyncSettings.tsx b/packages/tokens-studio-for-figma/src/app/components/SyncSettings.tsx new file mode 100644 index 000000000..a11991d6a --- /dev/null +++ b/packages/tokens-studio-for-figma/src/app/components/SyncSettings.tsx @@ -0,0 +1,202 @@ +/* eslint-disable jsx-a11y/label-has-associated-control */ +import React, { useMemo } from 'react'; +import { useDispatch, useSelector } from 'react-redux'; +import { useTranslation } from 'react-i18next'; +import { + Heading, Button, Box, Stack, Text, Dialog, +} from '@tokens-studio/ui'; +import { track } from '@/utils/analytics'; +import StorageItem from './StorageItem'; +import EditStorageItemModal from './modals/EditStorageItemModal'; +import CreateStorageItemModal from './modals/CreateStorageItemModal'; +import { Dispatch } from '../store'; +import { apiProvidersSelector, localApiStateSelector, storageTypeSelector } from '@/selectors'; +import { StorageProviderType } from '@/constants/StorageProviderType'; +import useRemoteTokens from '../store/remoteTokens'; +import { StorageTypeCredentials } from '@/types/StorageType'; +import LocalStorageItem from './LocalStorageItem'; +import { getProviderIcon } from '@/utils/getProviderIcon'; +import { StyledBetaBadge } from './SecondScreen'; + +const SyncSettings = () => { + const localApiState = useSelector(localApiStateSelector); + + const { t } = useTranslation(['storage']); + + const providers = useMemo(() => [ + { + text: t('providers.url.title'), + type: StorageProviderType.URL, + }, + { + text: t('providers.jsonbin.title'), + type: StorageProviderType.JSONBIN, + }, + { + text: 'GitHub', + type: StorageProviderType.GITHUB, + }, + { + text: 'GitLab', + type: StorageProviderType.GITLAB, + }, + { + text: 'Azure DevOps', + type: StorageProviderType.ADO, + }, + { + text: 'BitBucket', + type: StorageProviderType.BITBUCKET, + beta: true, + }, + { + text: 'Supernova', + type: StorageProviderType.SUPERNOVA, + }, + { + text: t('providers.generic.title'), + type: StorageProviderType.GENERIC_VERSIONED_STORAGE, + description: t('providers.generic.description'), + }, + { + text: 'Tokens Studio', + type: StorageProviderType.TOKENS_STUDIO, + beta: true, + }, + ], [t]); + + const apiProviders = useSelector(apiProvidersSelector); + const dispatch = useDispatch(); + + const [open, setOpen] = React.useState(false); + + const { fetchBranches } = useRemoteTokens(); + + const [editStorageItemModalVisible, setShowEditStorageModalVisible] = React.useState(Boolean(localApiState.new)); + const [createStorageItemModalVisible, setShowCreateStorageModalVisible] = React.useState(false); + const [storageProvider, setStorageProvider] = React.useState(localApiState.provider); + + const setLocalBranches = React.useCallback( + async (provider: StorageTypeCredentials) => { + const branches = await fetchBranches(provider); + if (branches) { + dispatch.branchState.setBranches(branches); + } + }, + [dispatch.branchState, fetchBranches], + ); + + const handleEditClick = React.useCallback( + (provider: any) => () => { + track('Edit Credentials'); + dispatch.uiState.setLocalApiState(provider); + setShowEditStorageModalVisible(true); + setLocalBranches(provider); + }, + [dispatch.uiState, setLocalBranches], + ); + + const handleShowAddCredentials = React.useCallback((provider: StorageProviderType) => { + track('Add Credentials', { provider }); + setShowCreateStorageModalVisible(true); + }, []); + + const handleProviderClick = React.useCallback( + (provider: StorageProviderType) => () => { + setOpen(false); + setStorageProvider(provider); + handleShowAddCredentials(provider); + }, + [handleShowAddCredentials], + ); + + const handleHideStorageModal = React.useCallback(() => { + setShowEditStorageModalVisible(false); + }, []); + + const handleHideAddCredentials = React.useCallback(() => { + setShowCreateStorageModalVisible(false); + }, []); + + return ( + + {editStorageItemModalVisible && ( + + )} + {createStorageItemModalVisible && ( + + )} + + + + {t('syncProviders')} + + + + + + + + {t('addNewSyncProvider')} + + + { + providers.map((provider) => ( + + + + {getProviderIcon(provider.type)} + {provider.text} + {provider.beta && BETA} + + {provider.description && {provider.description}} + + + + )) + } + + + + + + + + {apiProviders.length > 0 && apiProviders.map((item) => ( + + ))} + + + + + ); +}; + +export default SyncSettings; From 0fd2ce9d15849bd30b309e0685156da9a381fb16 Mon Sep 17 00:00:00 2001 From: hiroshi Date: Fri, 14 Jun 2024 08:45:39 -0400 Subject: [PATCH 3/6] update test case to follow the updates --- .../src/app/components/SyncSettings.test.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/tokens-studio-for-figma/src/app/components/SyncSettings.test.tsx b/packages/tokens-studio-for-figma/src/app/components/SyncSettings.test.tsx index 48ce0d855..4c0e6aefb 100644 --- a/packages/tokens-studio-for-figma/src/app/components/SyncSettings.test.tsx +++ b/packages/tokens-studio-for-figma/src/app/components/SyncSettings.test.tsx @@ -111,7 +111,7 @@ describe('ConfirmDialog', () => { ); await act(async () => { - const trigger = await result.getByTestId('add-storage-item-dropdown'); + const trigger = await result.getByTestId('add-storage-item-button'); trigger?.focus(); await userEvent.keyboard('[Enter]'); }); From d3719224b6b5ef170f2df54baf1e853fdb9e97ce Mon Sep 17 00:00:00 2001 From: Jan Six Date: Sat, 15 Jun 2024 11:23:07 +0200 Subject: [PATCH 4/6] update branch --- .github/workflows/{merge.yml => techdocs.yml} | 0 .../src/app/components/SyncSettings.tsx | 6 ++---- .../tokens-studio-for-figma/src/i18n/lang/en/storage.json | 1 + .../tokens-studio-for-figma/src/i18n/lang/es/storage.json | 1 + .../tokens-studio-for-figma/src/i18n/lang/fr/storage.json | 1 + .../tokens-studio-for-figma/src/i18n/lang/hi/storage.json | 1 + .../tokens-studio-for-figma/src/i18n/lang/nl/storage.json | 1 + .../tokens-studio-for-figma/src/i18n/lang/zh/storage.json | 1 + 8 files changed, 8 insertions(+), 4 deletions(-) rename .github/workflows/{merge.yml => techdocs.yml} (100%) diff --git a/.github/workflows/merge.yml b/.github/workflows/techdocs.yml similarity index 100% rename from .github/workflows/merge.yml rename to .github/workflows/techdocs.yml diff --git a/packages/tokens-studio-for-figma/src/app/components/SyncSettings.tsx b/packages/tokens-studio-for-figma/src/app/components/SyncSettings.tsx index a11991d6a..6523a4151 100644 --- a/packages/tokens-studio-for-figma/src/app/components/SyncSettings.tsx +++ b/packages/tokens-studio-for-figma/src/app/components/SyncSettings.tsx @@ -56,7 +56,6 @@ const SyncSettings = () => { { text: t('providers.generic.title'), type: StorageProviderType.GENERIC_VERSIONED_STORAGE, - description: t('providers.generic.description'), }, { text: 'Tokens Studio', @@ -157,14 +156,13 @@ const SyncSettings = () => { - {getProviderIcon(provider.type)} + {getProviderIcon(provider.type)} {provider.text} {provider.beta && BETA} - {provider.description && {provider.description}}