Răsfoiți Sursa

add toast error

itizawa 5 ani în urmă
părinte
comite
42c0d2af70
1 a modificat fișierele cu 9 adăugiri și 2 ștergeri
  1. 9 2
      src/client/js/services/PageContainer.js

+ 9 - 2
src/client/js/services/PageContainer.js

@@ -4,6 +4,7 @@ import loggerFactory from '@alias/logger';
 
 import * as entities from 'entities';
 import * as toastr from 'toastr';
+import { toastError } from '../util/apiNotification';
 
 const logger = loggerFactory('growi:services:PageContainer');
 const scrollThresForSticky = 0;
@@ -91,8 +92,14 @@ export default class PageContainer extends Container {
 
     const unlinkPageButton = document.getElementById('unlink-page-button');
     if (unlinkPageButton != null) {
-      unlinkPageButton.addEventListener('click', () => {
-        alert('ボタンが押されました。');
+      unlinkPageButton.addEventListener('click', async() => {
+        try {
+          const res = await this.appContainer.apiPost('/pages.unlink', { path });
+          window.location.href = encodeURI(`${res.path}?unlinked=true`);
+        }
+        catch (err) {
+          toastError(err);
+        }
       });
     }