Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Ms2 copy/edit shared process with artifacts #392

Merged
merged 109 commits into from
Dec 9, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
109 commits
Select commit Hold shift + click to select a range
ff3a551
initial configuration prisma
anishsapkota Jun 9, 2024
9a30f03
add: basic CRUD for user & process
anishsapkota Jun 9, 2024
91e3e04
Merge branch 'main' into ms-persistance-layer
OhKai Jun 16, 2024
8a7db6a
Merge remote-tracking branch 'origin' into ms-persistance-layer
anishsapkota Jun 20, 2024
aa7b69d
adjusted schema
anishsapkota Jun 20, 2024
0515b5e
itr 1 user fs --to--> user db
anishsapkota Jun 20, 2024
99176b5
squashed migrations
anishsapkota Jun 20, 2024
aee86a3
delete workspace -> delete all related to workspace
anishsapkota Jun 21, 2024
7c8f043
itr 1: environments.ts fs -> environments.ts db
anishsapkota Jun 21, 2024
7dd2fb2
itr 1: membership.ts fs -> db
anishsapkota Jun 21, 2024
2fcd16d
changed user.guest -> user.isGuest
anishsapkota Jun 21, 2024
31876dc
update: organization -> isOrganization
anishsapkota Jun 21, 2024
de561db
itr1: role , roleMapping fs -> db
anishsapkota Jun 23, 2024
b87e36f
itr1: folder fs -> db
anishsapkota Jun 23, 2024
4e40d76
schema update
anishsapkota Jun 23, 2024
6ec1d37
fix: folder not optional
anishsapkota Jun 23, 2024
5a1b150
update: renamed attributed to follow convention
anishsapkota Jun 23, 2024
8736bdc
itr1: process fs -> db
anishsapkota Jun 23, 2024
f42eed5
remove: old migrations
anishsapkota Jun 23, 2024
558e954
updated: added await at necessary locs
anishsapkota Jun 30, 2024
be30277
model update: workspace -> space
anishsapkota Jun 30, 2024
d787bc4
attribute name adjusted
anishsapkota Jun 30, 2024
7aea81b
add async await at necess. pos
anishsapkota Jun 30, 2024
048d401
adjusted auth to use db
anishsapkota Jun 30, 2024
4676d77
convert returned bigInt into numbers
anishsapkota Jun 30, 2024
38636ea
minor fixes
anishsapkota Jun 30, 2024
e69238a
schema adjustments
anishsapkota Jun 30, 2024
8d0f7b0
merge w. main
anishsapkota Jun 30, 2024
c15296c
add : contact num field
anishsapkota Jun 30, 2024
94a3ade
merge w. main
anishsapkota Jun 30, 2024
359548a
prettier fix
anishsapkota Jun 30, 2024
afd7e4b
fix: build error
anishsapkota Jun 30, 2024
3af71ea
fix: type errors
anishsapkota Jul 7, 2024
9d7343c
migrated: systemAdmin func -> db
anishsapkota Jul 7, 2024
adda7b2
Merge remote-tracking branch 'origin/main' into ms-persistance-layer
anishsapkota Jul 7, 2024
73bf8ab
fix: after merge errors
anishsapkota Jul 7, 2024
0ac1211
Merge remote-tracking branch 'origin/main' into ms-persistance-layer
anishsapkota Jul 20, 2024
b643045
add: filemanager for GCP bucket and fs
anishsapkota Jul 20, 2024
af71e75
add: JSDoc
anishsapkota Jul 20, 2024
b1f0bc9
fix: build error
anishsapkota Jul 20, 2024
5be297c
fix: build error
anishsapkota Jul 20, 2024
43b53ee
update: schema
anishsapkota Jul 20, 2024
1e0a50c
Merge remote-tracking branch 'origin/ms-persistance-layer' into ms2-f…
anishsapkota Jul 22, 2024
4f4f837
minor changes
anishsapkota Jul 28, 2024
03eadbc
adjusted schema
anishsapkota Jul 28, 2024
6a0a943
Merge remote-tracking branch 'origin/main' into ms-persistance-layer
anishsapkota Jul 28, 2024
ac63b91
fix: added await to async fun
anishsapkota Jul 28, 2024
db8a033
fix: build error after merge
anishsapkota Jul 28, 2024
25363f2
Merge remote-tracking branch 'origin/ms-persistance-layer' into ms2-f…
anishsapkota Jul 28, 2024
36bde00
turn off feature flag
anishsapkota Jul 29, 2024
6647499
turn off flag
anishsapkota Jul 29, 2024
8fa7a5b
remove unused
anishsapkota Jul 29, 2024
0d75198
Merge remote-tracking branch 'origin/main' into ms-persistance-layer
anishsapkota Jul 30, 2024
21772e2
fix: after merge build error
anishsapkota Jul 30, 2024
5d79823
Merge branch 'main' into ms-persistance-layer
OhKai Aug 3, 2024
f0ce7ab
Merge remote-tracking branch 'origin/ms-persistance-layer' into ms2-f…
anishsapkota Aug 4, 2024
b1c2a6e
impl: useFileManager hook
anishsapkota Aug 10, 2024
ab96349
.
anishsapkota Aug 10, 2024
37ebcfa
Merge remote-tracking branch 'origin/main' into ms2-file-manage
anishsapkota Aug 10, 2024
a185c60
update: image upload func using useFileMangager hook
anishsapkota Aug 10, 2024
cc3ba51
delete: test page
anishsapkota Aug 10, 2024
4ac435c
added save filepath in DB
anishsapkota Aug 12, 2024
cc973ff
turn off feature flag
anishsapkota Aug 12, 2024
8d0fb56
make owner optional in Space Model to allow user guests
anishsapkota Aug 12, 2024
5bf60d5
added CRON job to schedule sweeper
anishsapkota Aug 18, 2024
7c84fa1
merge w. main
anishsapkota Aug 18, 2024
dd5c9b9
fix: build error after merge
anishsapkota Aug 19, 2024
9715353
added redo event listener to modeler
anishsapkota Aug 19, 2024
18e3d6f
fix: after merge
anishsapkota Aug 19, 2024
91d0088
fix: build errors
anishsapkota Aug 19, 2024
b818f55
minor changes requested in review
anishsapkota Aug 23, 2024
8d6af55
moved db related code to /data/db, using dynamic import with feat flag
anishsapkota Aug 25, 2024
b88147a
fix: build error
anishsapkota Aug 25, 2024
f7a0bf9
added dtos and fixed type inference
anishsapkota Sep 1, 2024
3fe413e
Merge remote-tracking branch 'origin/main' into ms-persistance-layer
anishsapkota Sep 1, 2024
ad9d49b
Merge remote-tracking branch 'origin' into ms-persistance-layer
anishsapkota Sep 1, 2024
7660862
Merge remote-tracking branch 'origin/ms-persistance-layer' into ms2-f…
anishsapkota Sep 1, 2024
7e381d0
remove dynamic import from DTOs.ts
anishsapkota Sep 2, 2024
4bc3e18
useFM, for orgaLogo, process-doc page
anishsapkota Sep 8, 2024
bf850e1
fix:merge confits
anishsapkota Sep 8, 2024
6a342eb
Merge remote-tracking branch 'origin/ms-persistance-layer' into ms2-f…
anishsapkota Sep 8, 2024
69e7117
fix: build error
anishsapkota Sep 8, 2024
7709cd4
fix: createVersion db erro
anishsapkota Sep 8, 2024
e738b1f
Merge remote-tracking branch 'origin/ms-persistance-layer' into ms2-f…
anishsapkota Sep 8, 2024
35691f0
fix: regression, added awaits, fixed roles
anishsapkota Sep 9, 2024
d307eba
addressed requested changes + schema adjusted + minor bug fixes
anishsapkota Sep 15, 2024
0038d49
Merge remote-tracking branch 'origin/main' into ms-persistance-layer
anishsapkota Sep 15, 2024
570c789
Merge remote-tracking branch 'origin/ms-persistance-layer' into ms2-f…
anishsapkota Sep 16, 2024
df9a06f
remove migs
anishsapkota Sep 16, 2024
f8f06cc
minor improvements!
anishsapkota Sep 16, 2024
cf0be8e
copy/edit process inital impl
anishsapkota Sep 23, 2024
06ec3d9
added new dev commands
anishsapkota Sep 29, 2024
b3425a1
Merge remote-tracking branch 'origin/main' into ms2-file-manager
anishsapkota Sep 29, 2024
e1c0c42
fix: process.ts
anishsapkota Sep 29, 2024
cfa55d7
adjusted artefacts path
anishsapkota Sep 29, 2024
b152dc2
Merge remote-tracking branch 'origin/ms2-file-manager' into ms2-copy-…
anishsapkota Sep 29, 2024
fcb83e8
Merge remote-tracking branch 'origin/ms2-new-dev-commands' into ms2-c…
anishsapkota Sep 29, 2024
25a350e
refCounter 0 -> 1
anishsapkota Sep 29, 2024
f114171
remove -it option
anishsapkota Sep 30, 2024
c76c02d
fix: tty error
anishsapkota Sep 30, 2024
d130e9d
remove -it
anishsapkota Sep 30, 2024
c5464da
adjusted commands, removed husky
anishsapkota Sep 30, 2024
f139fa6
Merge remote-tracking branch 'origin/ms2-new-dev-commands' into ms2-c…
anishsapkota Sep 30, 2024
dc66c83
Merge branch 'main' into ms2-copy-shared-process-with-artifacts
OhKai Dec 3, 2024
0db6fb8
Clean up some merge changes
OhKai Dec 4, 2024
3b87418
Refactor workspace logo retrieval and update process artifact handling
OhKai Dec 8, 2024
d1499ca
Adjust E2E naming
OhKai Dec 9, 2024
af7d4bd
Add aria-label to edit button
OhKai Dec 9, 2024
48c1ee9
E2E adjust share import
OhKai Dec 9, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
42 changes: 22 additions & 20 deletions src/management-system-v2/app/api/private/file-manager/route.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,10 +23,15 @@ export async function GET(request: NextRequest) {
const entityType = searchParams.get('entityType');
const environmentId = searchParams.get('environmentId') || 'unauthenticated';
const fileName = searchParams.get('fileName') || undefined;
if (!entityId || !entityType || !environmentId) {
if (
!entityId ||
!entityType ||
!environmentId ||
(entityType === EntityType.PROCESS && !fileName)
) {
return new NextResponse(null, {
status: 400,
statusText: 'entityId,entityType, environmentId and fileName required as URL search params',
statusText: 'entityId, entityType, environmentId and fileName required as URL search params',
});
}

Expand All @@ -41,26 +46,25 @@ export async function GET(request: NextRequest) {
});
}

