[laboratory] collections select should contain description (#4977)

This commit is contained in:
Dimitri POSTOLOV 2024-06-15 10:09:01 +02:00 committed by GitHub
parent 8a8abc6a21
commit 7649ca9440
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
3 changed files with 20 additions and 13 deletions

View file

@ -174,7 +174,6 @@ export function CreateCollectionModal(props: {
},
input: {
collectionId,
name: values.name,
description: values.description,
},

View file

@ -4,7 +4,8 @@ import { useMutation } from 'urql';
import * as Yup from 'yup';
import { Button } from '@/components/ui/button';
import { Heading } from '@/components/ui/heading';
import { Input, Modal, Select } from '@/components/v2';
import { Select, SelectContent, SelectItem, SelectTrigger } from '@/components/ui/select';
import { Input, Modal } from '@/components/v2';
import { graphql } from '@/gql';
import { useCollections } from '@/pages/target-laboratory';
import { useEditorContext } from '@graphiql/react';
@ -80,6 +81,7 @@ export function CreateOperationModal(props: {
touched,
isSubmitting,
resetForm,
setFieldValue,
} = useFormik({
initialValues: {
name: '',
@ -144,18 +146,23 @@ export function CreateOperationModal(props: {
Which collection would you like to save this operation to?
</label>
<Select
name="collectionId"
placeholder="Select collection"
options={collections?.map(c => ({
value: c.id,
name: c.name,
}))}
value={values.collectionId}
onChange={handleChange}
onBlur={handleBlur}
isInvalid={!!(touched.collectionId && errors.collectionId)}
data-cy="select.collectionId"
/>
onValueChange={async v => {
await setFieldValue('collectionId', v);
}}
>
<SelectTrigger>
{collections.find(c => c.id === values.collectionId)?.name || 'Select collection'}
</SelectTrigger>
<SelectContent className="w-[--radix-select-trigger-width]">
{collections.map(c => (
<SelectItem key={c.id} value={c.id}>
{c.name}
<div className="mt-1 line-clamp-1 text-xs opacity-50">{c.description}</div>
</SelectItem>
))}
</SelectContent>
</Select>
{touched.collectionId && errors.collectionId && (
<div className="text-sm text-red-500">{errors.collectionId}</div>
)}

View file

@ -302,6 +302,7 @@ export const CollectionsQuery = graphql(`
node {
id
name
description
operations(first: 100) {
edges {
node {