mirror of
https://github.com/cpvalente/ontime.git
synced 2026-08-10 01:43:43 +00:00
ae15f3cdc5
* refactor: align header columns * refactor: improve scrollbar visibility * refactor: center align table elements * refactor: make param elements stateful * fix: issue with collapsed elements not loosing value * fix: prevent search params containing multiple alias references * fix: the issue where a file disappears if it is both migrated and recovered in the same load operation (#1744) * refactor: disable group action for elements in groups * refactor: move context menu items into the event element (#1747) * feat: sheet import new features for v4 (#1730) * import milestone * fixup! import milestone * test: milestone import * add entries to group stop on new group or on group-end type * fixup! add entries to group * cleanup * add event target duration * link start if undefined * add skip import type * extract some to the excel paresing functions * tweaks to presentation * move file --------- Co-authored-by: Carlos Valente <carlosvalente@pm.me> * fix: notify runtimeStore of events bieng groupd * fix: improve authentication and stage detection in demo * chore: ship logo with project * fix: client is referenced by name * fix: prevent reflow in event editor * fix: stale render on selected event due to ref mismatch * Create/Load/Delete multiple rundowns (#1696) * refactor: restore last loaded rundown * refactor: initialise rundown in ProjectService * feat: allow switching rundowns ensure on coordination between the db object and the working object server provide list of rundowns implement switch in the UI implement delete implement new rundown button * fix: render order for floating button * refactor: appropriate names to service * refactor: rundown endpoints * refactor: save last loaded rundown ID * refactor: rundown management UI * refactor: emit refetch all on project load --------- Co-authored-by: Carlos Valente <carlosvalente@pm.me> * feat: recover single event subscription * fixup! feat: sheet import new features for v4 (#1730) * fix: prevent dropping a group inside another * fixup! refactor: move context menu items into the event element (#1747) * fix: prevent stale references to custom fields * fix: propagate updates to all rundowns * refactor: client rundown metadata (#1728) * generate metadata in the hook * move test * ensure there is always a last element * use for-loop * update metadata in useEfect * fully extract metadata generation * use direct assignment * cleanup --------- Co-authored-by: Carlos Valente <carlosvalente@pm.me> * refactor: small imporvement and tests for coerce functions (#1752) * refactor: small imporvement and tests for coerce functions add test `coerceString` add test `coerceBoolean` add test `coerceColour` * remove old todo * fix: consistent quick add behaviour * refactor: create flat rundown with metadata * fix: show add buttons on top * feat: allow editing milestones * refactor: style tweaks to rundown elements refactor: milestones are full width refactor: cuesheet header alignment fix: editor styling in cuesheet * refactor: virtualise table * refactor: improve overscan (#1758) * bump version to 4.0.0-alpha.5 --------- Co-authored-by: Alex Christoffer Rasmussen <ac@omnivox.dk>
85 lines
2.3 KiB
TypeScript
85 lines
2.3 KiB
TypeScript
import { useEffect, useState } from 'react';
|
|
import { useForm } from 'react-hook-form';
|
|
|
|
import { createProject } from '../../../../common/api/db';
|
|
import { maybeAxiosError } from '../../../../common/api/utils';
|
|
import Button from '../../../../common/components/buttons/Button';
|
|
import Input from '../../../../common/components/input/input/Input';
|
|
import { preventEscape } from '../../../../common/utils/keyEvent';
|
|
import * as Panel from '../../panel-utils/PanelUtils';
|
|
|
|
import style from './ProjectPanel.module.scss';
|
|
|
|
interface ProjectCreateFromProps {
|
|
onClose: () => void;
|
|
}
|
|
|
|
type ProjectCreateFormValues = {
|
|
title?: string;
|
|
description?: string;
|
|
info?: string;
|
|
url?: string;
|
|
custom?: { title: string; value: string }[];
|
|
};
|
|
|
|
export default function ProjectCreateForm({ onClose }: ProjectCreateFromProps) {
|
|
const [error, setError] = useState<string | null>(null);
|
|
|
|
const {
|
|
handleSubmit,
|
|
register,
|
|
formState: { isSubmitting, isValid },
|
|
setFocus,
|
|
} = useForm<ProjectCreateFormValues>({
|
|
defaultValues: { title: '' },
|
|
values: { title: '' },
|
|
resetOptions: {
|
|
keepDirtyValues: true,
|
|
},
|
|
});
|
|
|
|
// set focus to first field
|
|
useEffect(() => {
|
|
setFocus('title');
|
|
}, [setFocus]);
|
|
|
|
const handleSubmitCreate = async (values: ProjectCreateFormValues) => {
|
|
try {
|
|
setError(null);
|
|
|
|
const filename = values.title ?? 'untitled';
|
|
|
|
await createProject({ filename });
|
|
|
|
onClose();
|
|
} catch (error) {
|
|
setError(maybeAxiosError(error));
|
|
}
|
|
};
|
|
|
|
return (
|
|
<Panel.Indent
|
|
as='form'
|
|
onSubmit={handleSubmit(handleSubmitCreate)}
|
|
onKeyDown={(event) => preventEscape(event, onClose)}
|
|
>
|
|
<Panel.Title>
|
|
Create new project
|
|
<Panel.InlineElements>
|
|
<Button onClick={onClose} variant='ghosted' disabled={isSubmitting}>
|
|
Cancel
|
|
</Button>
|
|
<Button disabled={!isValid} type='submit' loading={isSubmitting} variant='primary'>
|
|
Create project
|
|
</Button>
|
|
</Panel.InlineElements>
|
|
</Panel.Title>
|
|
{error && <Panel.Error>{error}</Panel.Error>}
|
|
<Panel.Section className={style.innerColumn}>
|
|
<Panel.Description>Project title</Panel.Description>
|
|
<Input fluid placeholder='Your project name' {...register('title')} />
|
|
</Panel.Section>
|
|
</Panel.Indent>
|
|
);
|
|
}
|