if (environmentId === 'unauthenticated') {
// if the user is not an owner check if they have access if a share token is provided in the query data of the url
const shareToken = searchParams.get('shareToken');
if (!canAccess && shareToken) {
const key = process.env.SHARING_ENCRYPTION_SECRET!;
const {
processId: shareProcessId,
embeddedMode,
timestamp,
} = jwt.verify(shareToken, key!) as TokenPayload;

canAccess =
!embeddedMode && shareProcessId === entityId && timestamp === processMeta.shareTimestamp;
}
} else {
// if the user is not unauthenticated check if they have access to the process due to being an owner
if (environmentId !== 'unauthenticated') {
const { ability } = await getCurrentEnvironment(environmentId);

canAccess = ability.can('view', toCaslResource('Process', processMeta));
}

// if the user is not an owner check if they have access if a share token is provided in the query data of the url
const shareToken = searchParams.get('shareToken');
if (!canAccess && shareToken) {
const key = process.env.SHARING_ENCRYPTION_SECRET!;
const {
processId: shareProcessId,
embeddedMode,
timestamp,
} = jwt.verify(shareToken, key!) as TokenPayload;
canAccess =
!embeddedMode && shareProcessId === entityId && timestamp === processMeta.shareTimestamp;
}

if (!canAccess) {
return new NextResponse(null, {
status: 403,
Expand All @@ -81,7 +85,6 @@ export async function GET(request: NextRequest) {
}

const headers = new Headers();
console.log(fileType.mime);
headers.set('Content-Type', fileType.mime);
return new NextResponse(data, { status: 200, statusText: 'OK', headers });
} catch (error: any) {
Expand Down Expand Up @@ -157,7 +160,6 @@ export async function PUT(request: NextRequest) {
);

const fileType = await fileTypeFromBuffer(buffer);
console.log(fileType);
if (!fileType) {
return new NextResponse(null, {
status: 415,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ import {
ImportsInfo,
getElementSVG,
} from './documentation-page-utils';
import { Environment } from '@/lib/data/environment-schema';

/**
* Import the Editor asynchronously since it implicitly uses browser logic which leads to errors when this file is loaded on the server
Expand All @@ -54,13 +55,15 @@ const markdownEditor: Promise<ToastEditorType> =
type BPMNSharedViewerProps = {
processData: Awaited<ReturnType<typeof getProcess>>;
isOwner: boolean;
userWorkspaces: Environment[];
defaultSettings?: SettingsOption;
availableImports: ImportsInfo;
};

const BPMNSharedViewer = ({
processData,
isOwner,
userWorkspaces,
defaultSettings,
availableImports,
}: BPMNSharedViewerProps) => {
Expand Down Expand Up @@ -223,6 +226,7 @@ const BPMNSharedViewer = ({
</Button>
{!isOwner && (
<WorkspaceSelectionModalButton
workspaces={userWorkspaces}
processData={processData}
versionInfo={versionInfo}
/>
Expand Down
9 changes: 5 additions & 4 deletions src/management-system-v2/app/shared-viewer/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ import { getDefinitionsAndProcessIdForEveryCallActivity } from '@proceed/bpmn-he

import { SettingsOption } from './settings-modal';
import { env } from '@/lib/env-vars';
import { asyncMap } from '@/lib/helpers/javascriptHelpers';

interface PageProps {
searchParams: {
Expand Down Expand Up @@ -131,11 +132,10 @@ const SharedViewer = async ({ searchParams }: PageProps) => {

const userEnvironments: Environment[] = [await getEnvironmentById(userId)];
const userOrgEnvs = await getUserOrganizationEnvironments(userId);
const orgEnvironmentsPromises = userOrgEnvs.map(async (environmentId) => {
return await getEnvironmentById(environmentId);
});

const orgEnvironments = await Promise.all(orgEnvironmentsPromises);
const orgEnvironments = await asyncMap(userOrgEnvs, (environmentId) =>
getEnvironmentById(environmentId),
);

userEnvironments.push(...orgEnvironments);

Expand Down Expand Up @@ -211,6 +211,7 @@ const SharedViewer = async ({ searchParams }: PageProps) => {
>
<BPMNSharedViewer
isOwner={isOwner}
userWorkspaces={userEnvironments}
processData={processData!}
defaultSettings={defaultSettings}
availableImports={availableImports}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,15 +1,18 @@
.WorkspaceSelection {
margin-bottom: 10px;
display: flex;
flex-direction: row;
flex-wrap: wrap;
justify-content: center;
gap: 10px;
overflow-x: auto;
overflow-y: hidden;
white-space: nowrap;

.WorkspaceButton {
border: 1px solid black;
width: 150px;
height: 100px;
display: flex;
margin: 5px;
width: 200px;
height: 120px;
display: inline-flex; /* Ensure buttons align horizontally */
flex-direction: column;
justify-content: center;
align-items: center;
Expand Down
Loading
Loading