-
-
Notifications
You must be signed in to change notification settings - Fork 197
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
Update sdk to v2 #3207
Changes from 11 commits
Commits
Show all changes
23 commits
Select commit
Hold shift + click to select a range
18dc85d
changes
roppazvan d21cc18
set reorde & sync to studio
roppazvan c07757c
rm logs and fetch org data on mount
roppazvan 741e57c
rm logs
roppazvan 25cb6ab
rm logs
roppazvan 848a986
Fix themes - create, delete and partial update
georgebuciuman 0265d9e
Merge branch 'main' into update-sdk-to-v2
roppazvan c09038b
Themes fixes + waterfall requests to studio
georgebuciuman 32dd5a9
cleanunp
roppazvan 4370c40
lint
roppazvan 456179f
fix lint
roppazvan 9f325bb
lint
roppazvan 713c5f0
Fix tests
georgebuciuman 6ddf15d
Merge branch 'main' into update-sdk-to-v2
roppazvan a42b01c
fix lint
roppazvan e891a1d
fix build
roppazvan 0ec98d6
fix build
roppazvan e822c5e
fix tests
roppazvan 5b45ab4
requested changes
roppazvan 5d5fab9
Merge branch 'main' into update-sdk-to-v2
roppazvan d9e0bd5
fix id issue
roppazvan 8cbef62
add changeset
roppazvan 9a748e3
updated changeset
roppazvan File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
4 changes: 3 additions & 1 deletion
4
packages/tokens-studio-for-figma/src/app/components/PresetProvider/DefaultPreset.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
4 changes: 3 additions & 1 deletion
4
packages/tokens-studio-for-figma/src/app/components/PresetProvider/FilePreset.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,17 +1,29 @@ | ||
import React from 'react'; | ||
import React, { useEffect } from 'react'; | ||
import zod from 'zod'; | ||
import { | ||
Box, Button, FormField, Heading, IconButton, Label, Link, Stack, Text, TextInput, | ||
Box, | ||
Button, | ||
FormField, | ||
Heading, | ||
IconButton, | ||
Label, | ||
Link, | ||
Select, | ||
Stack, | ||
Text, | ||
TextInput, | ||
} from '@tokens-studio/ui'; | ||
import { EyeClosedIcon, EyeOpenIcon } from '@radix-ui/react-icons'; | ||
import { useTranslation } from 'react-i18next'; | ||
import { create, Organization } from '@tokens-studio/sdk'; | ||
import { StorageProviderType } from '@/constants/StorageProviderType'; | ||
import { StorageTypeFormValues } from '@/types/StorageType'; | ||
import { generateId } from '@/utils/generateId'; | ||
import { ChangeEventHandler } from './types'; | ||
import { ErrorMessage } from '../ErrorMessage'; | ||
import TokensStudioWord from '@/icons/tokensstudio-word.svg'; | ||
import { styled } from '@/stitches.config'; | ||
import { GET_ORGS_QUERY } from '@/storage/tokensStudio/graphql'; | ||
|
||
const StyledTokensStudioWord = styled(TokensStudioWord, { | ||
width: '200px', | ||
|
@@ -32,6 +44,8 @@ | |
onChange, onSubmit, onCancel, values, hasErrored, errorMessage, | ||
}: Props) { | ||
const { t } = useTranslation(['storage']); | ||
const [fetchOrgsError, setFetchOrgsError] = React.useState<string | null>(null); | ||
const [orgData, setOrgData] = React.useState<Organization[]>([]); | ||
const syncGuideUrl = 'tokens-studio'; | ||
const [isMasked, setIsMasked] = React.useState(true); | ||
const [showTeaser, setShowTeaser] = React.useState(true); | ||
|
@@ -50,6 +64,7 @@ | |
id: zod.string(), | ||
secret: zod.string(), | ||
internalId: zod.string().optional(), | ||
orgId: zod.string(), | ||
}); | ||
const validationResult = zodSchema.safeParse(values); | ||
if (validationResult.success) { | ||
|
@@ -73,21 +88,88 @@ | |
setShowTeaser(false); | ||
}, []); | ||
|
||
return showTeaser ? ( | ||
<Stack direction="column" align="start" gap={5}> | ||
<StyledTokensStudioWord /> | ||
<Stack direction="column" gap={3}> | ||
<Heading size="large">A dedicated design tokens management platform</Heading> | ||
<Box>We are working a dedicated design tokens management platform built on our powerful node-based graph engine including plug and play token transformation - suitable for enterprises! Still in early access, sign up for the waitlist!</Box> | ||
<Link href="https://tokens.studio/studio" target="_blank" rel="noreferrer">Learn more</Link> | ||
</Stack> | ||
<Button onClick={handleDismissTeaser}>Already got access?</Button> | ||
const fetchOrgData = React.useCallback(async () => { | ||
try { | ||
const client = create({ | ||
host: process.env.API_HOST || 'localhost:4200', | ||
secure: process.env.NODE_ENV !== 'development', | ||
auth: `Bearer ${values.secret}`, | ||
}); | ||
const result = await client.query({ | ||
query: GET_ORGS_QUERY, | ||
}); | ||
if (result.data?.organizations) { | ||
setOrgData(result.data.organizations.data as Organization[]); | ||
} | ||
} catch (error) { | ||
setFetchOrgsError('Error fetching organization data. Please check your PAT.'); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Lets write the full name not PAT There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. sure |
||
} | ||
}, [values.secret]); | ||
|
||
useEffect(() => { | ||
if (values.secret) { | ||
fetchOrgData(); | ||
} | ||
}, [values.secret,]); | ||
|
||
|
||
const orgOptions = React.useMemo( | ||
() => orgData?.map((org) => ({ | ||
label: org.name, | ||
value: org.id, | ||
})), | ||
[orgData], | ||
); | ||
|
||
const onOrgChange = React.useCallback( | ||
(value: string) => { | ||
onChange({ target: { name: 'orgId', value } }); | ||
}, | ||
[onChange], | ||
); | ||
|
||
const projectOptions = React.useMemo(() => { | ||
if (!orgData) return []; | ||
const selectedOrgData = orgData.find((org) => org.id === values.orgId); | ||
if (!selectedOrgData) return []; | ||
return selectedOrgData.projects.data.map((project) => ({ | ||
label: project.name, | ||
value: project.id, | ||
})); | ||
}, [orgData, values.orgId]); | ||
|
||
const selectedOrg = orgOptions?.find((org) => org.value === values.orgId); | ||
|
||
const selectedProject = projectOptions?.find((project) => project.value === values.id); | ||
|
||
const onProjectChange = React.useCallback( | ||
(value: string) => { | ||
onChange({ target: { name: 'id', value } }); | ||
}, | ||
[onChange], | ||
); | ||
|
||
return showTeaser ? ( | ||
<Stack direction="column" align="start" gap={5}> | ||
<StyledTokensStudioWord /> | ||
<Stack direction="column" gap={3}> | ||
<Heading size="large">A dedicated design tokens management platform</Heading> | ||
<Box> | ||
We are working a dedicated design tokens management platform built on our powerful node-based graph engine | ||
including plug and play token transformation - suitable for enterprises! Still in early access, sign up for | ||
the waitlist! | ||
</Box> | ||
<Link href="https://tokens.studio/studio" target="_blank" rel="noreferrer"> | ||
Learn more | ||
</Link> | ||
</Stack> | ||
):( | ||
<Button onClick={handleDismissTeaser}>Already got access?</Button> | ||
</Stack> | ||
) : ( | ||
<form onSubmit={handleSubmit}> | ||
<Stack direction="column" gap={5}> | ||
<Text muted> | ||
{t('providers.tokensstudio.descriptionFirstPart')}{' '} | ||
<Text muted> | ||
{t('providers.tokensstudio.descriptionFirstPart')} | ||
{' '} | ||
<Link | ||
href="https://q2gsw2tok1e.typeform.com/to/pJCwLVh2?typeform-source=tokens.studio" | ||
target="_blank" | ||
|
@@ -118,6 +200,7 @@ | |
onChange={onChange} | ||
name="secret" | ||
id="secret" | ||
onBlur={fetchOrgData} | ||
required | ||
type={isMasked ? 'password' : 'text'} | ||
trailingAction={( | ||
|
@@ -129,11 +212,43 @@ | |
/> | ||
)} | ||
/> | ||
{fetchOrgsError && <Text muted>{fetchOrgsError}</Text>} | ||
</FormField> | ||
<FormField> | ||
<Label htmlFor="id">{t('providers.tokensstudio.id')}</Label> | ||
<TextInput value={values.id || ''} onChange={onChange} type="text" name="id" id="id" required /> | ||
</FormField> | ||
{orgOptions?.length > 0 && ( | ||
<Stack direction="column" gap={2}> | ||
<Label htmlFor="org">{t('providers.tokensstudio.selectOrgLabel')}</Label> | ||
<div> | ||
<Select value={values.orgId ?? ''} onValueChange={onOrgChange} name="org"> | ||
<Select.Trigger value={selectedOrg?.label || 'Choose an organization'} /> | ||
<Select.Content> | ||
{orgOptions?.map((option) => ( | ||
<Select.Item key={option.value} value={option.value}> | ||
{option.label} | ||
</Select.Item> | ||
))} | ||
</Select.Content> | ||
</Select> | ||
</div> | ||
</Stack> | ||
)} | ||
|
||
{projectOptions?.length > 0 && ( | ||
<Stack direction="column" gap={2}> | ||
<Label htmlFor="org">{t('providers.tokensstudio.selectProjectLabel')}</Label> | ||
<div> | ||
<Select value={values.id ?? ''} onValueChange={onProjectChange} name="id"> | ||
<Select.Trigger value={selectedProject?.label || 'Choose a project'} /> | ||
<Select.Content> | ||
{projectOptions?.map((option) => ( | ||
<Select.Item key={option.value} value={option.value}> | ||
{option.label} | ||
</Select.Item> | ||
))} | ||
</Select.Content> | ||
</Select> | ||
</div> | ||
</Stack> | ||
)} | ||
<Stack direction="row" justify="end" gap={4}> | ||
<Button variant="secondary" onClick={onCancel}> | ||
{t('cancel')} | ||
|
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
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
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
changed