Skip to content

Commit b4d222b

Browse files
authored
Merge pull request #734 from PROCEED-Labs/instance/documentation
Documentation Page: Features & Refactoring
2 parents bd96bdb + eb37138 commit b4d222b

33 files changed

Lines changed: 3352 additions & 781 deletions

src/management-system-v2/app/(dashboard)/[environmentId]/(automation)/executions/[processId]/instance-coloring.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ export const colorOptions = [
2323
] as const;
2424
export type ColorOptions = (typeof colorOptions)[number]['key'];
2525

26-
function getExecutionColor(executionState: string, wasInterrupted: boolean) {
26+
export function getExecutionColor(executionState: string, wasInterrupted: boolean) {
2727
switch (executionState) {
2828
case 'COMPLETED':
2929
return wasInterrupted ? 'yellow' : 'green';

src/management-system-v2/app/(dashboard)/[environmentId]/(automation)/executions/[processId]/instance-tokens.ts

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,10 @@ import type { Connection } from 'diagram-js/lib/util/Elements';
66

77
type TokenInfo = InstanceInfo['tokens'][number];
88

9-
function getTokenPosition(token: TokenInfo, bpmnViewer: BPMNCanvasRef) {
9+
export function getTokenPosition(
10+
token: TokenInfo,
11+
bpmnViewer: { getElement: (id: string) => Element | undefined },
12+
) {
1013
let targetFlowElement: Element | Connection | undefined = bpmnViewer.getElement(
1114
token.currentFlowElementId,
1215
);
@@ -108,7 +111,7 @@ function getTokenTooltip(token: InstanceInfo['tokens'][number], instance: Instan
108111
return token.state;
109112
}
110113

111-
function getTokenColor(token: TokenInfo, instance: InstanceInfo) {
114+
export function getTokenColor(token: TokenInfo, instance: InstanceInfo) {
112115
if (isPausingToken(token, instance)) {
113116
return '#faad14';
114117
}

src/management-system-v2/app/(dashboard)/[environmentId]/(automation)/executions/[processId]/process-deployment-view.tsx

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,9 @@ import {
4242
import { useSession } from 'next-auth/react';
4343
import { useEnvironment } from '@/components/auth-can';
4444

45+
import { GrDocumentUser } from 'react-icons/gr';
46+
import { handleOpenDocumentation } from '../../../processes/processes-helper';
47+
4548
export default function ProcessDeploymentView({
4649
processId,
4750
initialDeploymentInfo,
@@ -488,6 +491,23 @@ export default function ProcessDeploymentView({
488491

489492
<Space style={{ alignItems: 'start' }}>
490493
<ToolbarGroup>
494+
{selectedInstance && (
495+
<Tooltip title="View Instance Documentation">
496+
<Button
497+
aria-label="view-instance-documentation"
498+
icon={<GrDocumentUser />}
499+
onClick={() =>
500+
handleOpenDocumentation(
501+
processId,
502+
spaceId,
503+
selectedInstance.processVersion,
504+
selectedInstance.processInstanceId,
505+
selectedColoring,
506+
)
507+
}
508+
/>
509+
</Tooltip>
510+
)}
491511
<Tooltip title={infoPanelOpen ? 'Close Info Panel' : 'Open Info Panel'}>
492512
<Button
493513
icon={<InfoCircleOutlined />}

src/management-system-v2/app/(dashboard)/[environmentId]/processes/[mode]/[processId]/modeler-toolbar.tsx

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -419,7 +419,11 @@ const ModelerToolbar = ({
419419
aria-label="view-documentation"
420420
icon={<GrDocumentUser />}
421421
onClick={() => {
422-
handleOpenDocumentation(processId, selectedVersionId || undefined);
422+
handleOpenDocumentation(
423+
processId,
424+
environment.spaceId,
425+
selectedVersionId || undefined,
426+
);
423427
}}
424428
/>
425429
</Tooltip>

src/management-system-v2/app/(dashboard)/[environmentId]/processes/processes-helper.tsx

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,30 @@
11
import { generateSharedViewerUrl } from '@/lib/sharing/process-sharing';
22
import { message } from 'antd';
3+
import { ColorOptions } from '../(automation)/executions/[processId]/instance-coloring';
34

45
export async function handleOpenDocumentation(
56
processId: string,
6-
selectedVersionId?: string | null,
7+
spaceId: string,
8+
versionId?: string | null,
9+
instanceId?: string,
10+
coloring?: ColorOptions,
711
) {
812
// the timestamp does not matter here since it is overridden by the user being an owner of the process
913
try {
1014
const url = await generateSharedViewerUrl(
11-
{ processId, timestamp: 0 },
12-
selectedVersionId || undefined,
15+
{ processId, timestamp: 0, spaceId },
16+
versionId || undefined,
17+
undefined,
18+
instanceId,
19+
coloring,
1320
);
1421

1522
// open the documentation page in a new tab (unless it is already open in which case just show the tab)
1623
if (typeof url === 'string') {
17-
window.open(url, `${processId}-${selectedVersionId}-tab`);
24+
const tabKey = instanceId
25+
? `${processId}-${instanceId}-tab`
26+
: `${processId}-${versionId}-tab`;
27+
window.open(url, tabKey);
1828
} else {
1929
message.error('Failed to generate the documentation URL.');
2030
}

src/management-system-v2/app/shared-viewer/process-document.module.scss renamed to src/management-system-v2/app/shared-viewer/document-content.module.scss

Lines changed: 72 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,22 @@
44
max-width: 1200px;
55
background-color: white;
66

7+
overflow: hidden;
78
margin: 0 auto;
89

10+
@media print {
11+
table {
12+
width: 100%;
13+
max-width: 100%;
14+
table-layout: fixed;
15+
word-break: break-word;
16+
}
17+
td,
18+
th {
19+
word-break: break-word;
20+
overflow-wrap: break-word;
21+
}
22+
}
923
@media print {
1024
// needed so that the table header workaround below actually works
1125
display: table;
@@ -34,6 +48,11 @@
3448
}
3549

3650
.Main {
51+
@media print {
52+
:global(.bpmn-root-svg) {
53+
max-height: fit-content;
54+
}
55+
}
3756
@media screen {
3857
width: 95%;
3958
margin: auto;
@@ -42,6 +61,7 @@
4261
@media print {
4362
padding: 0 40pt 0 40pt;
4463
box-sizing: border-box;
64+
display: block;
4565
}
4666

4767
.Title {
@@ -52,6 +72,19 @@
5272
flex-direction: column;
5373
justify-content: center;
5474
}
75+
76+
.TitleHeader {
77+
text-align: center;
78+
}
79+
80+
.TitleProcessId {
81+
font-size: 1.3em;
82+
color: #666;
83+
margin-bottom: 4px;
84+
letter-spacing: 0.05em;
85+
font-weight: 500;
86+
text-align: center;
87+
}
5588
}
5689

5790
// used when the option that the title should be its own page is selected
@@ -71,7 +104,7 @@
71104
}
72105

73106
div {
74-
font-size: 1.3em;
107+
font-size: 14px;
75108
}
76109
}
77110

@@ -94,32 +127,18 @@
94127
}
95128

96129
.ElementPage {
97-
margin-top: 7dvh;
130+
margin-top: 2.7dvh;
98131

99132
.ElementOverview {
100133
break-inside: avoid;
101-
102-
.ElementCanvas {
103-
display: flex;
104-
justify-content: center;
105-
106-
@media print {
107-
max-height: 95%;
108-
width: 100%;
109-
}
110-
111-
svg {
112-
max-width: 100%;
113-
height: 100%;
114-
}
115-
}
116134
}
117135

118136
.MetaInformation {
119-
margin-top: 50px;
137+
margin-top: 20px;
120138

121139
// prevent the header from being put at the end of a page with the content starting on the next page
122-
h3 {
140+
h3,
141+
h4 {
123142
break-after: avoid;
124143
}
125144

@@ -134,15 +153,48 @@
134153
.ContainerPage {
135154
// start a new page for elements that contain other new elements and start with the container element at the top of the page
136155
break-before: always;
156+
page-break-before: always;
137157

138158
@media print {
139-
margin-top: 0;
159+
display: block;
140160
}
141161
}
142162

163+
// Print-specific styles
164+
@media print {
165+
// Page breaks for H1 sections
166+
:global(h1.ant-typography) {
167+
page-break-before: always;
168+
break-before: always;
169+
}
170+
171+
// First H1 should not have a page break before it
172+
:global(h1.ant-typography:first-of-type) {
173+
page-break-before: avoid;
174+
break-before: avoid;
175+
}
176+
// Prevent headings from being orphaned at page bottom
177+
:global(h2.ant-typography),
178+
:global(h3.ant-typography),
179+
:global(h4.ant-typography),
180+
:global(h5.ant-typography) {
181+
break-after: avoid;
182+
}
183+
184+
p {
185+
margin-top: 2pt;
186+
margin-bottom: 2pt;
187+
}
188+
}
143189
:nth-child(1 of .ContainerPage) {
144190
// the first page containing the main process diagram might follow directly after the table of contents based on the settings selected by the user
145191
break-before: auto;
146192
}
147193
}
194+
.ElementPage.SubprocessChild {
195+
margin-top: 2dvh;
196+
@media print {
197+
margin-top: 20pt;
198+
}
199+
}
148200
}

0 commit comments

Comments
 (0)