From eee4317dacbe977676c0ab4071d5f3d0051c76ea Mon Sep 17 00:00:00 2001 From: Gao Sun Date: Wed, 18 Sep 2024 20:46:42 +0800 Subject: [PATCH] feat(console): au region --- .../connector-logto-email/package.json | 2 +- packages/console/package.json | 2 +- .../components/CreateTenantModal/index.tsx | 28 +-- .../src/components/Region/assets/au.svg | 23 +++ .../src/components/Region/assets/eu.svg | 131 ++++++++++++++ .../src/components/Region/assets/us.svg | 161 ++++++++++++++++++ .../src/components/Region/index.module.scss | 6 +- .../console/src/components/Region/index.tsx | 24 ++- packages/core/package.json | 2 +- pnpm-lock.yaml | 47 ++--- 10 files changed, 376 insertions(+), 50 deletions(-) create mode 100644 packages/console/src/components/Region/assets/au.svg create mode 100644 packages/console/src/components/Region/assets/eu.svg create mode 100644 packages/console/src/components/Region/assets/us.svg diff --git a/packages/connectors/connector-logto-email/package.json b/packages/connectors/connector-logto-email/package.json index 37cc54450..a8d12fdf7 100644 --- a/packages/connectors/connector-logto-email/package.json +++ b/packages/connectors/connector-logto-email/package.json @@ -52,7 +52,7 @@ "access": "public" }, "devDependencies": { - "@logto/cloud": "0.2.5-582d792", + "@logto/cloud": "0.2.5-1661979", "@silverhand/eslint-config": "6.0.1", "@silverhand/ts-config": "6.0.0", "@types/node": "^20.11.20", diff --git a/packages/console/package.json b/packages/console/package.json index 0dccfd5cf..591c6ffec 100644 --- a/packages/console/package.json +++ b/packages/console/package.json @@ -27,7 +27,7 @@ "devDependencies": { "@fontsource/roboto-mono": "^5.0.0", "@jest/types": "^29.5.0", - "@logto/cloud": "0.2.5-91ab76c", + "@logto/cloud": "0.2.5-1661979", "@logto/connector-kit": "workspace:^4.0.0", "@logto/core-kit": "workspace:^2.5.0", "@logto/elements": "workspace:^0.0.0", diff --git a/packages/console/src/components/CreateTenantModal/index.tsx b/packages/console/src/components/CreateTenantModal/index.tsx index 3dc2fd678..d8a5b7824 100644 --- a/packages/console/src/components/CreateTenantModal/index.tsx +++ b/packages/console/src/components/CreateTenantModal/index.tsx @@ -10,6 +10,7 @@ import CreateTenantHeaderIcon from '@/assets/icons/create-tenant-header.svg?reac import { useCloudApi } from '@/cloud/hooks/use-cloud-api'; import { type TenantResponse } from '@/cloud/types/router'; import Region, { RegionName } from '@/components/Region'; +import { isDevFeaturesEnabled } from '@/consts/env'; import Button from '@/ds-components/Button'; import DangerousRaw from '@/ds-components/DangerousRaw'; import FormField from '@/ds-components/FormField'; @@ -122,18 +123,21 @@ function CreateTenantModal({ isOpen, onClose }: Props) { render={({ field: { onChange, value, name } }) => ( {/* Manually maintaining the list of regions to avoid unexpected changes. We may consider using an API in the future. */} - {[RegionName.EU, RegionName.US].map((region) => ( - - - - } - value={region} - isDisabled={isSubmitting} - /> - ))} + {[RegionName.EU, RegionName.US, RegionName.AU].map( + (region) => + (isDevFeaturesEnabled || region !== RegionName.AU) && ( + + + + } + value={region} + isDisabled={isSubmitting} + /> + ) + )} )} /> diff --git a/packages/console/src/components/Region/assets/au.svg b/packages/console/src/components/Region/assets/au.svg new file mode 100644 index 000000000..a237b779f --- /dev/null +++ b/packages/console/src/components/Region/assets/au.svg @@ -0,0 +1,23 @@ + + + + + + + + + + + + + + + + diff --git a/packages/console/src/components/Region/assets/eu.svg b/packages/console/src/components/Region/assets/eu.svg new file mode 100644 index 000000000..e030582cb --- /dev/null +++ b/packages/console/src/components/Region/assets/eu.svg @@ -0,0 +1,131 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/packages/console/src/components/Region/assets/us.svg b/packages/console/src/components/Region/assets/us.svg new file mode 100644 index 000000000..d59265a34 --- /dev/null +++ b/packages/console/src/components/Region/assets/us.svg @@ -0,0 +1,161 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/packages/console/src/components/Region/index.module.scss b/packages/console/src/components/Region/index.module.scss index 73727b5e2..8b4b82ab6 100644 --- a/packages/console/src/components/Region/index.module.scss +++ b/packages/console/src/components/Region/index.module.scss @@ -1,6 +1,10 @@ @use '@/scss/underscore' as _; -.regionText { +.wrapper { + display: flex; + align-items: center; + justify-content: center; + gap: _.unit(2); font: var(--font-label-2); .comingSoon { diff --git a/packages/console/src/components/Region/index.tsx b/packages/console/src/components/Region/index.tsx index ff4164aa8..50f2dd8cb 100644 --- a/packages/console/src/components/Region/index.tsx +++ b/packages/console/src/components/Region/index.tsx @@ -1,19 +1,31 @@ import classNames from 'classnames'; +import { type ComponentType } from 'react'; import { useTranslation } from 'react-i18next'; +import auFlag from './assets/au.svg?react'; +import euFlag from './assets/eu.svg?react'; +import usFlag from './assets/us.svg?react'; import styles from './index.module.scss'; // TODO: This is a copy from `@logto/cloud-models`, make a SSoT for this later export enum RegionName { EU = 'EU', US = 'US', + AU = 'AU', } -const regionFlagMap = Object.freeze({ - [RegionName.EU]: 'πŸ‡ͺπŸ‡Ί', - [RegionName.US]: 'πŸ‡ΊπŸ‡Έ', +const regionDisplayNameMap = Object.freeze({ + [RegionName.EU]: 'Europe', + [RegionName.US]: 'West US', + [RegionName.AU]: 'Australia', } satisfies Record); +const regionFlagMap = Object.freeze({ + [RegionName.EU]: euFlag, + [RegionName.US]: usFlag, + [RegionName.AU]: auFlag, +} satisfies Record); + type Props = { readonly regionName: RegionName; readonly isComingSoon?: boolean; @@ -22,10 +34,12 @@ type Props = { function Region({ isComingSoon = false, regionName, className }: Props) { const { t } = useTranslation(undefined, { keyPrefix: 'admin_console' }); + const Flag = regionFlagMap[regionName]; return ( - - {regionFlagMap[regionName]} {regionName} + + + {regionDisplayNameMap[regionName]} {isComingSoon && {`(${t('general.coming_soon')})`}} ); diff --git a/packages/core/package.json b/packages/core/package.json index 1fb465941..5a7ef9e87 100644 --- a/packages/core/package.json +++ b/packages/core/package.json @@ -97,7 +97,7 @@ "zod": "^3.23.8" }, "devDependencies": { - "@logto/cloud": "0.2.5-91ab76c", + "@logto/cloud": "0.2.5-1661979", "@silverhand/eslint-config": "6.0.1", "@silverhand/ts-config": "6.0.0", "@types/adm-zip": "^0.5.5", diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 064dd7d27..6b0896837 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -1269,8 +1269,8 @@ importers: version: 3.23.8 devDependencies: '@logto/cloud': - specifier: 0.2.5-582d792 - version: 0.2.5-582d792(zod@3.23.8) + specifier: 0.2.5-1661979 + version: 0.2.5-1661979(zod@3.23.8) '@silverhand/eslint-config': specifier: 6.0.1 version: 6.0.1(eslint@8.57.0)(prettier@3.0.0)(typescript@5.5.3) @@ -2568,8 +2568,8 @@ importers: specifier: ^29.5.0 version: 29.5.0 '@logto/cloud': - specifier: 0.2.5-91ab76c - version: 0.2.5-91ab76c(zod@3.23.8) + specifier: 0.2.5-1661979 + version: 0.2.5-1661979(zod@3.23.8) '@logto/connector-kit': specifier: workspace:^4.0.0 version: link:../toolkit/connector-kit @@ -3064,8 +3064,8 @@ importers: version: 3.23.8 devDependencies: '@logto/cloud': - specifier: 0.2.5-91ab76c - version: 0.2.5-91ab76c(zod@3.23.8) + specifier: 0.2.5-1661979 + version: 0.2.5-1661979(zod@3.23.8) '@silverhand/eslint-config': specifier: 6.0.1 version: 6.0.1(eslint@8.57.0)(prettier@3.0.0)(typescript@5.5.3) @@ -5571,12 +5571,8 @@ packages: '@logto/client@2.7.2': resolution: {integrity: sha512-jsmuDl9QpXfR3uLEMPE67tvYoL5XcjJi+4yGqucYPjd4GH6SUHp3N9skk8C/OyygnKDPLY+ttwD0LaIbpGvn+Q==} - '@logto/cloud@0.2.5-582d792': - resolution: {integrity: sha512-0fIZzqwyjQguTS0a5+XbgVZlGEB/MXIf6pbuBDkHh6JHlMTJ/XH041rWX+e+nMk5N7/Xk2XXS+d2RJUWumnmpw==} - engines: {node: ^20.9.0} - - '@logto/cloud@0.2.5-91ab76c': - resolution: {integrity: sha512-t/ZVrFICVxtqw6zh6/OJ+0VYt+fl+waNz77CdAJkhxC91KFMfojm4hWNrx1qTNSTUzg+gc/2p8cbKC9cH1ngeA==} + '@logto/cloud@0.2.5-1661979': + resolution: {integrity: sha512-CiH6VxaR281cZLWQyI54XUiwSXEnW9rxci6ptz73rS4OWYfIweOWzP3Z30OVLiOslznBfTLuBML8eVelxpG1iQ==} engines: {node: ^20.9.0} '@logto/js@4.1.4': @@ -15244,14 +15240,7 @@ snapshots: camelcase-keys: 7.0.2 jose: 5.6.3 - '@logto/cloud@0.2.5-582d792(zod@3.23.8)': - dependencies: - '@silverhand/essentials': 2.9.1 - '@withtyped/server': 0.14.0(zod@3.23.8) - transitivePeerDependencies: - - zod - - '@logto/cloud@0.2.5-91ab76c(zod@3.23.8)': + '@logto/cloud@0.2.5-1661979(zod@3.23.8)': dependencies: '@silverhand/essentials': 2.9.1 '@withtyped/server': 0.14.0(zod@3.23.8) @@ -15695,10 +15684,10 @@ snapshots: eslint-config-prettier: 9.1.0(eslint@8.57.0) eslint-config-xo: 0.44.0(eslint@8.57.0) eslint-config-xo-typescript: 4.0.0(@typescript-eslint/eslint-plugin@7.7.0(@typescript-eslint/parser@7.7.0(eslint@8.57.0)(typescript@5.5.3))(eslint@8.57.0)(typescript@5.5.3))(@typescript-eslint/parser@7.7.0(eslint@8.57.0)(typescript@5.5.3))(eslint@8.57.0)(typescript@5.5.3) - eslint-import-resolver-typescript: 3.6.1(@typescript-eslint/parser@7.7.0(eslint@8.57.0)(typescript@5.5.3))(eslint-plugin-import@2.29.1)(eslint@8.57.0) + eslint-import-resolver-typescript: 3.6.1(@typescript-eslint/parser@7.7.0(eslint@8.57.0)(typescript@5.5.3))(eslint-plugin-import@2.29.1(@typescript-eslint/parser@7.7.0(eslint@8.57.0)(typescript@5.5.3))(eslint@8.57.0))(eslint@8.57.0) eslint-plugin-consistent-default-export-name: 0.0.15 eslint-plugin-eslint-comments: 3.2.0(eslint@8.57.0) - eslint-plugin-import: 2.29.1(@typescript-eslint/parser@7.7.0(eslint@8.57.0)(typescript@5.5.3))(eslint-import-resolver-typescript@3.6.1)(eslint@8.57.0) + eslint-plugin-import: 2.29.1(@typescript-eslint/parser@7.7.0(eslint@8.57.0)(typescript@5.5.3))(eslint-import-resolver-typescript@3.6.1(@typescript-eslint/parser@7.7.0(eslint@8.57.0)(typescript@5.5.3))(eslint-plugin-import@2.29.1(@typescript-eslint/parser@7.7.0(eslint@8.57.0)(typescript@5.5.3))(eslint@8.57.0))(eslint@8.57.0))(eslint@8.57.0) eslint-plugin-n: 17.2.1(eslint@8.57.0) eslint-plugin-no-use-extend-native: 0.5.0 eslint-plugin-prettier: 5.1.3(eslint-config-prettier@9.1.0(eslint@8.57.0))(eslint@8.57.0)(prettier@3.0.0) @@ -18662,13 +18651,13 @@ snapshots: transitivePeerDependencies: - supports-color - eslint-import-resolver-typescript@3.6.1(@typescript-eslint/parser@7.7.0(eslint@8.57.0)(typescript@5.5.3))(eslint-plugin-import@2.29.1)(eslint@8.57.0): + eslint-import-resolver-typescript@3.6.1(@typescript-eslint/parser@7.7.0(eslint@8.57.0)(typescript@5.5.3))(eslint-plugin-import@2.29.1(@typescript-eslint/parser@7.7.0(eslint@8.57.0)(typescript@5.5.3))(eslint@8.57.0))(eslint@8.57.0): dependencies: debug: 4.3.5 enhanced-resolve: 5.16.0 eslint: 8.57.0 - eslint-module-utils: 2.8.1(@typescript-eslint/parser@7.7.0(eslint@8.57.0)(typescript@5.5.3))(eslint-import-resolver-node@0.3.9)(eslint-import-resolver-typescript@3.6.1(@typescript-eslint/parser@7.7.0(eslint@8.57.0)(typescript@5.5.3))(eslint-plugin-import@2.29.1)(eslint@8.57.0))(eslint@8.57.0) - eslint-plugin-import: 2.29.1(@typescript-eslint/parser@7.7.0(eslint@8.57.0)(typescript@5.5.3))(eslint-import-resolver-typescript@3.6.1)(eslint@8.57.0) + eslint-module-utils: 2.8.1(@typescript-eslint/parser@7.7.0(eslint@8.57.0)(typescript@5.5.3))(eslint-import-resolver-node@0.3.9)(eslint-import-resolver-typescript@3.6.1(@typescript-eslint/parser@7.7.0(eslint@8.57.0)(typescript@5.5.3))(eslint-plugin-import@2.29.1(@typescript-eslint/parser@7.7.0(eslint@8.57.0)(typescript@5.5.3))(eslint@8.57.0))(eslint@8.57.0))(eslint@8.57.0) + eslint-plugin-import: 2.29.1(@typescript-eslint/parser@7.7.0(eslint@8.57.0)(typescript@5.5.3))(eslint-import-resolver-typescript@3.6.1(@typescript-eslint/parser@7.7.0(eslint@8.57.0)(typescript@5.5.3))(eslint-plugin-import@2.29.1(@typescript-eslint/parser@7.7.0(eslint@8.57.0)(typescript@5.5.3))(eslint@8.57.0))(eslint@8.57.0))(eslint@8.57.0) fast-glob: 3.3.2 get-tsconfig: 4.7.3 is-core-module: 2.13.1 @@ -18679,14 +18668,14 @@ snapshots: - eslint-import-resolver-webpack - supports-color - eslint-module-utils@2.8.1(@typescript-eslint/parser@7.7.0(eslint@8.57.0)(typescript@5.5.3))(eslint-import-resolver-node@0.3.9)(eslint-import-resolver-typescript@3.6.1(@typescript-eslint/parser@7.7.0(eslint@8.57.0)(typescript@5.5.3))(eslint-plugin-import@2.29.1)(eslint@8.57.0))(eslint@8.57.0): + eslint-module-utils@2.8.1(@typescript-eslint/parser@7.7.0(eslint@8.57.0)(typescript@5.5.3))(eslint-import-resolver-node@0.3.9)(eslint-import-resolver-typescript@3.6.1(@typescript-eslint/parser@7.7.0(eslint@8.57.0)(typescript@5.5.3))(eslint-plugin-import@2.29.1(@typescript-eslint/parser@7.7.0(eslint@8.57.0)(typescript@5.5.3))(eslint@8.57.0))(eslint@8.57.0))(eslint@8.57.0): dependencies: debug: 3.2.7(supports-color@5.5.0) optionalDependencies: '@typescript-eslint/parser': 7.7.0(eslint@8.57.0)(typescript@5.5.3) eslint: 8.57.0 eslint-import-resolver-node: 0.3.9 - eslint-import-resolver-typescript: 3.6.1(@typescript-eslint/parser@7.7.0(eslint@8.57.0)(typescript@5.5.3))(eslint-plugin-import@2.29.1)(eslint@8.57.0) + eslint-import-resolver-typescript: 3.6.1(@typescript-eslint/parser@7.7.0(eslint@8.57.0)(typescript@5.5.3))(eslint-plugin-import@2.29.1(@typescript-eslint/parser@7.7.0(eslint@8.57.0)(typescript@5.5.3))(eslint@8.57.0))(eslint@8.57.0) transitivePeerDependencies: - supports-color @@ -18708,7 +18697,7 @@ snapshots: eslint: 8.57.0 ignore: 5.3.1 - eslint-plugin-import@2.29.1(@typescript-eslint/parser@7.7.0(eslint@8.57.0)(typescript@5.5.3))(eslint-import-resolver-typescript@3.6.1)(eslint@8.57.0): + eslint-plugin-import@2.29.1(@typescript-eslint/parser@7.7.0(eslint@8.57.0)(typescript@5.5.3))(eslint-import-resolver-typescript@3.6.1(@typescript-eslint/parser@7.7.0(eslint@8.57.0)(typescript@5.5.3))(eslint-plugin-import@2.29.1(@typescript-eslint/parser@7.7.0(eslint@8.57.0)(typescript@5.5.3))(eslint@8.57.0))(eslint@8.57.0))(eslint@8.57.0): dependencies: array-includes: 3.1.8 array.prototype.findlastindex: 1.2.5 @@ -18718,7 +18707,7 @@ snapshots: doctrine: 2.1.0 eslint: 8.57.0 eslint-import-resolver-node: 0.3.9 - eslint-module-utils: 2.8.1(@typescript-eslint/parser@7.7.0(eslint@8.57.0)(typescript@5.5.3))(eslint-import-resolver-node@0.3.9)(eslint-import-resolver-typescript@3.6.1(@typescript-eslint/parser@7.7.0(eslint@8.57.0)(typescript@5.5.3))(eslint-plugin-import@2.29.1)(eslint@8.57.0))(eslint@8.57.0) + eslint-module-utils: 2.8.1(@typescript-eslint/parser@7.7.0(eslint@8.57.0)(typescript@5.5.3))(eslint-import-resolver-node@0.3.9)(eslint-import-resolver-typescript@3.6.1(@typescript-eslint/parser@7.7.0(eslint@8.57.0)(typescript@5.5.3))(eslint-plugin-import@2.29.1(@typescript-eslint/parser@7.7.0(eslint@8.57.0)(typescript@5.5.3))(eslint@8.57.0))(eslint@8.57.0))(eslint@8.57.0) hasown: 2.0.2 is-core-module: 2.13.1 is-glob: 4.0.3