From cd9c6978a35d9fc3a571c7bd56c972939c49a9b5 Mon Sep 17 00:00:00 2001 From: Gao Sun Date: Wed, 21 Sep 2022 13:06:56 +0800 Subject: [PATCH] feat(core): machine to machine apps --- packages/console/src/consts/applications.ts | 8 +- .../components/AdvancedSettings.tsx | 11 ++ .../components/Settings.tsx | 186 +++++++++--------- .../src/pages/ApplicationDetails/index.tsx | 19 +- .../Applications/components/Guide/index.tsx | 16 +- packages/console/src/types/applications.ts | 2 + packages/core/src/__mocks__/index.ts | 1 + packages/core/src/oidc/adapter.test.ts | 6 +- packages/core/src/oidc/adapter.ts | 13 +- packages/core/src/oidc/init.ts | 13 +- packages/core/src/oidc/utils.test.ts | 32 ++- packages/core/src/oidc/utils.ts | 32 ++- .../admin-console/application-details.ts | 3 +- .../translation/admin-console/applications.ts | 5 + .../admin-console/application-details.ts | 3 +- .../translation/admin-console/applications.ts | 6 + .../admin-console/application-details.ts | 1 + .../translation/admin-console/applications.ts | 6 + .../admin-console/application-details.ts | 1 + .../translation/admin-console/applications.ts | 6 + .../admin-console/application-details.ts | 1 + .../translation/admin-console/applications.ts | 6 + .../admin-console/application-details.ts | 3 +- .../translation/admin-console/applications.ts | 6 + packages/schemas/src/types/oidc-config.ts | 1 + packages/schemas/tables/applications.sql | 3 +- 26 files changed, 251 insertions(+), 139 deletions(-) diff --git a/packages/console/src/consts/applications.ts b/packages/console/src/consts/applications.ts index bd913ad9a..dbf80ec03 100644 --- a/packages/console/src/consts/applications.ts +++ b/packages/console/src/consts/applications.ts @@ -7,12 +7,6 @@ import SinglePageApp from '@/assets/images/single-page-app.svg'; import TraditionalWebAppDark from '@/assets/images/traditional-web-app-dark.svg'; import TraditionalWebApp from '@/assets/images/traditional-web-app.svg'; -export const applicationTypeI18nKey = Object.freeze({ - [ApplicationType.Native]: 'applications.type.native', - [ApplicationType.SPA]: 'applications.type.spa', - [ApplicationType.Traditional]: 'applications.type.traditional', -} as const); - type ApplicationIconMap = { [key in ApplicationType]: SvgComponent; }; @@ -21,10 +15,12 @@ export const lightModeApplicationIconMap: ApplicationIconMap = Object.freeze({ [ApplicationType.Native]: NativeApp, [ApplicationType.SPA]: SinglePageApp, [ApplicationType.Traditional]: TraditionalWebApp, + [ApplicationType.MachineToMachine]: TraditionalWebApp, } as const); export const darkModeApplicationIconMap: ApplicationIconMap = Object.freeze({ [ApplicationType.Native]: NativeAppDark, [ApplicationType.SPA]: SinglePageAppDark, [ApplicationType.Traditional]: TraditionalWebAppDark, + [ApplicationType.MachineToMachine]: TraditionalWebAppDark, } as const); diff --git a/packages/console/src/pages/ApplicationDetails/components/AdvancedSettings.tsx b/packages/console/src/pages/ApplicationDetails/components/AdvancedSettings.tsx index 84d230465..e24ce1695 100644 --- a/packages/console/src/pages/ApplicationDetails/components/AdvancedSettings.tsx +++ b/packages/console/src/pages/ApplicationDetails/components/AdvancedSettings.tsx @@ -30,6 +30,17 @@ const AdvancedSettings = ({ oidcConfig, defaultData, isDeleted }: Props) => { return ( <> + + + - {applicationType === ApplicationType.Traditional && ( + + + + {[ApplicationType.Traditional, ApplicationType.MachineToMachine].includes( + applicationType + ) && ( )} - - - - - ( - - )} - /> - - - ( - - )} - /> - - - !value || uriOriginValidator(value), - message: t('errors.invalid_origin_format'), - }, - }), - }} - render={({ field: { onChange, value }, fieldState: { error } }) => ( - - )} - /> - + tooltip="application_details.redirect_uri_tip" + > + ( + + )} + /> + + )} + {applicationType !== ApplicationType.MachineToMachine && ( + + ( + + )} + /> + + )} + {applicationType !== ApplicationType.MachineToMachine && ( + + !value || uriOriginValidator(value), + message: t('errors.invalid_origin_format'), + }, + }), + }} + render={({ field: { onChange, value }, fieldState: { error } }) => ( + + )} + /> + + )} ); diff --git a/packages/console/src/pages/ApplicationDetails/index.tsx b/packages/console/src/pages/ApplicationDetails/index.tsx index 118962ed6..41eaa2593 100644 --- a/packages/console/src/pages/ApplicationDetails/index.tsx +++ b/packages/console/src/pages/ApplicationDetails/index.tsx @@ -1,4 +1,4 @@ -import { Application, SnakeCaseOidcConfig } from '@logto/schemas'; +import { Application, ApplicationType, SnakeCaseOidcConfig } from '@logto/schemas'; import classNames from 'classnames'; import { useEffect, useState } from 'react'; import { FormProvider, useForm } from 'react-hook-form'; @@ -144,13 +144,16 @@ const ApplicationDetails = () => {
-