Browse Source

remove PagePath adn use the one of GROWI main

Yuki Takei 7 years ago
parent
commit
489fd80f17

+ 2 - 2
packages/growi-plugin-lsx/src/resource/js/components/PageList/Page.js

@@ -4,7 +4,7 @@ import PropTypes from 'prop-types';
 import PageListMeta from '@client/js/components/PageList/PageListMeta';
 
 import { LsxContext } from '../../util/LsxContext';
-import { PagePath } from './PagePath';
+import { PagePathWrapper } from './PagePathWrapper';
 import { PageNode } from '../PageNode';
 
 export class Page extends React.Component {
@@ -89,7 +89,7 @@ export class Page extends React.Component {
     const pageNode = this.props.pageNode;
 
     // create PagePath element
-    let pagePathNode = <PagePath pagePath={pageNode.pagePath} isExists={this.state.isExists} />;
+    let pagePathNode = <PagePathWrapper pagePath={pageNode.pagePath} isExists={this.state.isExists} />;
     if (this.state.isLinkable) {
       pagePathNode = <a className="page-list-link" href={this.omitSlashOfEnd(pageNode.pagePath)}>{pagePathNode}</a>;
     }

+ 0 - 52
packages/growi-plugin-lsx/src/resource/js/components/PageList/PagePath.js

@@ -1,52 +0,0 @@
-import React from 'react';
-import PropTypes from 'prop-types';
-
-export class PagePath extends React.Component {
-
-  getShortPath(path) {
-    let name = path.replace(/(\/)$/, '');
-
-    // /.../hoge/YYYY/MM/DD 形式のページ
-    if (name.match(/.+\/([^/]+\/\d{4}\/\d{2}\/\d{2})$/)) {
-      return name.replace(/.+\/([^/]+\/\d{4}\/\d{2}\/\d{2})$/, '$1');
-    }
-
-    // /.../hoge/YYYY/MM 形式のページ
-    if (name.match(/.+\/([^/]+\/\d{4}\/\d{2})$/)) {
-      return name.replace(/.+\/([^/]+\/\d{4}\/\d{2})$/, '$1');
-    }
-
-    // /.../hoge/YYYY 形式のページ
-    if (name.match(/.+\/([^/]+\/\d{4})$/)) {
-      return name.replace(/.+\/([^/]+\/\d{4})$/, '$1');
-    }
-
-    // ページの末尾を拾う
-    return name.replace(/.+\/(.+)?$/, '$1');
-  }
-
-  render() {
-    const pagePath = this.props.pagePath.replace(this.props.excludePathString.replace(/^\//, ''), '');
-    const shortPath = this.getShortPath(pagePath);
-
-    let classNames = ['page-path']
-    if (!this.props.isExists) {
-      classNames.push('lsx-page-not-exist');
-    }
-
-    return (
-      <span className={classNames.join(' ')}>
-        {shortPath}
-      </span>
-    );
-  }
-}
-
-PagePath.propTypes = {
-  pagePath: PropTypes.string.isRequired,
-  isExists: PropTypes.bool.isRequired,
-};
-
-PagePath.defaultProps = {
-  excludePathString: '',
-};

+ 28 - 0
packages/growi-plugin-lsx/src/resource/js/components/PageList/PagePathWrapper.jsx

@@ -0,0 +1,28 @@
+import React from 'react';
+import PropTypes from 'prop-types';
+
+import PagePath from '@client/js/components/PageList/PagePath';
+
+export class PagePathWrapper extends React.Component {
+
+  render() {
+
+    let classNames = [];
+    if (!this.props.isExists) {
+      classNames.push('lsx-page-not-exist');
+    }
+
+    return (
+      <PagePath page={{ path: this.props.pagePath }} isShortPathOnly={true} additionalClassNames={classNames} />
+    );
+  }
+}
+
+PagePathWrapper.propTypes = {
+  pagePath: PropTypes.string.isRequired,
+  isExists: PropTypes.bool.isRequired,
+};
+
+PagePathWrapper.defaultProps = {
+  excludePathString: '',
+};