2020-02-29 20:01:09 -05:00
|
|
|
import React from 'react'
|
|
|
|
|
import {
|
|
|
|
|
TextInput,
|
|
|
|
|
SelectInput,
|
|
|
|
|
Create,
|
|
|
|
|
required,
|
|
|
|
|
SimpleForm,
|
2020-04-27 23:22:17 -04:00
|
|
|
useTranslate,
|
2020-02-29 20:01:09 -05:00
|
|
|
} from 'react-admin'
|
|
|
|
|
import { Title } from '../common'
|
fix(ui): allow setting a transcoding Default Bit Rate of 0
The Default Bit Rate dropdown on the Transcoding create/edit forms was fed
BITRATE_CHOICES, which starts at 32. There was no way to pick 0, and the
SelectInput was not resettable, so an admin could neither create nor restore a
transcoding with no default bit rate, such as the default FLAC one (seeded with
0 in consts.DefaultTranscodings). Editing that row also rendered a blank
dropdown, since its stored value matched no choice.
Adds TRANSCODING_BITRATE_CHOICES, which prepends a 0 entry labelled 'None' to
the shared list. The forms use it as SelectInput choices, and the list and
read-only show view render it through SelectField, so all four screens resolve
the label from the same array and cannot drift. The shared BITRATE_CHOICES is
left untouched, because 0 is not a meaningful option for the player Max. Bit
Rate or the share dialog.
Reported in discussion #6107, where a user had deleted the default
transcodings and could not recreate the FLAC one.
2026-09-09 16:09:58 -04:00
|
|
|
import { TRANSCODING_BITRATE_CHOICES } from '../consts'
|
2020-02-29 20:01:09 -05:00
|
|
|
|
2020-04-27 23:22:17 -04:00
|
|
|
const TranscodingTitle = () => {
|
|
|
|
|
const translate = useTranslate()
|
|
|
|
|
const resourceName = translate('resources.transcoding.name', {
|
|
|
|
|
smart_count: 1,
|
|
|
|
|
})
|
|
|
|
|
const title = translate('ra.page.create', {
|
|
|
|
|
name: `${resourceName}`,
|
|
|
|
|
})
|
|
|
|
|
return <Title subTitle={title} />
|
2020-02-29 20:01:09 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
const TranscodingCreate = (props) => (
|
|
|
|
|
<Create title={<TranscodingTitle />} {...props}>
|
2023-01-24 20:58:20 -05:00
|
|
|
<SimpleForm redirect="list" variant={'outlined'}>
|
2020-02-29 20:01:09 -05:00
|
|
|
<TextInput source="name" validate={[required()]} />
|
|
|
|
|
<TextInput source="targetFormat" validate={[required()]} />
|
|
|
|
|
<SelectInput
|
|
|
|
|
source="defaultBitRate"
|
fix(ui): allow setting a transcoding Default Bit Rate of 0
The Default Bit Rate dropdown on the Transcoding create/edit forms was fed
BITRATE_CHOICES, which starts at 32. There was no way to pick 0, and the
SelectInput was not resettable, so an admin could neither create nor restore a
transcoding with no default bit rate, such as the default FLAC one (seeded with
0 in consts.DefaultTranscodings). Editing that row also rendered a blank
dropdown, since its stored value matched no choice.
Adds TRANSCODING_BITRATE_CHOICES, which prepends a 0 entry labelled 'None' to
the shared list. The forms use it as SelectInput choices, and the list and
read-only show view render it through SelectField, so all four screens resolve
the label from the same array and cannot drift. The shared BITRATE_CHOICES is
left untouched, because 0 is not a meaningful option for the player Max. Bit
Rate or the share dialog.
Reported in discussion #6107, where a user had deleted the default
transcodings and could not recreate the FLAC one.
2026-09-09 16:09:58 -04:00
|
|
|
choices={TRANSCODING_BITRATE_CHOICES}
|
2020-04-03 21:03:34 -04:00
|
|
|
defaultValue={192}
|
2020-02-29 20:01:09 -05:00
|
|
|
/>
|
|
|
|
|
<TextInput
|
|
|
|
|
source="command"
|
|
|
|
|
fullWidth
|
|
|
|
|
validate={[required()]}
|
|
|
|
|
helperText={
|
|
|
|
|
<span>
|
|
|
|
|
Substitutions: <br />
|
|
|
|
|
%s: File path <br />
|
|
|
|
|
%b: BitRate (in kbps)
|
|
|
|
|
<br />
|
|
|
|
|
</span>
|
|
|
|
|
}
|
|
|
|
|
/>
|
|
|
|
|
</SimpleForm>
|
|
|
|
|
</Create>
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
export default TranscodingCreate
|