Skip to content

Commit

Permalink
Merge branch 'main' of github.com:PROCEED-Labs/proceed into ms2/small…
Browse files Browse the repository at this point in the history
…-editor-improvements
  • Loading branch information
jjoderis committed Dec 18, 2023
2 parents 15c0460 + f476e0c commit 58f0b1c
Show file tree
Hide file tree
Showing 17 changed files with 330 additions and 514 deletions.
5 changes: 5 additions & 0 deletions src/management-system-v2/app/(dashboard)/processes/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,11 @@ import { Result, Space } from 'antd';
import NotLoggedInFallback from './not-logged-in-fallback';
import { getProcesses } from '@/lib/data/legacy/process';
import Auth, { getCurrentUser } from '@/components/auth';
// This is a workaround to enable the Server Actions in that file to return any
// client components. This is not possible with the current nextjs compiler
// otherwise. It might be possible in the future with turbopack without this
// import.
import '@/lib/data/processes';

const ProcessesPage = async () => {
const { ability } = await getCurrentUser();
Expand Down
122 changes: 70 additions & 52 deletions src/management-system-v2/components/ProcessSider.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import { Menu } from 'antd';
const { SubMenu, Item, ItemGroup } = Menu;
import {
EditOutlined,
FileOutlined,
ProfileOutlined,
FileAddOutlined,
StarOutlined,
Expand All @@ -24,62 +25,79 @@ const ProcessSider: FC<PropsWithChildren> = () => {
<>
<ItemGroup key="processes" title="Processes">
{ability.can('view', 'Process') ? (
<SubMenu
key="processes"
title={
<span
onClick={() => {
router.push(`/processes`);
}}
>
Process List
</span>
}
className={activeSegment === 'processes' ? 'SelectedSegment' : ''}
icon={
<EditOutlined
onClick={() => {
router.push(`/processes`);
}}
/>
}
<Item
key="oricesses"
title="Processes"
icon={<FileOutlined />}
hidden={!ability.can('view', 'Process')}
>
<Item
key="newProcess"
icon={<FileAddOutlined />}
hidden={!ability.can('create', 'Process')}
<span
onClick={() => {
router.push(`/processes`);
}}
>
<ProcessCreationButton
wrapperElement={<span>New Process</span>}
></ProcessCreationButton>
</Item>
<Item
key="processImport"
icon={<UploadOutlined />}
hidden={!ability.can('create', 'Process')}
>
<ProcessImportButton />
</Item>
<Item key="processFavorites" icon={<StarOutlined />}>
Favorites
</Item>
</SubMenu>
) : null}
Process List
</span>
</Item>
) : // <SubMenu
// key="processes"
// title={
// <span
// onClick={() => {
// router.push(`/processes`);
// }}
// >
// Process List
// </span>
// }
// className={activeSegment === 'processes' ? 'SelectedSegment' : ''}
// icon={
// <EditOutlined
// onClick={() => {
// router.push(`/processes`);
// }}
// />
// }
// >
// <Item
// key="newProcess"
// icon={<FileAddOutlined />}
// hidden={!ability.can('create', 'Process')}
// >
// <ProcessCreationButton
// wrapperElement={<span>New Process</span>}
// ></ProcessCreationButton>
// </Item>
// <Item
// key="processImport"
// icon={<UploadOutlined />}
// hidden={!ability.can('create', 'Process')}
// >
// <ProcessImportButton />
// </Item>
// <Item key="processFavorites" icon={<StarOutlined />}>
// Favorites
// </Item>
// </SubMenu>
null}

{ability.can('view', 'Template') ? (
<SubMenu key="templates" title="Templates" icon={<ProfileOutlined />}>
<Item
key="newTemplate"
icon={<FileAddOutlined />}
hidden={!ability.can('create', 'Template')}
>
New Template
</Item>
<Item key="templateFavorites" icon={<StarOutlined />}>
Favorites
</Item>
</SubMenu>
) : null}
<Item key="template" icon={<ProfileOutlined />}>
Templates
</Item>
) : // <SubMenu key="templates" title="Templates" icon={<ProfileOutlined />}>
// <Item
// key="newTemplate"
// icon={<FileAddOutlined />}
// hidden={!ability.can('create', 'Template')}
// >
// New Template
// </Item>
// <Item key="templateFavorites" icon={<StarOutlined />}>
// Favorites
// </Item>
// </SubMenu>
null}
</ItemGroup>
</>
);
Expand Down
11 changes: 9 additions & 2 deletions src/management-system-v2/components/confirmation-button.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@ type ConfirmationModalProps = {
>;
buttonProps?: ComponentProps<typeof Button>;
tooltip?: string;
externalOpen?: boolean;
onExternalClose?: () => void;
};

