Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed source UI #22

Closed
wants to merge 1 commit into from
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
13 changes: 12 additions & 1 deletion frontend/components/software/add/AddSoftwareCard.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@ import {useEffect, useState} from 'react'
import {useRouter} from 'next/router'
import Button from '@mui/material/Button'
import Alert from '@mui/material/Alert'
import FormControlLabel from '@mui/material/FormControlLabel'
import Switch from '@mui/material/Switch'
import CircularProgress from '@mui/material/CircularProgress'

import {useForm} from 'react-hook-form'
Expand All @@ -35,6 +37,7 @@ type AddSoftwareForm = {
slug: string,
brand_name: string,
short_statement: string|null,
closed_source: boolean
}

let lastValidatedSlug = ''
Expand All @@ -52,7 +55,7 @@ export default function AddSoftwareCard() {
})
const {errors, isValid} = formState
// watch for data change in the form
const [slug,brand_name,short_statement] = watch(['slug', 'brand_name', 'short_statement'])
const [slug,brand_name,short_statement,closed_source] = watch(['slug', 'brand_name', 'short_statement', 'closed_source'])
// take the last slugValue
const bouncedSlug = useDebounce(slugValue, 700)

Expand Down Expand Up @@ -142,6 +145,7 @@ export default function AddSoftwareCard() {
brand_name: data.brand_name,
slug: data.slug,
short_statement: data.short_statement,
closed_source: data.closed_source,
is_published: false,
description: null,
description_type: 'markdown',
Expand Down Expand Up @@ -252,6 +256,13 @@ export default function AddSoftwareCard() {
}}
register={register('slug',config.slug.validation)}
/>
<div className="py-4"></div>
<FormControlLabel
control={
<Switch {...register('closed_source')} />
}
label="Closed Source"
/>
</section>
<section className='flex justify-end'>
<Button
Expand Down
4 changes: 4 additions & 0 deletions frontend/components/software/add/addConfig.ts
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,10 @@ export const addConfig = {
message: 'Restricted input violiation. Use letters, numbers and dashes "-" only between other input.'
}
}
},
closed_source: {
label: 'Closed source',
validation: {}
}
}

3 changes: 3 additions & 0 deletions frontend/components/software/edit/editSoftwareConfig.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,9 @@ export const softwareInformation = {
is_published: {
label: 'Published',
},
closed_source: {
label: 'Closed Source'
},
keywords: {
title: 'Keywords',
subtitle: 'Find, add or import using concept DOI.',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ import AutosaveRepositoryUrl from './AutosaveRepositoryUrl'
import AutosaveSoftwareLicenses from './AutosaveSoftwareLicenses'
import AutosaveSoftwareMarkdown from './AutosaveSoftwareMarkdown'
import AutosaveSoftwareLogo from './AutosaveSoftwareLogo'
import AutosaveSoftwareSwitch from './AutosaveSoftwareSwitch'

type SoftwareInformationFormProviderProps = {
editSoftware: EditSoftwareItem
Expand Down Expand Up @@ -110,6 +111,12 @@ export default function SoftwareInformationForm({editSoftware}: SoftwareInformat
rules={config.short_statement.validation}
/>
<div className="py-2"></div>
<AutosaveSoftwareSwitch
software_id={formData.id}
name='closed_source'
label={config.closed_source.label}
defaultValue={editSoftware.closed_source}
/>
<EditSectionTitle
title='Software URLs'
subtitle='Where can users find information to start?'
Expand Down
2 changes: 2 additions & 0 deletions frontend/types/SoftwareTypes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ export type NewSoftwareItem = {
description_url: string | null,
description_type: 'markdown'|'link',
get_started_url: string | null,
closed_source: boolean,
is_published: boolean,
short_statement: string | null,
image_id: string | null,
Expand Down Expand Up @@ -98,6 +99,7 @@ export const SoftwarePropsToSave = [
'description_url',
'get_started_url',
'image_id',
'closed_source',
'is_published',
'short_statement'
]
Expand Down