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

Release 111 #913

Merged
merged 8 commits into from
Jun 23, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "figma-tokens",
"version": "1.0.0",
"plugin_version": "110",
"plugin_version": "111",
"description": "Figma Tokens",
"license": "MIT",
"scripts": {
Expand Down
33 changes: 33 additions & 0 deletions src/app/components/DownshiftInput/DownShiftInput.test.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
describe('DownShiftInput', () => {
it('filteredValue should only replace {} or $ and remain all letters', () => {
const dataStore = [
{
input: '{opacity.10}',
output: 'opacity.10',
},
{
input: '{トランスペアレント.10',
output: 'トランスペアレント.10',
},
{
input: '$不透 明度.10',
output: '不透 明度.10',
},
{
input: '$불투명.10',
output: '불투명.10',
},
{
input: '{अस्पष्टता.10}',
output: 'अस्पष्टता.10',
},
{
input: 'թափանցիկ.10',
output: 'թափանցիկ.10',
},
];
dataStore.forEach((data) => {
expect(data.input.replace(/[{}$]/g, '')).toBe(data.output);
});
});
});
2 changes: 1 addition & 1 deletion src/app/components/DownshiftInput/DownshiftInput.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ export const DownshiftInput: React.FunctionComponent<DownShiftProps> = ({
const [showAutoSuggest, setShowAutoSuggest] = React.useState<boolean>(false);
const [isFirstLoading, setisFirstLoading] = React.useState<boolean>(true);

const filteredValue = useMemo(() => ((showAutoSuggest || typeof value !== 'string') ? '' : value?.replace(/[^a-zA-Z0-9.]/g, '')), [
const filteredValue = useMemo(() => ((showAutoSuggest || typeof value !== 'string') ? '' : value?.replace(/[{}$]/g, '')), [
showAutoSuggest,
value,
]); // removing non-alphanumberic except . from the input value
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import Input from '../Input';
import { allTokenSetsSelector, usedTokenSetSelector } from '@/selectors';
import { StyledNameInputBox } from './StyledNameInputBox';
import { tokenSetListToTree, tokenSetListToList, TreeItem } from '@/utils/tokenset';
import { useIsGithubMultiFileEnabled } from '@/app/hooks/useIsGithubMultiFileEnabled';
import { useIsGitMultiFileEnabled } from '@/app/hooks/useIsGitMultiFileEnabled';
import { TokenSetListOrTree } from '../TokenSetListOrTree';
import { TokenSetThemeItem } from './TokenSetThemeItem';
import { StyledForm } from './StyledForm';
Expand All @@ -25,7 +25,7 @@ type Props = {

export const CreateOrEditThemeForm: React.FC<Props> = ({ defaultValues, onSubmit }) => {
const store = useStore();
const githubMfsEnabled = useIsGithubMultiFileEnabled();
const githubMfsEnabled = useIsGitMultiFileEnabled();
const selectedTokenSets = useMemo(() => (
usedTokenSetSelector(store.getState())
), [store]);
Expand Down
6 changes: 3 additions & 3 deletions src/app/components/TokenSetSelector.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ import {
editProhibitedSelector, tokensSelector,
} from '@/selectors';
import Stack from './Stack';
import { useIsGithubMultiFileEnabled } from '../hooks/useIsGithubMultiFileEnabled';
import { useIsGitMultiFileEnabled } from '../hooks/useIsGitMultiFileEnabled';

const StyledButton = styled('button', {
flexShrink: 0,
Expand All @@ -37,7 +37,7 @@ const StyledButton = styled('button', {
export default function TokenSetSelector() {
const tokens = useSelector(tokensSelector);
const editProhibited = useSelector(editProhibitedSelector);
const mfsEnabled = useIsGithubMultiFileEnabled();
const mfsEnabled = useIsGitMultiFileEnabled();
const dispatch = useDispatch<Dispatch>();
const { confirm } = useConfirm();

Expand All @@ -54,7 +54,7 @@ export default function TokenSetSelector() {

React.useEffect(() => {
setShowNewTokenSetFields(false);
handleNewTokenSetNameChange('');
handleNewTokenSetNameChange(tokenSetMarkedForChange);
}, [tokens]);

const handleNewTokenSetSubmit = React.useCallback((e: React.FormEvent<HTMLFormElement>) => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,14 @@ import { useFlags } from 'launchdarkly-react-client-sdk';
import { apiSelector } from '@/selectors';
import { StorageProviderType } from '@/constants/StorageProviderType';

export function useIsGithubMultiFileEnabled() {
export function useIsGitMultiFileEnabled() {
const api = useSelector(apiSelector);
const { multiFileSync } = useFlags();

return useMemo(() => (
Boolean(
multiFileSync
&& (api?.provider === StorageProviderType.GITHUB || api?.provider === StorageProviderType.GITLAB)
&& (api?.provider === StorageProviderType.GITHUB || api?.provider === StorageProviderType.GITLAB || api?.provider === StorageProviderType.ADO)
&& !api?.filePath?.endsWith('.json'),
)
), [api, multiFileSync]);
Expand Down
3 changes: 2 additions & 1 deletion src/app/store/models/tokenState.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,8 @@ export const tokenState = createModel<RootModel>()({
}

const newName = `${name}_Copy`;
return updateTokenSetsInState(state, null, [newName]);

return updateTokenSetsInState(state, null, [newName, state.tokens[name]]);
},
deleteTokenSet: (state, name: string) => updateTokenSetsInState(
state,
Expand Down
3 changes: 1 addition & 2 deletions src/app/store/providers/ado/ado.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -45,8 +45,7 @@ export const useADO = () => {
text: 'Pull from Ado?',
description: 'Your repo already contains tokens, do you want to pull these now?',
});
if (confirmResult === false) return false;
return confirmResult.result;
return confirmResult
}, [confirm]);

const pushTokensToADO = React.useCallback(async (context: AdoCredentials) => {
Expand Down
6 changes: 3 additions & 3 deletions src/app/store/providers/github/github.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -48,14 +48,12 @@ export function useGitHub() {
text: 'Pull from GitHub?',
description: 'Your repo already contains tokens, do you want to pull these now?',
});
if (confirmResult === false) return false;
return confirmResult.result;
return confirmResult;
}, [confirm]);

const pushTokensToGitHub = useCallback(async (context: GithubCredentials): Promise<RemoteTokenStorageData<GitStorageMetadata> | null> => {
const storage = storageClientFactory(context);
const content = await storage.retrieve();

if (content) {
if (
content
Expand Down Expand Up @@ -136,6 +134,7 @@ export function useGitHub() {

try {
const content = await storage.retrieve();

if (content) {
return content;
}
Expand All @@ -162,6 +161,7 @@ export function useGitHub() {
await checkAndSetAccess({ context, owner, repo });

const content = await storage.retrieve();

if (content) {
if (
!isEqual(content.tokens, tokens)
Expand Down
4 changes: 1 addition & 3 deletions src/app/store/providers/gitlab/gitlab.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -49,8 +49,7 @@ export function useGitLab() {
text: 'Pull from GitLab?',
description: 'Your repo already contains tokens, do you want to pull these now?',
});
if (confirmResult === false) return false;
return confirmResult.result;
return confirmResult;
}, [confirm]);

const pushTokensToGitLab = useCallback(async (context: GitlabCredentials) => {
Expand Down Expand Up @@ -91,7 +90,6 @@ export function useGitLab() {
usedTokenSet,
activeTheme,
});

pushDialog('success');
return {
tokens,
Expand Down
1 change: 0 additions & 1 deletion src/app/store/providers/jsonbin.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,6 @@ export function useJSONbin() {
id, secret, name, internalId,
} = context;
if (!id || !secret) return null;

try {
const storage = new JSONBinTokenStorage(id, secret);
const data = await storage.retrieve();
Expand Down
Loading