Skip to content
Open
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
3 changes: 3 additions & 0 deletions packages/backend/src/graphql/schema.graphql
Original file line number Diff line number Diff line change
Expand Up @@ -296,6 +296,9 @@ type ActionSubstepArgument {

# Only for rich text
customRteMenuOptions: [RteMenuOption]

# Only for attachments
maxFiles: Int
}

type DropdownClickableLink {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ interface AttachmentSuggestionsProps {
description?: string
required?: boolean
variableTypes?: TDataOutMetadatumType[]
maxFiles?: number
}

function AttachmentSuggestions(props: AttachmentSuggestionsProps) {
Expand All @@ -37,6 +38,7 @@ function AttachmentSuggestions(props: AttachmentSuggestionsProps) {
label,
variableTypes = null,
defaultValue = [],
maxFiles,
} = props
const { priorExecutionSteps } = useContext(StepExecutionsContext)
const cancelRef = useRef<HTMLButtonElement>(null)
Expand Down Expand Up @@ -99,6 +101,7 @@ function AttachmentSuggestions(props: AttachmentSuggestionsProps) {
variable,
options,
getValues(name),
maxFiles,
)
if (!isValid) {
setError(name, { type: 'invalidFile', message: error })
Expand All @@ -107,7 +110,7 @@ function AttachmentSuggestions(props: AttachmentSuggestionsProps) {
}
}
},
[getValues, name, setError, options],
[getValues, name, setError, options, maxFiles],
)

useOutsideClick({
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -170,6 +170,7 @@ export function validateFiles(
file: File | CheckboxVariable,
options: CheckboxVariable[],
currentSelection: string[],
maxFiles: number = MAX_NUM_FILES,
): FileSizeValidationResult {
const fileSize = file.size ?? 0
const selectedOptions = options.filter((o) =>
Expand All @@ -182,10 +183,10 @@ export function validateFiles(
const totalSize = currentTotalSize + fileSize
const currentFileCount = currentSelection.length + 1

if (currentFileCount > MAX_NUM_FILES) {
if (currentFileCount > maxFiles) {
return {
isValid: false,
error: 'Total number of files cannot exceed 10',
error: `Total number of files cannot exceed ${maxFiles}`,
}
}

Expand Down
1 change: 1 addition & 0 deletions packages/frontend/src/components/InputCreator/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -198,6 +198,7 @@ export default function InputCreator(props: InputCreatorProps): JSX.Element {
description={description}
variableTypes={schema.variableTypes}
required={required}
maxFiles={schema.maxFiles}
/>
)
}
Expand Down
16 changes: 14 additions & 2 deletions packages/frontend/src/components/MultiCol.tsx/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -48,9 +48,21 @@ export default function MultiCol(props: MultiColProps) {
subFIndex: number,
) => {
const { type, variables } = subF

// Only show labels, descriptions, and tooltips on the first row
const schemaWithConditionalLabel =
index === 0
? subF
: {
...subF,
label: undefined,
description: undefined,
tooltipText: undefined,
}

return (
<InputCreator
schema={subF}
schema={schemaWithConditionalLabel}
namePrefix={name}
parentType="multicol"
autoFocus={subFIndex === 0 && type === 'string' && variables}
Expand All @@ -60,7 +72,7 @@ export default function MultiCol(props: MultiColProps) {
}

return (
<Flex flexDir={isMobile ? 'column' : 'row'} gap={2} alignItems="center">
<Flex flexDir={isMobile ? 'column' : 'row'} gap={2} alignItems="flex-end">
{subFields.map((subF, subFIndex) => {
const showDeleteButton = subFIndex === 0 && canRemoveRow
return isMobile ? (
Expand Down
1 change: 1 addition & 0 deletions packages/frontend/src/graphql/queries/get-apps.ts
Original file line number Diff line number Diff line change
Expand Up @@ -198,6 +198,7 @@ export const GET_APPS = gql`
tooltipText
value
noVariablesMessage
maxFiles
options {
label
description
Expand Down
3 changes: 3 additions & 0 deletions packages/types/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -448,6 +448,9 @@ export interface IFieldAttachment extends IBaseField {
type: 'attachment'
value?: string
variableTypes?: TDataOutMetadatumType[]

// Only for attachments
maxFiles?: number
}

export interface IFieldMultiline extends IBaseField {
Expand Down
Loading