Commit a89421d9 authored by Stefan Probst's avatar Stefan Probst
Browse files

fix: update edit button on item version page to draft workaround

parent a2a3bcbc
Pipeline #291219 passed with stages
in 13 minutes and 19 seconds
import { ItemVersionControls } from '@/components/item/ItemVersionControls'
import type { Dataset } from '@/data/sshoc/api/dataset'
import type { ItemStatus } from '@/data/sshoc/api/item'
export interface DatasetVersionControlsProps {
persistentId: Dataset['persistentId']
status: ItemStatus
versionId: Dataset['id']
}
export function DatasetVersionControls(props: DatasetVersionControlsProps): JSX.Element {
const { persistentId, versionId } = props
const { persistentId, status, versionId } = props
return (
<ItemVersionControls category="dataset" persistentId={persistentId} versionId={versionId} />
<ItemVersionControls
category="dataset"
persistentId={persistentId}
status={status}
versionId={versionId}
/>
)
}
......@@ -93,10 +93,13 @@ function EditItemMenuButton(props: EditItemMenuButtonProps): JSX.Element {
) : null}
{draft.data != null && draft.data.status === 'draft' ? (
<LinkButton
href={itemRoutes.ItemEditVersionPage(category)({
persistentId,
versionId: draft.data.id,
})}
href={itemRoutes.ItemEditVersionPage(category)(
{
persistentId,
versionId: draft.data.id,
},
{ draft: true },
)}
color="secondary"
size="xs"
>
......
......@@ -2,7 +2,7 @@ import { useRouter } from 'next/router'
import { LinkButton } from '@/components/common/LinkButton'
import css from '@/components/item/ItemVersionControls.module.css'
import type { Item, ItemCategory } from '@/data/sshoc/api/item'
import type { Item, ItemCategory, ItemStatus } from '@/data/sshoc/api/item'
import { useDeleteDatasetVersion } from '@/data/sshoc/hooks/dataset'
import { useDeletePublicationVersion } from '@/data/sshoc/hooks/publication'
import { useDeleteToolVersion } from '@/data/sshoc/hooks/tool-or-service'
......@@ -18,11 +18,12 @@ import { Button } from '@/lib/core/ui/Button/Button'
export interface ItemVersionControlsProps {
category: ItemCategory
persistentId: Item['persistentId']
status: ItemStatus
versionId: Item['id']
}
export function ItemVersionControls(props: ItemVersionControlsProps): JSX.Element {
const { category, persistentId, versionId } = props
const { category, persistentId, status, versionId } = props
const { t } = useI18n<'common'>()
......@@ -30,11 +31,14 @@ export function ItemVersionControls(props: ItemVersionControlsProps): JSX.Elemen
<AccessControl>
<div className={css['container']}>
<LinkButton
href={itemRoutes.ItemEditVersionPage(category)({ persistentId, versionId })}
href={itemRoutes.ItemEditVersionPage(category)(
{ persistentId, versionId },
{ draft: status === 'draft' ? true : undefined },
)}
color="secondary"
size="xs"
>
{t(['common', 'controls', 'edit'])}
{t(['common', 'controls', 'edit-version'])}
</LinkButton>
<LinkButton
......
import { ItemVersionControls } from '@/components/item/ItemVersionControls'
import type { ItemStatus } from '@/data/sshoc/api/item'
import type { Publication } from '@/data/sshoc/api/publication'
export interface PublicationVersionControlsProps {
persistentId: Publication['persistentId']
status: ItemStatus
versionId: Publication['id']
}
export function PublicationVersionControls(props: PublicationVersionControlsProps): JSX.Element {
const { persistentId, versionId } = props
const { persistentId, status, versionId } = props
return (
<ItemVersionControls category="publication" persistentId={persistentId} versionId={versionId} />
<ItemVersionControls
category="publication"
persistentId={persistentId}
status={status}
versionId={versionId}
/>
)
}
import { ItemVersionControls } from '@/components/item/ItemVersionControls'
import type { ItemStatus } from '@/data/sshoc/api/item'
import type { Tool } from '@/data/sshoc/api/tool-or-service'
export interface ToolOrServiceVersionControlsProps {
persistentId: Tool['persistentId']
status: ItemStatus
versionId: Tool['id']
}
export function ToolOrServiceVersionControls(
props: ToolOrServiceVersionControlsProps,
): JSX.Element {
const { persistentId, versionId } = props
const { persistentId, status, versionId } = props
return (
<ItemVersionControls
category="tool-or-service"
persistentId={persistentId}
status={status}
versionId={versionId}
/>
)
......
import { ItemVersionControls } from '@/components/item/ItemVersionControls'
import type { ItemStatus } from '@/data/sshoc/api/item'
import type { TrainingMaterial } from '@/data/sshoc/api/training-material'
export interface TrainingMaterialVersionControlsProps {
persistentId: TrainingMaterial['persistentId']
status: ItemStatus
versionId: TrainingMaterial['id']
}
export function TrainingMaterialVersionControls(
props: TrainingMaterialVersionControlsProps,
): JSX.Element {
const { persistentId, versionId } = props
const { persistentId, status, versionId } = props
return (
<ItemVersionControls
category="training-material"
persistentId={persistentId}
status={status}
versionId={versionId}
/>
)
......
import { ItemVersionControls } from '@/components/item/ItemVersionControls'
import type { ItemStatus } from '@/data/sshoc/api/item'
import type { Workflow } from '@/data/sshoc/api/workflow'
export interface WorkflowVersionControlsProps {
persistentId: Workflow['persistentId']
status: ItemStatus
versionId: Workflow['id']
}
export function WorkflowVersionControls(props: WorkflowVersionControlsProps): JSX.Element {
const { persistentId, versionId } = props
const { persistentId, status, versionId } = props
return (
<ItemVersionControls category="workflow" persistentId={persistentId} versionId={versionId} />
<ItemVersionControls
category="workflow"
persistentId={persistentId}
status={status}
versionId={versionId}
/>
)
}
......@@ -246,6 +246,7 @@ export const dictionary: Dictionary = {
controls: {
history: 'History',
edit: 'Edit',
'edit-version': 'Edit this version',
'edit-latest-draft': 'Edit latest draft',
'edit-latest-suggestion': 'Edit latest suggestion',
delete: 'Delete',
......
......@@ -225,6 +225,7 @@ export interface Dictionary {
controls: {
history: string
edit: string
'edit-version': string
'edit-latest-draft': string
'edit-latest-suggestion': string
delete: string
......
......@@ -169,7 +169,11 @@ export default function DatasetVersionPage(props: DatasetVersionPage.Props): JSX
</ItemTitle>
</ScreenHeader>
<ItemHeader>
<DatasetVersionControls persistentId={dataset.persistentId} versionId={dataset.id} />
<DatasetVersionControls
persistentId={dataset.persistentId}
status={dataset.status}
versionId={dataset.id}
/>
<ItemDescription description={dataset.description} />
</ItemHeader>
<ItemInfo>
......
......@@ -169,6 +169,7 @@ export default function PublicationVersionPage(props: PublicationVersionPage.Pro
<ItemHeader>
<PublicationVersionControls
persistentId={publication.persistentId}
status={publication.status}
versionId={publication.id}
/>
<ItemDescription description={publication.description} />
......
......@@ -171,6 +171,7 @@ export default function ToolOrServiceVersionPage(
<ItemHeader>
<ToolOrServiceVersionControls
persistentId={toolOrService.persistentId}
status={toolOrService.status}
versionId={toolOrService.id}
/>
<ItemDescription description={toolOrService.description} />
......
......@@ -176,6 +176,7 @@ export default function TrainingMaterialVersionPage(
<ItemHeader>
<TrainingMaterialVersionControls
persistentId={trainingMaterial.persistentId}
status={trainingMaterial.status}
versionId={trainingMaterial.id}
/>
<ItemDescription description={trainingMaterial.description} />
......
......@@ -167,7 +167,11 @@ export default function WorkflowVersionPage(props: WorkflowVersionPage.Props): J
</ItemTitle>
</ScreenHeader>
<ItemHeader>
<WorkflowVersionControls persistentId={workflow.persistentId} versionId={workflow.id} />
<WorkflowVersionControls
persistentId={workflow.persistentId}
status={workflow.status}
versionId={workflow.id}
/>
<ItemDescription description={workflow.description} />
</ItemHeader>
<ItemInfo>
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment