Skip to content

Commit

Permalink
Merge branch 'master' into feat/gw7925-normalize-cypress-test
Browse files Browse the repository at this point in the history
  • Loading branch information
ryoji-s committed Apr 28, 2023
2 parents ab0088b + be000f7 commit 83c54af
Show file tree
Hide file tree
Showing 75 changed files with 1,823 additions and 3,656 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ See [GROWI Docs: Environment Variables](https://docs.growi.org/en/admin-guide/ad
| `yarn app:server` | Launch GROWI app server |
| `yarn start` | Invoke `yarn app:build` and `yarn app:server` |

For more info, see [GROWI Docs: List of npm Commands](https://docs.growi.org/en/dev/startup-v2/launch-system.html#list-of-npm-commands).
For more info, see [GROWI Docs: List of npm Scripts](https://docs.growi.org/en/dev/startup-v5/start-development.html#list-of-npm-scripts).

# Documentation

Expand Down
2 changes: 1 addition & 1 deletion README_JP.md
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ Crowi からの移行は **[こちら](https://docs.growi.org/en/admin-guide/mig
| `yarn app:server` | GROWI app サーバーを起動します。 |
| `yarn start` | `yarn app:build``yarn app:server` を呼び出します。 |

詳しくは [GROWI Docs: List of npm Commands](https://docs.growi.org/ja/dev/startup-v2/launch-system.html#npm-コマンドリスト)をご覧ください。
詳しくは [GROWI Docs: npm スクリプトリスト](https://docs.growi.org/ja/dev/startup-v5/start-development.html#npm-%E3%82%B9%E3%82%AF%E3%83%AA%E3%83%95%E3%82%9A%E3%83%88%E3%83%AA%E3%82%B9%E3%83%88)をご覧ください。

# ドキュメント

Expand Down
23 changes: 16 additions & 7 deletions apps/app/next.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -85,16 +85,25 @@ module.exports = async(phase, { defaultConfig }) => {

/** @param config {import('next').NextConfig} */
webpack(config, options) {
// Avoid "Module not found: Can't resolve 'fs'"
// See: https://stackoverflow.com/a/68511591
if (!options.isServer) {
// Avoid "Module not found: Can't resolve 'fs'"
// See: https://stackoverflow.com/a/68511591
config.resolve.fallback.fs = false;
}

// See: https://webpack.js.org/configuration/externals/
// This provides a way of excluding dependencies from the output bundles
config.externals.push('dtrace-provider');
config.externals.push('mongoose');
// exclude packages from the output bundles
config.module.rules.push(
...[
/dtrace-provider/,
/mongoose/,
/mathjax-full/, // required from marp
].map((packageRegExp) => {
return {
test: packageRegExp,
use: 'null-loader',
};
}),
);
}

// extract sourcemap
if (options.dev) {
Expand Down
6 changes: 4 additions & 2 deletions apps/app/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@
"//// for development": "",
"dev": "yarn cross-env NODE_ENV=development yarn ts-node-dev --inspect --transpile-only src/server/app.ts",
"dev:styles-prebuilt": "yarn styles-prebuilt --mode dev",
"dev:analyze": "yarn cross-env ANALYZE=true yarn dev",
"dev:migrate-mongo": "yarn cross-env NODE_ENV=development yarn ts-node node_modules/.bin/migrate-mongo",
"dev:migrate": "yarn dev:migrate:status > tmp/cache/migration-status.out && yarn dev:migrate:up",
"dev:migrate:create": "yarn dev:migrate-mongo create -f config/migrate-mongo-config.js",
Expand Down Expand Up @@ -62,6 +61,7 @@
"@google-cloud/storage": "^5.8.5",
"@growi/core": "^6.1.0-RC.0",
"@growi/hackmd": "^6.1.0-RC.0",
"@growi/remark-attachment-refs": "^6.1.0-RC.0",
"@growi/preset-themes": "^6.1.0-RC.0",
"@growi/remark-drawio": "^6.1.0-RC.0",
"@growi/remark-growi-directive": "^6.1.0-RC.0",
Expand Down Expand Up @@ -144,6 +144,7 @@
"passport-local": "^1.0.0",
"passport-saml": "^3.2.0",
"prom-client": "^14.1.1",
"qs": "^6.11.1",
"rate-limiter-flexible": "^2.3.7",
"react": "^18.2.0",
"react-bootstrap-typeahead": "^5.2.2",
Expand Down Expand Up @@ -192,7 +193,7 @@
"usehooks-ts": "^2.6.0",
"validator": "^13.7.0",
"ws": "^8.3.0",
"xss": "^1.0.6"
"xss": "^1.0.14"
},
"// comments for defDependencies": {
"@handsontable/react": "v3 requires handsontable >= 7.0.0.",
Expand Down Expand Up @@ -225,6 +226,7 @@
"load-css-file": "^1.0.0",
"material-icons": "^1.11.3",
"morgan": "^1.10.0",
"null-loader": "^4.0.1",
"penpal": "^4.0.0",
"plantuml-encoder": "^1.2.5",
"prettier": "^1.19.1",
Expand Down
26 changes: 26 additions & 0 deletions apps/app/src/client/services/renderer/renderer.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import assert from 'assert';

import { isClient } from '@growi/core/dist/utils/browser-utils';
import * as refsGrowiPlugin from '@growi/remark-attachment-refs/dist/client/index.mjs';
import * as drawioPlugin from '@growi/remark-drawio';
// eslint-disable-next-line import/extensions
import * as lsxGrowiPlugin from '@growi/remark-lsx/dist/client/index.mjs';
Expand Down Expand Up @@ -33,6 +34,7 @@ import loggerFactory from '~/utils/logger';
// import EasyGrid from './PreProcessor/EasyGrid';

import '@growi/remark-lsx/dist/client/style.css';
import '@growi/remark-attachment-refs/dist/client/style.css';


const logger = loggerFactory('growi:cli:services:renderer');
Expand All @@ -58,6 +60,7 @@ export const generateViewOptions = (
drawioPlugin.remarkPlugin,
xsvToTable.remarkPlugin,
lsxGrowiPlugin.remarkPlugin,
refsGrowiPlugin.remarkPlugin,
);
if (config.isEnabledLinebreaks) {
remarkPlugins.push(breaks);
Expand All @@ -72,13 +75,15 @@ export const generateViewOptions = (
commonSanitizeOption,
drawioPlugin.sanitizeOption,
lsxGrowiPlugin.sanitizeOption,
refsGrowiPlugin.sanitizeOption,
)]
: () => {};

// add rehype plugins
rehypePlugins.push(
slug,
[lsxGrowiPlugin.rehypePlugin, { pagePath, isSharedPage: config.isSharedPage }],
[refsGrowiPlugin.rehypePlugin, { pagePath }],
rehypeSanitizePlugin,
katex,
[relocateToc.rehypePluginStore, { storeTocNode }],
Expand All @@ -93,6 +98,11 @@ export const generateViewOptions = (
components.h5 = Header;
components.h6 = Header;
components.lsx = lsxGrowiPlugin.Lsx;
components.ref = refsGrowiPlugin.Ref;
components.refs = refsGrowiPlugin.Refs;
components.refimg = refsGrowiPlugin.RefImg;
components.refsimg = refsGrowiPlugin.RefsImg;
components.gallery = refsGrowiPlugin.Gallery;
components.drawio = DrawioViewerWithEditButton;
components.table = TableWithEditButton;
}
Expand Down Expand Up @@ -153,6 +163,7 @@ export const generateSimpleViewOptions = (
drawioPlugin.remarkPlugin,
xsvToTable.remarkPlugin,
lsxGrowiPlugin.remarkPlugin,
refsGrowiPlugin.remarkPlugin,
);

const isEnabledLinebreaks = overrideIsEnabledLinebreaks ?? config.isEnabledLinebreaks;
Expand All @@ -171,12 +182,14 @@ export const generateSimpleViewOptions = (
commonSanitizeOption,
drawioPlugin.sanitizeOption,
lsxGrowiPlugin.sanitizeOption,
refsGrowiPlugin.sanitizeOption,
)]
: () => {};

// add rehype plugins
rehypePlugins.push(
[lsxGrowiPlugin.rehypePlugin, { pagePath, isSharedPage: config.isSharedPage }],
[refsGrowiPlugin.rehypePlugin, { pagePath }],
[keywordHighlighter.rehypePlugin, { keywords: highlightKeywords }],
rehypeSanitizePlugin,
katex,
Expand All @@ -185,6 +198,11 @@ export const generateSimpleViewOptions = (
// add components
if (components != null) {
components.lsx = lsxGrowiPlugin.LsxImmutable;
components.ref = refsGrowiPlugin.RefImmutable;
components.refs = refsGrowiPlugin.RefsImmutable;
components.refimg = refsGrowiPlugin.RefImgImmutable;
components.refsimg = refsGrowiPlugin.RefsImgImmutable;
components.gallery = refsGrowiPlugin.GalleryImmutable;
components.drawio = drawioPlugin.DrawioViewer;
}

Expand Down Expand Up @@ -219,6 +237,7 @@ export const generatePreviewOptions = (config: RendererConfig, pagePath: string)
drawioPlugin.remarkPlugin,
xsvToTable.remarkPlugin,
lsxGrowiPlugin.remarkPlugin,
refsGrowiPlugin.remarkPlugin,
);
if (config.isEnabledLinebreaks) {
remarkPlugins.push(breaks);
Expand All @@ -232,6 +251,7 @@ export const generatePreviewOptions = (config: RendererConfig, pagePath: string)
? [sanitize, deepmerge(
commonSanitizeOption,
lsxGrowiPlugin.sanitizeOption,
refsGrowiPlugin.sanitizeOption,
drawioPlugin.sanitizeOption,
addLineNumberAttribute.sanitizeOption,
)]
Expand All @@ -240,6 +260,7 @@ export const generatePreviewOptions = (config: RendererConfig, pagePath: string)
// add rehype plugins
rehypePlugins.push(
[lsxGrowiPlugin.rehypePlugin, { pagePath, isSharedPage: config.isSharedPage }],
[refsGrowiPlugin.rehypePlugin, { pagePath }],
addLineNumberAttribute.rehypePlugin,
rehypeSanitizePlugin,
katex,
Expand All @@ -248,6 +269,11 @@ export const generatePreviewOptions = (config: RendererConfig, pagePath: string)
// add components
if (components != null) {
components.lsx = lsxGrowiPlugin.LsxImmutable;
components.ref = refsGrowiPlugin.RefImmutable;
components.refs = refsGrowiPlugin.RefsImmutable;
components.refimg = refsGrowiPlugin.RefImgImmutable;
components.refsimg = refsGrowiPlugin.RefsImgImmutable;
components.gallery = refsGrowiPlugin.GalleryImmutable;
components.drawio = drawioPlugin.DrawioViewer;
}

Expand Down
4 changes: 3 additions & 1 deletion apps/app/src/components/Common/Dropdown/PageItemControl.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import React, { useState, useCallback, useEffect } from 'react';

import { modifiersForRightAlign } from '@growi/ui/dist/utils';
import { useTranslation } from 'next-i18next';
import {
Dropdown, DropdownMenu, DropdownToggle, DropdownItem,
Expand Down Expand Up @@ -248,9 +249,10 @@ const PageItemControlDropdownMenu = React.memo((props: DropdownMenuProps): JSX.E
return (
<DropdownMenu
data-testid="page-item-control-menu"
modifiers={{ preventOverflow: { boundariesElement: 'viewport' } }}
right={alignRight}
modifiers={modifiersForRightAlign}
container="body"
persist={!!alignRight}
style={{ zIndex: 1055 }} /* make it larger than $zindex-modal of bootstrap */
>
{contents}
Expand Down
2 changes: 1 addition & 1 deletion apps/app/src/components/Me/InAppNotificationSettings.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import React, {
FC, useState, useEffect, useCallback,
} from 'react';

import { pullAllBy } from 'lodash';
import pullAllBy from 'lodash/pullAllBy';
import { useTranslation } from 'next-i18next';

import { apiv3Get, apiv3Put } from '~/client/util/apiv3-client';
Expand Down
7 changes: 5 additions & 2 deletions apps/app/src/components/Page/CopyDropdown.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -118,8 +118,11 @@ const CopyDropdown = (props) => {
<span id={dropdownToggleId}>{children}</span>
</DropdownToggle>

<DropdownMenu positionFixed modifiers={{ preventOverflow: { boundariesElement: 'viewport' } }}>

<DropdownMenu
positionFixed
modifiers={{ preventOverflow: { boundariesElement: 'viewport' } }}
style={{ zIndex: 1016 }} /* zIndex: 1016 // larger than z-index value of grw-subnav-fixed-container in GrowiSubNavigationSwitcher.module.scss */
>
<div className="d-flex align-items-center justify-content-between">
<DropdownItem header className="px-3">
{ t('copy_to_clipboard.Copy to clipboard') }
Expand Down
7 changes: 5 additions & 2 deletions apps/app/src/components/PageSideContents.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ import TableOfContents from './TableOfContents';
import styles from './PageSideContents.module.scss';


const { isTopPage, isUsersHomePage } = pagePathUtils;
const { isTopPage, isUsersHomePage, isTrashPage } = pagePathUtils;


export type PageSideContentsProps = {
Expand All @@ -32,6 +32,7 @@ export const PageSideContents = (props: PageSideContentsProps): JSX.Element => {
const pagePath = page.path;
const isTopPagePath = isTopPage(pagePath);
const isUsersHomePagePath = isUsersHomePage(pagePath);
const isTrash = isTrashPage(pagePath);

return (
<>
Expand All @@ -48,7 +49,9 @@ export const PageSideContents = (props: PageSideContentsProps): JSX.Element => {
<PageListIcon />
</div>
{t('page_list')}
<CountBadge count={page?.descendantCount} offset={1} />

{/* Do not display CountBadge if '/trash/*': https://github.com/weseek/growi/pull/7600 */}
{ !isTrash ? <CountBadge count={page?.descendantCount} offset={1} /> : <div className='px-2'></div>}
</button>
)}
</div>
Expand Down
26 changes: 13 additions & 13 deletions apps/app/src/components/SavePageControls.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -80,17 +80,17 @@ export const SavePageControls = (props: SavePageControlsProps): JSX.Element | nu
<div className="d-flex align-items-center form-inline flex-nowrap">

{isAclEnabled
&& (
<div className="mr-2">
<GrantSelector
grant={grant}
disabled={isRootPage}
grantGroupId={grantedGroup?.id}
grantGroupName={grantedGroup?.name}
onUpdateGrant={updateGrantHandler}
/>
</div>
)
&& (
<div className="mr-2">
<GrantSelector
grant={grant}
disabled={isRootPage}
grantGroupId={grantedGroup?.id}
grantGroupName={grantedGroup?.name}
onUpdateGrant={updateGrantHandler}
/>
</div>
)
}

<UncontrolledButtonDropdown direction="up">
Expand All @@ -101,9 +101,9 @@ export const SavePageControls = (props: SavePageControlsProps): JSX.Element | nu
onClick={save}
disabled={isWaitingSaveProcessing}
>
{ isWaitingSaveProcessing && (
{isWaitingSaveProcessing && (
<i className="fa fa-spinner fa-pulse mr-1"></i>
) }
)}
{labelSubmitButton}
</Button>
<DropdownToggle caret color="primary" disabled={isWaitingSaveProcessing} />
Expand Down
2 changes: 2 additions & 0 deletions apps/app/src/server/crowi/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import http from 'http';
import path from 'path';

import { createTerminus } from '@godaddy/terminus';
import attachmentRoutes from '@growi/remark-attachment-refs/dist/server';
import lsxRoutes from '@growi/remark-lsx/dist/server';
import mongoose from 'mongoose';
import next from 'next';
Expand Down Expand Up @@ -531,6 +532,7 @@ Crowi.prototype.setupTerminus = function(server) {

Crowi.prototype.setupRoutesForPlugins = function() {
lsxRoutes(this, this.express);
attachmentRoutes(this, this.express);
};

/**
Expand Down
2 changes: 1 addition & 1 deletion apps/app/src/server/models/page.ts
Original file line number Diff line number Diff line change
Expand Up @@ -566,7 +566,7 @@ schema.statics.findByIdsAndViewer = async function(
};

/*
* Find a page by path and viewer. Pass false to useFindOne to use findOne method.
* Find a page by path and viewer. Pass true to useFindOne to use findOne method.
*/
schema.statics.findByPathAndViewer = async function(
path: string | null, user, userGroups = null, useFindOne = false, includeEmpty = false,
Expand Down
4 changes: 2 additions & 2 deletions apps/app/src/server/service/search.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import mongoose from 'mongoose';
import xss from 'xss';
import { FilterXSS } from 'xss';

import { SearchDelegatorName } from '~/interfaces/named-query';
import { IPageHasId } from '~/interfaces/page';
Expand Down Expand Up @@ -31,7 +31,7 @@ const filterXssOptions = {
},
};

const filterXss = new xss.FilterXSS(filterXssOptions);
const filterXss = new FilterXSS(filterXssOptions);

const normalizeQueryString = (_queryString: string): string => {
let queryString = _queryString.trim();
Expand Down
Loading

0 comments on commit 83c54af

Please sign in to comment.