Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 14 additions & 0 deletions apps/app/.eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,20 @@ module.exports = {
'src/interfaces/**',
'src/utils/**',
'src/components/**',
'src/client/components/DescendantsPageListModal/**',
'src/client/components/ItemsTree/**',
'src/client/components/LoginForm/**',
'src/client/components/Page/**',
'src/client/components/PageAttachment/**',
'src/client/components/PageDeleteModal/**',
'src/client/components/PageDuplicateModal/**',
'src/client/components/PageList/**',
'src/client/components/PageManagement/**',
'src/client/components/PagePathNavSticky/**',
'src/client/components/PagePresentationModal/**',
'src/client/components/PageRenameModal/**',
'src/client/components/PageSelectModal/**',
'src/client/components/PageSideContents/**',
'src/client/components/*.tsx',
'src/client/components/*.jsx',
'src/client/components/*.ts',
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { render, screen, fireEvent } from '@testing-library/react';
import { fireEvent, render, screen } from '@testing-library/react';

import { DescendantsPageListModal } from './DescendantsPageListModal';

Expand Down Expand Up @@ -33,15 +33,16 @@ vi.mock('~/states/context', () => ({
}));

vi.mock('../DescendantsPageList', () => ({
DescendantsPageList: () => <div data-testid="descendants-page-list">DescendantsPageList</div>,
DescendantsPageList: () => (
<div data-testid="descendants-page-list">DescendantsPageList</div>
),
}));

vi.mock('../PageTimeline', () => ({
PageTimeline: () => <div data-testid="page-timeline">PageTimeline</div>,
}));

describe('DescendantsPageListModal.tsx', () => {

it('should render the modal when isOpened is true', () => {
render(<DescendantsPageListModal />);
expect(screen.getByTestId('descendants-page-list-modal')).not.toBeNull();
Expand All @@ -55,7 +56,6 @@ describe('DescendantsPageListModal.tsx', () => {
});

describe('when device is larger than lg', () => {

it('should render CustomNavTab', () => {
render(<DescendantsPageListModal />);
expect(screen.getByTestId('custom-nav-tab')).not.toBeNull();
Expand Down
Original file line number Diff line number Diff line change
@@ -1,18 +1,16 @@

import React, {
useState, useMemo, useEffect, useCallback,
} from 'react';

import { useTranslation } from 'next-i18next';
import type React from 'react';
import { useCallback, useEffect, useMemo, useState } from 'react';
import dynamic from 'next/dynamic';
import { useRouter } from 'next/router';
import {
Modal, ModalHeader, ModalBody,
} from 'reactstrap';
import { useTranslation } from 'next-i18next';
import { Modal, ModalBody, ModalHeader } from 'reactstrap';

import { useIsSharedUser } from '~/states/context';
import { useDeviceLargerThanLg } from '~/states/ui/device';
import { useDescendantsPageListModalActions, useDescendantsPageListModalStatus } from '~/states/ui/modal/descendants-page-list';
import {
useDescendantsPageListModalActions,
useDescendantsPageListModalStatus,
} from '~/states/ui/modal/descendants-page-list';

import { CustomNavDropdown, CustomNavTab } from '../CustomNavigation/CustomNav';
import CustomTabContent from '../CustomNavigation/CustomTabContent';
Expand All @@ -21,9 +19,38 @@ import ExpandOrContractButton from '../ExpandOrContractButton';

import styles from './DescendantsPageListModal.module.scss';

const DescendantsPageList = dynamic<DescendantsPageListProps>(() => import('../DescendantsPageList').then(mod => mod.DescendantsPageList), { ssr: false });
const DescendantsPageList = dynamic<DescendantsPageListProps>(
() => import('../DescendantsPageList').then((mod) => mod.DescendantsPageList),
{ ssr: false },
);

const PageTimeline = dynamic(
() => import('../PageTimeline').then((mod) => mod.PageTimeline),
{ ssr: false },
);

const PageListTabIcon = (): React.JSX.Element => (
<span className="material-symbols-outlined">subject</span>
);

const PageListTabContent = (): React.JSX.Element => {
const status = useDescendantsPageListModalStatus();
const path = status?.path;

if (path == null) {
return <></>;
}

return <DescendantsPageList path={path} />;
};

const TimelineTabIcon = (): React.JSX.Element => (
<span data-testid="timeline-tab-button" className="material-symbols-outlined">
timeline
</span>
);

const PageTimeline = dynamic(() => import('../PageTimeline').then(mod => mod.PageTimeline), { ssr: false });
const TimelineTabContent = (): React.JSX.Element => <PageTimeline />;

/**
* DescendantsPageListModalSubstance - Presentation component (all logic here)
Expand Down Expand Up @@ -58,26 +85,19 @@ const DescendantsPageListModalSubstance = ({
const navTabMapping = useMemo(() => {
return {
pagelist: {
Icon: () => <span className="material-symbols-outlined">subject</span>,
Content: () => {
if (path == null) {
return <></>;
}
return <DescendantsPageList path={path} />;
},
Icon: PageListTabIcon,
Content: PageListTabContent,
i18n: t('page_list'),
isLinkEnabled: () => !isSharedUser,
},
timeline: {
Icon: () => <span data-testid="timeline-tab-button" className="material-symbols-outlined">timeline</span>,
Content: () => {
return <PageTimeline />;
},
Icon: TimelineTabIcon,
Content: TimelineTabContent,
i18n: t('Timeline View'),
isLinkEnabled: () => !isSharedUser,
},
};
}, [isSharedUser, path, t]);
}, [isSharedUser, t]);

// Memoize event handlers
const expandWindow = useCallback(() => {
Expand All @@ -90,20 +110,32 @@ const DescendantsPageListModalSubstance = ({
}, [onExpandedChange]);
const onNavSelected = useCallback((v: string) => setActiveTab(v), []);

const buttons = useMemo(() => (
<span className="me-3">
<ExpandOrContractButton
isWindowExpanded={isWindowExpanded}
expandWindow={expandWindow}
contractWindow={contractWindow}
/>
<button type="button" className="btn btn-close ms-2" onClick={closeModal} aria-label="Close"></button>
</span>
), [closeModal, isWindowExpanded, expandWindow, contractWindow]);
const buttons = useMemo(
() => (
<span className="me-3">
<ExpandOrContractButton
isWindowExpanded={isWindowExpanded}
expandWindow={expandWindow}
contractWindow={contractWindow}
/>
<button
type="button"
className="btn btn-close ms-2"
onClick={closeModal}
aria-label="Close"
></button>
</span>
),
[closeModal, isWindowExpanded, expandWindow, contractWindow],
);

return (
<div>
<ModalHeader className={isDeviceLargerThanLg ? 'p-0' : ''} toggle={closeModal} close={buttons}>
<ModalHeader
className={isDeviceLargerThanLg ? 'p-0' : ''}
toggle={closeModal}
close={buttons}
>
{isDeviceLargerThanLg && (
<CustomNavTab
activeTab={activeTab}
Expand All @@ -125,7 +157,11 @@ const DescendantsPageListModalSubstance = ({
<CustomTabContent
activeTab={activeTab}
navTabMapping={navTabMapping}
additionalClassNames={!isDeviceLargerThanLg ? ['grw-tab-content-style-md-down'] : undefined}
additionalClassNames={
!isDeviceLargerThanLg
? ['grw-tab-content-style-md-down']
: undefined
}
/>
</ModalBody>
</div>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,10 @@ export const DescendantsPageListModalLazyLoaded = (): JSX.Element => {

const DescendantsPageListModal = useLazyLoader<DescendantsPageListModalProps>(
'descendants-page-list-modal',
() => import('./DescendantsPageListModal').then(mod => ({ default: mod.DescendantsPageListModal })),
() =>
import('./DescendantsPageListModal').then((mod) => ({
default: mod.DescendantsPageListModal,
})),
status?.isOpened ?? false,
);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,7 @@ import { Skeleton } from '~/client/components/Skeleton';

import styles from './ItemsTreeContentSkeleton.module.scss';


const ItemsTreeContentSkeleton = (): JSX.Element => {

return (
<ul className="list-group py-3">
<Skeleton additionalClass={`${styles['text-skeleton-level1']} pe-3`} />
Expand Down
30 changes: 21 additions & 9 deletions apps/app/src/client/components/LoginForm/ExternalAuthButton.tsx
Original file line number Diff line number Diff line change
@@ -1,14 +1,21 @@
import { useCallback, type JSX } from 'react';

import { type JSX, useCallback } from 'react';
import { useTranslation } from 'next-i18next';

import { IExternalAuthProviderType } from '~/interfaces/external-auth-provider';

const authIcon = {
[IExternalAuthProviderType.google]: <span className="growi-custom-icons align-bottom">google</span>,
[IExternalAuthProviderType.github]: <span className="growi-custom-icons align-bottom">github</span>,
[IExternalAuthProviderType.oidc]: <span className="growi-custom-icons align-bottom">openid</span>,
[IExternalAuthProviderType.saml]: <span className="material-symbols-outlined align-bottom">key</span>,
[IExternalAuthProviderType.google]: (
<span className="growi-custom-icons align-bottom">google</span>
),
[IExternalAuthProviderType.github]: (
<span className="growi-custom-icons align-bottom">github</span>
),
[IExternalAuthProviderType.oidc]: (
<span className="growi-custom-icons align-bottom">openid</span>
),
[IExternalAuthProviderType.saml]: (
<span className="material-symbols-outlined align-bottom">key</span>
),
};

const authLabel = {
Expand All @@ -18,8 +25,11 @@ const authLabel = {
[IExternalAuthProviderType.saml]: 'SAML',
};


export const ExternalAuthButton = ({ authType }: {authType: IExternalAuthProviderType}): JSX.Element => {
export const ExternalAuthButton = ({
authType,
}: {
authType: IExternalAuthProviderType;
}): JSX.Element => {
const { t } = useTranslation();

const key = `btn-auth-${authType.toString()}`;
Expand All @@ -37,7 +47,9 @@ export const ExternalAuthButton = ({ authType }: {authType: IExternalAuthProvide
onClick={handleLoginWithExternalAuth}
>
<span>{authIcon[authType]}</span>
<span className="flex-grow-1">{t('Sign in with External auth', { signin: authLabel[authType] })}</span>
<span className="flex-grow-1">
{t('Sign in with External auth', { signin: authLabel[authType] })}
</span>
</button>
);
};
Loading
Loading