diff --git a/src/main/utils/nodeTools.ts b/src/main/utils/nodeTools.ts index 8ab4f32..f8775b5 100644 --- a/src/main/utils/nodeTools.ts +++ b/src/main/utils/nodeTools.ts @@ -32,11 +32,31 @@ function shouldIncludeNode( return false; } if ( - (settings.ignoreHiddenLayers || - typeof settings.ignoreHiddenLayers === "undefined") && - !node.visible + settings.ignoreHiddenLayers || + typeof settings.ignoreHiddenLayers === "undefined" ) { - return false; + if (!node.visible) { + return false; + } + if (settings.ignoreHiddenLayersIncludingChildren) { + let isParentHidden = false; + let parent = node.parent; + try { + while (parent) { + if ("visible" in parent && !(parent as SceneNode).visible) { + console.log(parent, "PARENT HIDDEN"); + isParentHidden = true; + break; + } + parent = parent.parent; + } + if (isParentHidden) { + return false; + } + } catch (error) { + console.error("Error checking parent visibility:", error); + } + } } if ( settings.ignoreTextLayers && diff --git a/src/main/utils/settingsTools.ts b/src/main/utils/settingsTools.ts index 42c4102..3e64247 100644 --- a/src/main/utils/settingsTools.ts +++ b/src/main/utils/settingsTools.ts @@ -73,6 +73,7 @@ export const setPluginData = async (data: Partial) => { apiKey, apiUrl, ignoreHiddenLayers, + ignoreHiddenLayersIncludingChildren, ignoreNumbers, ignorePrefix, ignoreTextLayers, @@ -92,6 +93,7 @@ export const setPluginData = async (data: Partial) => { apiUrl, documentInfo: true, ignoreHiddenLayers, + ignoreHiddenLayersIncludingChildren, ignoreNumbers, ignorePrefix, ignoreTextLayers, diff --git a/src/types.ts b/src/types.ts index d607019..3b48f27 100644 --- a/src/types.ts +++ b/src/types.ts @@ -115,6 +115,7 @@ export type GlobalSettings = { */ keyFormat?: string; ignoreHiddenLayers?: boolean; + ignoreHiddenLayersIncludingChildren?: boolean; ignoreTextLayers?: boolean; variableCasing?: | "snake_case" diff --git a/src/ui/components/ActionsBottom/ActionsBottom.css b/src/ui/components/ActionsBottom/ActionsBottom.css index c5e0f2e..21e477c 100644 --- a/src/ui/components/ActionsBottom/ActionsBottom.css +++ b/src/ui/components/ActionsBottom/ActionsBottom.css @@ -7,7 +7,7 @@ flex-direction: column; align-items: flex-end; background-color: var(--figma-color-bg); - z-index: 1; + z-index: 2; } .actions { diff --git a/src/ui/components/InfoTooltip/InfoTooltip.css b/src/ui/components/InfoTooltip/InfoTooltip.css index 28f8aa2..fed355b 100644 --- a/src/ui/components/InfoTooltip/InfoTooltip.css +++ b/src/ui/components/InfoTooltip/InfoTooltip.css @@ -3,5 +3,6 @@ align-items: center; justify-content: center; cursor: pointer; + z-index: 2; color: var(--figma-color-text-primary); } diff --git a/src/ui/styles.css b/src/ui/styles.css index 89ee17e..1c4a8e8 100644 --- a/src/ui/styles.css +++ b/src/ui/styles.css @@ -36,6 +36,7 @@ --figma-color-teal-bg: rgb(53, 196, 176, 0.16); --figma-color-red: rgb(255, 46, 83); --figma-color-red-bg: rgb(255, 46, 83, 0.16); + --figma-color-text-primary: #ffffff; } } diff --git a/src/ui/views/Index/ListItem.tsx b/src/ui/views/Index/ListItem.tsx index 3930f48..74ad26b 100644 --- a/src/ui/views/Index/ListItem.tsx +++ b/src/ui/views/Index/ListItem.tsx @@ -123,18 +123,17 @@ export const ListItem = ({ node, loadedNamespaces }: Props) => { onClick={() => handleConnect(node)} className={styles.connectButton} > - {editorMode.data !== "dev" && - (node.connected ? ( - - ) : ( - - ))} + {node.connected ? ( + + ) : ( + + )} diff --git a/src/ui/views/Pull/Pull.tsx b/src/ui/views/Pull/Pull.tsx index 5375abc..35990f1 100644 --- a/src/ui/views/Pull/Pull.tsx +++ b/src/ui/views/Pull/Pull.tsx @@ -53,6 +53,10 @@ export const Pull: FunctionalComponent = ({ lang }) => { } catch (e) { if (e === "invalid_project_api_key") { setError("Invalid project API key"); + } else if (e === "too_many_uploaded_images") { + setError( + "Too many uploaded images. Disable update screenshots in settings." + ); } else { setError(`Cannot get translation data. ${e}`); } diff --git a/src/ui/views/Push/Push.tsx b/src/ui/views/Push/Push.tsx index 61dca45..43b701b 100644 --- a/src/ui/views/Push/Push.tsx +++ b/src/ui/views/Push/Push.tsx @@ -44,6 +44,7 @@ export const Push: FunctionalComponent = () => { const [changes, setChanges] = useState(); const selectedNodes = useConnectedNodes({ ignoreSelection: false }); const tolgeeConfig = useGlobalState((c) => c.config); + const [screenshotCount, setScreenshotCount] = useState(0); const nodes = selectedNodes.data?.items ?? []; @@ -100,6 +101,10 @@ export const Push: FunctionalComponent = () => { computeDiff(); }, [nodes.length]); + const totalScreenshotCount = useMemo(() => { + return changes?.screenshots.length || 0; + }, [changes]); + const setNodesDataMutation = useSetNodesDataMutation(); const loadingStatus = @@ -112,11 +117,6 @@ export const Push: FunctionalComponent = () => { method: "post", }); - const addNewTranslations = useApiMutation({ - url: "/v2/projects/keys/import", - method: "post", - }); - const addTagsToKeys = useApiMutation({ url: "/v2/projects/tag-complex", method: "put", @@ -231,7 +231,7 @@ export const Push: FunctionalComponent = () => { translations: { [language]: { text: item.newValue, - resolution: "OVERRIDE", + resolution: item.oldValue ? "OVERRIDE" : "NEW", }, }, }); @@ -256,44 +256,63 @@ export const Push: FunctionalComponent = () => { }, }); - // Add tags to keys - if ( - (tolgeeConfig?.addTags ?? false) && - tolgeeConfig?.tags && - tolgeeConfig.tags.length > 0 - ) { - await addTagsToKeys.mutateAsync({ - content: { - "application/json": { - tagFiltered: tolgeeConfig?.tags ?? [], - filterKeys: [ - ...changes.newKeys, - ...changes.unchangedKeys, - ...changes.changedKeys, - ].map((k) => ({ - name: k.key, - namespace: k.ns || undefined, - })), + try { + // Add tags to keys + if ( + (tolgeeConfig?.addTags ?? false) && + tolgeeConfig?.tags && + tolgeeConfig.tags.length > 0 + ) { + await addTagsToKeys.mutateAsync({ + content: { + "application/json": { + tagFiltered: tolgeeConfig?.tags ?? [], + filterKeys: [ + ...changes.newKeys, + ...changes.unchangedKeys, + ...changes.changedKeys, + ].map((k) => ({ + name: k.key, + namespace: k.ns || undefined, + })), + }, }, - }, - }); + }); + } + } catch (e) { + setErrorMessage( + `Error adding tags. ${e}. Translations were still updated.` + ); } if (tolgeeConfig?.updateScreenshots ?? true) { for (const screenshot of changes.screenshots.values()) { - const relatedKeys = screenshot.keys - .map((data) => ({ - keyName: data.key, - namespace: data.ns || undefined, - })) - .slice(0, 100); - await bigMeta.mutateAsync({ - content: { - "application/json": { - relatedKeysInOrder: relatedKeys, + try { + const relatedKeys = screenshot.keys + .map((data) => ({ + keyName: data.key, + namespace: data.ns || undefined, + })) + .slice(0, 100); + await bigMeta.mutateAsync({ + content: { + "application/json": { + relatedKeysInOrder: relatedKeys, + }, }, - }, - }); + }); + setScreenshotCount(screenshotCount + 1); + } catch (e) { + if (e === "too_many_uploaded_images") { + setErrorMessage( + "Too many uploaded images. Disable update screenshots in settings. Translations were still updated." + ); + } else { + setErrorMessage( + `Error updating screenshots. ${e}. Translations were still updated.` + ); + } + } } } @@ -303,8 +322,14 @@ export const Push: FunctionalComponent = () => { setError(true); if (e === "invalid_project_api_key") { setErrorMessage("Invalid project API key"); + } else if (e === "too_many_uploaded_images") { + setErrorMessage( + "Too many uploaded images. Disable update screenshots in settings." + ); + } else if (e === "import_keys_error") { + setErrorMessage("Error importing keys. Please try again."); } else { - setErrorMessage(`Cannot get translation data. ${e}`); + setErrorMessage(`Cannot push translations. ${e}`); } console.error(e); } finally { @@ -327,8 +352,6 @@ export const Push: FunctionalComponent = () => { ? changes.changedKeys.length + changes.newKeys.length : 0; - const screenshotCount = changes?.screenshots.length || 0; - const noChanges = changesSize === 0; return ( @@ -373,7 +396,7 @@ export const Push: FunctionalComponent = () => { ) : ( - {screenshotCount !== 0 && ( + {totalScreenshotCount !== 0 && ( { setUploadScreenshots(Boolean(e.currentTarget.checked)) } > - Upload {screenshotCount} screenshot(s) + Upload {totalScreenshotCount} screenshot(s) @@ -397,7 +420,8 @@ export const Push: FunctionalComponent = () => { > Cancel - {noChanges && (screenshotCount === 0 || !uploadScreenshots) ? ( + {noChanges && + (totalScreenshotCount === 0 || !uploadScreenshots) ? (