diff --git a/apps/portals/nf/src/config/synapseConfigs/tools.ts b/apps/portals/nf/src/config/synapseConfigs/tools.ts index aee2252554..f1e7d70f84 100644 --- a/apps/portals/nf/src/config/synapseConfigs/tools.ts +++ b/apps/portals/nf/src/config/synapseConfigs/tools.ts @@ -278,12 +278,26 @@ export const toolDetailsPageConfig: DetailsPageProps = { }, { name: 'Markdown', - title: 'Submit an Observation', + title: 'Share Your Observation', standalone: true, props: { ownerId: 'syn26338068', - wikiId: '613438', + wikiId: '629946', + }, + }, + { + name: 'DynamicFormModal', + props: { + schemaUrl: + 'https://raw.githubusercontent.com/nf-osi/nf-research-tools-schema/refs/heads/main/NF-Tools-Schemas/observations/SubmitObservationSchema.json', + uiSchemaUrl: + 'https://raw.githubusercontent.com/nf-osi/nf-research-tools-schema/refs/heads/main/NF-Tools-Schemas/observations/SubmitObservationUiSchema.json', + postUrl: 'https://submit-form.com/KwZ46H4T', + submitButtonText: 'Submit Observation', }, + outsideContainerClassName: 'home-spacer', + tableSqlKeys: ['resourceId'], + columnName: 'resourceId', }, ], }, diff --git a/apps/synapse-portal-framework/src/components/nf/NFBrowseToolsPage.tsx b/apps/synapse-portal-framework/src/components/nf/NFBrowseToolsPage.tsx index aecfaedda6..ef633cee80 100644 --- a/apps/synapse-portal-framework/src/components/nf/NFBrowseToolsPage.tsx +++ b/apps/synapse-portal-framework/src/components/nf/NFBrowseToolsPage.tsx @@ -26,6 +26,55 @@ const categories: Category[] = [ { resourceName: 'Biobank', image: }, ] +const host = window.location.host +const baseUrl = `${encodeURIComponent( + 'Research Tools Central', +)}/${encodeURIComponent('Submit ')}` +const baseSchemaUrl = + 'https://raw.githubusercontent.com/nf-osi/nf-research-tools-schema/refs/heads/main/NF-Tools-Schemas/' +const postUrl = 'https://submit-form.com/KwZ46H4T' + +const createHref = path => + `http://${host}/${baseUrl}${encodeURIComponent(path)}` + +const submitToolButtons = [ + { + label: 'Submit Animal Model', + href: createHref('Animal Model'), + schemaUrl: `${baseSchemaUrl}animal-model/submitAnimalModel.json`, + uiSchemaUrl: `${baseSchemaUrl}animal-model/SubmitAnimalModelUiSchema.json`, + postUrl: postUrl, + }, + { + label: 'Submit Observation', + href: createHref('Observation'), + schemaUrl: `${baseSchemaUrl}observations/SubmitObservationSchema.json`, + uiSchemaUrl: `${baseSchemaUrl}observations/SubmitObservationUiSchema.json`, + postUrl: postUrl, + }, + { + label: 'Submit Cell Line', + href: createHref('Cell Line'), + schemaUrl: `${baseSchemaUrl}cell-line/submitCellLine.json`, + uiSchemaUrl: `${baseSchemaUrl}cell-line/submitCellLineUiSchema.json`, + postUrl: postUrl, + }, + { + label: 'Submit Genetic Reagents', + href: createHref('Genetic Reagent'), + schemaUrl: `${baseSchemaUrl}genetic-reagent/submitGeneticReagent.json`, + uiSchemaUrl: `${baseSchemaUrl}genetic-reagent/submitGeneticReagentUiSchema.json`, + postUrl: postUrl, + }, + { + label: 'Submit Antibody', + href: createHref('Antibody'), + schemaUrl: `${baseSchemaUrl}antibody/submitAntibody.json`, + uiSchemaUrl: `${baseSchemaUrl}antibody/SubmitAntibodyUiSchema.json`, + postUrl: postUrl, + }, +] + export type NFBrowseToolsPageProps = { popularSearchesSql: string toolsSql: string @@ -238,16 +287,32 @@ const NFBrowseToolsPage = (props: NFBrowseToolsPageProps) => {
- - Submit A Tool - + {submitToolButtons.map(button => ( + + {button.label} + + ))} +
diff --git a/apps/synapse-portal-framework/src/types/portal-config.ts b/apps/synapse-portal-framework/src/types/portal-config.ts index 864a1736b0..c50c2468ee 100644 --- a/apps/synapse-portal-framework/src/types/portal-config.ts +++ b/apps/synapse-portal-framework/src/types/portal-config.ts @@ -27,6 +27,8 @@ import { UserCardListRotateProps, UserCardProps, DynamicFormProps, + DynamicFormModalProps, + DynamicFormModal, SharePageLinkButtonProps, } from 'synapse-react-client' import { RouteControlWrapperProps } from '../components/RouteControlWrapper' @@ -84,6 +86,11 @@ type DynamicForm = { props: DynamicFormProps } +type DynamicFormModal = { + name: 'DynamicFormModal' + props: DynamicFormModalProps +} + type Markdown = { name: 'Markdown' props: MarkdownSynapseProps @@ -401,6 +408,7 @@ export type SynapseConfig = ( | DatasetJsonLdScript | DynamicForm | SharePageLinkButton + | DynamicFormModal ) & Metadata diff --git a/packages/synapse-react-client/src/components/DynamicForm/DynamicForm.tsx b/packages/synapse-react-client/src/components/DynamicForm/DynamicForm.tsx index 8bd167d7fc..9879ebdeb2 100644 --- a/packages/synapse-react-client/src/components/DynamicForm/DynamicForm.tsx +++ b/packages/synapse-react-client/src/components/DynamicForm/DynamicForm.tsx @@ -12,6 +12,7 @@ export type DynamicFormProps = { postUrl: string mutateFormDataBeforePost?: (formData: any) => any // allow caller to embed formdata into custom request body object onCancel?: () => void + onSubmit?: () => void } function DynamicForm(props: DynamicFormProps) { @@ -21,6 +22,7 @@ function DynamicForm(props: DynamicFormProps) { postUrl, mutateFormDataBeforePost, onCancel, + onSubmit, } = props const [formData, setFormData] = useState({}) @@ -80,6 +82,9 @@ function DynamicForm(props: DynamicFormProps) { }, onSuccess: () => { displayToast('Form submitted successfully!', 'success') + if (onSubmit) { + onSubmit() + } }, onError: error => { displayToast(`Error submitting form: ${error.message}`, 'danger') diff --git a/packages/synapse-react-client/src/components/DynamicForm/DynamicFormModal.tsx b/packages/synapse-react-client/src/components/DynamicForm/DynamicFormModal.tsx new file mode 100644 index 0000000000..436258742d --- /dev/null +++ b/packages/synapse-react-client/src/components/DynamicForm/DynamicFormModal.tsx @@ -0,0 +1,68 @@ +import React, { useState } from 'react' +import ConfirmationDialog from '../ConfirmationDialog' +import { SynapseComponents } from '../..' +import { Box } from '@mui/material' +import DynamicForm, { DynamicFormProps } from '.' + +type ModalProps = { + submitButtonText?: string +} + +export type DynamicFormModalProps = DynamicFormProps & ModalProps + +const DynamicFormModal = ({ + schemaUrl, + uiSchemaUrl, + postUrl, + submitButtonText, +}: DynamicFormModalProps) => { + const [open, setOpen] = useState(false) + + const handleClickOpen = () => { + setOpen(true) + } + + const handleClose = () => { + setOpen(false) + } + + const form = ( + { + handleClose() + }} + /> + ) + + return ( +
+ + + {submitButtonText} + + {}} + confirmButtonProps={{ + sx: { display: 'none' }, + }} + cancelButtonProps={{ + children: 'cancel', + }} + /> + +
+ ) +} + +export default DynamicFormModal diff --git a/packages/synapse-react-client/src/components/DynamicForm/index.ts b/packages/synapse-react-client/src/components/DynamicForm/index.ts index 771db05a17..43e6d502dd 100644 --- a/packages/synapse-react-client/src/components/DynamicForm/index.ts +++ b/packages/synapse-react-client/src/components/DynamicForm/index.ts @@ -1,4 +1,11 @@ import DynamicForm from './DynamicForm' +import DynamicFormModal from './DynamicFormModal' import type { DynamicFormProps } from './DynamicForm' -export { DynamicForm, DynamicFormProps } +import type { DynamicFormModalProps } from './DynamicFormModal' +export { + DynamicForm, + DynamicFormModal, + DynamicFormProps, + DynamicFormModalProps, +} export default DynamicForm