Skip to content
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
33 changes: 4 additions & 29 deletions cypress/e2e/index.cy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,35 +23,10 @@ describe("Index", () => {
.should("have.value", "test_key");

cy.iframe()
.findDcy("general_node_list_row_namespace")
.find("select")
.should("have.value", "");
});

it("hides namespace selector", () => {
const nodes = [createTestNode({ text: "Test node", key: "test_key" })];
visitWithState({
config: { ...SIGNED_IN, namespacesDisabled: true },
selectedNodes: nodes,
allNodes: nodes,
});

cy.iframe().contains("Test node").should("be.visible");

cy.iframe()
.findDcy("general_node_list_row_text")
.contains("Test node")
.should("be.visible");

cy.iframe()
.findDcy("general_node_list_row_key")
.find("input")
.should("have.value", "test_key");

cy.iframe()
.findDcy("general_node_list_row_namespace")
.find("select")
.should("not.exist");
.findDcy("general_namespace_select_input")
.should(($input) => {
expect($input.val() || "").to.be.empty;
});
});

it("shows connected node correctly", () => {
Expand Down
74 changes: 72 additions & 2 deletions cypress/e2e/push.cy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -79,9 +79,79 @@ describe("Push", () => {
cy.iframe().findDcy("push_ok_button").should("be.visible").click();
});

it("shows correct key count in success message after pushing new keys", () => {
const nodes = [
createTestNode({ text: "New key 1", key: "new_key_1" }),
createTestNode({ text: "New key 2", key: "new_key_2" }),
];
visitWithState({
config: SIGNED_IN,
selectedNodes: nodes,
allNodes: nodes,
});

cy.frameLoaded("#plugin_iframe");

cy.iframe().contains("New key 1").should("exist");
cy.iframe().findDcy("index_push_button").should("be.visible").click();

// Verify we see the new keys in the diff
cy.iframe().contains("New keys").should("exist");
cy.iframe()
.findDcy("changes_new_keys")
.contains("new_key_1")
.should("be.visible");
cy.iframe()
.findDcy("changes_new_keys")
.contains("new_key_2")
.should("be.visible");

// Push the changes
cy.iframe().findDcy("push_submit_button").should("be.visible").click();

// Verify success message shows correct count (2 keys)
cy.iframe().contains("Successfully updated 2 key(s)").should("be.visible");
cy.iframe().findDcy("push_ok_button").should("be.visible").click();
});

it("shows correct key count in success message after pushing changed keys", () => {
const nodes = [
createTestNode({ text: "Changed text 1", key: "on-the-road-subtitle" }),
createTestNode({ text: "Changed text 2", key: "on-the-road-title" }),
];
visitWithState({
config: SIGNED_IN,
selectedNodes: nodes,
allNodes: nodes,
});

cy.frameLoaded("#plugin_iframe");

cy.iframe().contains("Changed text 1").should("exist");
cy.iframe().findDcy("index_push_button").should("be.visible").click();

// Verify we see the changed keys in the diff
cy.iframe().contains("Changed keys").should("exist");
cy.iframe()
.findDcy("changes_changed_keys")
.contains("on-the-road-subtitle")
.should("be.visible");
cy.iframe()
.findDcy("changes_changed_keys")
.contains("on-the-road-title")
.should("be.visible");

// Push the changes
cy.iframe().findDcy("push_submit_button").should("be.visible").click();

// Verify success message shows correct count (2 keys)
cy.iframe().contains("Successfully updated 2 key(s)").should("be.visible");
cy.iframe().findDcy("push_ok_button").should("be.visible").click();
});

it("doesn't push screenshot when disabled", () => {
const nodes = [
createTestNode({ text: "On the road", key: "on-the-road-title" }),
createTestNode({ text: "Changed text 2", key: "on-the-road-title" }),
];
visitWithState({
config: { ...SIGNED_IN, updateScreenshots: false },
Expand All @@ -91,7 +161,7 @@ describe("Push", () => {

cy.frameLoaded("#plugin_iframe");

cy.iframe().contains("On the road").should("exist");
cy.iframe().contains("Changed text 2").should("exist");
cy.iframe().findDcy("index_push_button").should("be.visible").click();

cy.iframe().contains("No changes necessary").should("be.visible");
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
"scripts": {
"build": "build-figma-plugin --typecheck --minify",
"watch": "build-figma-plugin --typecheck --watch",
"schema": "openapi-typescript http://localhost:8080/v3/api-docs/Accessible%20with%20API%20key --output ./src/client/apiSchema.generated.ts",
"schema": "openapi-typescript 'http://localhost:8085/v3/api-docs/Accessible with Project API key (All)' --output ./src/ui/client/apiSchema.generated.ts",
"eslint": "eslint --ext .ts,.tsx,.js,.jsx src",
"watch:web": "npm run --prefix web watch",
"dev:web": "ts-node ./scripts/runAfterApp.ts \"npm run watch:web\"",
Expand Down
27 changes: 23 additions & 4 deletions src/main/utils/nodeTools.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,11 +32,30 @@ 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) {
isParentHidden = true;
break;
}
parent = parent.parent;
}
if (isParentHidden) {
return false;
}
} catch (error) {
console.error("Error checking parent visibility:", error);
}
}
}
if (
settings.ignoreTextLayers &&
Expand Down
4 changes: 2 additions & 2 deletions src/main/utils/settingsTools.ts
Original file line number Diff line number Diff line change
Expand Up @@ -73,13 +73,13 @@ export const setPluginData = async (data: Partial<TolgeeConfig>) => {
apiKey,
apiUrl,
ignoreHiddenLayers,
ignoreHiddenLayersIncludingChildren,
ignoreNumbers,
ignorePrefix,
ignoreTextLayers,
keyFormat,
language,
namespace,
namespacesDisabled,
prefillKeyFormat,
tags,
updateScreenshots,
Expand All @@ -92,12 +92,12 @@ export const setPluginData = async (data: Partial<TolgeeConfig>) => {
apiUrl,
documentInfo: true,
ignoreHiddenLayers,
ignoreHiddenLayersIncludingChildren,
ignoreNumbers,
ignorePrefix,
ignoreTextLayers,
keyFormat,
namespace,
namespacesDisabled,
prefillKeyFormat,
tags,
updateScreenshots,
Expand Down
8 changes: 5 additions & 3 deletions src/tools/getPushChanges.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ export type KeyChanges = {
export const getPushChanges = (
nodes: NodeInfo[],
translations: TranslationData,
language: string,
hasNamespacesEnabled: boolean,
screenshots: FrameScreenshot[],
tolgeeConfig: Partial<TolgeeConfig> | null
): KeyChanges => {
Expand All @@ -37,7 +37,9 @@ export const getPushChanges = (
screenshots.forEach((screenshot) => {
if (
screenshot.keys.find(
(node) => node.key === value.key && compareNs(node.ns, value.ns)
(node) =>
node.key === value.key &&
(!hasNamespacesEnabled || compareNs(node.ns, value.ns))
)
) {
result.push(screenshot);
Expand Down Expand Up @@ -82,7 +84,7 @@ export const getPushChanges = (

const change: KeyChangeValue = {
key: node.key,
ns: node.ns,
ns: hasNamespacesEnabled ? node.ns : undefined,
oldValue: oldValue ? oldValue.translation : undefined,
oldIsPlural: oldValue ? oldValue.keyIsPlural : undefined,
isPlural: node.isPlural,
Expand Down
2 changes: 1 addition & 1 deletion src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,7 @@ export type GlobalSettings = {
*/
keyFormat?: string;
ignoreHiddenLayers?: boolean;
ignoreHiddenLayersIncludingChildren?: boolean;
ignoreTextLayers?: boolean;
variableCasing?:
| "snake_case"
Expand All @@ -126,7 +127,6 @@ export type GlobalSettings = {

export type CurrentDocumentSettings = GlobalSettings & {
namespace: string;
namespacesDisabled: boolean;
documentInfo: true;
};

Expand Down
68 changes: 68 additions & 0 deletions src/ui/client/apiSchema.custom.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
import { components } from "./apiSchema.generated";

/**
* This file contains endpoints that are not generated by openapi-typescript but are still needed for the app.
*/
export interface customPaths {
"/v2/projects/{projectId}": {
/**
* Get project info
* @description Returns info about a project
*/
get: operations["get"];
};
}

export interface operations {
/**
* Get project info
* @description Returns info about a project
*/
get: {
parameters: {
path: {
projectId: number;
};
};
responses: {
/** @description OK */
200: {
content: {
"application/json": components["schemas"]["ProjectModel"];
};
};
/** @description Bad Request */
400: {
content: {
"application/json":
| components["schemas"]["ErrorResponseTyped"]
| components["schemas"]["ErrorResponseBody"];
};
};
/** @description Unauthorized */
401: {
content: {
"application/json":
| components["schemas"]["ErrorResponseTyped"]
| components["schemas"]["ErrorResponseBody"];
};
};
/** @description Forbidden */
403: {
content: {
"application/json":
| components["schemas"]["ErrorResponseTyped"]
| components["schemas"]["ErrorResponseBody"];
};
};
/** @description Not Found */
404: {
content: {
"application/json":
| components["schemas"]["ErrorResponseTyped"]
| components["schemas"]["ErrorResponseBody"];
};
};
};
};
}
Loading