Explorar o código

Merge pull request #3895 from weseek/fix/6170-link-edit-modal-fix

Fix: "GW-6166 Bug: LinkEditModal.jsxの「パーマリンクを使う」チェックボックスがdisabledのままになっている"
Yuki Takei %!s(int64=4) %!d(string=hai) anos
pai
achega
8c8d27fb06
Modificáronse 1 ficheiros con 3 adicións e 5 borrados
  1. 3 5
      src/client/js/components/PageEditor/LinkEditModal.jsx

+ 3 - 5
src/client/js/components/PageEditor/LinkEditModal.jsx

@@ -153,7 +153,6 @@ class LinkEditModal extends React.PureComponent {
     const path = this.state.linkInputValue;
     let markdown = '';
     let previewError = '';
-    let permalink = '';
 
     if (path.startsWith('/')) {
       const pathWithoutFragment = new URL(path, 'http://dummy').pathname;
@@ -163,8 +162,6 @@ class LinkEditModal extends React.PureComponent {
       try {
         const { page } = await this.props.appContainer.apiGet('/pages.get', { path: pathWithoutFragment, page_id: pageId });
         markdown = page.revision.body;
-        // create permanent link only if path isn't permanent link because checkbox for isUsePermanentLink is disabled when permalink is ''.
-        permalink = !isPermanentLink ? `${window.location.origin}/${page.id}` : '';
       }
       catch (err) {
         previewError = err.message;
@@ -173,7 +170,7 @@ class LinkEditModal extends React.PureComponent {
     else {
       previewError = t('link_edit.page_not_found_in_preview', { path });
     }
-    this.setState({ markdown, previewError, permalink });
+    this.setState({ markdown, previewError });
   }
 
   getLinkForPreview() {
@@ -217,7 +214,8 @@ class LinkEditModal extends React.PureComponent {
   handleChangeTypeahead(selected) {
     const page = selected[0];
     if (page != null) {
-      this.setState({ linkInputValue: page.path });
+      const permalink = `${window.location.origin}/${page.id}`;
+      this.setState({ linkInputValue: page.path, permalink });
     }
   }