Commit 896e7083 authored by Stefan Probst's avatar Stefan Probst
Browse files

feat: link to related steps

parent a8c5275f
<svg version="1.0" id="Warstwa_1" xmlns="http://www.w3.org/2000/svg" x="0" y="0" viewBox="0 0 85.039 85.039" xml:space="preserve"><style>.st0{opacity:.38;fill:#494949}.st20{fill:#8f27d0}</style><path fill="#4d3292" d="M39.842 8.754l-.007 37.727-32.51-21.593z"/><path class="st0" d="M76.295 66.445H30.887c-.82 0-1.486-.665-1.486-1.486V22.484c0-.821.665-1.486 1.486-1.486h45.408c.82 0 1.486.665 1.486 1.486v42.475c0 .821-.665 1.486-1.486 1.486z"/><path d="M75.752 65.874H30.345a1.486 1.486 0 01-1.486-1.486V21.912c0-.82.665-1.486 1.486-1.486h45.407c.821 0 1.487.666 1.487 1.486v42.476c0 .82-.666 1.486-1.487 1.486z" fill="#cf63ea"/><path class="st20" d="M77.239 32.448V21.737a1.31 1.31 0 00-1.31-1.31h-45.76a1.31 1.31 0 00-1.31 1.31v10.71h48.38z"/><path class="st0" d="M40.637 44.968c.047-1.86-1.275-2.503-1.275-2.503l-1.752-1a143894.593 143894.593 0 00-21.946-12.71l-1.727-1a.652.652 0 01-.244-.223l-5.12-2.93a2.643 2.643 0 00-.424 1.475v32.495c.01.308.122 1.126 1.03 1.646l2.554 1.463L36.13 75.85l1.889 1.082.846.484s.21.112.315.146c.054.016.115.033.177.044.237.042.557.051.821-.1.282-.164.5-.51.483-1.2V47.67l-.023-2.702z"/><path d="M38.537 41.276l-1.752-1-21.468-12.438-.478-.273-1.727-.999c-.579-.33-.2-.777.008-.864l25.492-14.9a2.46 2.46 0 10-2.46-4.26l-9.04 5.4-18.57 10.656a2.656 2.656 0 00-1.218 2.29v32.495c.01.308.122 1.126 1.03 1.646l2.554 1.463 24.396 14.169 1.889 1.082.846.484s.21.112.315.146c.054.016.115.033.177.044.237.042.557.051.821-.1.282-.164.5-.511.483-1.2V46.481l-.023-2.702c.047-1.86-1.275-2.503-1.275-2.503z" fill="#624ec4"/><path class="st20" d="M55.539 56.705a8.22 8.22 0 001.462-.604l2.563 1.372 1.141-1.169.017-.017 1.14-1.169-1.441-2.54a8.19 8.19 0 00.533-1.298l2.792-.81v-1.657l-.002-1.633-2.808-.81c-.01-.032-.013-.065-.023-.096a8.199 8.199 0 00-.496-1.189l1.445-2.547-1.14-1.17-.017-.016-1.14-1.17-2.6 1.392a8.187 8.187 0 00-1.45-.604l-.816-2.82h-3.29l-.815 2.814a8.215 8.215 0 00-1.465.62L46.543 40.2l-1.141 1.17-.017.016-1.14 1.17 1.457 2.568a8.18 8.18 0 00-.524 1.274l-2.817.818.001 1.633v.023l.001 1.634 2.826.816c.134.425.307.831.505 1.224l-1.45 2.555 1.141 1.169.017.017 1.14 1.169 2.56-1.37c.476.26.986.461 1.512.626l.816 2.821h3.29l.819-2.828zm-6.952-7.846a4.476 4.476 0 118.953 0 4.476 4.476 0 01-8.953 0z"/><path d="M55.529 56.253a8.22 8.22 0 001.462-.604l2.563 1.372 1.141-1.17.017-.016 1.14-1.169-1.441-2.541a8.19 8.19 0 00.533-1.297l2.792-.81V48.36l-.002-1.633-2.808-.811c-.01-.03-.013-.064-.023-.095a8.2 8.2 0 00-.496-1.19l1.445-2.547-1.14-1.169-.017-.016-1.14-1.17-2.6 1.392a8.187 8.187 0 00-1.45-.605l-.816-2.819h-3.29l-.815 2.814a8.215 8.215 0 00-1.465.62l-2.586-1.384-1.141 1.17-.017.016-1.14 1.17 1.457 2.568a8.18 8.18 0 00-.524 1.274l-2.817.817.001 1.634v.023l.001 1.633 2.826.816c.134.426.307.832.505 1.224l-1.45 2.555 1.141 1.17.017.016 1.14 1.17 2.56-1.37c.476.26.986.461 1.512.625l.816 2.822h3.29l.819-2.828zm-6.952-7.847a4.476 4.476 0 118.953 0 4.476 4.476 0 01-8.953 0z" fill="#fff"/></svg>
\ No newline at end of file
......@@ -17,6 +17,8 @@ const outputFolder = join(process.cwd(), 'src', 'api', 'sshoc')
const outputFile = join(outputFolder, 'index.ts')
async function run() {
log.info(`Generating sshoc api client from ${openApiDocumentUrl}.`)
const response = await fetch(openApiDocumentUrl)
const openApiDocument = await response.json()
......
This diff is collapsed.
......@@ -15,7 +15,7 @@ import { SectionTitle } from '@/modules/ui/typography/SectionTitle'
const Plaintext = dynamic(() => import('@/modules/markdown/Plaintext'))
type ItemCategory = Exclude<ItemCategoryWithStep, 'step'>
type ItemCategory = ItemCategoryWithStep
type RelatedItems = Exclude<Item['relatedItems'], undefined>
type RelatedItem = RelatedItems[number]
......@@ -74,7 +74,13 @@ export default function RelatedItems({
}
function RelatedItem({ item }: { item: RelatedItem }): JSX.Element {
const pathname = `/${item.category}/${item.persistentId}`
const pathname =
item.category === 'step'
? `/workflow/${(item as any).workflowId}` // RelatedStepDto has workflowId, but this isn't exposed via openapi docs
: `/${item.category}/${item.persistentId}`
/** link to step via `step` query param on workflow page */
const query = item.category === 'step' ? { step: item.persistentId } : {}
return (
<VStack as="article" className="px-4 py-5 space-y-4">
<h3 className="flex items-center space-x-4 text-lg font-medium leading-5">
......@@ -83,7 +89,7 @@ function RelatedItem({ item }: { item: RelatedItem }): JSX.Element {
height="2.5em"
className="flex-shrink-0"
/>
<Link href={{ pathname }}>
<Link href={{ pathname, query }}>
<a className="hover:text-primary-700">{item.label}</a>
</Link>
</h3>
......@@ -93,7 +99,7 @@ function RelatedItem({ item }: { item: RelatedItem }): JSX.Element {
maxLength={MAX_RELATED_ITEMS_DESCRIPTION}
/>
</div>
<Link href={{ pathname }} passHref>
<Link href={{ pathname, query }} passHref>
<Anchor className="self-end text-sm" aria-label={item.label}>
Read more
</Anchor>
......
......@@ -6,12 +6,13 @@ import type { ItemCategory } from '@/api/sshoc/types'
import UnreachableError from '@/utils/ts/UnreachableError'
import { Svg as DatasetIcon } from '@@/assets/icons/dataset.svg'
import { Svg as PublicationIcon } from '@@/assets/icons/publication.svg'
import { Svg as StepIcon } from '@@/assets/icons/step.svg'
import { Svg as ToolOrServiceIcon } from '@@/assets/icons/tool-or-service.svg'
import { Svg as TrainingMaterialIcon } from '@@/assets/icons/training-material.svg'
import { Svg as WorkflowIcon } from '@@/assets/icons/workflow.svg'
type ItemCategoryIconProps = ComponentPropsWithoutRef<'svg'> & {
category: Exclude<ItemCategory, 'step'>
category: ItemCategory
}
const ItemCategoryIcon = forwardRef(function ItemCategoryIcon(
......@@ -26,6 +27,8 @@ const ItemCategoryIcon = forwardRef(function ItemCategoryIcon(
return <DatasetIcon ref={ref} title={title} {...props} />
case 'publication':
return <PublicationIcon ref={ref} title={title} {...props} />
case 'step':
return <StepIcon ref={ref} title={title} {...props} />
case 'tool-or-service':
return <ToolOrServiceIcon ref={ref} title={title} {...props} />
case 'training-material':
......
......@@ -191,6 +191,7 @@ function ItemVersion(props: ItemVersionProps) {
) : null}
</ProtectedView>
<ProtectedView roles={['moderator', 'administrator']}>
{/** TODO: also need to check that this version has already been approved before reverting (?) */}
{props.isCurrentApprovedVersion !== true ? (
<Button variant="link" onPress={onRevert}>
Revert to this version
......
......@@ -61,10 +61,7 @@ export default function ItemLayout({
order: ['label'],
}
// TODO: allow linking to individual workflow steps
const relatedItems = (item.relatedItems as RelatedItems).filter(
(item) => item.category !== 'step',
)
const relatedItems = item.relatedItems as RelatedItems
return (
<Fragment>
......
......@@ -109,7 +109,7 @@ function Step({ step, index }: { step: Step; index: number }) {
<b style={{ gridColumn: '1 / span 2' }} className="bg-gray-50" />
<DisclosurePanel
style={{ gridColumn: '3 / span 7' }}
className="px-6 py-12 space-y-4 bg-gray-50"
className="px-6 py-12 space-y-12 bg-gray-50"
>
<ItemMetadata item={step} />
<div className="leading-8">
......@@ -124,8 +124,7 @@ function Step({ step, index }: { step: Step; index: number }) {
function Related({ items }: { items?: Array<any> }) {
if (items == null) return null
// TODO: relations to steps
const relatedItems = items.filter((item) => item.category !== 'step')
const relatedItems = items
if (relatedItems.length === 0) return null
return (
......
......@@ -2,6 +2,9 @@
* Log message to console.
*/
const log = {
info(message: string): void {
console.info('ℹ️', message)
},
success(message: string): void {
console.info('', message)
},
......
......@@ -8766,7 +8766,7 @@ onetime@^5.1.0:
 
"openapi-ts-client@git+https://github.com/stefanprobst/openapi-ts-client":
version "0.1.0"
resolved "git+https://github.com/stefanprobst/openapi-ts-client#e8475ec231fe0b3028426f095aeade1f4b97944a"
resolved "git+https://github.com/stefanprobst/openapi-ts-client#6f2d334e70e08bffd0723250767a71311afe13eb"
dependencies:
got "^11.6.0"
lodash.camelcase "^4.3.0"
......
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