const ConfirmationButton: FC<PropsWithChildren<ConfirmationModalProps>> = ({
Expand All @@ -23,12 +25,15 @@ const ConfirmationButton: FC<PropsWithChildren<ConfirmationModalProps>> = ({
modalProps,
buttonProps,
tooltip,
externalOpen,
onExternalClose,
}) => {
const [modalOpen, setModalOpen] = useState(false);
const [loading, setLoading] = useState(false);

const clearModal = () => {
setModalOpen(false);
onExternalClose?.();
setLoading(false);
};

Expand All @@ -48,10 +53,12 @@ const ConfirmationButton: FC<PropsWithChildren<ConfirmationModalProps>> = ({
closeIcon={null}
{...modalProps}
title={title}
open={modalOpen}
open={externalOpen || modalOpen}
onOk={onConfirmWrapper}
confirmLoading={loading}
onCancel={() => (canCloseWhileLoading || !loading) && setModalOpen(false)}
onCancel={() =>
((canCloseWhileLoading || !loading) && setModalOpen(false)) || onExternalClose?.()
}
cancelButtonProps={{ disabled: !canCloseWhileLoading && loading }}
>
<p>{description}</p>
Expand Down
24 changes: 24 additions & 0 deletions src/management-system-v2/components/content.module.scss
Original file line number Diff line number Diff line change
Expand Up @@ -29,4 +29,28 @@
padding: 0;
}
}

.Icon {
margin: 15px -10px;
}

.LogoContainer {
display: flex;
justify-content: center;
align-items: center;
height: 64px;
background: #fff;
border-bottom: 1px solid #eee;
transition: all 0.2s;

&.collapsed {
justify-content: flex-start;
padding-left: 20px;
}
}

.Hamburger {
margin-bottom: 10px;
margin-right: 10px;
}
}
36 changes: 30 additions & 6 deletions src/management-system-v2/components/content.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,11 @@

import styles from './content.module.scss';
import { FC, PropsWithChildren, ReactNode } from 'react';
import { Layout as AntLayout, Grid, Button } from 'antd';
import { Layout as AntLayout, Grid, Button, Image } from 'antd';
import { MenuOutlined } from '@ant-design/icons';
import cn from 'classnames';
import HeaderActions from './header-actions';
import Link from 'next/link';

type ContentProps = PropsWithChildren<{
/** Top left title in the header (or custom node). */
Expand All @@ -22,8 +23,12 @@ type ContentProps = PropsWithChildren<{
wrapperClass?: string;
/** Class name for the header. */
headerClass?: string;

siderOpened?: boolean;
}>;

//TODO: open and close hamburger menu

const Content: FC<ContentProps> = ({
children,
title,
Expand All @@ -33,22 +38,41 @@ const Content: FC<ContentProps> = ({
noHeader = false,
wrapperClass,
headerClass,
siderOpened,
}) => {
const breakpoint = Grid.useBreakpoint();

return (
<AntLayout className={cn(styles.Main, wrapperClass)}>
{noHeader ? null : (
<AntLayout.Header className={cn(styles.Header, headerClass)}>
{/* Add icon into header for xs screens*/}
{breakpoint.xs ? (
<div className={styles.LogoContainer}>
<Link href="/processes">
<Image
src={'/proceed-icon.png'}
alt="PROCEED Logo"
className={styles.Icon}
width={breakpoint.xs ? 85 : 160}
height={breakpoint.xs ? 35 : 63}
/>
</Link>
</div>
) : null}

{headerLeft || <div className={styles.Title}>{title}</div>}
{headerCenter || null}
{breakpoint.xs ? (
// Hamburger menu for mobile view
<Button
type="text"
style={{ marginTop: '20px', marginLeft: '15px' }}
icon={<MenuOutlined style={{ fontSize: '170%' }} />}
/>
<div>
<Button
className={styles.Hamburger}
type="text"
style={{ marginTop: '20px', marginLeft: '15px' }}
icon={<MenuOutlined style={{ fontSize: '170%' }} />}
/>
</div>
) : (
// Logout and User Profile in header for screens larger than 412px
<HeaderActions />
Expand Down
4 changes: 4 additions & 0 deletions src/management-system-v2/components/layout.module.scss
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,10 @@
}
}

// .SiderNone {
// display: none;
// }

.Main {
//margin-left: 200px;
transition: margin-left 0.2s;
Expand Down
3 changes: 2 additions & 1 deletion src/management-system-v2/components/layout.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -39,10 +39,11 @@ const Layout: FC<PropsWithChildren> = ({ children }) => {
backgroundColor: '#fff',
borderRight: '1px solid #eee',
}}
className={styles.Sider}
className={cn(styles.Sider)}
collapsible
collapsed={collapsed}
onCollapse={(collapsed) => setCollapsed(collapsed)}
collapsedWidth={breakpoint.xs ? '0' : '80'}
breakpoint="md"
trigger={null}
>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
.Checkbox {
font-size: 12px;
// width: 55%;
width: 65%;
}

.ClippedProcessTitle {
Expand Down
Loading

0 comments on commit 58f0b1c

Please sign in to comment.