From 1090fb8fada88f7182e8f13b073595325b35bd97 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?F=C3=A9lix=20Malfait?= Date: Fri, 14 Feb 2025 09:41:35 +0100 Subject: [PATCH] Remove localization feature flag and improve CI workflow (#10208) --- .github/workflows/i18n-compile.yaml | 50 ------------------- .github/workflows/i18n-pull.yaml | 31 +++++++++++- .github/workflows/i18n-push.yaml | 7 +++ .../src/generated-metadata/graphql.ts | 1 - .../twenty-front/src/generated/graphql.tsx | 3 +- .../components/SettingsExperience.tsx | 22 +++----- .../typeorm-seeds/core/feature-flags.ts | 5 -- .../constants/public-feature-flag.const.ts | 14 +----- .../enums/feature-flag-key.enum.ts | 1 - 9 files changed, 46 insertions(+), 88 deletions(-) delete mode 100644 .github/workflows/i18n-compile.yaml diff --git a/.github/workflows/i18n-compile.yaml b/.github/workflows/i18n-compile.yaml deleted file mode 100644 index 3d317c019..000000000 --- a/.github/workflows/i18n-compile.yaml +++ /dev/null @@ -1,50 +0,0 @@ -name: 'Compile translations' - -on: - push: - branches: ['i18n'] - pull_request: - branches: ['i18n'] - workflow_dispatch: - -concurrency: - group: ${{ github.workflow }}-${{ github.head_ref || github.run_id }} - cancel-in-progress: true - -jobs: - compile_translations: - name: Compile translations - runs-on: ubuntu-latest - permissions: - contents: write - pull-requests: write - - steps: - - name: Checkout - uses: actions/checkout@v4 - with: - token: ${{ github.token }} - ref: i18n - - - name: Install dependencies - uses: ./.github/workflows/actions/yarn-install - - - name: Build twenty-shared - run: npx nx build twenty-shared - - - name: Compile translations - id: compile_translations - run: | - npx nx run twenty-server:lingui:compile - npx nx run twenty-emails:lingui:compile - npx nx run twenty-front:lingui:compile - - - name: Check and commit compiled files - run: | - git config --global user.name 'github-actions' - git config --global user.email 'github-actions@twenty.com' - git add . - if ! git diff --staged --quiet --exit-code; then - git commit -m "chore: compile translations [skip ci]" - git push origin HEAD:i18n - fi diff --git a/.github/workflows/i18n-pull.yaml b/.github/workflows/i18n-pull.yaml index 96d1e3d98..e0948f70a 100644 --- a/.github/workflows/i18n-pull.yaml +++ b/.github/workflows/i18n-pull.yaml @@ -80,8 +80,37 @@ jobs: github_base_url: 'github.com' github_user_name: 'Crowdin Bot' github_user_email: 'support+bot@crowdin.com' - env: GITHUB_TOKEN: ${{ github.token }} CROWDIN_PROJECT_ID: '1' CROWDIN_PERSONAL_TOKEN: ${{ secrets.CROWDIN_PERSONAL_TOKEN }} + + - name: Compile translations + if: inputs.force_pull || steps.compile_translations.outcome == 'failure' + run: | + npx nx run twenty-server:lingui:compile + npx nx run twenty-emails:lingui:compile + npx nx run twenty-front:lingui:compile + + - name: Check and commit compiled files + id: check_changes + run: | + git config --global user.name 'github-actions' + git config --global user.email 'github-actions@twenty.com' + git add . + if ! git diff --staged --quiet --exit-code; then + git commit -m "chore: compile translations [skip ci]" + echo "changes_detected=true" >> $GITHUB_OUTPUT + else + echo "changes_detected=false" >> $GITHUB_OUTPUT + fi + + - name: Push changes + if: steps.check_changes.outputs.changes_detected == 'true' + run: git push origin HEAD:i18n + + - name: Create pull request + if: steps.check_changes.outputs.changes_detected == 'true' + run: gh pr create -B main -H i18n --title 'i18n - translations' --body 'Created by Github action' || true + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} diff --git a/.github/workflows/i18n-push.yaml b/.github/workflows/i18n-push.yaml index 69b251c3e..fb590bcff 100644 --- a/.github/workflows/i18n-push.yaml +++ b/.github/workflows/i18n-push.yaml @@ -28,6 +28,7 @@ jobs: if ! git ls-remote --heads origin i18n | grep i18n; then git checkout -b i18n else + git fetch origin i18n git checkout i18n git merge origin/main fi @@ -44,6 +45,12 @@ jobs: npx nx run twenty-emails:lingui:extract npx nx run twenty-front:lingui:extract + - name: Compile translations + run: | + npx nx run twenty-server:lingui:compile + npx nx run twenty-emails:lingui:compile + npx nx run twenty-front:lingui:compile + - name: Check and commit any files created id: check_changes run: | diff --git a/packages/twenty-front/src/generated-metadata/graphql.ts b/packages/twenty-front/src/generated-metadata/graphql.ts index 8ced32d24..368e8226a 100644 --- a/packages/twenty-front/src/generated-metadata/graphql.ts +++ b/packages/twenty-front/src/generated-metadata/graphql.ts @@ -528,7 +528,6 @@ export enum FeatureFlagKey { IsCustomDomainEnabled = 'IsCustomDomainEnabled', IsEventObjectEnabled = 'IsEventObjectEnabled', IsJsonFilterEnabled = 'IsJsonFilterEnabled', - IsLocalizationEnabled = 'IsLocalizationEnabled', IsNewRelationEnabled = 'IsNewRelationEnabled', IsPermissionsEnabled = 'IsPermissionsEnabled', IsPostgreSQLIntegrationEnabled = 'IsPostgreSQLIntegrationEnabled', diff --git a/packages/twenty-front/src/generated/graphql.tsx b/packages/twenty-front/src/generated/graphql.tsx index fd711907a..bbb8e87c2 100644 --- a/packages/twenty-front/src/generated/graphql.tsx +++ b/packages/twenty-front/src/generated/graphql.tsx @@ -1,5 +1,5 @@ -import { gql } from '@apollo/client'; import * as Apollo from '@apollo/client'; +import { gql } from '@apollo/client'; export type Maybe = T | null; export type InputMaybe = Maybe; export type Exact = { [K in keyof T]: T[K] }; @@ -460,7 +460,6 @@ export enum FeatureFlagKey { IsCustomDomainEnabled = 'IsCustomDomainEnabled', IsEventObjectEnabled = 'IsEventObjectEnabled', IsJsonFilterEnabled = 'IsJsonFilterEnabled', - IsLocalizationEnabled = 'IsLocalizationEnabled', IsNewRelationEnabled = 'IsNewRelationEnabled', IsPermissionsEnabled = 'IsPermissionsEnabled', IsPostgreSQLIntegrationEnabled = 'IsPostgreSQLIntegrationEnabled', diff --git a/packages/twenty-front/src/pages/settings/profile/appearance/components/SettingsExperience.tsx b/packages/twenty-front/src/pages/settings/profile/appearance/components/SettingsExperience.tsx index ed5229d3b..c588925d0 100644 --- a/packages/twenty-front/src/pages/settings/profile/appearance/components/SettingsExperience.tsx +++ b/packages/twenty-front/src/pages/settings/profile/appearance/components/SettingsExperience.tsx @@ -4,10 +4,8 @@ import { SettingsPageContainer } from '@/settings/components/SettingsPageContain import { SettingsPath } from '@/types/SettingsPath'; import { SubMenuTopBarContainer } from '@/ui/layout/page/components/SubMenuTopBarContainer'; import { useColorScheme } from '@/ui/theme/hooks/useColorScheme'; -import { useIsFeatureEnabled } from '@/workspace/hooks/useIsFeatureEnabled'; import { Trans, useLingui } from '@lingui/react/macro'; -import { FeatureFlagKey } from '~/generated/graphql'; import { DateTimeSettings } from '~/pages/settings/profile/appearance/components/DateTimeSettings'; import { LocalePicker } from '~/pages/settings/profile/appearance/components/LocalePicker'; import { getSettingsPath } from '~/utils/navigation/getSettingsPath'; @@ -15,10 +13,6 @@ import { getSettingsPath } from '~/utils/navigation/getSettingsPath'; export const SettingsExperience = () => { const { colorScheme, setColorScheme } = useColorScheme(); - const isLocalizationEnabled = useIsFeatureEnabled( - FeatureFlagKey.IsLocalizationEnabled, - ); - const { t } = useLingui(); return ( @@ -51,15 +45,13 @@ export const SettingsExperience = () => { - {isLocalizationEnabled && ( -
- - -
- )} +
+ + +
); diff --git a/packages/twenty-server/src/database/typeorm-seeds/core/feature-flags.ts b/packages/twenty-server/src/database/typeorm-seeds/core/feature-flags.ts index 548b98166..d1b975f84 100644 --- a/packages/twenty-server/src/database/typeorm-seeds/core/feature-flags.ts +++ b/packages/twenty-server/src/database/typeorm-seeds/core/feature-flags.ts @@ -70,11 +70,6 @@ export const seedFeatureFlags = async ( workspaceId: workspaceId, value: true, }, - { - key: FeatureFlagKey.IsLocalizationEnabled, - workspaceId: workspaceId, - value: true, - }, { key: FeatureFlagKey.IsRichTextV2Enabled, workspaceId: workspaceId, diff --git a/packages/twenty-server/src/engine/core-modules/feature-flag/constants/public-feature-flag.const.ts b/packages/twenty-server/src/engine/core-modules/feature-flag/constants/public-feature-flag.const.ts index 2f312b6ac..cef1bfdd4 100644 --- a/packages/twenty-server/src/engine/core-modules/feature-flag/constants/public-feature-flag.const.ts +++ b/packages/twenty-server/src/engine/core-modules/feature-flag/constants/public-feature-flag.const.ts @@ -7,23 +7,11 @@ type FeatureFlagMetadata = { }; export type PublicFeatureFlag = { - key: Extract< - FeatureFlagKey, - FeatureFlagKey.IsLocalizationEnabled | FeatureFlagKey.IsWorkflowEnabled - >; + key: Extract; metadata: FeatureFlagMetadata; }; export const PUBLIC_FEATURE_FLAGS: PublicFeatureFlag[] = [ - { - key: FeatureFlagKey.IsLocalizationEnabled, - metadata: { - label: 'Localization', - description: - "Enable this and go to Settings > Experience to change your account's language. You can also help us improve the translations on Github.", - imagePath: 'https://twenty.com/images/releases/labs/translation.png', - }, - }, { key: FeatureFlagKey.IsWorkflowEnabled, metadata: { diff --git a/packages/twenty-server/src/engine/core-modules/feature-flag/enums/feature-flag-key.enum.ts b/packages/twenty-server/src/engine/core-modules/feature-flag/enums/feature-flag-key.enum.ts index 04286215a..105d4da17 100644 --- a/packages/twenty-server/src/engine/core-modules/feature-flag/enums/feature-flag-key.enum.ts +++ b/packages/twenty-server/src/engine/core-modules/feature-flag/enums/feature-flag-key.enum.ts @@ -11,7 +11,6 @@ export enum FeatureFlagKey { IsCommandMenuV2Enabled = 'IS_COMMAND_MENU_V2_ENABLED', IsJsonFilterEnabled = 'IS_JSON_FILTER_ENABLED', IsCustomDomainEnabled = 'IS_CUSTOM_DOMAIN_ENABLED', - IsLocalizationEnabled = 'IS_LOCALIZATION_ENABLED', IsBillingPlansEnabled = 'IS_BILLING_PLANS_ENABLED', IsRichTextV2Enabled = 'IS_RICH_TEXT_V2_ENABLED', IsNewRelationEnabled = 'IS_NEW_RELATION_ENABLED',