mirror of
https://github.com/logto-io/logto.git
synced 2024-12-16 20:26:19 -05:00
chore: update code
This commit is contained in:
parent
1a431572c0
commit
e47545a7bb
10 changed files with 43 additions and 16 deletions
|
@ -160,14 +160,22 @@ function CreateForm({
|
|||
onChange={onChange}
|
||||
>
|
||||
{Object.values(ApplicationType)
|
||||
// Other application types (e.g. "Protected") should not show up in the creation modal
|
||||
.filter((value): value is Exclude<ApplicationType, ApplicationType.SAML> =>
|
||||
[
|
||||
ApplicationType.Native,
|
||||
ApplicationType.SPA,
|
||||
ApplicationType.Traditional,
|
||||
ApplicationType.MachineToMachine,
|
||||
].includes(value)
|
||||
.filter(
|
||||
(
|
||||
value
|
||||
): value is Extract<
|
||||
ApplicationType,
|
||||
| ApplicationType.Native
|
||||
| ApplicationType.SPA
|
||||
| ApplicationType.Traditional
|
||||
| ApplicationType.MachineToMachine
|
||||
> =>
|
||||
[
|
||||
ApplicationType.Native,
|
||||
ApplicationType.SPA,
|
||||
ApplicationType.Traditional,
|
||||
ApplicationType.MachineToMachine,
|
||||
].includes(value)
|
||||
)
|
||||
.map((type) => (
|
||||
<Radio
|
||||
|
|
|
@ -16,6 +16,7 @@ type Props = {
|
|||
|
||||
const getIcon = (type: ApplicationType, isLightMode: boolean, isThirdParty?: boolean) => {
|
||||
// We have ensured that SAML applications are always third party in DB schema, we use `??` here to make TypeScript happy.
|
||||
// TODO: @darcy fix this when SAML application <Icon /> is ready
|
||||
if (isThirdParty ?? type === ApplicationType.SAML) {
|
||||
return isLightMode ? thirdPartyApplicationIcon : thirdPartyApplicationIconDark;
|
||||
}
|
||||
|
|
|
@ -100,6 +100,7 @@ export const useAppGuideMetadata = (): {
|
|||
}
|
||||
|
||||
// We have ensured that SAML applications are always third party in DB schema, we use `||` here to make TypeScript happy.
|
||||
// TODO: @darcy fix this when SAML third-party app guide is ready
|
||||
if (target === ApplicationType.SAML || isThirdParty) {
|
||||
return {
|
||||
...accumulated,
|
||||
|
|
|
@ -22,6 +22,7 @@ function ApplicationPreview({ data: { id, name, isThirdParty, type } }: Props) {
|
|||
title={name}
|
||||
subtitle={
|
||||
// We have ensured that SAML applications are always third party in DB schema, we use `||` here to make TypeScript happy.
|
||||
// TODO: @darcy fix this when SAML app preview is ready
|
||||
isThirdParty || type === ApplicationType.SAML
|
||||
? t(`${applicationTypeI18nKey.thirdParty}.title`)
|
||||
: t(`${applicationTypeI18nKey[type]}.title`)
|
||||
|
|
|
@ -12,8 +12,15 @@ import TraditionalWebAppDark from '@/assets/icons/traditional-web-app-dark.svg?r
|
|||
import TraditionalWebApp from '@/assets/icons/traditional-web-app.svg?react';
|
||||
|
||||
type ApplicationIconMap = {
|
||||
// TODO: Add SAML icon when we support SAML application in console
|
||||
[key in Exclude<ApplicationType, ApplicationType.SAML>]: SvgComponent;
|
||||
// TODO: @darcy Add SAML icon when we support SAML application in console
|
||||
[key in Extract<
|
||||
ApplicationType,
|
||||
| ApplicationType.Native
|
||||
| ApplicationType.SPA
|
||||
| ApplicationType.Traditional
|
||||
| ApplicationType.MachineToMachine
|
||||
| ApplicationType.Protected
|
||||
>]: SvgComponent;
|
||||
};
|
||||
|
||||
export const lightModeApplicationIconMap: ApplicationIconMap = Object.freeze({
|
||||
|
|
|
@ -124,6 +124,7 @@ function ApplicationDetailsContent({ data, secrets, oidcConfig, onApplicationUpd
|
|||
title={data.name}
|
||||
primaryTag={
|
||||
// We have ensured that SAML applications are always third party in DB schema, we use `||` here to make TypeScript happy.
|
||||
// TODO: @darcy fix this when we add SAML apps details page
|
||||
data.isThirdParty || data.type === ApplicationType.SAML
|
||||
? t(`${applicationTypeI18nKey.thirdParty}.title`)
|
||||
: t(`${applicationTypeI18nKey[data.type]}.title`)
|
||||
|
|
|
@ -179,14 +179,15 @@ function ConfigForm({
|
|||
)}
|
||||
options={applications
|
||||
.filter(
|
||||
// See definition of `applicationsSearchUrl`, there is only non-third party SPA/Traditional applications here, and SAML applications are always third party secured by DB schema, we need to manually exclude other application types here to make TypeScript happy.
|
||||
(
|
||||
application
|
||||
): application is Exclude<Application, 'type'> & {
|
||||
type: Extract<ApplicationType, 'SPA' | 'Traditional'>;
|
||||
): application is Omit<Application, 'type'> & {
|
||||
type: Exclude<ApplicationType, ApplicationType.SAML>;
|
||||
} =>
|
||||
application.type === ApplicationType.SPA ||
|
||||
application.type === ApplicationType.Traditional
|
||||
/**
|
||||
* See definition of `applicationsSearchUrl`, there is only non-third party SPA/Traditional applications here, and SAML applications are always third party secured by DB schema, we need to manually exclude other application types here to make TypeScript happy.
|
||||
*/
|
||||
application.type !== ApplicationType.SAML
|
||||
)
|
||||
.map((application) => ({
|
||||
value: application.id,
|
||||
|
|
|
@ -346,6 +346,11 @@ export default function applicationRoutes<T extends ManagementApiRouter>(
|
|||
async (ctx, next) => {
|
||||
const { id } = ctx.guard.params;
|
||||
const { type, protectedAppMetadata } = await queries.applications.findApplicationById(id);
|
||||
|
||||
if (type === ApplicationType.SAML) {
|
||||
throw new RequestError('application.use_saml_app_api');
|
||||
}
|
||||
|
||||
if (type === ApplicationType.Protected && protectedAppMetadata) {
|
||||
assertThat(
|
||||
!protectedAppMetadata.customDomains || protectedAppMetadata.customDomains.length === 0,
|
||||
|
|
|
@ -35,7 +35,7 @@ describe('application APIs', () => {
|
|||
);
|
||||
});
|
||||
|
||||
it('should throw error when creating a non-third party SAML application', async () => {
|
||||
it('should throw error when creating a SAML application', async () => {
|
||||
await expectRejects(createApplication('test-create-saml-app', ApplicationType.SAML), {
|
||||
code: 'application.use_saml_app_api',
|
||||
status: 400,
|
||||
|
|
|
@ -6,4 +6,6 @@ export const hasSecrets = (type: ApplicationType) =>
|
|||
ApplicationType.MachineToMachine,
|
||||
ApplicationType.Protected,
|
||||
ApplicationType.Traditional,
|
||||
// SAML applications are used as traditional web applications.
|
||||
ApplicationType.SAML,
|
||||
].includes(type);
|
||||
|
|
Loading…
Reference in a new issue