Skip to content

Commit c54cd46

Browse files
authored
Merge pull request #396 from AVAnnotate/develop
Publish to main
2 parents fa83857 + 136cbcd commit c54cd46

11 files changed

Lines changed: 93 additions & 63 deletions

File tree

src/apps/EventDetail/AnnotationTableHeader.tsx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -53,14 +53,14 @@ export const AnnotationTableHeader: React.FC<Props> = (props) => {
5353
className='dropdown-item'
5454
onClick={() => props.setShowAnnoCreateModal(true)}
5555
>
56-
<FileEarmarkArrowUp />
57-
{t['Add']}
56+
<Plus color='black' />
57+
{t['Create']}
5858
</Dropdown.Item>
5959
<Dropdown.Item className='dropdown-item'>
6060
<a
6161
href={`/${lang}/projects/${props.projectSlug}/events/${props.eventUuid}/import`}
6262
>
63-
<Plus color='black' />
63+
<FileEarmarkArrowUp />
6464
{t['Import']}
6565
</a>
6666
</Dropdown.Item>

src/components/DropdownButton/DropdownButton.tsx

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,11 @@ export const DropdownButton: React.FC<DropdownButtonProps> = (props) => {
2323

2424
return (
2525
<>
26-
<Dropdown.Root modal={false} open={open}>
26+
<Dropdown.Root
27+
modal={false}
28+
open={open}
29+
onOpenChange={(isOpen) => (isOpen ? {} : setOpen(false))}
30+
>
2731
<Dropdown.Trigger asChild>
2832
<Button
2933
className='dropdown-button primary'

src/components/EventList/EventList.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -204,7 +204,7 @@ export const EventList: React.FC<Props> = (props) => {
204204
items={[
205205
{
206206
icon: <PlusIcon />,
207-
label: t['Add single event'],
207+
label: t['Create'],
208208
onClick: () =>
209209
(window.location.href = `/${props.i18n.lang}/projects/${props.projectSlug}/events/new`),
210210
},

src/components/Formic/SlateInput/FormattingComponents.tsx

Lines changed: 18 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ import * as Dialog from '@radix-ui/react-dialog';
77
import type { AVAEditor, ImageData, ImageSize } from '@ty/slate.ts';
88
import type { Translations } from '@ty/Types.ts';
99
import { ToolbarTooltip } from './ToolbarTooltip.tsx';
10+
import { Editor } from 'slate';
1011

1112
export const HighlightColorButton = (props: SlateButtonProps) => {
1213
const editor = useSlate();
@@ -83,9 +84,13 @@ export const LinkButton = (props: LinkDialogProps) => {
8384

8485
const submit = () => {
8586
props.onSubmit(url);
87+
setUrl('');
8688
setOpen(false);
8789
};
8890

91+
// @ts-expect-error
92+
const isActive = Editor.marks(editor)?.link;
93+
8994
return (
9095
<Dialog.Root open={open}>
9196
<Dialog.Trigger asChild>
@@ -95,10 +100,16 @@ export const LinkButton = (props: LinkDialogProps) => {
95100
>
96101
<Button
97102
className={`link-button unstyled ${
98-
highlightedText ? '' : 'disabled-link-button'
103+
isActive ? 'activated-link-button' : ''
99104
}`}
100-
disabled={!highlightedText}
101-
onClick={() => setOpen(true)}
105+
onMouseDown={(event) => {
106+
event.preventDefault();
107+
if (isActive) {
108+
Editor.removeMark(editor, 'link');
109+
} else {
110+
setOpen(true);
111+
}
112+
}}
102113
type='button'
103114
>
104115
<props.icon />
@@ -132,7 +143,10 @@ export const LinkButton = (props: LinkDialogProps) => {
132143
<Dialog.Close asChild>
133144
<Button
134145
className='unstyled'
135-
onClick={() => setOpen(false)}
146+
onClick={() => {
147+
setUrl('');
148+
setOpen(false);
149+
}}
136150
role='button'
137151
>
138152
{t['cancel']}

src/components/Formic/SlateInput/SlateInput.css

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -165,8 +165,8 @@
165165
border-radius: 4px;
166166
}
167167

168-
.slate-form .disabled-link-button svg {
169-
color: var(--gray-500);
168+
.slate-form .activated-link-button svg {
169+
color: var(--primary);
170170
}
171171

172172
.slate-form .disabled svg {
@@ -269,4 +269,4 @@
269269
font-size: 16px;
270270
font-weight: normal;
271271
line-height: 150%;
272-
}
272+
}

src/components/InsertEventButton/FormElements.tsx

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -189,6 +189,12 @@ interface EventSelectProps {
189189
}
190190

191191
export const EventSelect: React.FC<EventSelectProps> = (props) => {
192+
const sortedEvents = Object.keys(props.project.events)
193+
.map((uuid) => {
194+
const event = props.project.events[uuid];
195+
return { uuid, label: event.label };
196+
})
197+
.sort((a, b) => a.label.localeCompare(b.label));
192198
return (
193199
<label className='slate-event-select'>
194200
{props.label}
@@ -205,11 +211,15 @@ export const EventSelect: React.FC<EventSelectProps> = (props) => {
205211
<Select.Content className='select-content' position='popper'>
206212
<Select.Viewport className='select-viewport'>
207213
{/* @ts-ignore */}
208-
{Object.keys(props.project.events).map((uuid) => (
209-
<Select.Item className='select-item' key={uuid} value={uuid}>
214+
{sortedEvents.map((ev) => (
215+
<Select.Item
216+
className='select-item'
217+
key={ev.uuid}
218+
value={ev.uuid}
219+
>
210220
<Select.ItemText>
211221
{/* @ts-ignore */}
212-
{props.project.events[uuid].label}
222+
{ev.label}
213223
</Select.ItemText>
214224
<Select.ItemIndicator />
215225
</Select.Item>

src/components/InsertEventButton/SingleEventModal.tsx

Lines changed: 1 addition & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import * as Dialog from '@radix-ui/react-dialog';
22
import type { Includes, SlateEventNodeData } from '../../types/slate.ts';
3-
import { useEffect, useMemo, useState } from 'react';
3+
import { useMemo, useState } from 'react';
44
import {
55
ClipInterface,
66
DurationInterface,
@@ -38,7 +38,6 @@ export const SingleEventModal: React.FC<SingleEventModalProps> = (props) => {
3838
props.start || props.end ? 'clip' : 'full'
3939
);
4040
const [file, setFile] = useState(props.file || undefined);
41-
const [type, setType] = useState<'Audio' | 'Video' | undefined>();
4241
const [includes, setIncludes] = useState<Includes[]>(
4342
props.includes || ['media', 'annotations', 'label', 'description']
4443
);
@@ -53,16 +52,6 @@ export const SingleEventModal: React.FC<SingleEventModalProps> = (props) => {
5352
}
5453
}, [eventUuid]);
5554

56-
useEffect(() => {
57-
if (file && eventUuid) {
58-
const type =
59-
props.project.events[eventUuid as string].audiovisual_files[file]
60-
.file_type;
61-
62-
setType(type);
63-
}
64-
}, [file, eventUuid]);
65-
6655
const { t } = props.i18n;
6756

6857
return (
@@ -137,7 +126,6 @@ export const SingleEventModal: React.FC<SingleEventModalProps> = (props) => {
137126
start,
138127
end,
139128
file,
140-
type,
141129
})
142130
}
143131
>

src/components/PageList/PageList.tsx

Lines changed: 45 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -38,18 +38,20 @@ export const PageList: React.FC<Props> = (props) => {
3838

3939
useEffect(() => {
4040
if (pageOrder) {
41-
let state: RowState = {};
41+
let state: RowState = { ...rowState };
4242

4343
const orderArray = makePageArray(project, pageOrder);
4444

4545
orderArray.forEach((entry, idx) => {
46-
state[entry.id] = {
47-
uuid: entry.id,
48-
expanded: true,
49-
parent: entry.parent,
50-
visible: true,
51-
hasChildren: entry.children.length > 0,
52-
};
46+
if (!state[entry.id]) {
47+
state[entry.id] = {
48+
uuid: entry.id,
49+
expanded: true,
50+
parent: entry.parent,
51+
visible: true,
52+
hasChildren: entry.children.length > 0,
53+
};
54+
}
5355

5456
// Now determine how we can move this item
5557
state[entry.id].canGoDown = false;
@@ -114,36 +116,47 @@ export const PageList: React.FC<Props> = (props) => {
114116
//If there is no content in the page, pre-populate with an embed of the related event, for convenience
115117
if (!page.content || !page.content.length) {
116118
const eventUuid = page.autogenerate.type_id;
117-
if (eventUuid) {
118-
page.content = [
119-
{
120-
type: 'paragraph',
121-
children: [
119+
if (eventUuid || page.autogenerate.type === 'home') {
120+
page.autogenerate.type === 'home'
121+
? (page.content = [
122122
{
123-
text: '',
123+
type: 'paragraph',
124+
children: [
125+
{
126+
text: '',
127+
},
128+
],
124129
},
125-
],
126-
},
127-
{
128-
//@ts-ignore
129-
type: 'event',
130-
uuid: eventUuid,
131-
includes: ['media', 'annotations', 'description'],
132-
children: [
130+
])
131+
: (page.content = [
133132
{
134-
text: '',
133+
type: 'paragraph',
134+
children: [
135+
{
136+
text: '',
137+
},
138+
],
135139
},
136-
],
137-
},
138-
{
139-
type: 'paragraph',
140-
children: [
141140
{
142-
text: '',
141+
//@ts-ignore
142+
type: 'event',
143+
uuid: eventUuid,
144+
includes: ['media', 'annotations', 'description'],
145+
children: [
146+
{
147+
text: '',
148+
},
149+
],
143150
},
144-
],
145-
},
146-
];
151+
{
152+
type: 'paragraph',
153+
children: [
154+
{
155+
text: '',
156+
},
157+
],
158+
},
159+
]);
147160
}
148161
}
149162
setSaving(true);

src/components/PageList/PageRow.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -131,7 +131,7 @@ export const PageRow: React.FC<Props> = (props) => {
131131
icon: ListNested,
132132
// @ts-ignore
133133
onClick: () => {},
134-
children: childPages,
134+
children: childPages.sort((a, b) => a.label.localeCompare(b.label)),
135135
});
136136
}
137137

src/components/ProjectForm/NewProjectForm.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ const FormContents = (props: NewProjectFormProps) => {
4848
creator: '',
4949
authors: '',
5050
media_player: 'avannotate',
51-
auto_populate_home_page: false,
51+
auto_populate_home_page: true,
5252
additional_users: [],
5353
tags: {
5454
tagGroups: [],

0 commit comments

Comments
 (0)