Skip to content

Commit

Permalink
Merge of #9580
Browse files Browse the repository at this point in the history
  • Loading branch information
mergify[bot] authored Jan 27, 2025
2 parents ee21b4e + 4b0769a commit 6773265
Show file tree
Hide file tree
Showing 114 changed files with 683 additions and 278 deletions.
12 changes: 0 additions & 12 deletions .github/workflows/reusable-app-prod.yml
Original file line number Diff line number Diff line change
Expand Up @@ -50,18 +50,6 @@ jobs:
run: |
pnpm install --frozen-lockfile
- name: Cache/Restore dist
uses: actions/cache@v4
with:
path: |
**/.turbo
**/dist
**/node_modules/.cache/turbo
${{ github.workspace }}/apps/app/.next
key: dist-app-prod-${{ runner.OS }}-node${{ inputs.node-version }}-${{ github.sha }}
restore-keys: |
dist-app-prod-${{ runner.OS }}-node${{ inputs.node-version }}-
- name: Build
working-directory: ./apps/app
run: |
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,10 @@ import type {
import { pagePathUtils } from '@growi/core/dist/utils';
import { GlobalCodeMirrorEditorKey } from '@growi/editor';
import { useCodeMirrorEditorIsolated } from '@growi/editor/dist/client/stores/codemirror-editor';
import { auto } from '@popperjs/core';
import { useTranslation } from 'next-i18next';
import dynamic from 'next/dynamic';
import Link from 'next/link';
import { useRouter } from 'next/router';
import { useTranslation } from 'next-i18next';
import Sticky from 'react-stickynode';
import { DropdownItem, UncontrolledTooltip } from 'reactstrap';

Expand All @@ -22,11 +21,6 @@ import { toastSuccess, toastError, toastWarning } from '~/client/util/toastr';
import { GroundGlassBar } from '~/components/Navbar/GroundGlassBar';
import type { OnDuplicatedFunction, OnRenamedFunction, OnDeletedFunction } from '~/interfaces/ui';
import { useShouldExpandContent } from '~/services/layout/use-should-expand-content';
import {
useCurrentPathname,
useCurrentUser, useIsGuestUser, useIsReadOnlyUser, useIsLocalAccountRegistrationEnabled, useIsSharedUser, useShareLinkId,
} from '~/stores-universal/context';
import { useEditorMode } from '~/stores-universal/ui';
import {
usePageAccessoriesModal, PageAccessoriesModalContents, type IPageForPageDuplicateModal,
usePageDuplicateModal, usePageRenameModal, usePageDeleteModal, usePagePresentationModal,
Expand All @@ -40,6 +34,11 @@ import {
useIsAbleToChangeEditorMode,
useIsDeviceLargerThanMd,
} from '~/stores/ui';
import {
useCurrentPathname,
useCurrentUser, useIsGuestUser, useIsReadOnlyUser, useIsLocalAccountRegistrationEnabled, useIsSharedUser, useShareLinkId,
} from '~/stores-universal/context';
import { useEditorMode } from '~/stores-universal/ui';

import { NotAvailable } from '../NotAvailable';
import { Skeleton } from '../Skeleton';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,3 +13,11 @@
}
}
}

