Explorar el Código

WIP: move lsx clients to @growi/lsx-plugin

Yuki Takei hace 3 años
padre
commit
d294841fbb

+ 1 - 0
package.json

@@ -53,6 +53,7 @@
   },
   "devDependencies": {
     "@testing-library/cypress": "^8.0.2",
+    "@types/css-modules": "^1.0.2",
     "@types/jest": "^26.0.22",
     "@types/node": "^17.0.43",
     "@types/rewire": "^2.5.28",

+ 0 - 0
packages/app/src/components/ReactMarkdownComponents/Lsx/Lsx.module.scss → packages/plugin-lsx/src/components/Lsx.module.scss


+ 6 - 7
packages/app/src/components/ReactMarkdownComponents/Lsx/Lsx.tsx → packages/plugin-lsx/src/components/Lsx.tsx

@@ -5,10 +5,7 @@ import React, {
 import * as url from 'url';
 
 import { pathUtils } from '@growi/core';
-
-import { apiGet } from '~/client/util/apiv1-client';
-
-// eslint-disable-next-line no-unused-vars
+import axios from 'axios';
 
 import { LsxListView } from './LsxPageList/LsxListView';
 import { PageNode } from './PageNode';
@@ -175,9 +172,11 @@ export const Lsx = ({
 
     let newNodeTree: PageNode[] = [];
     try {
-      const result: any = await apiGet('/plugins/lsx', {
-        pagePath,
-        options: lsxContext.options,
+      const result: any = await axios.get('/plugins/lsx', {
+        params: {
+          pagePath,
+          options: lsxContext.options,
+        },
       });
 
       newNodeTree = generatePageNodeTree(pagePath, result.pages);

+ 0 - 0
packages/app/src/components/ReactMarkdownComponents/Lsx/LsxPageList/LsxListView.jsx → packages/plugin-lsx/src/components/LsxPageList/LsxListView.jsx


+ 0 - 0
packages/app/src/components/ReactMarkdownComponents/Lsx/LsxPageList/LsxPage.jsx → packages/plugin-lsx/src/components/LsxPageList/LsxPage.jsx


+ 0 - 0
packages/app/src/components/ReactMarkdownComponents/Lsx/LsxPageList/PagePathWrapper.jsx → packages/plugin-lsx/src/components/LsxPageList/PagePathWrapper.jsx


+ 0 - 0
packages/app/src/components/ReactMarkdownComponents/Lsx/PageNode.js → packages/plugin-lsx/src/components/PageNode.js


+ 0 - 0
packages/app/src/components/ReactMarkdownComponents/Lsx/lsx-context.ts → packages/plugin-lsx/src/components/lsx-context.ts


+ 0 - 0
packages/app/src/components/ReactMarkdownComponents/Lsx/tag-cache-manager.ts → packages/plugin-lsx/src/components/tag-cache-manager.ts


+ 4 - 4
packages/plugin-lsx/src/server/routes/lsx.js

@@ -202,7 +202,7 @@ module.exports = (crowi, app) => {
       options = JSON.parse(req.query.options);
     }
     catch (error) {
-      return res.json(ApiResponse.error(error));
+      return res.status(400).send(error);
     }
 
     const builder = await generateBaseQueryBuilder(pagePath, user);
@@ -220,7 +220,7 @@ module.exports = (crowi, app) => {
         : 1;
     }
     catch (error) {
-      return res.json(ApiResponse.error(error));
+      return res.status(500).send(error);
     }
 
     let query = builder.query;
@@ -243,10 +243,10 @@ module.exports = (crowi, app) => {
       query = Lsx.addSortCondition(query, pagePath, options.sort, options.reverse);
 
       const pages = await query.exec();
-      res.json(ApiResponse.success({ pages, toppageViewersCount }));
+      res.status(200).send({ pages, toppageViewersCount });
     }
     catch (error) {
-      return res.json(ApiResponse.error(error));
+      return res.status(500).send(error);
     }
   };
 

+ 1 - 0
packages/plugin-lsx/tsconfig.base.json

@@ -1,6 +1,7 @@
 {
   "extends": "../../tsconfig.base.json",
   "compilerOptions": {
+    "jsx": "preserve",
   },
   "include": [
     "src"

+ 5 - 0
yarn.lock

@@ -3957,6 +3957,11 @@
   resolved "https://registry.yarnpkg.com/@types/cors/-/cors-2.8.12.tgz#6b2c510a7ad7039e98e7b8d3d6598f4359e5c080"
   integrity sha512-vt+kDhq/M2ayberEtJcIN/hxXy1Pk+59g2FV/ZQceeaTyCtCucjL2Q7FXlFjtWn4n15KCr1NE2lNNFhp0lEThw==
 
+"@types/css-modules@^1.0.2":
+  version "1.0.2"
+  resolved "https://registry.yarnpkg.com/@types/css-modules/-/css-modules-1.0.2.tgz#8884135f9be3e204b42ef7ad7fce2474e8d74cb6"
+  integrity sha512-tyqlt2GtEBdsxJylh78zSxI/kOJK5Iz8Ta4Fxr8KLTP8mD/IgMa84D8EKPS/AWCp+MDoctgJyikrVWY28GKmcg==
+
 "@types/debug@^0.0.30":
   version "0.0.30"
   resolved "https://registry.yarnpkg.com/@types/debug/-/debug-0.0.30.tgz#dc1e40f7af3b9c815013a7860e6252f6352a84df"