Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions apps/website/e2e/workshop-workflows.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,10 @@ test('workflow launch groups lead to the existing shared form', async ({
await expect(
page.getByRole('heading', { name: 'Change a material', exact: true })
).toBeVisible()
// The eyebrow names the shelf this workflow sits on, and leads back to it.
const shelf = page.getByTestId('workflow-use-case')
await expect(shelf).toHaveText('Edit images')
await expect(shelf).toHaveAttribute('href', '/models?useCase=edit-images')
await expect(
page.getByRole('group', { name: 'Your original image' })
).toBeVisible()
Expand Down
47 changes: 47 additions & 0 deletions apps/website/src/components/workshop/WorkflowPage.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
import { render, screen } from '@testing-library/vue'
import { assert, describe, expect, it } from 'vitest'

import { workflowDetailsBySlug } from '../../config/workshop-workflow-content'
import WorkflowPage from './WorkflowPage.vue'

const model = workflowDetailsBySlug.get('workflows/remove-background')
assert(model)

// Who made the workflow stands over its name, and the shelf it sits on is the
// one thing up there that leads somewhere.
describe('WorkflowPage header', () => {
it('sends the shelf it names to that shelf, filtered', () => {
render(WorkflowPage, { props: { model } })

const shelf = screen.getByTestId('workflow-use-case')
expect(shelf.textContent.trim()).toBe('Edit images')
expect(shelf.getAttribute('href')).toBe('/models?useCase=edit-images')
})

it('says nothing about a shelf a workflow has none of', () => {
render(WorkflowPage, {
props: {
model: {
...model,
useCases: [],
task: undefined,
modality: undefined
}
}
})

expect(screen.queryByTestId('workflow-use-case')).toBeNull()
})

it.for([
{ author: 'ComfyUI', authors: 1 },
{ author: undefined, authors: 0 }
] as const)('names $authors author(s)', ({ author, authors }) => {
render(WorkflowPage, { props: { model: { ...model, author } } })

const named = screen.queryAllByTestId('workflow-author')
expect(named).toHaveLength(authors)
if (author) expect(named[0]).toHaveTextContent(author)
expect(screen.getByTestId('workflow-use-case')).toBeTruthy()
})
})
59 changes: 37 additions & 22 deletions apps/website/src/components/workshop/WorkflowPage.vue
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,11 @@ import { ChevronLeft } from '@lucide/vue'
import { computed } from 'vue'

import type { WorkflowWorkshopModelDetail } from '../../config/models-catalogue'
import { catalogSearch, useCaseFor } from '../../config/models-catalogue'
import { getRoutes } from '../../config/routes'
import { WORKSHOP_CLOUD_BASE_URL } from '../../config/workshop-env'
import { useWorkshopSession } from '../../config/workshop-session-state'
import { useCaseLabelKey } from '../../lib/workshop/use-case-label'
import { t } from '../../i18n/translations'
import WorkflowPlayground from './WorkflowPlayground.vue'

Expand All @@ -16,6 +19,24 @@ const scope = computed(() =>
? JSON.stringify([session.value.uid, session.value.workspace.id])
: 'anonymous'
)
const routes = getRoutes()

// The one thing the eyebrow can lead somewhere: the shelf this workflow sits
// on. It was a word before, and a word is not a way back.
const shelf = computed(() => {
const useCase = useCaseFor(model)
return useCase
? {
label: useCaseLabelKey[useCase],
href: `${routes.workshop}${catalogSearch({ useCase })}`
}
: undefined
})
const eyebrowClass =
'text-sm leading-none font-medium tracking-widest text-primary-comfy-yellow uppercase'
const pillClass =
'inline-flex h-7 items-center rounded-full border border-transparency-white-t20 px-3 text-xs leading-none text-primary-comfy-canvas transition-colors hover:border-primary-comfy-yellow hover:text-primary-comfy-yellow'

const template = model.workflow.template
const cloudHref = template
? `${WORKSHOP_CLOUD_BASE_URL}/?template=${encodeURIComponent(template.id)}`
Expand All @@ -32,9 +53,22 @@ const cloudHref = template
{{ t('workshop.catalogue.backToWorkflows') }}
</a>
<header class="mb-9" data-testid="workflow-hero">
<p v-if="model.category" class="mb-3 text-sm text-primary-comfy-yellow">
{{ model.categoryLabel?.en ?? model.category }}
</p>
<div class="mb-3 flex flex-wrap items-center gap-3">
<p
v-if="model.author"
:class="eyebrowClass"
data-testid="workflow-author"
>
{{ model.author }}
Comment thread
coderabbitai[bot] marked this conversation as resolved.
Resolved
</p>
<a
v-if="shelf"
:href="shelf.href"
:class="pillClass"
data-testid="workflow-use-case"
>{{ t(shelf.label) }}</a
>
</div>
<h1
class="max-w-4xl text-3xl font-light text-primary-comfy-canvas lg:text-5xl"
>
Expand All @@ -46,25 +80,6 @@ const cloudHref = template
>
{{ model.summary }}
</p>
<div
v-if="template"
class="mt-5 flex flex-wrap gap-2 text-xs text-primary-warm-gray"
>
<span
v-for="name in template.models"
:key="name"
class="rounded-full border border-transparency-white-t20 px-3 py-1.5"
>{{ name }}</span
>
<span class="px-2 py-1.5">
{{
t('workshop.workflow.templateBy').replace(
'{author}',
template.author
)
}}
</span>
</div>
</header>

<WorkflowPlayground
Expand Down
4 changes: 0 additions & 4 deletions apps/website/src/i18n/translations.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10594,10 +10594,6 @@ Enterprise`
'workshop.hub.io.video': { en: 'Video', 'zh-CN': '视频' },
'workshop.hub.io.audio': { en: 'Audio', 'zh-CN': '音频' },
'workshop.hub.io.3d': { en: '3D', 'zh-CN': '3D' },
'workshop.workflow.templateBy': {
en: 'Template by {author}',
'zh-CN': '模板作者:{author}'
},
'workshop.workflow.makeYours': { en: 'Make it yours', 'zh-CN': '开始创作' },
'workshop.workflow.sections': {
en: 'Workflow sections',
Expand Down
Loading