@griddo/ax 12.8.6 → 12.8.8-rc.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@griddo/ax",
|
|
3
3
|
"description": "Griddo Author Experience",
|
|
4
|
-
"version": "12.8.
|
|
4
|
+
"version": "12.8.8-rc.0",
|
|
5
5
|
"authors": [
|
|
6
6
|
"Álvaro Sánchez' <alvaro.sanches@secuoyas.com>",
|
|
7
7
|
"Diego M. Béjar <diego.bejar@secuoyas.com>",
|
|
@@ -201,5 +201,5 @@
|
|
|
201
201
|
"publishConfig": {
|
|
202
202
|
"access": "public"
|
|
203
203
|
},
|
|
204
|
-
"gitHead": "
|
|
204
|
+
"gitHead": "663a3900aff18833cb1fe18f8854f0d42fad2a57"
|
|
205
205
|
}
|
|
@@ -157,10 +157,16 @@ describe("Translate Button component rendering", () => {
|
|
|
157
157
|
const translateButtonWrapper = screen.queryByTestId("translate-button-wrapper");
|
|
158
158
|
const translatedNotificationWrapper = screen.queryByTestId("update-translation-button-wrapper");
|
|
159
159
|
expect(translatedNotificationWrapper).toBeTruthy();
|
|
160
|
+
expect(translatedNotificationWrapper?.textContent).toContain("You can update it");
|
|
161
|
+
expect(screen.queryByText("Update translation with AI")).toBeTruthy();
|
|
160
162
|
expect(translateButtonWrapper).toBeFalsy();
|
|
161
163
|
});
|
|
162
164
|
|
|
163
|
-
|
|
165
|
+
// sc-119164 — la retraducción solo existe para páginas. El aviso se mostraba también en
|
|
166
|
+
// datos y formularios, y al pulsarlo no se llamaba a ninguna API: `getRetranslationAction`
|
|
167
|
+
// es undefined ahí, así que el componente pintaba «The translation could not be completed»
|
|
168
|
+
// sin haber intentado nada. Mientras no haya endpoint, no se ofrece la acción.
|
|
169
|
+
it("should show the already-translated notice for structured data but NOT offer the update action", () => {
|
|
164
170
|
const initialStore = {
|
|
165
171
|
app: { globalSettings: { autoTranslation: true } },
|
|
166
172
|
pageEditor: { editorContent: null, isIATranslated: false },
|
|
@@ -178,10 +184,35 @@ describe("Translate Button component rendering", () => {
|
|
|
178
184
|
{ store },
|
|
179
185
|
);
|
|
180
186
|
|
|
181
|
-
const
|
|
182
|
-
|
|
183
|
-
expect(translatedNotificationWrapper).
|
|
184
|
-
expect(
|
|
187
|
+
const translatedNotificationWrapper = screen.getByTestId("update-translation-button-wrapper");
|
|
188
|
+
expect(translatedNotificationWrapper.textContent).toContain("already been translated");
|
|
189
|
+
expect(translatedNotificationWrapper.textContent).not.toContain("You can update it");
|
|
190
|
+
expect(screen.queryByText("Update translation with AI")).toBeFalsy();
|
|
191
|
+
expect(screen.queryByTestId("translate-button-wrapper")).toBeFalsy();
|
|
192
|
+
});
|
|
193
|
+
|
|
194
|
+
it("should show the already-translated notice for forms but NOT offer the update action", () => {
|
|
195
|
+
const initialStore = {
|
|
196
|
+
app: { globalSettings: { autoTranslation: true } },
|
|
197
|
+
pageEditor: { editorContent: null, isIATranslated: false },
|
|
198
|
+
structuredData: { form: null, isIATranslated: false },
|
|
199
|
+
forms: { formContent: { canBeTranslated: false, originalLanguage: 2 } },
|
|
200
|
+
};
|
|
201
|
+
const store = mockStore(initialStore);
|
|
202
|
+
|
|
203
|
+
defaultProps.contentType = "form";
|
|
204
|
+
|
|
205
|
+
render(
|
|
206
|
+
<ThemeProvider theme={parseTheme(globalTheme)}>
|
|
207
|
+
<TranslateButton {...defaultProps} />
|
|
208
|
+
</ThemeProvider>,
|
|
209
|
+
{ store },
|
|
210
|
+
);
|
|
211
|
+
|
|
212
|
+
const wrapper = screen.getByTestId("update-translation-button-wrapper");
|
|
213
|
+
expect(wrapper.textContent).toContain("already been translated");
|
|
214
|
+
expect(screen.queryByText("Update translation with AI")).toBeFalsy();
|
|
215
|
+
expect(screen.queryByTestId("translate-button-wrapper")).toBeFalsy();
|
|
185
216
|
});
|
|
186
217
|
|
|
187
218
|
it("should render the component if page is already translated but can be translated", () => {
|
|
@@ -47,6 +47,14 @@ const TranslateButton = (props: ITranslateButtonProps): JSX.Element => {
|
|
|
47
47
|
|
|
48
48
|
const isOriginal = content?.originalLanguage === lang;
|
|
49
49
|
|
|
50
|
+
// La retraducción solo está implementada para páginas: `getContent` no define
|
|
51
|
+
// `getRetranslationAction` para datos ni formularios. Sin ella, el botón despachaba
|
|
52
|
+
// `undefined?.(...)` y pintaba «The translation could not be completed» sin haber llamado a
|
|
53
|
+
// ninguna API (sc-119164). Se mantiene el aviso de que el contenido ya está traducido, pero
|
|
54
|
+
// no se ofrece una acción inexistente. El día que Back añada el endpoint para datos o
|
|
55
|
+
// formularios, basta con registrar la acción en `getContent`.
|
|
56
|
+
const canRetranslate = !!getRetranslationAction;
|
|
57
|
+
|
|
50
58
|
const initialState = {
|
|
51
59
|
isLoading: false,
|
|
52
60
|
error: false,
|
|
@@ -88,42 +96,48 @@ const TranslateButton = (props: ITranslateButtonProps): JSX.Element => {
|
|
|
88
96
|
<>
|
|
89
97
|
<S.Wrapper data-testid="update-translation-button-wrapper" isSmall={!!structuredDataForm}>
|
|
90
98
|
<S.Text>
|
|
91
|
-
This page has <strong>already been translated</strong>.
|
|
92
|
-
source language.
|
|
99
|
+
This {canRetranslate ? "page" : "content"} has <strong>already been translated</strong>.
|
|
100
|
+
{canRetranslate && " You can update it with the latest changes from the source language."}
|
|
93
101
|
</S.Text>
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
102
|
+
{canRetranslate && (
|
|
103
|
+
<>
|
|
104
|
+
<S.ButtonWrapper>
|
|
105
|
+
<S.StyledButton
|
|
106
|
+
type="button"
|
|
107
|
+
onClick={() => toggleModal("update")}
|
|
108
|
+
icon={!state.isLoading ? "Ia" : undefined}
|
|
109
|
+
loader={state.isLoading ? "circle" : undefined}
|
|
110
|
+
disabled={disabled}
|
|
111
|
+
buttonStyle="line"
|
|
112
|
+
>
|
|
113
|
+
{updateButtonText}
|
|
114
|
+
</S.StyledButton>
|
|
115
|
+
</S.ButtonWrapper>
|
|
116
|
+
{state.error && (
|
|
117
|
+
<S.ErrorText>
|
|
118
|
+
The translation could not be completed. Your previous content has been preserved.
|
|
119
|
+
</S.ErrorText>
|
|
120
|
+
)}
|
|
121
|
+
</>
|
|
110
122
|
)}
|
|
111
123
|
</S.Wrapper>
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
124
|
+
{canRetranslate && (
|
|
125
|
+
<Modal
|
|
126
|
+
isOpen={isOpen("update")}
|
|
127
|
+
hide={() => toggleModal("update")}
|
|
128
|
+
size="S"
|
|
129
|
+
title="Update translation page with AI"
|
|
130
|
+
mainAction={{ title: "Update translation with AI", icon: "Ia", onClick: handleUpdateClick }}
|
|
131
|
+
secondaryAction={{ title: "Cancel", onClick: () => toggleModal("update") }}
|
|
132
|
+
height="auto"
|
|
133
|
+
>
|
|
134
|
+
<S.ModalContent>
|
|
135
|
+
This page <strong>already has a translation</strong>. Updating it{" "}
|
|
136
|
+
<strong>will replace all existing text in this language</strong>, including any manual edits made after
|
|
137
|
+
the previous translation. This action cannot be undone.
|
|
138
|
+
</S.ModalContent>
|
|
139
|
+
</Modal>
|
|
140
|
+
)}
|
|
127
141
|
</>
|
|
128
142
|
)}
|
|
129
143
|
{autoTranslation && content?.canBeTranslated ? (
|