From d2fcb6945bbef5c17385ec0318e4ad7ce609e9da Mon Sep 17 00:00:00 2001 From: LenaertsJ Date: Wed, 19 Feb 2025 10:57:59 +0000 Subject: [PATCH] Setup alias for use in standalone chill-bundles project and replace relative paths --- .changes/unreleased/DX-20250131-131801.yaml | 6 + .gitignore | 1 + .gitlab-ci.yml | 2 +- assets/translator.ts | 9 + composer.json | 1 + config/bundles.php | 1 + config/packages/ux_translator.yaml | 3 + .../installation/installation-production.rst | 50 +- package.json | 15 +- .../Activity/components/ConcernedGroups.vue | 35 +- .../vuejs/Activity/components/Location.vue | 30 +- .../components/Location/NewLocation.vue | 46 +- .../Activity/components/SocialIssuesAcc.vue | 73 +- .../translations/messages.fr.yml | 26 + .../translations/messages.fr.yml | 5 - .../public/module/ckeditor5/editor_config.ts | 55 +- .../public/module/ckeditor5/index.ts | 14 +- .../public/module/notification/toggle_read.js | 3 +- .../Component/PickGenericDocItem.vue | 3 +- .../public/vuejs/_components/BadgeEntity.vue | 76 +- .../_components/Entity/AddressRenderBox.vue | 8 +- .../EntityWorkflowVueSubscriber.vue | 125 +- .../EntityWorkflow/ListWorkflow.vue | 140 +- .../EntityWorkflow/ListWorkflowModal.vue | 148 +- .../public/vuejs/_components/Modal.vue | 52 +- .../Notification/NotificationReadToggle.vue | 151 +- .../public/vuejs/_components/OpenWopiLink.vue | 307 +- .../ChillMainBundle/chill.webpack.config.js | 44 - .../translations/messages.fr.yml | 98 + .../AccompanyingCourse/components/Comment.vue | 13 +- .../components/Resources/WriteComment.vue | 11 +- .../vuejs/AccompanyingCourseWorkEdit/App.vue | 34 +- .../components/FormEvaluation.vue | 28 +- .../components/MemberDetails.vue | 21 +- .../components/PersonComment.vue | 15 +- .../components/Positioning.vue | 2 +- src/vuex.d.ts | 6 + symfony.lock | 15 + ts-config-base.json | 28 + tsconfig.json | 38 +- webpack.config.js | 23 +- yarn.lock | 8612 ----------------- 42 files changed, 924 insertions(+), 9449 deletions(-) create mode 100644 .changes/unreleased/DX-20250131-131801.yaml create mode 100644 assets/translator.ts create mode 100644 config/packages/ux_translator.yaml create mode 100644 src/vuex.d.ts create mode 100644 ts-config-base.json delete mode 100644 yarn.lock diff --git a/.changes/unreleased/DX-20250131-131801.yaml b/.changes/unreleased/DX-20250131-131801.yaml new file mode 100644 index 000000000..387f48054 --- /dev/null +++ b/.changes/unreleased/DX-20250131-131801.yaml @@ -0,0 +1,6 @@ +kind: DX +body: Create an unique source of trust for translations +time: 2025-01-31T13:18:01.239211506+01:00 +custom: + Issue: "333" + SchemaChange: No schema change diff --git a/.gitignore b/.gitignore index 210b03aa6..ec5200ebd 100644 --- a/.gitignore +++ b/.gitignore @@ -12,6 +12,7 @@ docker/rabbitmq/data # in this development bundle, we want to ignore directories related to a real app assets/* +!assets/translator.ts migrations/* templates/* translations/* diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index a632f8f18..02c01640c 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -113,7 +113,7 @@ lint: - export PATH="./node_modules/.bin:$PATH" script: - yarn install --ignore-optional - - npx eslint-baseline "**/*.{js,vue}" + - npx eslint-baseline "src/**/*.{js,ts,vue}" cache: paths: - node_modules/ diff --git a/assets/translator.ts b/assets/translator.ts new file mode 100644 index 000000000..4834e30a6 --- /dev/null +++ b/assets/translator.ts @@ -0,0 +1,9 @@ +// @ts-ignore Cannot find module (when used within an app) +import { trans, getLocale, setLocale, setLocaleFallbacks } from "@symfony/ux-translator"; + +setLocaleFallbacks({"en": "fr", "nl": "fr", "fr": "en"}); +setLocale('fr'); + +export { trans }; +// @ts-ignore Cannot find module (when used within an app) +export * from '../var/translations'; diff --git a/composer.json b/composer.json index d4134c916..8d36d4d07 100644 --- a/composer.json +++ b/composer.json @@ -75,6 +75,7 @@ "symfony/templating": "^5.4", "symfony/translation": "^5.4", "symfony/twig-bundle": "^5.4", + "symfony/ux-translator": "^2.22", "symfony/validator": "^5.4", "symfony/webpack-encore-bundle": "^1.11", "symfony/workflow": "^5.4", diff --git a/config/bundles.php b/config/bundles.php index 815c3e62d..ec11bc0b6 100644 --- a/config/bundles.php +++ b/config/bundles.php @@ -36,4 +36,5 @@ return [ Chill\BudgetBundle\ChillBudgetBundle::class => ['all' => true], Chill\WopiBundle\ChillWopiBundle::class => ['all' => true], Symfony\Bundle\WebProfilerBundle\WebProfilerBundle::class => ['dev' => true, 'test' => true], + Symfony\UX\Translator\UxTranslatorBundle::class => ['all' => true], ]; diff --git a/config/packages/ux_translator.yaml b/config/packages/ux_translator.yaml new file mode 100644 index 000000000..1c1c70608 --- /dev/null +++ b/config/packages/ux_translator.yaml @@ -0,0 +1,3 @@ +ux_translator: + # The directory where the JavaScript translations are dumped + dump_directory: '%kernel.project_dir%/var/translations' diff --git a/docs/source/installation/installation-production.rst b/docs/source/installation/installation-production.rst index c12581265..08ede3d40 100644 --- a/docs/source/installation/installation-production.rst +++ b/docs/source/installation/installation-production.rst @@ -29,8 +29,7 @@ We strongly encourage you to initialize a git repository at this step, to track # add the flex endpoints required for custom recipes cat <<< "$(jq '.extra.symfony += {"endpoint": ["flex://defaults", "https://gitlab.com/api/v4/projects/57371968/repository/files/index.json/raw?ref=main"]}' composer.json)" > composer.json # install chill and some dependencies - # TODO fix the suffix "alpha1" and replace by ^3.0.0 when version 3.0.0 will be released - symfony composer require chill-project/chill-bundles v3.0.0-RC3 champs-libres/wopi-lib dev-master@dev champs-libres/wopi-bundle dev-master@dev + symfony composer require chill-project/chill-bundles ^3.7.1 champs-libres/wopi-lib dev-master@dev champs-libres/wopi-bundle dev-master@dev symfony/amqp-messenger We encourage you to accept the inclusion of the "Docker configuration from recipes": this is the documented way to run the database. You must also accept to configure recipes from the contrib repository, unless you want to configure the bundles manually). @@ -48,7 +47,7 @@ You must also accept to configure recipes from the contrib repository, unless yo If you encounter this error during assets compilation (:code:`yarn run encore production`) (repeated multiple times): - .. code-block:: txt + .. code-block:: [tsl] ERROR in /tmp/chill/v1/public/bundles/chillcalendar/types.ts(2,65) TS2307: Cannot find module '../../../ChillMainBundle/Resources/public/types' or its corresponding type declarations. @@ -74,14 +73,22 @@ or in the :code:`.env.local` file, which should not be committed to the git repo You do not need to set variables for the smtp server, redis server and relatorio server, as they are generated automatically by the symfony server, from the docker compose services. -The only required variable is the :code:`ADMIN_PASSWORD`. You can generate a hashed and salted admin password using the command -:code:`symfony console security:hash-password 'Symfony\Component\Security\Core\User\User'`. Then, +The required variables are: + +- the :code:`ADMIN_PASSWORD`; +- the :code:`OVHCLOUD_DSN` variable; + +:code:`ADMIN_PASSWORD` +^^^^^^^^^^^^^^^^^^^^^^ + +You can generate a hashed and salted admin password using the command +:code:`symfony console security:hash-password 'Symfony\Component\Security\Core\User\User'`.Then, you can either: - add this password to the :code:`.env.local` file, you must escape the character :code:`$`: if the generated password is :code:`$2y$13$iyvJLuT4YEa6iWXyQV4/N.hNHpNG8kXlYDkkt5MkYy4FXcSwYAwmm`, your :code:`.env.local` file will be: - .. code-block:: env + .. code-block:: bash ADMIN_PASSWORD=\$2y\$13\$iyvJLuT4YEa6iWXyQV4/N.hNHpNG8kXlYDkkt5MkYy4FXcSwYAwmm # note: if you copy-paste the line above, the password will be "admin". @@ -89,12 +96,24 @@ you can either: - add the generated password to the secrets manager (**note**: you must add the generated hashed password to the secrets env, not the password in clear text). -- set up the jwt authentication bundle +:code:`OVHCLOUD_DSN` and sending SMS messages +^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +This is a temporary dependency, for ensuring compatibility for previous behaviour. + +You can set it to :code:`null://null` if you do not plan to use sending SMS. + +.. code-block:: bash + + OVHCLOUD_DSN=null://null + +If you plan to do it, you can configure the notifier component `as described in the symfony documentation `_. + Some environment variables are available for the JWT authentication bundle in the :code:`.env` file. -Prepare migrations and other tools ----------------------------------- +Prepare database, messenger queue, and other configuration +---------------------------------------------------------- To continue the installation process, you will have to run migrations: @@ -114,14 +133,17 @@ To continue the installation process, you will have to run migrations: # generate jwt token, required for some api features (webdav access, ...) symfony console lexik:jwt:generate-keypair -.. warning:: +.. note:: - If you encounter an error while running :code:`symfony console messenger:setup-transports`, you can set up the messenger - transport to redis, by adding this in the :code:`.env.local` or :code:`.env` file: + If you encounter this error: + + .. code-block:: + + No transport supports the given Messenger DSN. + + Please check that you installed the package `symfony/amqp-messenger`. - .. code-block:: env - MESSENGER_TRANSPORT_DSN=redis://${REDIS_HOST}:${REDIS_PORT}/messages Start your web server locally ----------------------------- diff --git a/package.json b/package.json index 397676b1b..a24c4ee8f 100644 --- a/package.json +++ b/package.json @@ -6,15 +6,11 @@ "@apidevtools/swagger-cli": "^4.0.4", "@babel/core": "^7.20.5", "@babel/preset-env": "^7.20.2", - "@ckeditor/ckeditor5-build-classic": "^41.4.2", - "@ckeditor/ckeditor5-dev-translations": "^40.2.0", - "@ckeditor/ckeditor5-dev-utils": "^40.2.0", - "@ckeditor/ckeditor5-dev-webpack-plugin": "^31.1.13", - "@ckeditor/ckeditor5-markdown-gfm": "^41.4.2", - "@ckeditor/ckeditor5-theme-lark": "^41.4.2", - "@ckeditor/ckeditor5-vue": "^5.1.0", + "@ckeditor/ckeditor5-vue": "^7.3.0", "@eslint/js": "^9.14.0", + "@hotwired/stimulus": "^3.0.0", "@luminateone/eslint-baseline": "^1.0.9", + "@symfony/stimulus-bridge": "^3.2.0", "@symfony/webpack-encore": "^4.1.0", "@tsconfig/node20": "^20.1.4", "@types/dompurify": "^3.0.5", @@ -23,12 +19,14 @@ "bindings": "^1.5.0", "bootstrap": "5.2.3", "chokidar": "^3.5.1", + "ckeditor5": "^44.1.0", "dompurify": "^3.1.0", "eslint": "^9.14.0", "eslint-config-prettier": "^9.1.0", "eslint-plugin-prettier": "^5.2.1", "eslint-plugin-vue": "^9.30.0", "fork-awesome": "^1.1.7", + "intl-messageformat": "^10.5.11", "jquery": "^3.6.0", "node-sass": "^8.0.0", "popper.js": "^1.16.1", @@ -54,6 +52,7 @@ "@fullcalendar/timegrid": "^6.1.4", "@fullcalendar/vue3": "^6.1.4", "@popperjs/core": "^2.9.2", + "@tsconfig/node20": "^20.1.4", "@types/dompurify": "^3.0.5", "@types/leaflet": "^1.9.3", "bootstrap-icons": "^1.11.3", @@ -72,7 +71,7 @@ "vuex": "^4.0.0" }, "browserslist": [ - "Firefox ESR" + "defaults and fully supports es6-module and not dead" ], "scripts": { "dev-server": "encore dev-server", diff --git a/src/Bundle/ChillActivityBundle/Resources/public/vuejs/Activity/components/ConcernedGroups.vue b/src/Bundle/ChillActivityBundle/Resources/public/vuejs/Activity/components/ConcernedGroups.vue index 8437a1524..b99de220d 100644 --- a/src/Bundle/ChillActivityBundle/Resources/public/vuejs/Activity/components/ConcernedGroups.vue +++ b/src/Bundle/ChillActivityBundle/Resources/public/vuejs/Activity/components/ConcernedGroups.vue @@ -30,13 +30,14 @@
  • + > +
