diff --git a/CHANGELOG.md b/CHANGELOG.md index f002a60..6c1f3f8 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,7 @@ +0.26.0 +------ +- Feat: Add possibility to translate the workflow texts + 0.25.2 ------ - feat: use label property to render info in search inputs and to sort elements diff --git a/e2e/cypress/integration/gmi-type-content.js b/e2e/cypress/integration/gmi-type-content.js index c99c423..b959b2a 100644 --- a/e2e/cypress/integration/gmi-type-content.js +++ b/e2e/cypress/integration/gmi-type-content.js @@ -269,15 +269,15 @@ LOGIN_TYPES.forEach((loginType) => { ) // Modify workflow - cy.findByText(/Current state: private/) + cy.findByText(/Current state: Private/) cy.findByText('Publish').click() cy.findByText('Confirm').click() cy.get(NOTIFICATION_SELECTOR).should('contain', `Great status changed!`) - cy.findByText(/Current state: public/) + cy.findByText(/Current state: Public/) cy.findByText('Retire').click() cy.findByText('Confirm').click() cy.get(NOTIFICATION_SELECTOR).should('contain', `Great status changed!`) - cy.findByText(/Current state: private/) + cy.findByText(/Current state: Private/) // Upload multiple image cy.get(`[data-test='formMultiimageOrderedAttachmentTest']`).within(() => { diff --git a/e2e/vite_example/package-lock.json b/e2e/vite_example/package-lock.json index 496cd68..0a82001 100644 --- a/e2e/vite_example/package-lock.json +++ b/e2e/vite_example/package-lock.json @@ -30,7 +30,7 @@ }, "../..": { "name": "@guillotinaweb/react-gmi", - "version": "0.24.0", + "version": "0.26.0", "license": "MIT", "dependencies": { "brace": "0.11.1", @@ -38,15 +38,18 @@ "jwt-decode": "3.1.2", "prop-types": "15.7.2", "react-beautiful-dnd": "13.1.1", + "react-intl": "6.5.5", "react-useportal": "1.0.19", "uuid": "9.0.1" }, "devDependencies": { "@babel/cli": "7.12.10", "@babel/core": "7.12.10", + "@formatjs/cli": "^6.2.4", "@testing-library/jest-dom": "5.11.6", "@testing-library/react": "11.2.2", "@testing-library/user-event": "12.6.0", + "babel-plugin-formatjs": "^10.5.10", "husky": "4.3.6", "microbundle": "0.13.0", "prettier": "2.2.1", @@ -4946,9 +4949,11 @@ "requires": { "@babel/cli": "7.12.10", "@babel/core": "7.12.10", + "@formatjs/cli": "^6.2.4", "@testing-library/jest-dom": "5.11.6", "@testing-library/react": "11.2.2", "@testing-library/user-event": "12.6.0", + "babel-plugin-formatjs": "^10.5.10", "brace": "0.11.1", "bulma": "0.9.4", "husky": "4.3.6", @@ -4957,6 +4962,7 @@ "prettier": "2.2.1", "prop-types": "15.7.2", "react-beautiful-dnd": "13.1.1", + "react-intl": "6.5.5", "react-useportal": "1.0.19", "sass": "1.69.5", "serialize-javascript": "5.0.1", diff --git a/e2e/vite_example/src/App.tsx b/e2e/vite_example/src/App.tsx index 8d1de09..e910708 100644 --- a/e2e/vite_example/src/App.tsx +++ b/e2e/vite_example/src/App.tsx @@ -132,7 +132,11 @@ function App() { {isLogged && ( { + if (vocabulary.data?.items?.length > 0) { + const vocabularyValue = vocabulary.data.items.find( + (item) => item.token === currentState + ) + if (vocabularyValue) { + const translatedValue = get( + vocabularyValue, + `title.translated_title.${intl.locale}`, + null + ) + if (translatedValue !== null) { + return translatedValue + } + const titleValue = get( + vocabularyValue, + `title.title.${intl.locale}`, + null + ) + if (titleValue !== null) { + return titleValue + } + } + } + return currentState + } + if (definition === undefined) return null return ( @@ -92,10 +122,12 @@ export function IWorkflow() { className="has-text-weight-bold" data-test={`textInfoStatus-${currentState}`} > - {intl.formatMessage(messages.current_state, { state: currentState })} + {intl.formatMessage(messages.current_state, { + state: getStateTitle(), + })} - {modifyContent && ( + {modifyContent && definition.transitions.length > 0 && (
- {transition.title} + {get( + transition, + `metadata.translated_title.${intl.locale}`, + transition.title + )} ) })} diff --git a/src/guillo-gmi/components/fields/renderField.tsx b/src/guillo-gmi/components/fields/renderField.tsx index 048f598..fdf59f2 100644 --- a/src/guillo-gmi/components/fields/renderField.tsx +++ b/src/guillo-gmi/components/fields/renderField.tsx @@ -113,7 +113,6 @@ export const SearchRenderField = ({ schema, value, modifyContent }) => { }, [value]) const getRenderValue = () => { - console.log('get render values', value, valuesLabels) if (value === undefined) { if (modifyContent) { return DEFAULT_VALUE_EDITABLE_FIELD