@media print {
.grw-page-path-nav-sticky :global {
.sticky-inner-wrapper {
position: static !important;
}
}
}
2 changes: 1 addition & 1 deletion apps/app/src/components/Layout/BasicLayout.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ export const BasicLayout = ({ children, className }: Props): JSX.Element => {
return (
<RawLayout className={`${moduleClass} ${className ?? ''}`}>
<div className="page-wrapper flex-row">
<div className="z-2">
<div className="z-2 d-print-none">
<Sidebar />
</div>

Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
@use '@growi/core-styles/scss/bootstrap/init' as bs;

.page-content-footer :global {
border-top: solid 1px transparent;
border-top: solid 1px var(--bs-border-color);
.page-meta {
font-size: 0.95em;
}
Expand Down
10 changes: 4 additions & 6 deletions apps/app/src/components/PageView/PageContentFooter.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -22,12 +22,10 @@ export const PageContentFooter = (props: PageContentFooterProps): JSX.Element =>
}

return (
<div className={`${styles['page-content-footer']} page-content-footer py-4 d-edit-none d-print-none}`}>
<div className="container-lg grw-container-convertible">
<div className="page-meta">
<AuthorInfo user={creator} date={createdAt} mode="create" locate="footer" />
<AuthorInfo user={lastUpdateUser} date={updatedAt} mode="update" locate="footer" />
</div>
<div className={`${styles['page-content-footer']} my-4 pt-4 d-edit-none d-print-none}`}>
<div className="page-meta">
<AuthorInfo user={creator} date={createdAt} mode="create" locate="footer" />
<AuthorInfo user={lastUpdateUser} date={updatedAt} mode="update" locate="footer" />
</div>
</div>
);
Expand Down
2 changes: 1 addition & 1 deletion apps/app/src/components/PageView/PageViewLayout.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ export const PageViewLayout = (props: Props): JSX.Element => {
</div>

{ footerContents != null && (
<footer className={`footer d-edit-none wide-gutter-x-lg ${fluidLayoutClass}`}>
<footer className={`footer d-edit-none container-lg wide-gutter-x-lg ${fluidLayoutClass}`}>
{footerContents}
</footer>
) }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ interface AuthorizedRequest extends Request {
module.exports = (crowi: Crowi): Router => {
const loginRequiredStrictly = require('~/server/middlewares/login-required')(crowi);
const adminRequired = require('~/server/middlewares/admin-required')(crowi);
const addActivity = generateAddActivityMiddleware(crowi);
const addActivity = generateAddActivityMiddleware();

const activityEvent = crowi.event('activity');

Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import axiosRetry from 'axios-retry';

import type Crowi from '~/server/crowi';
import { configManager } from '~/server/service/config-manager';
import loggerFactory from '~/utils/logger';
import { getRandomIntInRange } from '~/utils/rand';
Expand Down Expand Up @@ -28,12 +29,11 @@ axiosRetry(axios, { retries: 3 });
*/
class QuestionnaireCronService {

crowi: any;
crowi: Crowi;

cronJob: any;

// eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types
constructor(crowi) {
constructor(crowi: Crowi) {
this.crowi = crowi;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ class QuestionnaireService {
crowi: Crowi;

// eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types
constructor(crowi) {
constructor(crowi: Crowi) {
this.crowi = crowi;
}

Expand Down
3 changes: 2 additions & 1 deletion apps/app/src/features/templates/server/routes/apiv3/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import { param, query } from 'express-validator';

import { PLUGIN_STORING_PATH } from '~/features/growi-plugin/server/consts';
import { GrowiPlugin } from '~/features/growi-plugin/server/models';
import type Crowi from '~/server/crowi';
import { apiV3FormValidator } from '~/server/middlewares/apiv3-form-validator';
import type { ApiV3Response } from '~/server/routes/apiv3/interfaces/apiv3-response';
import loggerFactory from '~/utils/logger';
Expand All @@ -32,7 +33,7 @@ const validator = {
let presetTemplateSummaries: TemplateSummary[];


module.exports = (crowi) => {
module.exports = (crowi: Crowi) => {
const loginRequiredStrictly = require('~/server/middlewares/login-required')(crowi);

router.get('/', loginRequiredStrictly, validator.list, apiV3FormValidator, async(req, res: ApiV3Response) => {
Expand Down
3 changes: 1 addition & 2 deletions apps/app/src/server/crowi/dev.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,7 @@ const logger = loggerFactory('growi:crowi:dev');
class CrowiDev {

/**
* Creates an instance of CrowiDev.
* @param {Crowi} crowi
* @param {import('~/server/crowi').default} crowi Crowi instance
*
* @memberOf CrowiDev
*/
Expand Down
9 changes: 9 additions & 0 deletions apps/app/src/server/crowi/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,9 @@ class Crowi {
*/
accessTokenParser;

/** @type {ReturnType<typeof next>} */
nextApp;

/** @type {import('../service/config-manager').IConfigManagerForApp} */
configManager;

Expand All @@ -75,6 +78,12 @@ class Crowi {
/** @type {import('../service/page').IPageService} */
pageService;

/** @type {import('../service/page-grant').default} */
pageGrantService;

/** @type {import('../service/page-operation').default} */
pageOperationService;

/** @type {PassportService} */
passportService;

Expand Down
3 changes: 2 additions & 1 deletion apps/app/src/server/events/admin.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
const util = require('util');
const events = require('events');
const util = require('util');

/** @param {import('~/server/crowi').default} crowi Crowi instance */
function AdminEvent(crowi) {
this.crowi = crowi;

Expand Down
1 change: 1 addition & 0 deletions apps/app/src/server/events/bookmark.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
const events = require('events');
const util = require('util');

/** @param {import('~/server/crowi').default} crowi Crowi instance */
function BookmarkEvent(crowi) {
this.crowi = crowi;

Expand Down
1 change: 1 addition & 0 deletions apps/app/src/server/events/page.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import loggerFactory from '~/utils/logger';

const logger = loggerFactory('growi:events:page');

/** @param {import('~/server/crowi').default} crowi Crowi instance */
function PageEvent(crowi) {
this.crowi = crowi;

Expand Down
3 changes: 2 additions & 1 deletion apps/app/src/server/events/tag.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
const util = require('util');
const events = require('events');
const util = require('util');

/** @param {import('~/server/crowi').default} crowi Crowi instance */
function TagEvent(crowi) {
this.crowi = crowi;

Expand Down
4 changes: 2 additions & 2 deletions apps/app/src/server/middlewares/add-activity.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import type { IUserHasId } from '@growi/core';
import { NextFunction, Request, Response } from 'express';
import type { NextFunction, Request, Response } from 'express';

import { SupportedAction } from '~/interfaces/activity';
import Activity from '~/server/models/activity';
Expand All @@ -12,7 +12,7 @@ interface AuthorizedRequest extends Request {
user?: IUserHasId
}

export const generateAddActivityMiddleware = crowi => async(req: AuthorizedRequest, res: Response, next: NextFunction): Promise<void> => {
export const generateAddActivityMiddleware = () => async(req: AuthorizedRequest, res: Response, next: NextFunction): Promise<void> => {
if (req.method === 'GET') {
logger.warn('This middleware is not available for GET requests');
return next();
Expand Down
1 change: 1 addition & 0 deletions apps/app/src/server/middlewares/admin-required.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import loggerFactory from '~/utils/logger';

const logger = loggerFactory('growi:middleware:admin-required');

/** @param {import('~/server/crowi').default} crowi Crowi instance */
module.exports = (crowi, fallback = null) => {

return function(req, res, next) {
Expand Down
1 change: 1 addition & 0 deletions apps/app/src/server/middlewares/application-installed.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
/** @param {import('~/server/crowi').default} crowi Crowi instance */
module.exports = (crowi) => {
const { appService } = crowi;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
/** @param {import('~/server/crowi').default} crowi Crowi instance */
module.exports = (crowi) => {
const { appService } = crowi;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
/** @param {import('~/server/crowi').default} crowi Crowi instance */
module.exports = (crowi) => {
const { s2sMessagingService } = crowi;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ const { ReconnectContext, nextTick } = require('../service/search-reconnect-cont

const logger = loggerFactory('growi:middlewares:auto-reconnect-to-search');

/** @param {import('~/server/crowi').default} crowi Crowi instance */
module.exports = (crowi) => {
const { searchService } = crowi;
const reconnectContext = new ReconnectContext();
Expand Down
4 changes: 3 additions & 1 deletion apps/app/src/server/middlewares/certify-brand-logo.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
export const generateCertifyBrandLogoMiddleware = (crowi) => {
import type Crowi from '../crowi';

export const generateCertifyBrandLogoMiddleware = (crowi: Crowi) => {

return async(req, res, next) => {
req.isBrandLogo = true;
Expand Down
1 change: 1 addition & 0 deletions apps/app/src/server/middlewares/certify-shared-page.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import loggerFactory from '~/utils/logger';

const logger = loggerFactory('growi:middleware:certify-shared-page');

/** @param {import('~/server/crowi').default} crowi Crowi instance */
module.exports = (crowi) => {

return async(req, res, next) => {
Expand Down
2 changes: 1 addition & 1 deletion apps/app/src/server/middlewares/login-required.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ const logger = loggerFactory('growi:middleware:login-required');

/**
* require login handler
*
* @param {import('~/server/crowi').default} crowi Crowi instance
* @param {boolean} isGuestAllowed whether guest user is allowed (default false)
* @param {function} fallback fallback function which will be triggered when the check cannot be passed
*/
Expand Down
Original file line number Diff line number Diff line change
@@ -1,38 +1,41 @@
import { NextFunction, Request, Response } from 'express';
import type { NextFunction, Request, Response } from 'express';

import loggerFactory from '~/utils/logger';

const logger = loggerFactory('growi:middlewares:unavailable-when-maintenance-mode');
import type Crowi from '../crowi';

type Crowi = {
// eslint-disable-next-line @typescript-eslint/no-explicit-any
nextApp: any,
}
const logger = loggerFactory('growi:middlewares:unavailable-when-maintenance-mode');

type CrowiReq = Request & {
crowi: Crowi,
}

export const generateUnavailableWhenMaintenanceModeMiddleware = crowi => async(req: CrowiReq, res: Response, next: NextFunction): Promise<void> => {
const isMaintenanceMode = crowi.appService.isMaintenanceMode();
type IMiddleware = (req: CrowiReq, res: Response, next: NextFunction) => Promise<void>;

export const generateUnavailableWhenMaintenanceModeMiddleware = (crowi: Crowi): IMiddleware => {
return async(req, res, next) => {
const isMaintenanceMode = crowi.appService.isMaintenanceMode();

if (!isMaintenanceMode) {
next();
return;
}
if (!isMaintenanceMode) {
next();
return;
}

const { nextApp } = crowi;
req.crowi = crowi;
nextApp.render(req, res, '/maintenance');
const { nextApp } = crowi;
req.crowi = crowi;
nextApp.render(req, res, '/maintenance');
};
};

export const generateUnavailableWhenMaintenanceModeMiddlewareForApi = crowi => async(req: Request, res: Response, next: NextFunction): Promise<void> => {
const isMaintenanceMode = crowi.appService.isMaintenanceMode();
export const generateUnavailableWhenMaintenanceModeMiddlewareForApi = (crowi: Crowi): IMiddleware => {
return async(req, res, next) => {
const isMaintenanceMode = crowi.appService.isMaintenanceMode();

if (!isMaintenanceMode) {
next();
return;
}
if (!isMaintenanceMode) {
next();
return;
}

res.status(503).json({ error: 'GROWI is under maintenance.' });
res.status(503).json({ error: 'GROWI is under maintenance.' });
};
};
1 change: 1 addition & 0 deletions apps/app/src/server/models/GlobalNotificationSetting.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ export const GlobalNotificationSettingType = {
SLACK: 'slack',
};

/** @param {import('~/server/crowi').default} crowi Crowi instance */
const factory = function(crowi) {
GlobalNotificationSettingClass.crowi = crowi;
GlobalNotificationSettingSchema.loadClass(GlobalNotificationSettingClass);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ const GlobalNotificationSetting = require('./index');
const GlobalNotificationSettingClass = GlobalNotificationSetting.class;
const GlobalNotificationSettingSchema = GlobalNotificationSetting.schema;

/** @param {import('~/server/crowi').default} crowi Crowi instance */
const factory = (crowi) => {
GlobalNotificationSettingClass.crowi = crowi;
GlobalNotificationSettingSchema.loadClass(GlobalNotificationSettingClass);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ const GlobalNotificationSetting = require('./index');
const GlobalNotificationSettingClass = GlobalNotificationSetting.class;
const GlobalNotificationSettingSchema = GlobalNotificationSetting.schema;

/** @param {import('~/server/crowi').default} crowi Crowi instance */
const factory = (crowi) => {
GlobalNotificationSettingClass.crowi = crowi;
GlobalNotificationSettingSchema.loadClass(GlobalNotificationSettingClass);
Expand Down
Loading

0 comments on commit 6773265

Please sign in to comment.