Просмотр исходного кода

add attributes for ContextExtractor

yohei0125 4 лет назад
Родитель
Сommit
4574993b02

+ 6 - 3
packages/app/src/components/DuplicatePage.tsx

@@ -1,7 +1,10 @@
-import React from 'react';
+import React, { FC } from 'react';
 
-const DuplicatePage = () => {
-  return <div>duplicate pages</div>;
+type DuplicatePageProps= {
+
+}
+const DuplicatePage:FC<DuplicatePageProps> = (props:DuplicatePageProps) => {
+  return <div></div>;
 };
 
 export default DuplicatePage;

+ 5 - 2
packages/app/src/server/routes/page.js

@@ -613,8 +613,11 @@ module.exports = function(crowi, app) {
     const { redirectFrom } = req.query;
 
     if (pages.length >= 2) {
-      // pass only redirectFrom since it is not sure whether the query params are related to the pages
-      return res.render('layout-growi/select-go-to-page', { pages, redirectFrom });
+      const duplicatePageIds = pages.map(p => p._id.toString());
+      const duplicatePath = pages[0].path; // index doesn't matter since the path is duplicate
+      return res.render('layout-growi/duplicate-page-list', {
+        pages, duplicatePageIds, duplicatePath, redirectFrom,
+      });
     }
 
     if (pages.length === 1) {

+ 12 - 4
packages/app/src/server/views/layout-growi/duplicate-page-list.html

@@ -1,15 +1,23 @@
 {% extends 'base/layout.html' %}
 
-{% block content_header_wrapper %}
-<div id="grw-subnav-switcher-container" class="d-edit-none"></div>
+
+{% block content_main_before %}
+<div
+  {# attributes to get extracted by ContextExtractor #}
+  id="growi-duplicate-page-list-context"
+  data-duplicate-page-ids="{{ duplicatePageIds }}"
+  duplicate-page-path="{{duplicatePath}}"
+>
+</div>
 {% endblock %}
 
-{% block layout_main %}
+{% block content_main %}
 <div id="grw-fav-sticky-trigger" class="sticky-top"></div>
 <div>
   {% for page in pages %}
     <li>{{page._id.toString()}}: {{page.path}}</li>
   {% endfor %}
 </div>
-<div id="duplicate-page-list"></div>
+<div id="duplicate-page-list-context"
+></div>
 {% endblock %}