-
-
Notifications
You must be signed in to change notification settings - Fork 492
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
refactor(console): setup m2m roles after creating m2m app
- Loading branch information
Showing
23 changed files
with
266 additions
and
48 deletions.
There are no files selected for viewing
50 changes: 50 additions & 0 deletions
50
packages/console/src/pages/Applications/components/ApplicationCreation/index.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
import { ApplicationType, RoleType, type Application } from '@logto/schemas'; | ||
import { useCallback, useState } from 'react'; | ||
|
||
import { isDevFeaturesEnabled } from '@/consts/env'; | ||
import AssignToRoleModal from '@/pages/Roles/components/AssignToRoleModal'; | ||
|
||
import CreateForm, { type Props as CreateApplicationFormProps } from '../CreateForm'; | ||
|
||
/** | ||
* The component for handling application creation (including creating an application and setup its permissions if needed). | ||
*/ | ||
function ApplicationCreation({ onClose, ...reset }: CreateApplicationFormProps) { | ||
const [createdMachineToMachineApplication, setCreatedMachineToMachineApplication] = | ||
useState<Application>(); | ||
|
||
const closeHandler = useCallback( | ||
(createdApp?: Application) => { | ||
// Todo @xiaoyijun remove dev feature flag | ||
if (isDevFeaturesEnabled && createdApp?.type === ApplicationType.MachineToMachine) { | ||
setCreatedMachineToMachineApplication(createdApp); | ||
return; | ||
} | ||
|
||
onClose?.(createdApp); | ||
}, | ||
[onClose] | ||
); | ||
|
||
if (createdMachineToMachineApplication) { | ||
return ( | ||
<AssignToRoleModal | ||
isSkippable | ||
isMachineToMachineRoleCreationHintVisible | ||
entity={createdMachineToMachineApplication} | ||
type={RoleType.MachineToMachine} | ||
modalTextOverrides={{ | ||
title: 'applications.m2m_role_assignment.title', | ||
subtitle: 'applications.m2m_role_assignment.subtitle', | ||
}} | ||
onClose={() => { | ||
onClose?.(createdMachineToMachineApplication); | ||
}} | ||
/> | ||
); | ||
} | ||
|
||
return <CreateForm {...reset} onClose={closeHandler} />; | ||
} | ||
|
||
export default ApplicationCreation; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
6 changes: 6 additions & 0 deletions
6
packages/console/src/pages/Roles/components/AssignToRoleModal/index.module.scss
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
@use '@/scss/underscore' as _; | ||
|
||
.hint { | ||
margin-top: _.unit(2); | ||
font: var(--font-body-2); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.