Преглед изворни кода

Ignore the latestRevision constraint when updating from editor

Shun Miyazawa пре 2 година
родитељ
комит
7e9c39f167

+ 1 - 0
apps/app/src/client/services/side-effects/drawio-modal-launcher-for-view.ts

@@ -47,6 +47,7 @@ export const useDrawioModalLauncherForView = (opts?: {
         pageId: currentPage._id,
         pageId: currentPage._id,
         revisionId: currentRevisionId,
         revisionId: currentRevisionId,
         body: newMarkdown,
         body: newMarkdown,
+        origin: 'view',
       });
       });
 
 
       opts?.onSaveSuccess?.();
       opts?.onSaveSuccess?.();

+ 1 - 0
apps/app/src/client/services/side-effects/handsontable-modal-launcher-for-view.ts

@@ -46,6 +46,7 @@ export const useHandsontableModalLauncherForView = (opts?: {
         pageId: currentPage._id,
         pageId: currentPage._id,
         revisionId: currentRevisionId,
         revisionId: currentRevisionId,
         body: newMarkdown,
         body: newMarkdown,
+        origin: 'view',
       });
       });
 
 
       opts?.onSaveSuccess?.();
       opts?.onSaveSuccess?.();

+ 1 - 0
apps/app/src/components/PageEditor/PageEditor.tsx

@@ -215,6 +215,7 @@ export const PageEditor = React.memo((props: Props): JSX.Element => {
         revisionId: currentRevisionId,
         revisionId: currentRevisionId,
         body: codeMirrorEditor?.getDoc() ?? '',
         body: codeMirrorEditor?.getDoc() ?? '',
         grant: grantData?.grant,
         grant: grantData?.grant,
+        origin: 'editor',
         userRelatedGrantUserGroupIds: grantData?.userRelatedGrantedGroups?.map((group) => {
         userRelatedGrantUserGroupIds: grantData?.userRelatedGrantedGroups?.map((group) => {
           return { item: group.id, type: group.type };
           return { item: group.id, type: group.type };
         }),
         }),

+ 3 - 1
apps/app/src/server/routes/apiv3/page/update-page.ts

@@ -132,6 +132,8 @@ export const updatePageHandlersFactory: UpdatePageHandlersFactory = (crowi) => {
         pageId, revisionId, body, origin,
         pageId, revisionId, body, origin,
       } = req.body;
       } = req.body;
 
 
+      const ignoreLatestRevision = origin === 'editor';
+
       // check page existence
       // check page existence
       const isExist = await Page.count({ _id: pageId }) > 0;
       const isExist = await Page.count({ _id: pageId }) > 0;
       if (!isExist) {
       if (!isExist) {
@@ -140,7 +142,7 @@ export const updatePageHandlersFactory: UpdatePageHandlersFactory = (crowi) => {
 
 
       // check revision
       // check revision
       const currentPage = await Page.findByIdAndViewer(pageId, req.user);
       const currentPage = await Page.findByIdAndViewer(pageId, req.user);
-      if (currentPage != null && !currentPage.isUpdatable(revisionId)) {
+      if (!ignoreLatestRevision && currentPage != null && !currentPage.isUpdatable(revisionId)) {
         const latestRevision = await Revision.findById(currentPage.revision).populate('author');
         const latestRevision = await Revision.findById(currentPage.revision).populate('author');
         const returnLatestRevision = {
         const returnLatestRevision = {
           revisionId: latestRevision?._id.toString(),
           revisionId: latestRevision?._id.toString(),