Skip to content

Commit

Permalink
fix: make eslint happy
Browse files Browse the repository at this point in the history
  • Loading branch information
martastain committed Apr 1, 2024
1 parent f7a8fec commit f4aff5e
Show file tree
Hide file tree
Showing 10 changed files with 64 additions and 40 deletions.
1 change: 1 addition & 0 deletions frontend/src/components/Button.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,7 @@ const Button = forwardRef(
}
)

Button.displayName = 'Button'
Button.defaultProps = {
iconOnRight: false,
//component: 'button',
Expand Down
3 changes: 1 addition & 2 deletions frontend/src/components/Dropdown.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -64,14 +64,13 @@ const DropdownOption = ({
currentValue,
separator,
disabled,
active,
...props
}) => (
<span>
{separator && <hr />}
<Button
{...props}
disabled={props.disabled || currentValue === props.value}
disabled={disabled || currentValue === props.value}
/>
</span>
)
Expand Down
3 changes: 1 addition & 2 deletions frontend/src/components/InputDatetime.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,11 @@ import Dialog from './Dialog'
import BaseInput from './BaseInput'
import Button from './Button'

//import "react-datepicker/dist/react-datepicker.css"

import './datepicker.sass'

const timeRegex = /^(\d{4})-(\d{2})-(\d{2}) (\d{2}):(\d{2}):(\d{2})$/
const dateRegex = /^(\d{4})-(\d{2})-(\d{2})$/
//eslint-disable-next-line
const allowedDateCharsRegex = /^[\d-\:\ ]*$/

const DateTimeWrapper = styled.div`
Expand Down
1 change: 1 addition & 0 deletions frontend/src/components/InputPassword.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -15,5 +15,6 @@ const InputPassword = forwardRef(
)
}
)
InputPassword.displayName = 'InputPassword'

export default InputPassword
1 change: 1 addition & 0 deletions frontend/src/components/InputText.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,5 +13,6 @@ const InputText = forwardRef(({ value, onChange, tooltip, ...props }, ref) => {
/>
)
})
InputText.displayName = 'InputText'

export default InputText
2 changes: 1 addition & 1 deletion frontend/src/components/Video.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ const Video = ({ src, style, showMarks, marks = {}, setMarks = () => {} }) => {
const [videoPosition, setVideoPosition] = useState(0)
const [videoDuration, setVideoDuration] = useState(0)
const [trackbarPosition, setTrackbarPosition] = useState(0)
const [maximize, setMaximize] = useState(false)
//const [maximize, setMaximize] = useState(false)

const frameRate = 25

Expand Down
2 changes: 2 additions & 0 deletions frontend/src/containers/Browser/Browser.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,9 @@ const BrowserTable = () => {
}

useEffect(() => {
// eslint-disable-next-line no-undef
const token = PubSub.subscribe('objects_changed', handlePubSub)
// eslint-disable-next-line no-undef
return () => PubSub.unsubscribe(token)
}, [])

Expand Down
87 changes: 52 additions & 35 deletions frontend/src/containers/Browser/Formatting.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -47,19 +47,67 @@ const getColumnWidth = (key) => {

// Field formatters


const getDefaultFormatter = (key) => {
const metaType = nebula.metaType(key)
switch (metaType.type) {
case 'boolean':
// eslint-disable-next-line
return (rowData, key) => <td>{rowData[key] ? '✓' : ''}</td>

case 'datetime':
// eslint-disable-next-line
return (rowData, key) => (
<td>
<Timestamp timestamp={rowData[key]} mode={metaType.mode} />{' '}
</td>
)

case 'select':
// eslint-disable-next-line
return (rowData, key) => {
if (!metaType.cs) return <td>{rowData[key]}</td>

const option = nebula
.csOptions(metaType.cs)
.find((opt) => opt.value === rowData[key])

return <td>{option?.title}</td>
}

case 'list':
// eslint-disable-next-line
return (rowData, key) => {
if (!metaType.cs) return <td>{rowData[key].join(', ')}</td>
const options = nebula
.csOptions(metaType.cs)
.filter((opt) => rowData[key].includes(opt.value))
return <td>{options.map((opt) => opt.title).join(', ')}</td>
}

default:
// eslint-disable-next-line
return (rowData, key) => <td>{rowData[key]}</td>
} // switch metaType
}


const getFormatter = (key) => {
if (['title', 'subtitle', 'description'].includes(key))
// eslint-disable-next-line
return (rowData, key) => <td>{rowData[key]}</td>

switch (key) {
case 'qc/state':
// eslint-disable-next-line
return (rowData, key) => (
<td>
<QCState className={`qc-state-${rowData[key]}`} />
</td>
)

case 'id_folder':
// eslint-disable-next-line
return (rowData, key) => {
const folder = nebula.settings.folders.find(
(f) => f.id === rowData[key]
Expand All @@ -68,6 +116,7 @@ const getFormatter = (key) => {
}

case 'duration':
// eslint-disable-next-line
return (rowData, key) => {
const fps = rowData['video/fps_f'] || 25
const duration = rowData[key] || 0
Expand All @@ -76,51 +125,19 @@ const getFormatter = (key) => {
}

case 'created_by':
// eslint-disable-next-line
return (rowData, key) => {
return <td>{nebula.getUserName(rowData[key])}</td>
}

case 'updated_by':
// eslint-disable-next-line
return (rowData, key) => {
return <td>{nebula.getUserName(rowData[key])}</td>
}

default:
const metaType = nebula.metaType(key)
switch (metaType.type) {
case 'boolean':
return (rowData, key) => <td>{rowData[key] ? '✓' : ''}</td>

case 'datetime':
return (rowData, key) => (
<td>
<Timestamp timestamp={rowData[key]} mode={metaType.mode} />{' '}
</td>
)

case 'select':
return (rowData, key) => {
if (!metaType.cs) return <td>{rowData[key]}</td>

const option = nebula
.csOptions(metaType.cs)
.find((opt) => opt.value === rowData[key])

return <td>{option?.title}</td>
}

case 'list':
return (rowData, key) => {
if (!metaType.cs) return <td>{rowData[key].join(', ')}</td>
const options = nebula
.csOptions(metaType.cs)
.filter((opt) => rowData[key].includes(opt.value))
return <td>{options.map((opt) => opt.title).join(', ')}</td>
}

default:
return (rowData, key) => <td>{rowData[key]}</td>
} // switch metaType
return getDefaultFormatter(key)
} // end switch key
} // end getFormatter

Expand Down
1 change: 1 addition & 0 deletions frontend/src/hooks.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ const useConfirm = () => {
const [message, setMessage] = useState('')

const confirm = (title, message) =>
// eslint-disable-next-line
new Promise((resolve, reject) => {
setTitle(title)
setMessage(message)
Expand Down
3 changes: 3 additions & 0 deletions frontend/src/pages/JobsPage/JobsPage.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ const JobsPage = () => {
nebula.request('jobs', { abort: id }).then(() => loadJobs())
}

// eslint-disable-next-line
const formatAction = (rowData, key) => {
if ([0, 1, 5].includes(rowData['status']))
return (
Expand Down Expand Up @@ -168,7 +169,9 @@ const JobsPage = () => {
} // handlePubSub

useEffect(() => {
// eslint-disable-next-line no-undef
const token = PubSub.subscribe('job_progress', handlePubSub)
// eslint-disable-next-line no-undef
return () => PubSub.unsubscribe(token)
}, [])

Expand Down

0 comments on commit f4aff5e

Please sign in to comment.