itizawa 5 лет назад
Родитель
Сommit
2930283c9c
3 измененных файлов с 16 добавлено и 12 удалено
  1. 3 11
      src/client/js/components/PageList/PageListMeta.jsx
  2. 12 0
      src/lib/util/path-utils.js
  3. 1 1
      src/server/models/page.js

+ 3 - 11
src/client/js/components/PageList/PageListMeta.jsx

@@ -1,24 +1,16 @@
 import React from 'react';
 import React from 'react';
 import PropTypes from 'prop-types';
 import PropTypes from 'prop-types';
 import templateChecker from '@commons/util/template-checker';
 import templateChecker from '@commons/util/template-checker';
+import { isTopPage } from '@commons/util/path-utils';
 
 
 export default class PageListMeta extends React.Component {
 export default class PageListMeta extends React.Component {
 
 
-  isPortalPath(path) {
-    if (path.match(/.*\/$/)) {
-      return true;
-    }
-
-    return false;
-  }
-
   render() {
   render() {
-    // TODO isPortal()
-    const page = this.props.page;
+    const { page } = this.props;
 
 
     // portal check
     // portal check
     let portalLabel;
     let portalLabel;
-    if (this.isPortalPath(page.path)) {
+    if (isTopPage(page.path)) {
       portalLabel = <span className="badge badge-info">PORTAL</span>;
       portalLabel = <span className="badge badge-info">PORTAL</span>;
     }
     }
 
 

+ 12 - 0
src/lib/util/path-utils.js

@@ -1,3 +1,14 @@
+/**
+ * Whether path is the top page
+ * @param {string} path
+ * @returns {boolean}
+ */
+const isTopPage = (path) => {
+  if (path === '/') {
+    return true;
+  }
+  return false;
+};
 
 
 /**
 /**
  * Whether path belongs to the trash page
  * Whether path belongs to the trash page
@@ -40,6 +51,7 @@ const userPageRoot = (user) => {
 };
 };
 
 
 module.exports = {
 module.exports = {
+  isTopPage,
   isTrashPage,
   isTrashPage,
   isUserPage,
   isUserPage,
   userPageRoot,
   userPageRoot,

+ 1 - 1
src/server/models/page.js

@@ -292,7 +292,7 @@ module.exports = function(crowi) {
   }
   }
 
 
   function isPortalPath(path) {
   function isPortalPath(path) {
-    if (path.match(/.*\/$/)) {
+    if (path === '/') {
       return true;
       return true;
     }
     }