mirror of
https://github.com/oceanprotocol/market.git
synced 2024-12-02 05:57:29 +01:00
Display generic info message for file inputs (#1334)
* display generic message * add helper message * bold text in json, remove unused css file * fixes * different help message displayed as tooltip * tooltip help not displayed for files/links fields on publish * conditionally hide/show tooltip * use same mechanism for edit form * add prominentHelp file into content pages * type fix * remove unused code * error message position fix * error doesn't overlap help message * show validation error message fix Co-authored-by: ClaudiaHolhos <claudia@oceanprotocol.com>
This commit is contained in:
parent
6ef2082724
commit
97744820ac
@ -33,7 +33,8 @@
|
|||||||
"name": "links",
|
"name": "links",
|
||||||
"label": "Sample file",
|
"label": "Sample file",
|
||||||
"placeholder": "e.g. https://file.com/samplefile.json",
|
"placeholder": "e.g. https://file.com/samplefile.json",
|
||||||
"help": "Please provide a URL to a sample of your data set file. This file should reveal the data structure of your data set, e.g. by including the header and one line of a CSV file. This file URL will be publicly available after publishing.",
|
"help": "Please provide a URL to a sample of your data set file. This file should reveal the data structure of your data set, e.g. by including the header and one line of a CSV file. This file URL will be publicly available after publishing. **Please make sure that the endpoint is accessible over the internet and is not protected by a firewall or by credentials.**",
|
||||||
|
"prominentHelp": true,
|
||||||
"type": "files"
|
"type": "files"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
|
@ -104,7 +104,8 @@
|
|||||||
"name": "files",
|
"name": "files",
|
||||||
"label": "File",
|
"label": "File",
|
||||||
"placeholder": "e.g. https://file.com/file.json",
|
"placeholder": "e.g. https://file.com/file.json",
|
||||||
"help": "Please enter the URL to your data set file and click \"ADD FILE\" to validate the data. This URL will be stored encrypted after publishing. For a compute data set, your file should match the file type required by the algorithm, and should not exceed 1 GB in file size.",
|
"help": "This URL will be stored encrypted after publishing. **Please make sure that the endpoint is accessible over the internet and is not protected by a firewall or by credentials.** For a compute data set, your file should match the file type required by the algorithm, and should not exceed 1 GB in file size. ",
|
||||||
|
"prominentHelp": true,
|
||||||
"type": "files",
|
"type": "files",
|
||||||
"required": true
|
"required": true
|
||||||
},
|
},
|
||||||
@ -112,7 +113,8 @@
|
|||||||
"name": "links",
|
"name": "links",
|
||||||
"label": "Sample file",
|
"label": "Sample file",
|
||||||
"placeholder": "e.g. https://file.com/samplefile.json",
|
"placeholder": "e.g. https://file.com/samplefile.json",
|
||||||
"help": "Please enter the URL to a sample of your data set file and click \"ADD FILE\" to validate the data. This file should reveal the data structure of your data set, e.g. by including the header and one line of a CSV file. This file URL will be publicly available after publishing.",
|
"help": "This file should reveal the data structure of your data set, e.g. by including the header and one line of a CSV file. This file URL will be publicly available after publishing. **Please make sure that the endpoint is accessible over the internet and is not protected by a firewall or by credentials.**",
|
||||||
|
"prominentHelp": true,
|
||||||
"type": "files"
|
"type": "files"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
|
@ -3,7 +3,6 @@ import { prettySize } from './utils'
|
|||||||
import cleanupContentType from '@utils/cleanupContentType'
|
import cleanupContentType from '@utils/cleanupContentType'
|
||||||
import styles from './Info.module.css'
|
import styles from './Info.module.css'
|
||||||
import { FileMetadata } from '@oceanprotocol/lib'
|
import { FileMetadata } from '@oceanprotocol/lib'
|
||||||
import Alert from '@shared/atoms/Alert'
|
|
||||||
|
|
||||||
export default function FileInfo({
|
export default function FileInfo({
|
||||||
file,
|
file,
|
||||||
@ -16,11 +15,6 @@ export default function FileInfo({
|
|||||||
? cleanupContentType(file.contentType)
|
? cleanupContentType(file.contentType)
|
||||||
: null
|
: null
|
||||||
|
|
||||||
// Prevent accidential publishing of error pages (e.g. 404) for
|
|
||||||
// popular file hosting services by warning about it.
|
|
||||||
// See https://github.com/oceanprotocol/market/issues/1246
|
|
||||||
const shouldWarnAboutFile = file.valid && contentTypeCleaned === 'html'
|
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div className={styles.info}>
|
<div className={styles.info}>
|
||||||
<h3 className={styles.url}>{file.url}</h3>
|
<h3 className={styles.url}>{file.url}</h3>
|
||||||
@ -29,13 +23,6 @@ export default function FileInfo({
|
|||||||
{file.contentLength && <li>{prettySize(+file.contentLength)}</li>}
|
{file.contentLength && <li>{prettySize(+file.contentLength)}</li>}
|
||||||
{contentTypeCleaned && <li>{contentTypeCleaned}</li>}
|
{contentTypeCleaned && <li>{contentTypeCleaned}</li>}
|
||||||
</ul>
|
</ul>
|
||||||
{shouldWarnAboutFile && (
|
|
||||||
<Alert
|
|
||||||
state="info"
|
|
||||||
text={`Your file was detected as ${contentTypeCleaned}, which is unusal for a data asset. If you did not intend to use a ${contentTypeCleaned} file, try a different URL pointing directly to your data asset file.`}
|
|
||||||
className={styles.warning}
|
|
||||||
/>
|
|
||||||
)}
|
|
||||||
<button className={styles.removeButton} onClick={handleClose}>
|
<button className={styles.removeButton} onClick={handleClose}>
|
||||||
×
|
×
|
||||||
</button>
|
</button>
|
||||||
|
@ -42,6 +42,7 @@ export default function InputElement({
|
|||||||
multiple,
|
multiple,
|
||||||
disabled,
|
disabled,
|
||||||
help,
|
help,
|
||||||
|
prominentHelp,
|
||||||
form,
|
form,
|
||||||
additionalComponent,
|
additionalComponent,
|
||||||
disclaimer,
|
disclaimer,
|
||||||
|
@ -30,7 +30,6 @@
|
|||||||
padding: 0.2rem 0.4rem;
|
padding: 0.2rem 0.4rem;
|
||||||
position: absolute;
|
position: absolute;
|
||||||
right: 0;
|
right: 0;
|
||||||
top: 85%;
|
|
||||||
z-index: 1;
|
z-index: 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -15,6 +15,7 @@ import classNames from 'classnames/bind'
|
|||||||
import Disclaimer from './Disclaimer'
|
import Disclaimer from './Disclaimer'
|
||||||
import Tooltip from '@shared/atoms/Tooltip'
|
import Tooltip from '@shared/atoms/Tooltip'
|
||||||
import Markdown from '@shared/Markdown'
|
import Markdown from '@shared/Markdown'
|
||||||
|
import FormHelp from './Help'
|
||||||
|
|
||||||
const cx = classNames.bind(styles)
|
const cx = classNames.bind(styles)
|
||||||
|
|
||||||
@ -24,6 +25,7 @@ export interface InputProps {
|
|||||||
placeholder?: string
|
placeholder?: string
|
||||||
required?: boolean
|
required?: boolean
|
||||||
help?: string
|
help?: string
|
||||||
|
prominentHelp?: boolean
|
||||||
tag?: string
|
tag?: string
|
||||||
type?: string
|
type?: string
|
||||||
options?: string[]
|
options?: string[]
|
||||||
@ -68,6 +70,7 @@ export default function Input(props: Partial<InputProps>): ReactElement {
|
|||||||
const {
|
const {
|
||||||
label,
|
label,
|
||||||
help,
|
help,
|
||||||
|
prominentHelp,
|
||||||
additionalComponent,
|
additionalComponent,
|
||||||
size,
|
size,
|
||||||
form,
|
form,
|
||||||
@ -118,16 +121,17 @@ export default function Input(props: Partial<InputProps>): ReactElement {
|
|||||||
*
|
*
|
||||||
</span>
|
</span>
|
||||||
)}
|
)}
|
||||||
{help && <Tooltip content={<Markdown text={help} />} />}
|
{help && !prominentHelp && (
|
||||||
|
<Tooltip content={<Markdown text={help} />} />
|
||||||
|
)}
|
||||||
</Label>
|
</Label>
|
||||||
<InputElement size={size} {...field} {...props} />
|
<InputElement size={size} {...field} {...props} />
|
||||||
|
{help && prominentHelp && <FormHelp>{help}</FormHelp>}
|
||||||
{isFormikField && hasFormikError && (
|
{isFormikField && hasFormikError && (
|
||||||
<div className={styles.error}>
|
<div className={styles.error}>
|
||||||
<ErrorMessage name={field.name} />
|
<ErrorMessage name={field.name} />
|
||||||
</div>
|
</div>
|
||||||
)}
|
)}
|
||||||
|
|
||||||
{disclaimer && (
|
{disclaimer && (
|
||||||
<Disclaimer visible={disclaimerVisible}>{disclaimer}</Disclaimer>
|
<Disclaimer visible={disclaimerVisible}>{disclaimer}</Disclaimer>
|
||||||
)}
|
)}
|
||||||
|
Loading…
Reference in New Issue
Block a user