Skip to content

Commit

Permalink
Merge pull request #6594 from logto-io/gao-au-region
Browse files Browse the repository at this point in the history
feat(console): au region
  • Loading branch information
gao-sun authored Sep 19, 2024
2 parents 43d83e8 + 3c9b1ea commit 8e5127f
Show file tree
Hide file tree
Showing 11 changed files with 384 additions and 51 deletions.
2 changes: 1 addition & 1 deletion packages/connectors/connector-logto-email/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
2 changes: 1 addition & 1 deletion packages/console/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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.1",
Expand Down
49 changes: 28 additions & 21 deletions packages/console/src/components/CreateTenantModal/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand All @@ -18,6 +19,7 @@ import RadioGroup, { Radio } from '@/ds-components/RadioGroup';
import TextInput from '@/ds-components/TextInput';
import useTheme from '@/hooks/use-theme';
import modalStyles from '@/scss/modal.module.scss';
import { trySubmitSafe } from '@/utils/form';

import EnvTagOptionContent from './EnvTagOptionContent';
import SelectTenantPlanModal from './SelectTenantPlanModal';
Expand Down Expand Up @@ -56,16 +58,18 @@ function CreateTenantModal({ isOpen, onClose }: Props) {
};
const { t } = useTranslation(undefined, { keyPrefix: 'admin_console' });

const onCreateClick = handleSubmit(async (data: CreateTenantData) => {
const { tag } = data;
if (tag === TenantTag.Development) {
await createTenant(data);
toast.success(t('tenants.create_modal.tenant_created'));
return;
}
const onCreateClick = handleSubmit(
trySubmitSafe(async (data: CreateTenantData) => {
const { tag } = data;
if (tag === TenantTag.Development) {
await createTenant(data);
toast.success(t('tenants.create_modal.tenant_created'));
return;
}

setTenantData(data);
});
setTenantData(data);
})
);

return (
<Modal
Expand Down Expand Up @@ -122,18 +126,21 @@ function CreateTenantModal({ isOpen, onClose }: Props) {
render={({ field: { onChange, value, name } }) => (
<RadioGroup type="small" name={name} value={value} onChange={onChange}>
{/* 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) => (
<Radio
key={region}
title={
<DangerousRaw>
<Region regionName={region} />
</DangerousRaw>
}
value={region}
isDisabled={isSubmitting}
/>
))}
{[RegionName.EU, RegionName.US, RegionName.AU].map(
(region) =>
(isDevFeaturesEnabled || region !== RegionName.AU) && (
<Radio
key={region}
title={
<DangerousRaw>
<Region regionName={region} />
</DangerousRaw>
}
value={region}
isDisabled={isSubmitting}
/>
)
)}
</RadioGroup>
)}
/>
Expand Down
23 changes: 23 additions & 0 deletions packages/console/src/components/Region/assets/au.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
131 changes: 131 additions & 0 deletions packages/console/src/components/Region/assets/eu.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading

0 comments on commit 8e5127f

Please sign in to comment.