Skip to content

Commit

Permalink
Merge pull request #3886 from signalco-io/feat/doprocess/runs-empty-p…
Browse files Browse the repository at this point in the history
…laceholder

feat(doprocess): Runs list empty placeholder with CTA
  • Loading branch information
AleksandarDev authored Nov 18, 2023
2 parents 1c1c28b + 50a3bb6 commit b2aa9bb
Show file tree
Hide file tree
Showing 25 changed files with 105 additions and 70 deletions.
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { TaskDetails } from '../../../../../components/processes/tasks/TaskDetails';
import { ProcessDetails } from '../../../../../components/processes/ProcessDetails';
import { ProcessDetails } from '../../../../../components/processes/processes/ProcessDetails';
import { SplitView } from '../../../../../components/layouts/SplitView';

export default function ProcessEmbeddedPage({ params }: { params: { id: string } }) {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { TaskDetails } from '../../../../../../../components/processes/tasks/TaskDetails';
import { ProcessDetails } from '../../../../../../../components/processes/ProcessDetails';
import { ProcessDetails } from '../../../../../../../components/processes/processes/ProcessDetails';
import { SplitView } from '../../../../../../../components/layouts/SplitView';

export default function ProcessEmbeddedPage({ params }: { params: { id: string, runId: string } }) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@ import { usePathname } from 'next/navigation';
import { Stack } from '@signalco/ui/dist/Stack';
import { Breadcrumbs } from '@signalco/ui/dist/Breadcrumbs';
import { KnownPages } from '../../../../../src/knownPages';
import { TypographyProcessName } from '../../../../../components/processes/TypographyProcessName';
import { ProcessDetails } from '../../../../../components/processes/ProcessDetails';
import { TypographyProcessName } from '../../../../../components/processes/processes/TypographyProcessName';
import { ProcessDetails } from '../../../../../components/processes/processes/ProcessDetails';
import { SplitView } from '../../../../../components/layouts/SplitView';

export default function ProcessLayout({ children, params }: PropsWithChildren<{ params: { id: string } }>) {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { RunsListView } from '../../../../../../components/processes/RunsListView';
import { RunsListView } from '../../../../../../components/processes/processes/RunsListView';

export default function ProcessRunsPage({ params }: { params: { id: string } }) {
const processId = params.id;
Expand Down
2 changes: 1 addition & 1 deletion web/apps/doprocess.app/app/(rest)/(app)/processes/page.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { ProcessesListView } from '../../../../components/processes/ProcessesListView';
import { ProcessesListView } from '../../../../components/processes/processes/ProcessesListView';

export default function ProcessesPage() {
return (
Expand Down
2 changes: 1 addition & 1 deletion web/apps/doprocess.app/app/(rest)/(app)/runs/page.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { RunsListView } from '../../../../components/processes/RunsListView';
import { RunsListView } from '../../../../components/processes/processes/RunsListView';

export default function RunsPage() {
return (
Expand Down
4 changes: 2 additions & 2 deletions web/apps/doprocess.app/components/PageNav.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ function NavMenu({ cta }: { cta?: boolean }) {
))}
<SignedOut>
<SignInButton
redirectUrl={KnownPages.Processes}
redirectUrl={KnownPages.Runs}
mode="modal">
<Button variant="plain">Sign in</Button>
</SignInButton>
Expand All @@ -47,7 +47,7 @@ function NavMenu({ cta }: { cta?: boolean }) {
{cta && (
<Button
variant="solid"
href={KnownPages.Processes}
href={KnownPages.Runs}
endDecorator={<Navigate />}>
Go to app
</Button>
Expand Down
18 changes: 0 additions & 18 deletions web/apps/doprocess.app/components/processes/RunsList.tsx

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ export function DocumentsList() {
query={useDocuments}
itemRender={(item) => (<DocumentsListItem document={item} />)}
editable
itemCreateLabel="Create new document"
itemCreateLabel="New document"
createForm={<DocumentCreateForm redirect />}
/>
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@ import { Tooltip } from '@signalco/ui/dist/Tooltip';
import { Stack } from '@signalco/ui/dist/Stack';
import { Input } from '@signalco/ui/dist/Input';
import { Button } from '@signalco/ui/dist/Button';
import { KnownPages } from '../../src/knownPages';
import { useProcessCreate } from '../../src/hooks/useProcessCreate';
import { KnownPages } from '../../../src/knownPages';
import { useProcessCreate } from '../../../src/hooks/useProcessCreate';

export function ProcessCreateForm({ redirect }: { redirect?: boolean }) {
const router = useRouter();
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { Stack } from '@signalco/ui/dist/Stack';
import { TaskList } from './tasks/TaskList';
import { TaskList } from '../tasks/TaskList';
import { ProcessDetailsHeader } from './ProcessDetailsHeader';

type ProcessDetailsProps = {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,14 +1,15 @@
'use client';

import { useState } from 'react';
import { cx } from 'classix';
import { Delete, ListChecks, MoreHorizontal, Play } from '@signalco/ui-icons';
import { Skeleton } from '@signalco/ui/dist/Skeleton';
import { DropdownMenu, DropdownMenuContent, DropdownMenuItem, DropdownMenuSeparator, DropdownMenuTrigger } from '@signalco/ui/dist/Menu';
import { Loadable } from '@signalco/ui/dist/Loadable';
import { IconButton } from '@signalco/ui/dist/IconButton';
import { ListHeader } from '../shared/ListHeader';
import { KnownPages } from '../../src/knownPages';
import { useProcess } from '../../src/hooks/useProcess';
import { ListHeader } from '../../shared/ListHeader';
import { KnownPages } from '../../../src/knownPages';
import { useProcess } from '../../../src/hooks/useProcess';
import { TypographyProcessRunName } from './TypographyProcessRunName';
import { TypographyProcessName } from './TypographyProcessName';
import { ProcessRunCreateModal } from './ProcessRunCreateModal';
Expand Down Expand Up @@ -38,7 +39,7 @@ export function ProcessDetailsHeader({
? (<TypographyProcessRunName id={processId} runId={runId} level="h5" editable={editable} noWrap />)
: (<TypographyProcessName id={processId} level="h5" editable={editable} noWrap />)}
actions={[
(process && editable && !isRun) && <ProcessRunCreateModal process={process} />,
(process && editable && !isRun) && <ProcessRunCreateModal processId={processId} />,
(editable) && (
<DropdownMenu>
<DropdownMenuTrigger
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@

import { useRouter } from 'next/navigation';
import { ModalConfirm, ModalConfirmProps } from '@signalco/ui/dist/ModalConfirm';
import { useProcessRunDelete } from '../../src/hooks/useProcessRunDelete';
import { useProcessDelete } from '../../src/hooks/useProcessDelete';
import { useProcessRunDelete } from '../../../src/hooks/useProcessRunDelete';
import { useProcessDelete } from '../../../src/hooks/useProcessDelete';

type ProcessDeleteModalProps = Omit<ModalConfirmProps, 'header' | 'onConfirm' | 'children' | 'expectedConfirm' | 'promptLabel'> & {
processId: string;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,21 +1,26 @@
'use client';
import { useState } from 'react';

import { useEffect, useState } from 'react';
import { useRouter } from 'next/navigation';
import { Play } from '@signalco/ui-icons';
import { Stack } from '@signalco/ui/dist/Stack';
import { Row } from '@signalco/ui/dist/Row';
import { Input } from '@signalco/ui/dist/Input';
import { Button } from '@signalco/ui/dist/Button';
import { KnownPages } from '../../src/knownPages';
import { useProcessRunCreate } from '../../src/hooks/useProcessRunCreate';
import { ProcessDto } from '../../app/api/dtos/dtos';
import { KnownPages } from '../../../src/knownPages';
import { useProcessRunCreate } from '../../../src/hooks/useProcessRunCreate';
import { useProcess } from '../../../src/hooks/useProcess';

export function ProcessRunCreateForm({ process }: { process: ProcessDto; }) {
const { id: processId, name: processName } = process;
export function ProcessRunCreateForm({ processId, redirect }: { processId: string, redirect?: boolean }) {
const { data: process } = useProcess(processId);

const router = useRouter();
const processRunCreate = useProcessRunCreate();
const [name, setName] = useState(`${processName} - ${new Date().toLocaleString()} run`);
const [name, setName] = useState(`${process?.name} - ${new Date().toLocaleString()} run`);

useEffect(() => {
setName(`${process?.name} - ${new Date().toLocaleString()} run`);
}, [process?.name]);

const handleRunProcess = async () => {
if (!name.length) {
Expand All @@ -26,7 +31,7 @@ export function ProcessRunCreateForm({ process }: { process: ProcessDto; }) {
processId: processId.toString(),
name
});
if (result?.id) {
if (redirect && result?.id) {
router.push(KnownPages.ProcessRun(processId, result.id));
}
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,13 @@ import { Stack } from '@signalco/ui/dist/Stack';
import { Row } from '@signalco/ui/dist/Row';
import { Modal } from '@signalco/ui/dist/Modal';
import { IconButton } from '@signalco/ui/dist/IconButton';
import { ProcessDto } from '../../app/api/dtos/dtos';
import { ProcessRunCreateForm } from './ProcessRunCreateForm';

type ProcessRunCreateModalProps = {
process: ProcessDto;
processId: string;
};

export function ProcessRunCreateModal({ process }: ProcessRunCreateModalProps) {
export function ProcessRunCreateModal({ processId }: ProcessRunCreateModalProps) {
return (
<Modal trigger={(
<Tooltip title="Run process">
Expand All @@ -26,7 +25,7 @@ export function ProcessRunCreateModal({ process }: ProcessRunCreateModalProps) {
<Play />
<Typography level="h5">Run process</Typography>
</Row>
<ProcessRunCreateForm process={process} />
<ProcessRunCreateForm processId={processId} redirect />
</Stack>
</Modal>
);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
'use client';

import { List } from '../shared/List';
import { useProcesses } from '../../src/hooks/useProcesses';
import { List } from '../../shared/List';
import { useProcesses } from '../../../src/hooks/useProcesses';
import { ProcessesListItem } from './ProcessesListItem';
import { ProcessCreateForm } from './ProcessCreateForm';

Expand All @@ -11,7 +11,7 @@ export function ProcessesList() {
query={useProcesses}
itemRender={(item) => (<ProcessesListItem process={item} />)}
editable
itemCreateLabel="Create new process"
itemCreateLabel="New process"
createForm={<ProcessCreateForm redirect />} />
);
}
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { ListChecks, Navigate } from '@signalco/ui-icons';
import { ListItem } from '../shared/ListItem';
import { KnownPages } from '../../src/knownPages';
import { ProcessDto } from '../../app/api/dtos/dtos';
import { ListItem } from '../../shared/ListItem';
import { KnownPages } from '../../../src/knownPages';
import { ProcessDto } from '../../../app/api/dtos/dtos';

export type ProcessListItemProps = {
process: ProcessDto;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { Stack } from '@signalco/ui/dist/Stack';
import { ListHeader } from '../shared/ListHeader';
import { ListHeader } from '../../shared/ListHeader';
import { ProcessesList } from './ProcessesList';

export function ProcessesListView() {
Expand Down
41 changes: 41 additions & 0 deletions web/apps/doprocess.app/components/processes/processes/RunsList.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
'use client';

import { Play } from '@signalco/ui-icons';
import { Typography } from '@signalco/ui/dist/Typography';
import { Stack } from '@signalco/ui/dist/Stack';
import { NavigatingButton } from '@signalco/ui/dist/NavigatingButton';
import { List } from '../../shared/List';
import { KnownPages } from '../../../src/knownPages';
import { useProcessRuns } from '../../../src/hooks/useProcessRuns';
import { useProcessesRuns } from '../../../src/hooks/useProcessesRuns';
import { RunsListItem } from './RunsListItem';
import { ProcessRunCreateForm } from './ProcessRunCreateForm';

function RunsListEmptyPlaceholder() {
return (
<Stack spacing={4} alignItems="center" className="px-4 py-12 text-center sm:py-24 md:py-40 lg:py-60">
<Play size={64} className="opacity-60" />
<Stack spacing={2}>
<Typography level="h4" secondary>No runs</Typography>
<Typography secondary>You do not have any process runs yet. You can start by creating a process.</Typography>
</Stack>
<NavigatingButton href={KnownPages.Processes}>Processes</NavigatingButton>
</Stack>
);
}

export function RunsList({ processId }: { processId?: string }) {
const processRuns = useProcessRuns(processId);
const processesRuns = useProcessesRuns(!processId);

return (
<List
query={() => processId ? processRuns : processesRuns}
itemRender={(item) => (<RunsListItem run={item} />)}
editable={Boolean(processId)}
itemCreateLabel="New process run"
createForm={processId ? <ProcessRunCreateForm processId={processId} redirect /> : undefined}
emptyPlaceholder={<RunsListEmptyPlaceholder />}
/>
);
}
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import { ListChecks, Navigate, Play } from '@signalco/ui-icons';
import { Row } from '@signalco/ui/dist/Row';
import { ListItem } from '../shared/ListItem';
import { KnownPages } from '../../src/knownPages';
import { ProcessRunDto } from '../../app/api/dtos/dtos';
import { ListItem } from '../../shared/ListItem';
import { KnownPages } from '../../../src/knownPages';
import { ProcessRunDto } from '../../../app/api/dtos/dtos';
import { TypographyProcessName } from './TypographyProcessName';

export type RunsListItemProps = {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
import { Typography } from '@signalco/ui/dist/Typography';
import { Stack } from '@signalco/ui/dist/Stack';
import { useSearchParam } from '@signalco/hooks/dist/useSearchParam';
import { ListHeader } from '../shared/ListHeader';
import { ListHeader } from '../../shared/ListHeader';
import { TypographyProcessName } from './TypographyProcessName';
import { RunsList } from './RunsList';

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@
import { TypographyEditable, TypographyEditableProps } from '@signalco/ui/dist/TypographyEditable';
import { Typography } from '@signalco/ui/dist/Typography';
import { Loadable } from '@signalco/ui/dist/Loadable';
import { useProcessUpdate } from '../../src/hooks/useProcessUpdate';
import { useProcess } from '../../src/hooks/useProcess';
import { useProcessUpdate } from '../../../src/hooks/useProcessUpdate';
import { useProcess } from '../../../src/hooks/useProcess';

export type TypographyProcessNameProps = Omit<TypographyEditableProps, 'children' | 'onChange'> & {
id: string | undefined;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@
import { TypographyEditable, TypographyEditableProps } from '@signalco/ui/dist/TypographyEditable';
import { Typography } from '@signalco/ui/dist/Typography';
import { Loadable } from '@signalco/ui/dist/Loadable';
import { useProcessRunUpdate } from '../../src/hooks/useProcessRunUpdate';
import { useProcessRun } from '../../src/hooks/useProcessRun';
import { useProcessRunUpdate } from '../../../src/hooks/useProcessRunUpdate';
import { useProcessRun } from '../../../src/hooks/useProcessRun';

export type TypographyProcessRunNameProps = Omit<TypographyEditableProps, 'children' | 'onChange'> & {
id: string | undefined;
Expand Down
17 changes: 12 additions & 5 deletions web/apps/doprocess.app/components/shared/List.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,10 @@ type ListProps<T> = {
itemCreateLabel?: string;
itemRender?: (item: T) => ReactElement;
createForm?: ReactNode;
emptyPlaceholder?: ReactNode;
};

export function List<T>({ query, itemRender, editable, itemCreateLabel, createForm }: ListProps<T>) {
export function List<T>({ query, itemRender, editable, itemCreateLabel, createForm, emptyPlaceholder }: ListProps<T>) {
const { data, isLoading, error } = query();
const [showCreateModal, setShowCreateModal] = useState(false);

Expand Down Expand Up @@ -57,10 +58,16 @@ export function List<T>({ query, itemRender, editable, itemCreateLabel, createFo
) : (
<>
{!data?.length && (
<ListItem
disabled
className={'text-muted-foreground'}
label="No items" />
<>
{emptyPlaceholder ? (
emptyPlaceholder
) : (
<ListItem
disabled
className={'text-muted-foreground'}
label="No items" />
)}
</>
)}
</>
)}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ export function TypographyEditable({ children, className, onChange, onEditingCha
{...rest}>
{children || placeholder}
{!hideEditIcon && (
<Edit size={20} className="uitw-ml-2 uitw-inline uitw-align-baseline uitw-opacity-0 uitw-transition-opacity group-hover:uitw-opacity-60" />
<Edit size={20} className="uitw-ml-2 uitw-inline uitw-opacity-0 uitw-transition-opacity group-hover:uitw-opacity-60" />
)}
</Typography>
);
Expand Down

0 comments on commit b2aa9bb

Please sign in to comment.