@@ -47,6 +48,14 @@ import { mapState, mapGetters } from "vuex"; import AddPersons from "ChillPersonAssets/vuejs/_components/AddPersons.vue"; import PersonsBloc from "./ConcernedGroups/PersonsBloc.vue"; import PersonText from "ChillPersonAssets/vuejs/_components/Entity/PersonText.vue"; +import { + ACTIVITY_BLOC_PERSONS, + ACTIVITY_BLOC_PERSONS_ASSOCIATED, + ACTIVITY_BLOC_THIRDPARTY, + ACTIVITY_BLOC_USERS, + ACTIVITY_ADD_PERSONS, + trans, +} from "translator"; export default { name: "ConcernedGroups", @@ -55,18 +64,24 @@ export default { PersonsBloc, PersonText, }, + setup() { + return { + trans, + ACTIVITY_ADD_PERSONS, + }; + }, data() { return { personsBlocs: [ { key: "persons", - title: "activity.bloc_persons", + title: trans(ACTIVITY_BLOC_PERSONS), persons: [], included: false, }, { key: "personsAssociated", - title: "activity.bloc_persons_associated", + title: trans(ACTIVITY_BLOC_PERSONS_ASSOCIATED), persons: [], included: window.activity ? window.activity.activityType.personsVisible !== 0 @@ -82,7 +97,7 @@ export default { }, { key: "thirdparty", - title: "activity.bloc_thirdparty", + title: trans(ACTIVITY_BLOC_THIRDPARTY), persons: [], included: window.activity ? window.activity.activityType.thirdPartiesVisible !== 0 @@ -90,7 +105,7 @@ export default { }, { key: "users", - title: "activity.bloc_users", + title: trans(ACTIVITY_BLOC_USERS), persons: [], included: window.activity ? window.activity.activityType.usersVisible !== 0 diff --git a/src/Bundle/ChillActivityBundle/Resources/public/vuejs/Activity/components/Location.vue b/src/Bundle/ChillActivityBundle/Resources/public/vuejs/Activity/components/Location.vue index efa1ca9e5..79df05da5 100644 --- a/src/Bundle/ChillActivityBundle/Resources/public/vuejs/Activity/components/Location.vue +++ b/src/Bundle/ChillActivityBundle/Resources/public/vuejs/Activity/components/Location.vue @@ -2,7 +2,7 @@
- +
@@ -33,6 +33,14 @@ import { mapState, mapGetters } from "vuex"; import VueMultiselect from "vue-multiselect"; import NewLocation from "./Location/NewLocation.vue"; +import { + trans, + ACTIVITY_LOCATION, + ACTIVITY_CHOOSE_LOCATION, + MULTISELECT_SELECT_LABEL, + MULTISELECT_DESELECT_LABEL, + MULTISELECT_SELECTED_LABEL, +} from "translator"; export default { name: "Location", @@ -40,6 +48,16 @@ export default { NewLocation, VueMultiselect, }, + setup() { + return { + trans, + ACTIVITY_LOCATION, + ACTIVITY_CHOOSE_LOCATION, + MULTISELECT_SELECT_LABEL, + MULTISELECT_DESELECT_LABEL, + MULTISELECT_SELECTED_LABEL, + }; + }, data() { return { locationClassList: `col-form-label col-sm-4 ${document.querySelector("input#chill_activitybundle_activity_location").getAttribute("required") ? "required" : ""}`, diff --git a/src/Bundle/ChillActivityBundle/Resources/public/vuejs/Activity/components/Location/NewLocation.vue b/src/Bundle/ChillActivityBundle/Resources/public/vuejs/Activity/components/Location/NewLocation.vue index da3e471ef..bea758ff8 100644 --- a/src/Bundle/ChillActivityBundle/Resources/public/vuejs/Activity/components/Location/NewLocation.vue +++ b/src/Bundle/ChillActivityBundle/Resources/public/vuejs/Activity/components/Location/NewLocation.vue @@ -3,7 +3,7 @@ @@ -11,12 +11,12 @@ @@ -126,6 +126,17 @@ import AddAddress from "ChillMainAssets/vuejs/Address/components/AddAddress.vue" import { mapState } from "vuex"; import { getLocationTypes } from "../../api"; import { makeFetch } from "ChillMainAssets/lib/api/apiMethods"; +import { + SAVE, + ACTIVITY_LOCATION_FIELDS_EMAIL, + ACTIVITY_LOCATION_FIELDS_PHONENUMBER1, + ACTIVITY_LOCATION_FIELDS_PHONENUMBER2, + ACTIVITY_LOCATION_FIELDS_NAME, + ACTIVITY_LOCATION_FIELDS_TYPE, + ACTIVITY_CHOOSE_LOCATION_TYPE, + ACTIVITY_CREATE_NEW_LOCATION, + trans, +} from "translator"; export default { name: "NewLocation", @@ -133,6 +144,19 @@ export default { Modal, AddAddress, }, + setup() { + return { + trans, + SAVE, + ACTIVITY_LOCATION_FIELDS_EMAIL, + ACTIVITY_LOCATION_FIELDS_PHONENUMBER1, + ACTIVITY_LOCATION_FIELDS_PHONENUMBER2, + ACTIVITY_LOCATION_FIELDS_NAME, + ACTIVITY_LOCATION_FIELDS_TYPE, + ACTIVITY_CHOOSE_LOCATION_TYPE, + ACTIVITY_CREATE_NEW_LOCATION, + }; + }, props: ["availableLocations"], data() { return { diff --git a/src/Bundle/ChillActivityBundle/Resources/public/vuejs/Activity/components/SocialIssuesAcc.vue b/src/Bundle/ChillActivityBundle/Resources/public/vuejs/Activity/components/SocialIssuesAcc.vue index a055fa725..10ed84d79 100644 --- a/src/Bundle/ChillActivityBundle/Resources/public/vuejs/Activity/components/SocialIssuesAcc.vue +++ b/src/Bundle/ChillActivityBundle/Resources/public/vuejs/Activity/components/SocialIssuesAcc.vue @@ -3,7 +3,7 @@
@@ -12,8 +12,9 @@ :key="issue.id" :issue="issue" :selection="socialIssuesSelected" - @update-selected="updateIssuesSelected" - /> + @updateSelected="updateIssuesSelected" + > +
+ > +
@@ -42,36 +44,38 @@
- +
- {{ $t("activity.select_first_a_social_issue") }} + {{ trans(ACTIVITY_SELECT_FIRST_A_SOCIAL_ISSUE) }} - - {{ $t("activity.social_action_list_empty") }} + {{ trans(ACTIVITY_SOCIAL_ACTION_LIST_EMPTY) }}
@@ -92,6 +96,14 @@ import VueMultiselect from "vue-multiselect"; import CheckSocialIssue from "./SocialIssuesAcc/CheckSocialIssue.vue"; import CheckSocialAction from "./SocialIssuesAcc/CheckSocialAction.vue"; import { getSocialIssues, getSocialActionByIssue } from "../api.js"; +import { + ACTIVITY_SOCIAL_ACTION_LIST_EMPTY, + ACTIVITY_SELECT_FIRST_A_SOCIAL_ISSUE, + ACTIVITY_SOCIAL_ACTIONS, + ACTIVITY_SOCIAL_ISSUES, + ACTIVITY_CHOOSE_OTHER_SOCIAL_ISSUE, + trans, +} from "translator"; export default { name: "SocialIssuesAcc", @@ -100,6 +112,16 @@ export default { CheckSocialAction, VueMultiselect, }, + setup() { + return { + trans, + ACTIVITY_SOCIAL_ACTION_LIST_EMPTY, + ACTIVITY_SELECT_FIRST_A_SOCIAL_ISSUE, + ACTIVITY_SOCIAL_ACTIONS, + ACTIVITY_SOCIAL_ISSUES, + ACTIVITY_CHOOSE_OTHER_SOCIAL_ISSUE, + }; + }, data() { return { issueIsLoading: false, @@ -133,7 +155,7 @@ export default { this.actionAreLoaded = false; getSocialIssues().then( (response) => - new Promise((resolve, reject) => { + new Promise((resolve) => { this.$store.commit("updateIssuesOther", response.results); /* Add in list the issues already associated (if not yet listed) @@ -208,7 +230,7 @@ export default { this.actionIsLoading = true; getSocialActionByIssue(item.id).then( (actions) => - new Promise((resolve, reject) => { + new Promise((resolve) => { actions.results.forEach((action) => { this.$store.commit("addActionInList", action); }, this); @@ -235,7 +257,6 @@ export default { }; - diff --git a/src/Bundle/ChillMainBundle/Resources/public/vuejs/_components/EntityWorkflow/ListWorkflow.vue b/src/Bundle/ChillMainBundle/Resources/public/vuejs/_components/EntityWorkflow/ListWorkflow.vue index 608508dd8..ebcc5128c 100644 --- a/src/Bundle/ChillMainBundle/Resources/public/vuejs/_components/EntityWorkflow/ListWorkflow.vue +++ b/src/Bundle/ChillMainBundle/Resources/public/vuejs/_components/EntityWorkflow/ListWorkflow.vue @@ -1,7 +1,7 @@ - diff --git a/src/Bundle/ChillMainBundle/Resources/public/vuejs/_components/EntityWorkflow/ListWorkflowModal.vue b/src/Bundle/ChillMainBundle/Resources/public/vuejs/_components/EntityWorkflow/ListWorkflowModal.vue index 022f274a3..59dcd80f4 100644 --- a/src/Bundle/ChillMainBundle/Resources/public/vuejs/_components/EntityWorkflow/ListWorkflowModal.vue +++ b/src/Bundle/ChillMainBundle/Resources/public/vuejs/_components/EntityWorkflow/ListWorkflowModal.vue @@ -1,23 +1,24 @@ -