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,8 +160,16 @@ function CreateForm({
|
||||||
onChange={onChange}
|
onChange={onChange}
|
||||||
>
|
>
|
||||||
{Object.values(ApplicationType)
|
{Object.values(ApplicationType)
|
||||||
// Other application types (e.g. "Protected") should not show up in the creation modal
|
.filter(
|
||||||
.filter((value): value is Exclude<ApplicationType, ApplicationType.SAML> =>
|
(
|
||||||
|
value
|
||||||
|
): value is Extract<
|
||||||
|
ApplicationType,
|
||||||
|
| ApplicationType.Native
|
||||||
|
| ApplicationType.SPA
|
||||||
|
| ApplicationType.Traditional
|
||||||
|
| ApplicationType.MachineToMachine
|
||||||
|
> =>
|
||||||
[
|
[
|
||||||
ApplicationType.Native,
|
ApplicationType.Native,
|
||||||
ApplicationType.SPA,
|
ApplicationType.SPA,
|
||||||
|
|
|
@ -16,6 +16,7 @@ type Props = {
|
||||||
|
|
||||||
const getIcon = (type: ApplicationType, isLightMode: boolean, isThirdParty?: boolean) => {
|
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.
|
// 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) {
|
if (isThirdParty ?? type === ApplicationType.SAML) {
|
||||||
return isLightMode ? thirdPartyApplicationIcon : thirdPartyApplicationIconDark;
|
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.
|
// 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) {
|
if (target === ApplicationType.SAML || isThirdParty) {
|
||||||
return {
|
return {
|
||||||
...accumulated,
|
...accumulated,
|
||||||
|
|
|
@ -22,6 +22,7 @@ function ApplicationPreview({ data: { id, name, isThirdParty, type } }: Props) {
|
||||||
title={name}
|
title={name}
|
||||||
subtitle={
|
subtitle={
|
||||||
// We have ensured that SAML applications are always third party in DB schema, we use `||` here to make TypeScript happy.
|
// 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
|
isThirdParty || type === ApplicationType.SAML
|
||||||
? t(`${applicationTypeI18nKey.thirdParty}.title`)
|
? t(`${applicationTypeI18nKey.thirdParty}.title`)
|
||||||
: t(`${applicationTypeI18nKey[type]}.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';
|
import TraditionalWebApp from '@/assets/icons/traditional-web-app.svg?react';
|
||||||
|
|
||||||
type ApplicationIconMap = {
|
type ApplicationIconMap = {
|
||||||
// TODO: Add SAML icon when we support SAML application in console
|
// TODO: @darcy Add SAML icon when we support SAML application in console
|
||||||
[key in Exclude<ApplicationType, ApplicationType.SAML>]: SvgComponent;
|
[key in Extract<
|
||||||
|
ApplicationType,
|
||||||
|
| ApplicationType.Native
|
||||||
|
| ApplicationType.SPA
|
||||||
|
| ApplicationType.Traditional
|
||||||
|
| ApplicationType.MachineToMachine
|
||||||
|
| ApplicationType.Protected
|
||||||
|
>]: SvgComponent;
|
||||||
};
|
};
|
||||||
|
|
||||||
export const lightModeApplicationIconMap: ApplicationIconMap = Object.freeze({
|
export const lightModeApplicationIconMap: ApplicationIconMap = Object.freeze({
|
||||||
|
|
|
@ -124,6 +124,7 @@ function ApplicationDetailsContent({ data, secrets, oidcConfig, onApplicationUpd
|
||||||
title={data.name}
|
title={data.name}
|
||||||
primaryTag={
|
primaryTag={
|
||||||
// We have ensured that SAML applications are always third party in DB schema, we use `||` here to make TypeScript happy.
|
// 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
|
data.isThirdParty || data.type === ApplicationType.SAML
|
||||||
? t(`${applicationTypeI18nKey.thirdParty}.title`)
|
? t(`${applicationTypeI18nKey.thirdParty}.title`)
|
||||||
: t(`${applicationTypeI18nKey[data.type]}.title`)
|
: t(`${applicationTypeI18nKey[data.type]}.title`)
|
||||||
|
|
|
@ -179,14 +179,15 @@ function ConfigForm({
|
||||||
)}
|
)}
|
||||||
options={applications
|
options={applications
|
||||||
.filter(
|
.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
|
||||||
): application is Exclude<Application, 'type'> & {
|
): application is Omit<Application, 'type'> & {
|
||||||
type: Extract<ApplicationType, 'SPA' | 'Traditional'>;
|
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) => ({
|
.map((application) => ({
|
||||||
value: application.id,
|
value: application.id,
|
||||||
|
|
|
@ -346,6 +346,11 @@ export default function applicationRoutes<T extends ManagementApiRouter>(
|
||||||
async (ctx, next) => {
|
async (ctx, next) => {
|
||||||
const { id } = ctx.guard.params;
|
const { id } = ctx.guard.params;
|
||||||
const { type, protectedAppMetadata } = await queries.applications.findApplicationById(id);
|
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) {
|
if (type === ApplicationType.Protected && protectedAppMetadata) {
|
||||||
assertThat(
|
assertThat(
|
||||||
!protectedAppMetadata.customDomains || protectedAppMetadata.customDomains.length === 0,
|
!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), {
|
await expectRejects(createApplication('test-create-saml-app', ApplicationType.SAML), {
|
||||||
code: 'application.use_saml_app_api',
|
code: 'application.use_saml_app_api',
|
||||||
status: 400,
|
status: 400,
|
||||||
|
|
|
@ -6,4 +6,6 @@ export const hasSecrets = (type: ApplicationType) =>
|
||||||
ApplicationType.MachineToMachine,
|
ApplicationType.MachineToMachine,
|
||||||
ApplicationType.Protected,
|
ApplicationType.Protected,
|
||||||
ApplicationType.Traditional,
|
ApplicationType.Traditional,
|
||||||
|
// SAML applications are used as traditional web applications.
|
||||||
|
ApplicationType.SAML,
|
||||||
].includes(type);
|
].includes(type);
|
||||||
|
|
Loading…
Reference in a new issue