Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
SSHOC
sshoc-marketplace-frontend
Commits
0e9c0111
Commit
0e9c0111
authored
Mar 04, 2021
by
Stefan Probst
Browse files
fix: use singular category labels in toast
parent
8746cd7e
Pipeline
#178016
passed with stage
in 5 minutes and 8 seconds
Changes
12
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
src/components/item/DatasetCreateForm/DatasetCreateForm.tsx
View file @
0e9c0111
import
{
useRouter
}
from
'
next/router
'
import
{
useQueryClient
}
from
'
react-query
'
import
type
{
DatasetCore
,
DatasetDto
}
from
'
@/api/sshoc
'
import
{
useCreateDataset
,
useGetItemCategories
}
from
'
@/api/sshoc
'
import
{
useCreateDataset
}
from
'
@/api/sshoc
'
import
type
{
ItemCategory
}
from
'
@/api/sshoc/types
'
import
{
ActorsFormSection
}
from
'
@/components/item/ActorsFormSection/ActorsFormSection
'
import
{
DateFormSection
}
from
'
@/components/item/DateFormSection/DateFormSection
'
import
{
MainFormSection
}
from
'
@/components/item/MainFormSection/MainFormSection
'
...
...
@@ -15,6 +14,7 @@ import { useToast } from '@/elements/Toast/useToast'
import
{
validate
}
from
'
@/lib/sshoc/validate
'
import
{
useAuth
}
from
'
@/modules/auth/AuthContext
'
import
{
Form
}
from
'
@/modules/form/Form
'
import
{
getSingularItemCategoryLabel
}
from
'
@/utils/getSingularItemCategoryLabel
'
export
type
ItemFormValues
=
DatasetCore
...
...
@@ -29,8 +29,7 @@ export interface ItemFormProps<T> {
export
function
ItemForm
(
props
:
ItemFormProps
<
ItemFormValues
>
):
JSX
.
Element
{
const
{
category
,
initialValues
}
=
props
const
categories
=
useGetItemCategories
()
const
categoryLabel
=
categories
.
data
?.[
category
]
??
category
const
categoryLabel
=
getSingularItemCategoryLabel
(
category
)
const
useItemMutation
=
useCreateDataset
...
...
src/components/item/DatasetEditForm/DatasetEditForm.tsx
View file @
0e9c0111
import
{
useRouter
}
from
'
next/router
'
import
{
useQueryClient
}
from
'
react-query
'
import
type
{
DatasetCore
,
DatasetDto
}
from
'
@/api/sshoc
'
import
{
useGetItemCategories
,
useUpdateDataset
}
from
'
@/api/sshoc
'
import
{
useUpdateDataset
}
from
'
@/api/sshoc
'
import
type
{
ItemCategory
}
from
'
@/api/sshoc/types
'
import
{
ActorsFormSection
}
from
'
@/components/item/ActorsFormSection/ActorsFormSection
'
import
{
DateFormSection
}
from
'
@/components/item/DateFormSection/DateFormSection
'
import
{
MainFormSection
}
from
'
@/components/item/MainFormSection/MainFormSection
'
...
...
@@ -15,6 +14,7 @@ import { useToast } from '@/elements/Toast/useToast'
import
{
validate
}
from
'
@/lib/sshoc/validate
'
import
{
useAuth
}
from
'
@/modules/auth/AuthContext
'
import
{
Form
}
from
'
@/modules/form/Form
'
import
{
getSingularItemCategoryLabel
}
from
'
@/utils/getSingularItemCategoryLabel
'
export
type
ItemFormValues
=
DatasetCore
...
...
@@ -31,8 +31,7 @@ export interface ItemFormProps<T> {
export
function
ItemForm
(
props
:
ItemFormProps
<
ItemFormValues
>
):
JSX
.
Element
{
const
{
id
,
category
,
initialValues
}
=
props
const
categories
=
useGetItemCategories
()
const
categoryLabel
=
categories
.
data
?.[
category
]
??
category
const
categoryLabel
=
getSingularItemCategoryLabel
(
category
)
const
useItemMutation
=
useUpdateDataset
...
...
src/components/item/PublicationCreateForm/PublicationCreateForm.tsx
View file @
0e9c0111
import
{
useRouter
}
from
'
next/router
'
import
{
useQueryClient
}
from
'
react-query
'
import
type
{
PublicationCore
,
PublicationDto
}
from
'
@/api/sshoc
'
import
{
useGetItemCategories
,
useCreatePublication
}
from
'
@/api/sshoc
'
import
{
useCreatePublication
}
from
'
@/api/sshoc
'
import
type
{
ItemCategory
}
from
'
@/api/sshoc/types
'
import
{
ActorsFormSection
}
from
'
@/components/item/ActorsFormSection/ActorsFormSection
'
import
{
DateFormSection
}
from
'
@/components/item/DateFormSection/DateFormSection
'
import
{
MainFormSection
}
from
'
@/components/item/MainFormSection/MainFormSection
'
...
...
@@ -15,6 +14,7 @@ import { useToast } from '@/elements/Toast/useToast'
import
{
validate
}
from
'
@/lib/sshoc/validate
'
import
{
useAuth
}
from
'
@/modules/auth/AuthContext
'
import
{
Form
}
from
'
@/modules/form/Form
'
import
{
getSingularItemCategoryLabel
}
from
'
@/utils/getSingularItemCategoryLabel
'
export
type
ItemFormValues
=
PublicationCore
...
...
@@ -29,8 +29,7 @@ export interface ItemFormProps<T> {
export
function
ItemForm
(
props
:
ItemFormProps
<
ItemFormValues
>
):
JSX
.
Element
{
const
{
category
,
initialValues
}
=
props
const
categories
=
useGetItemCategories
()
const
categoryLabel
=
categories
.
data
?.[
category
]
??
category
const
categoryLabel
=
getSingularItemCategoryLabel
(
category
)
const
useItemMutation
=
useCreatePublication
...
...
src/components/item/PublicationEditForm/PublicationEditForm.tsx
View file @
0e9c0111
import
{
useRouter
}
from
'
next/router
'
import
{
useQueryClient
}
from
'
react-query
'
import
type
{
PublicationCore
,
PublicationDto
}
from
'
@/api/sshoc
'
import
{
useUpdatePublication
,
useGetItemCategories
}
from
'
@/api/sshoc
'
import
{
useUpdatePublication
}
from
'
@/api/sshoc
'
import
type
{
ItemCategory
}
from
'
@/api/sshoc/types
'
import
{
ActorsFormSection
}
from
'
@/components/item/ActorsFormSection/ActorsFormSection
'
import
{
DateFormSection
}
from
'
@/components/item/DateFormSection/DateFormSection
'
import
{
MainFormSection
}
from
'
@/components/item/MainFormSection/MainFormSection
'
...
...
@@ -15,6 +14,7 @@ import { useToast } from '@/elements/Toast/useToast'
import
{
validate
}
from
'
@/lib/sshoc/validate
'
import
{
useAuth
}
from
'
@/modules/auth/AuthContext
'
import
{
Form
}
from
'
@/modules/form/Form
'
import
{
getSingularItemCategoryLabel
}
from
'
@/utils/getSingularItemCategoryLabel
'
export
type
ItemFormValues
=
PublicationCore
...
...
@@ -31,8 +31,7 @@ export interface ItemFormProps<T> {
export
function
ItemForm
(
props
:
ItemFormProps
<
ItemFormValues
>
):
JSX
.
Element
{
const
{
id
,
category
,
initialValues
}
=
props
const
categories
=
useGetItemCategories
()
const
categoryLabel
=
categories
.
data
?.[
category
]
??
category
const
categoryLabel
=
getSingularItemCategoryLabel
(
category
)
const
useItemMutation
=
useUpdatePublication
...
...
src/components/item/ToolCreateForm/ToolCreateForm.tsx
View file @
0e9c0111
import
{
useRouter
}
from
'
next/router
'
import
{
useQueryClient
}
from
'
react-query
'
import
type
{
ToolCore
,
ToolDto
}
from
'
@/api/sshoc
'
import
{
useCreateTool
,
useGetItemCategories
}
from
'
@/api/sshoc
'
import
{
useCreateTool
}
from
'
@/api/sshoc
'
import
type
{
ItemCategory
}
from
'
@/api/sshoc/types
'
import
{
ActorsFormSection
}
from
'
@/components/item/ActorsFormSection/ActorsFormSection
'
import
{
MainFormSection
}
from
'
@/components/item/MainFormSection/MainFormSection
'
import
{
PropertiesFormSection
}
from
'
@/components/item/PropertiesFormSection/PropertiesFormSection
'
...
...
@@ -14,6 +13,7 @@ import { useToast } from '@/elements/Toast/useToast'
import
{
validate
}
from
'
@/lib/sshoc/validate
'
import
{
useAuth
}
from
'
@/modules/auth/AuthContext
'
import
{
Form
}
from
'
@/modules/form/Form
'
import
{
getSingularItemCategoryLabel
}
from
'
@/utils/getSingularItemCategoryLabel
'
export
type
ItemFormValues
=
ToolCore
...
...
@@ -28,8 +28,7 @@ export interface ItemFormProps<T> {
export
function
ItemForm
(
props
:
ItemFormProps
<
ItemFormValues
>
):
JSX
.
Element
{
const
{
category
,
initialValues
}
=
props
const
categories
=
useGetItemCategories
()
const
categoryLabel
=
categories
.
data
?.[
category
]
??
category
const
categoryLabel
=
getSingularItemCategoryLabel
(
category
)
const
useItemMutation
=
useCreateTool
...
...
src/components/item/ToolEditForm/ToolEditForm.tsx
View file @
0e9c0111
import
{
useRouter
}
from
'
next/router
'
import
{
useQueryClient
}
from
'
react-query
'
import
type
{
ToolCore
,
ToolDto
}
from
'
@/api/sshoc
'
import
{
useUpdateTool
,
useGetItemCategories
}
from
'
@/api/sshoc
'
import
{
useUpdateTool
}
from
'
@/api/sshoc
'
import
type
{
ItemCategory
}
from
'
@/api/sshoc/types
'
import
{
ActorsFormSection
}
from
'
@/components/item/ActorsFormSection/ActorsFormSection
'
import
{
MainFormSection
}
from
'
@/components/item/MainFormSection/MainFormSection
'
import
{
PropertiesFormSection
}
from
'
@/components/item/PropertiesFormSection/PropertiesFormSection
'
...
...
@@ -14,6 +13,7 @@ import { useToast } from '@/elements/Toast/useToast'
import
{
validate
}
from
'
@/lib/sshoc/validate
'
import
{
useAuth
}
from
'
@/modules/auth/AuthContext
'
import
{
Form
}
from
'
@/modules/form/Form
'
import
{
getSingularItemCategoryLabel
}
from
'
@/utils/getSingularItemCategoryLabel
'
export
type
ItemFormValues
=
ToolCore
...
...
@@ -30,8 +30,7 @@ export interface ItemFormProps<T> {
export
function
ItemForm
(
props
:
ItemFormProps
<
ItemFormValues
>
):
JSX
.
Element
{
const
{
id
,
category
,
initialValues
}
=
props
const
categories
=
useGetItemCategories
()
const
categoryLabel
=
categories
.
data
?.[
category
]
??
category
const
categoryLabel
=
getSingularItemCategoryLabel
(
category
)
const
useItemMutation
=
useUpdateTool
...
...
src/components/item/TrainingMaterialCreateForm/TrainingMaterialCreateForm.tsx
View file @
0e9c0111
import
{
useRouter
}
from
'
next/router
'
import
{
useQueryClient
}
from
'
react-query
'
import
type
{
TrainingMaterialCore
,
TrainingMaterialDto
}
from
'
@/api/sshoc
'
import
{
useCreateTrainingMaterial
,
useGetItemCategories
}
from
'
@/api/sshoc
'
import
{
useCreateTrainingMaterial
}
from
'
@/api/sshoc
'
import
type
{
ItemCategory
}
from
'
@/api/sshoc/types
'
import
{
ActorsFormSection
}
from
'
@/components/item/ActorsFormSection/ActorsFormSection
'
import
{
MainFormSection
}
from
'
@/components/item/MainFormSection/MainFormSection
'
import
{
PropertiesFormSection
}
from
'
@/components/item/PropertiesFormSection/PropertiesFormSection
'
...
...
@@ -14,6 +13,7 @@ import { useToast } from '@/elements/Toast/useToast'
import
{
validate
}
from
'
@/lib/sshoc/validate
'
import
{
useAuth
}
from
'
@/modules/auth/AuthContext
'
import
{
Form
}
from
'
@/modules/form/Form
'
import
{
getSingularItemCategoryLabel
}
from
'
@/utils/getSingularItemCategoryLabel
'
export
type
ItemFormValues
=
TrainingMaterialCore
...
...
@@ -28,8 +28,7 @@ export interface ItemFormProps<T> {
export
function
ItemForm
(
props
:
ItemFormProps
<
ItemFormValues
>
):
JSX
.
Element
{
const
{
category
,
initialValues
}
=
props
const
categories
=
useGetItemCategories
()
const
categoryLabel
=
categories
.
data
?.[
category
]
??
category
const
categoryLabel
=
getSingularItemCategoryLabel
(
category
)
const
useItemMutation
=
useCreateTrainingMaterial
...
...
src/components/item/TrainingMaterialEditForm/TrainingMaterialEditForm.tsx
View file @
0e9c0111
import
{
useRouter
}
from
'
next/router
'
import
{
useQueryClient
}
from
'
react-query
'
import
type
{
TrainingMaterialCore
,
TrainingMaterialDto
}
from
'
@/api/sshoc
'
import
{
useUpdateTrainingMaterial
,
useGetItemCategories
}
from
'
@/api/sshoc
'
import
{
useUpdateTrainingMaterial
}
from
'
@/api/sshoc
'
import
type
{
ItemCategory
}
from
'
@/api/sshoc/types
'
import
{
ActorsFormSection
}
from
'
@/components/item/ActorsFormSection/ActorsFormSection
'
import
{
MainFormSection
}
from
'
@/components/item/MainFormSection/MainFormSection
'
import
{
PropertiesFormSection
}
from
'
@/components/item/PropertiesFormSection/PropertiesFormSection
'
...
...
@@ -14,6 +13,7 @@ import { useToast } from '@/elements/Toast/useToast'
import
{
validate
}
from
'
@/lib/sshoc/validate
'
import
{
useAuth
}
from
'
@/modules/auth/AuthContext
'
import
{
Form
}
from
'
@/modules/form/Form
'
import
{
getSingularItemCategoryLabel
}
from
'
@/utils/getSingularItemCategoryLabel
'
export
type
ItemFormValues
=
TrainingMaterialCore
...
...
@@ -30,8 +30,7 @@ export interface ItemFormProps<T> {
export
function
ItemForm
(
props
:
ItemFormProps
<
ItemFormValues
>
):
JSX
.
Element
{
const
{
id
,
category
,
initialValues
}
=
props
const
categories
=
useGetItemCategories
()
const
categoryLabel
=
categories
.
data
?.[
category
]
??
category
const
categoryLabel
=
getSingularItemCategoryLabel
(
category
)
const
useItemMutation
=
useUpdateTrainingMaterial
...
...
src/components/item/WorkflowCreateForm/WorkflowCreateForm.tsx
View file @
0e9c0111
import
{
useRouter
}
from
'
next/router
'
import
{
useQueryClient
}
from
'
react-query
'
import
type
{
WorkflowCore
,
WorkflowDto
}
from
'
@/api/sshoc
'
import
{
useCreateWorkflow
,
useGetItemCategories
}
from
'
@/api/sshoc
'
import
{
useCreateWorkflow
}
from
'
@/api/sshoc
'
import
type
{
ItemCategory
}
from
'
@/api/sshoc/types
'
import
{
ActorsFormSection
}
from
'
@/components/item/ActorsFormSection/ActorsFormSection
'
import
{
MainFormSection
}
from
'
@/components/item/MainFormSection/MainFormSection
'
import
{
PropertiesFormSection
}
from
'
@/components/item/PropertiesFormSection/PropertiesFormSection
'
...
...
@@ -14,6 +13,7 @@ import { useToast } from '@/elements/Toast/useToast'
import
{
validate
}
from
'
@/lib/sshoc/validate
'
import
{
useAuth
}
from
'
@/modules/auth/AuthContext
'
import
{
Form
}
from
'
@/modules/form/Form
'
import
{
getSingularItemCategoryLabel
}
from
'
@/utils/getSingularItemCategoryLabel
'
export
type
ItemFormValues
=
WorkflowCore
...
...
@@ -28,8 +28,7 @@ export interface ItemFormProps<T> {
export
function
ItemForm
(
props
:
ItemFormProps
<
ItemFormValues
>
):
JSX
.
Element
{
const
{
category
,
initialValues
}
=
props
const
categories
=
useGetItemCategories
()
const
categoryLabel
=
categories
.
data
?.[
category
]
??
category
const
categoryLabel
=
getSingularItemCategoryLabel
(
category
)
const
useItemMutation
=
useCreateWorkflow
...
...
src/components/item/WorkflowEditForm/WorkflowEditForm.tsx
View file @
0e9c0111
import
{
useRouter
}
from
'
next/router
'
import
{
useQueryClient
}
from
'
react-query
'
import
type
{
WorkflowCore
,
WorkflowDto
}
from
'
@/api/sshoc
'
import
{
useUpdateWorkflow
,
useGetItemCategories
}
from
'
@/api/sshoc
'
import
{
useUpdateWorkflow
}
from
'
@/api/sshoc
'
import
type
{
ItemCategory
}
from
'
@/api/sshoc/types
'
import
{
ActorsFormSection
}
from
'
@/components/item/ActorsFormSection/ActorsFormSection
'
import
{
MainFormSection
}
from
'
@/components/item/MainFormSection/MainFormSection
'
import
{
PropertiesFormSection
}
from
'
@/components/item/PropertiesFormSection/PropertiesFormSection
'
...
...
@@ -14,6 +13,7 @@ import { useToast } from '@/elements/Toast/useToast'
import
{
validate
}
from
'
@/lib/sshoc/validate
'
import
{
useAuth
}
from
'
@/modules/auth/AuthContext
'
import
{
Form
}
from
'
@/modules/form/Form
'
import
{
getSingularItemCategoryLabel
}
from
'
@/utils/getSingularItemCategoryLabel
'
export
type
ItemFormValues
=
WorkflowCore
...
...
@@ -30,8 +30,7 @@ export interface ItemFormProps<T> {
export
function
ItemForm
(
props
:
ItemFormProps
<
ItemFormValues
>
):
JSX
.
Element
{
const
{
id
,
category
,
initialValues
}
=
props
const
categories
=
useGetItemCategories
()
const
categoryLabel
=
categories
.
data
?.[
category
]
??
category
const
categoryLabel
=
getSingularItemCategoryLabel
(
category
)
const
useItemMutation
=
useUpdateWorkflow
...
...
src/modules/page/PageHeader.tsx
View file @
0e9c0111
...
...
@@ -481,9 +481,7 @@ function CreateItemsMenu() {
<
Link
href
=
{
{
pathname
:
`/
${
category
}
/create`
}
}
>
<
a
className
=
"transition-colors duration-150 hover:text-secondary-500"
>
Create
{
'
'
}
{
getSingularItemCategoryLabel
(
category
as
Exclude
<
ItemCategory
,
'
step
'
>
,
)
}
{
getSingularItemCategoryLabel
(
category
as
ItemCategory
)
}
</
a
>
</
Link
>
</
li
>
...
...
src/utils/getSingularItemCategoryLabel.ts
View file @
0e9c0111
import
type
{
ItemCategory
as
ItemCategoryWithStep
}
from
'
@/api/sshoc/types
'
type
ItemCategory
=
Exclude
<
ItemCategoryWithStep
,
'
step
'
>
import
type
{
ItemCategory
}
from
'
@/api/sshoc/types
'
/**
* Returns item category in singular.
...
...
@@ -11,6 +9,7 @@ export function getSingularItemCategoryLabel(category: ItemCategory): string {
const
labels
=
{
dataset
:
'
Dataset
'
,
publication
:
'
Publication
'
,
step
:
'
Step
'
,
'
tool-or-service
'
:
'
Tool or service
'
,
'
training-material
'
:
'
Training material
'
,
workflow
:
'
Workflow
'
,
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment