Skip to content

Commit

Permalink
Merge pull request #808 from digirati-co-uk/feature/2.2-bugs
Browse files Browse the repository at this point in the history
2.2 bugs
  • Loading branch information
stephenwf committed Jan 12, 2024
2 parents 2e750a4 + 63f8942 commit a0b7ec2
Show file tree
Hide file tree
Showing 6 changed files with 86 additions and 15 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ export const NewProjectFromTemplate: React.FC = () => {
try {
return await api.createProject(config);
} catch (e) {
return { error: e.message };
return { error: (e as any).message };
}
});
const isError = !!data?.error;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,7 @@ export const Project: UniversalComponent<ProjectType> = createUniversalComponent
</div>
) : (
<div>
<strong>{t('Custom project')}</strong> |{' '}
<HrefLink href={`/projects/create/remote?template=urn:madoc:project:${data.id}`}>
Duplicate project →
</HrefLink>
Expand Down
5 changes: 3 additions & 2 deletions services/madoc-ts/src/frontend/shared/layout/EmptyState.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,9 @@ export const EmptyState = styled.div<{ $box?: boolean; $noMargin?: boolean }>`
svg {
margin-bottom: 1.5em;
}
span {
> span,
> div {
font-size: 0.8em;
width: 400px;
margin-top: 1em;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import React, { useRef, useState } from 'react';
import { useMutation } from 'react-query';
import { useParams } from 'react-router-dom';
import { CrowdsourcingReview } from '../../../../../gateway/tasks/crowdsourcing-review';
import { CrowdsourcingTask } from '../../../../../gateway/tasks/crowdsourcing-task';
Expand All @@ -12,7 +13,9 @@ import {
CanvasViewerEditorStyleReset,
CanvasViewerGrid,
} from '../../../../shared/atoms/CanvasViewerGrid';
import { useApi } from '../../../../shared/hooks/use-api';
import { useData } from '../../../../shared/hooks/use-data';
import { CloseIcon } from '../../../../shared/icons/CloseIcon';
import { PreviewIcon } from '../../../../shared/icons/PreviewIcon';
import { EmptyState } from '../../../../shared/layout/EmptyState';
import {
Expand All @@ -24,14 +27,15 @@ import { serverRendererFor } from '../../../../shared/plugins/external/server-re
import { HrefLink } from '../../../../shared/utility/href-link';
import { RefetchProvider, useRefetch } from '../../../../shared/utility/refetch-context';
import { useCrowdsourcingTaskDetails } from '../../../hooks/use-crowdsourcing-task-details';
import { useRelativeLinks } from '../../../hooks/use-relative-links';
import { ApproveSubmission } from '../actions/approve-submission';
import { RejectSubmission } from '../actions/reject-submission';
import { RequestChanges } from '../actions/request-changes';
import { LocaleString } from '../../../../shared/components/LocaleString';
import { useTaskMetadata } from '../../../hooks/use-task-metadata';
import { SubjectSnippet } from '../../../../../extensions/tasks/resolvers/subject-resolver';
import { SimpleStatus } from '../../../../shared/atoms/SimpleStatus';
import { Button } from '../../../../shared/navigation/Button';
import { Button, ButtonRow } from '../../../../shared/navigation/Button';
import useDropdownMenu from 'react-accessible-dropdown-menu-hook';
import { EditIcon } from '../../../../shared/icons/EditIcon';
import { DirectEditButton } from '../../../../shared/capture-models/new/components/DirectEditButton';
Expand Down Expand Up @@ -191,6 +195,7 @@ function ViewSingleReview({
} = useCrowdsourcingTaskDetails(task);

const refetch = useRefetch();
const createLink = useRelativeLinks();
const metadata = useTaskMetadata<{ subject?: SubjectSnippet }>(task);
const [isEditing, setIsEditing] = useState(false);
// const isLocked = props.lockedTasks && props.lockedTasks.indexOf(props.task.id) !== -1;
Expand All @@ -214,6 +219,18 @@ function ViewSingleReview({
const gridRef = useRef<any>();
const runtime = useRef<Runtime>();
const annotationTheme = useProjectAnnotationStyles();
const api = useApi();
const [unassignUser] = useMutation(
async () => {
if (task) {
await api.updateTask(task.id, { status: -1, status_text: 'unassigned' });
await refetch();
}
},
{
throwOnError: true,
}
);

const goHome = () => {
if (runtime.current) {
Expand All @@ -234,6 +251,44 @@ function ViewSingleReview({
};

if (!review) {
if (task.status === -1) {
// Task has been rejected
return (
<>
<ReviewHeader>
<Label>
{metadata && metadata.subject ? <LocaleString>{metadata.subject.label}</LocaleString> : task.name}
</Label>

<SubLabel>
{metadata.subject && metadata.subject.parent && (
<LocaleString style={{ minWidth: 0, overflow: 'hidden', textOverflow: 'ellipsis' }}>
{metadata.subject.parent.label}
</LocaleString>
)}
</SubLabel>

<ReviewNavigation taskId={taskId} />
</ReviewHeader>
<EmptyState>
<CloseIcon />
{t('This task has been rejected.')}
<div>
<HrefLink
href={createLink({
taskId: task.id,
subRoute: 'tasks',
query: { type: 'crowdsourcing-task' },
})}
>
{t('View task')}
</HrefLink>
</div>
</EmptyState>
</>
);
}

return (
<>
<ReviewHeader>
Expand All @@ -253,8 +308,13 @@ function ViewSingleReview({
</ReviewHeader>
<EmptyState>
<UnlockSmileyIcon />
This task is not yet ready for review.
<span>This means this task has been assigned or is in progress, but nothing has been submitted</span>
{t('This task is not yet ready for review.')}
<span>{t('This means this task has been assigned or is in progress, but nothing has been submitted')}</span>
<br />

<ButtonRow $center>
<Button onClick={() => unassignUser()}>Unassign from user</Button>
</ButtonRow>
</EmptyState>
</>
);
Expand Down Expand Up @@ -315,7 +375,7 @@ function ViewSingleReview({
<EditorToolbarIcon>
<EditIcon />
</EditorToolbarIcon>
<EditorToolbarLabel>{isEditing ? 'Exit Correction' : 'Make Correction'}</EditorToolbarLabel>
<EditorToolbarLabel>{isEditing ? t('Exit Correction') : t('Make Correction')}</EditorToolbarLabel>
</EditorToolbarButton>

<RequestChanges
Expand Down Expand Up @@ -358,7 +418,7 @@ function ViewSingleReview({
<div style={{ flex: 1, minWidth: 200, display: 'flex', flexDirection: 'column' }}>
<ReviewDropdownContainer>
<Button $link {...buttonProps}>
View options
{t('View options')}
</Button>
<ReviewDropdownPopup $visible={isDropdownOpen} role="menu">
<>
Expand All @@ -371,15 +431,15 @@ function ViewSingleReview({
<EditorToolbarIcon>
<PreviewIcon />
</EditorToolbarIcon>
<EditorToolbarLabel>View resource</EditorToolbarLabel>
<EditorToolbarLabel>{t('View resource')}</EditorToolbarLabel>
</EditorToolbarButton>
) : null}
{manifestLink ? (
<EditorToolbarButton as={HrefLink} href={manifestLink}>
<EditorToolbarIcon>
<PreviewIcon />
</EditorToolbarIcon>
<EditorToolbarLabel>View manifest</EditorToolbarLabel>
<EditorToolbarLabel>{t('View manifest')}</EditorToolbarLabel>
</EditorToolbarButton>
) : null}
</>
Expand Down
10 changes: 5 additions & 5 deletions services/madoc-ts/stories/admin/project-config.stories.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ export const defaultStory = () => {
<AccordionItem
large
label="Interface"
description="With description"
description="Customise project pages, manifest pages and canvas pages"
icon={<InterfaceIcon />}
maxHeight={false}
>
Expand All @@ -34,7 +34,7 @@ export const defaultStory = () => {
<AccordionItem
large
label="Search & browse"
description="With description"
description="Customise navigation and search options"
icon={<SearchIcon />}
maxHeight={false}
>
Expand All @@ -46,7 +46,7 @@ export const defaultStory = () => {
<AccordionItem
large
label="Contributions"
description="With description"
description="Customise the contribution process, contribution interface and submission process"
icon={<ContributionIcon />}
maxHeight={false}
>
Expand All @@ -62,7 +62,7 @@ export const defaultStory = () => {
<AccordionItem
large
label="Review process"
description="With description"
description="Customise the review process and reviewers"
icon={<ReviewIcon />}
maxHeight={false}
>
Expand All @@ -71,7 +71,7 @@ export const defaultStory = () => {
</div>
</AccordionItem>

<AccordionItem large label="Other" description="With description" icon={<SettingsIcon />} maxHeight={false}>
<AccordionItem large label="Other" description="Remainder category" icon={<SettingsIcon />} maxHeight={false}>
<div style={{ height: '650px' }}>
<EditShorthandCaptureModel key={4} data={ProjectConfigOther} template={ProjectConfigOther} />
</div>
Expand Down
9 changes: 9 additions & 0 deletions services/madoc-ts/translations/en/madoc.json
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
{
"...": "...",
"A longer description for your form field, appears under the label (like this)": "A longer description for your form field, appears under the label (like this)",
"A longer description for your transcription form field, appears under the label (like this)": "A longer description for your transcription form field, appears under the label (like this)",
"A short bio about yourself": "A short bio about yourself",
Expand Down Expand Up @@ -263,6 +264,7 @@
"Current translations": "Current translations",
"Currently assigned": "Currently assigned",
"Custom button label": "Custom button label",
"Custom project": "Custom project",
"Custom reviewer (numeric id)": "Custom reviewer (numeric id)",
"Customise site pages": "Customise site pages",
"Dark": "Dark",
Expand Down Expand Up @@ -551,6 +553,7 @@
"Logout": "Logout",
"Long expiry time (minutes)": "Long expiry time (minutes)",
"Lost connection to server, retrying...": "Lost connection to server, retrying...",
"Make Correction": "Make Correction",
"Make initial search": "Make initial search",
"Manage collections": "Manage collections",
"Manage collections_plural": "Manage collections",
Expand Down Expand Up @@ -914,10 +917,13 @@
"This manifest is complete": "This manifest is complete",
"This manifest is currently in review": "This manifest is currently in review",
"This manifest is not available to browse": "This manifest is not available to browse",
"This means this task has been assigned or is in progress, but nothing has been submitted": "This means this task has been assigned or is in progress, but nothing has been submitted",
"This merge may be corrupted": "This merge may be corrupted. Would you like to remove it?",
"This page is complete": "This page is complete",
"This task has been rejected.": "This task has been rejected.",
"This task is complete.": "This task is complete.",
"This task is complete. You can make another contribution from the": "This task is complete. You can make another contribution from the",
"This task is not yet ready for review.": "This task is not yet ready for review.",
"This tasks parent is complete, you can no longer edit or submit this task": "This tasks parent is complete, you can no longer edit or submit this task",
"Thumbnail background": "Thumbnail background",
"Thumbnail layout": "Thumbnail layout",
Expand Down Expand Up @@ -987,6 +993,7 @@
"View new terms": "View new terms",
"View on admin dashboard": "View on admin dashboard",
"View on site": "View on site",
"View options": "View options",
"View options for the contributions page": "View options for the contributions page",
"View options for the contributions pnnel": "View options for the contributions pnnel",
"View options for the global site navigation": "View options for the global site navigation",
Expand All @@ -995,10 +1002,12 @@
"View options for the menu": "View options for the menu",
"View options for the project landing page": "View options for the project landing page",
"View project dashboard": "View project dashboard",
"View resource": "View resource",
"View site": "View site",
"View style": "View style",
"View submission": "View submission",
"View submissions": "View submissions",
"View task": "View task",
"Waiting for resource": "Waiting for resource",
"Webhooks": "Webhooks",
"Welcome back {{user}}": "Welcome back {{user}}",
Expand Down

0 comments on commit a0b7ec2

Please sign in to comment.