-
Notifications
You must be signed in to change notification settings - Fork 9
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
16 changed files
with
198 additions
and
83 deletions.
There are no files selected for viewing
19 changes: 19 additions & 0 deletions
19
src/management-system-v2/app/(dashboard)/processes/[processId]/loading.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,19 @@ | ||
import Content from '@/components/content'; | ||
import { Space, Spin } from 'antd'; | ||
import { LoadingOutlined } from '@ant-design/icons'; | ||
|
||
const ProcessSkeleton = () => { | ||
return ( | ||
<Content> | ||
<Space | ||
direction="vertical" | ||
size="large" | ||
style={{ display: 'flex', textAlign: 'center', marginTop: '2rem' }} | ||
> | ||
<Spin indicator={<LoadingOutlined style={{ fontSize: 24 }} spin />} /> | ||
</Space> | ||
</Content> | ||
); | ||
}; | ||
|
||
export default ProcessSkeleton; |
46 changes: 43 additions & 3 deletions
46
src/management-system-v2/app/(dashboard)/processes/[processId]/page.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 |
---|---|---|
@@ -1,11 +1,51 @@ | ||
import Auth from '@/components/auth'; | ||
import Processes from './_page'; | ||
import Auth, { getCurrentUser } from '@/components/auth'; | ||
import Wrapper from './wrapper'; | ||
import styles from './page.module.scss'; | ||
import { FC, useEffect, useState } from 'react'; | ||
import { useParams, usePathname, useRouter, useSearchParams } from 'next/navigation'; | ||
import Modeler from '@/components/modeler'; | ||
import cn from 'classnames'; | ||
import { getProcess, getProcessVersionBpmn, getProcesses } from '@/lib/data/legacy/process'; | ||
import { toCaslResource } from '@/lib/ability/caslAbility'; | ||
|
||
type ProcessProps = { | ||
params: { processId: string }; | ||
searchParams: { version?: string }; | ||
}; | ||
|
||
const Process = async ({ params: { processId }, searchParams }: ProcessProps) => { | ||
// TODO: check if params is correct after fix release. And maybe don't need | ||
// refresh in processes.tsx anymore? | ||
console.log('processId', processId); | ||
console.log('query', searchParams); | ||
const selectedVersionId = searchParams.version ? searchParams.version : undefined; | ||
const { ability } = await getCurrentUser(); | ||
// Only load bpmn if no version selected. | ||
const process = await getProcess(processId, !selectedVersionId); | ||
const processes = await getProcesses(ability); | ||
|
||
if (!ability.can('view', toCaslResource('Process', process))) { | ||
throw new Error('Forbidden.'); | ||
} | ||
|
||
const selectedVersionBpmn = selectedVersionId | ||
? await getProcessVersionBpmn(processId, selectedVersionId) | ||
: process.bpmn; | ||
|
||
// Since the user is able to minimize and close the page, everyting is in a | ||
// client component from here. | ||
return ( | ||
<Wrapper processName={process.definitionName} versions={process.versions}> | ||
<Modeler className={styles.Modeler} processBpmn={selectedVersionBpmn} /> | ||
</Wrapper> | ||
); | ||
}; | ||
|
||
export default Auth( | ||
{ | ||
action: 'view', | ||
resource: 'Process', | ||
fallbackRedirect: '/processes', | ||
}, | ||
Processes, | ||
Process, | ||
); |
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
2 changes: 1 addition & 1 deletion
2
...-v2/app/(dashboard)/processes/loading.tsx → ...v2/app/(dashboard)/processes/_loading.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
21 changes: 21 additions & 0 deletions
21
src/management-system-v2/app/api/auth/[...nextauth]/auth-options.ts
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,21 @@ | ||
import { AuthOptions } from 'next-auth'; | ||
import { User } from '@/types/next-auth'; | ||
import { randomUUID } from 'crypto'; | ||
|
||
export const nextAuthOptions: AuthOptions = { | ||
secret: process.env.NEXTAUTH_SECRET, | ||
providers: [], | ||
callbacks: { | ||
async jwt({ token, user, trigger }) { | ||
if (trigger === 'signIn') token.csrfToken = randomUUID(); | ||
if (user) token.user = user as User; | ||
return token; | ||
}, | ||
session(args) { | ||
const { session, token } = args; | ||
if (token.user) session.user = token.user; | ||
session.csrfToken = token.csrfToken; | ||
return session; | ||
}, | ||
}, | ||
}; |
22 changes: 1 addition & 21 deletions
22
src/management-system-v2/app/api/auth/[...nextauth]/route.ts
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.