Skip to content

Commit

Permalink
Some changes
Browse files Browse the repository at this point in the history
  • Loading branch information
OhKai committed Dec 2, 2024
1 parent 0686971 commit af90b73
Show file tree
Hide file tree
Showing 8 changed files with 115 additions and 96 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -233,15 +233,12 @@ const ModelerToolbar = ({
placeholder="Select Version"
showSearch
filterOption={filterOption}
value={{
value: selectedVersion.id,
label: selectedVersion.name,
}}
onSelect={(_, option) => {
value={selectedVersion.id}
onChange={(value) => {
// change the version info in the query but keep other info (e.g. the currently open subprocess)
const searchParams = new URLSearchParams(query);
if (!option.value || option.value === '-1') searchParams.delete('version');
else searchParams.set(`version`, `${option.value}`);
if (!value || value === '-1') searchParams.delete('version');
else searchParams.set(`version`, `${value}`);
router.push(
spaceURL(
environment,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,6 @@ type ModelerProps = React.HTMLAttributes<HTMLDivElement> & {
const Modeler = ({ versionName, process, versions, ...divProps }: ModelerProps) => {
const pathname = usePathname();
const environment = useEnvironment();
const { data, status } = useSession({ required: true });
const [xmlEditorBpmn, setXmlEditorBpmn] = useState<string | undefined>(undefined);
const query = useSearchParams();
const router = useRouter();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ const Process = async ({ params: { processId, environmentId }, searchParams }: P
? await getProcessBPMN(processId, environmentId, selectedVersionId)
: process.bpmn;
const selectedVersion = selectedVersionId
? process.versions.find((version: { id: string }) => version.id === selectedVersionId)
? process.versions.find((version) => version.id === selectedVersionId)
: undefined;

// Since the user is able to minimize and close the page, everyting is in a
Expand Down
2 changes: 1 addition & 1 deletion src/management-system-v2/app/shared-viewer/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,7 @@ const SharedViewer = async ({ searchParams }: PageProps) => {
try {
const { processId, embeddedMode, timestamp } = jwt.verify(token, key!) as TokenPayload;

const versionId = version === undefined ? version : (version as string);
const versionId = version as string | undefined;

const processInfo = await getProcessInfo(
processId as string,
Expand Down
5 changes: 4 additions & 1 deletion src/management-system-v2/components/process-list.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -410,7 +410,10 @@ const ProcessManagementList: FC<ProcessManagementListProps> = ({
processActions={processActions}
tableProps={{
scroll: {
y: `${window?.innerHeight - 32 /* Footer */ - 64 /* Header */ - 82 /* Table-Search etc */ - 60 /* Table-head */ - 60 /* Table-Footer / Pagination */}px`,
y:
typeof window !== 'undefined' && window.innerHeight > 0
? `${window?.innerHeight - 32 /* Footer */ - 64 /* Header */ - 82 /* Table-Search etc */ - 60 /* Table-head */ - 60 /* Table-Footer / Pagination */}px`
: undefined,
},
pagination: { position: ['bottomCenter'], pageSize: 20 },
onRow: (item) => ({
Expand Down
5 changes: 5 additions & 0 deletions src/management-system-v2/lib/data/legacy/fileHandling.js
Original file line number Diff line number Diff line change
Expand Up @@ -258,6 +258,11 @@ function getVersionFileName(definitionId) {
export async function saveProcessVersion(definitionId, versionCreatedOn, bpmn) {
const currentProcessFolder = path.join(getFolder(definitionId), versionCreatedOn);

// creates the directory if it doesn't exist
fse.ensureDirSync(
path.dirname(path.join(currentProcessFolder, getVersionFileName(definitionId))),
);

fse.writeFileSync(path.join(currentProcessFolder, getVersionFileName(definitionId)), bpmn);
}

Expand Down
8 changes: 4 additions & 4 deletions src/management-system-v2/lib/data/processes.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@ const getBpmnVersion = async (definitionId: string, versionId?: string) => {
const process = await _getProcess(definitionId);

if (versionId) {
const version = process.versions.find((version: { id: string }) => version.id === versionId);
const version = process.versions.find((version) => version.id === versionId);

if (!version) {
return userError(
Expand Down Expand Up @@ -427,16 +427,16 @@ export const createVersion = async (
}
const bpmnObj = await toBpmnObject(bpmn);

const { versionBasedOn, versionCreatedOn } = await getDefinitionsVersionInformation(bpmnObj);

const { versionBasedOn } = await getDefinitionsVersionInformation(bpmnObj);
const versionCreatedOn = toCustomUTCString(new Date());
// add process version to bpmn
const versionId = `_${v4()}`;
await setDefinitionsVersionInformation(bpmnObj, {
versionId: versionId,
versionName,
versionDescription,
versionBasedOn,
versionCreatedOn: toCustomUTCString(new Date()),
versionCreatedOn,
});

const process = (await _getProcess(processId)) as Process;
Expand Down
Loading

0 comments on commit af90b73

Please sign in to comment.