Commit 6cfd7273 authored by Mohammad Nakhaee's avatar Mohammad Nakhaee
Browse files

Use dataFetch callback. And display the warning in front of the newUploadButton

parent ac03f271
Pipeline #113115 passed with stages
in 27 minutes and 42 seconds
......@@ -15,7 +15,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import React, {useEffect, useState} from 'react'
import React, {useCallback, useEffect, useState} from 'react'
import PropTypes from 'prop-types'
import Markdown from '../Markdown'
import {
......@@ -243,7 +243,7 @@ function UploadsPage() {
order_by: 'upload_create_time'
})
const handleReload = () => {
const fetchData = useCallback(() => {
const {page_size, page} = pagination
api.get(`/uploads?page_size=${page_size}&page=${page}`)
.then(setData)
......@@ -251,23 +251,18 @@ function UploadsPage() {
api.get(`/uploads?is_published=false&page_size=0`)
.then(setUnpublished)
.catch(errors.raiseError)
}, [pagination, setData, setUnpublished, errors, api])
const handleReload = () => {
fetchData()
}
useEffect(() => {
api.get(`/uploads?is_published=false&page_size=0`)
.then(setUnpublished)
.catch(errors.raiseError)
}, [setData, errors, api])
fetchData()
}, [fetchData])
const isDisable = unpublished ? (unpublished.pagination ? unpublished.pagination.total >= servicesUploadLimit : true) : true
useEffect(() => {
const {page_size, page} = pagination
api.get(`/uploads?page_size=${page_size}&page=${page}`)
.then(setData)
.catch(errors.raiseError)
}, [pagination, setData, errors, api])
useEffect(() => {
api.get('/uploads/command-examples')
.then(setUploadCommands)
......@@ -281,7 +276,14 @@ function UploadsPage() {
You can create an upload and upload files through this browser-based interface:
</Typography>
</Box>
<NewUploadButton color="primary" isDisable={isDisable}/>
<Box>
<NewUploadButton color="primary" isDisable={isDisable}/>
<Box display="inline-block" marginLeft={2}>
<Typography hidden={!isDisable} color="error">
You have reached maximum number of unpublished uploads!
</Typography>
</Box>
</Box>
<Box marginTop={4}>
<Typography>
Or, you can create an upload by sending a file-archive via shell command:
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment