revise Storage forms, and add basic validation to it; misc field cleanup
This commit is contained in:
@@ -184,3 +184,69 @@ export const DEFAULT_SOCIAL_HANDLE: SocialHandle = {
|
||||
};
|
||||
|
||||
export const OTHER_SOCIAL_HANDLE_OPTION = 'OTHER_SOCIAL_HANDLE_OPTION';
|
||||
|
||||
|
||||
export const TEXTFIELD_PROPS_S3_COMMON = {
|
||||
maxLength: 255,
|
||||
}
|
||||
|
||||
|
||||
// export const FIELD_PROPS_CUSTOM_CONTENT = {
|
||||
// apiPath: API_CUSTOM_CONTENT,
|
||||
// configPath: 'instanceDetails',
|
||||
// placeholder: '',
|
||||
// label: 'Extra page content',
|
||||
// tip: 'Custom markup about yourself',
|
||||
// };
|
||||
|
||||
export const S3_TEXT_FIELDS_INFO = {
|
||||
accessKey: {
|
||||
fieldName: 'accessKey',
|
||||
label: 'Access Key',
|
||||
maxLength: 255,
|
||||
placeholder: 'access key 123',
|
||||
tip: '',
|
||||
},
|
||||
acl: {
|
||||
fieldName: 'acl',
|
||||
label: 'ACL',
|
||||
maxLength: 255,
|
||||
placeholder: 'acl thing',
|
||||
tip: '',
|
||||
},
|
||||
bucket: {
|
||||
fieldName: 'bucket',
|
||||
label: 'Bucket',
|
||||
maxLength: 255,
|
||||
placeholder: 'bucket 123',
|
||||
tip: '',
|
||||
},
|
||||
endpoint: {
|
||||
fieldName: 'endpoint',
|
||||
label: 'Endpoint',
|
||||
maxLength: 255,
|
||||
placeholder: 'endpoint 123',
|
||||
tip: 'This field has a some info',
|
||||
},
|
||||
region: {
|
||||
fieldName: 'region',
|
||||
label: 'Region',
|
||||
maxLength: 255,
|
||||
placeholder: 'region 123',
|
||||
tip: '',
|
||||
},
|
||||
secret: {
|
||||
fieldName: 'secret',
|
||||
label: 'Secret key',
|
||||
maxLength: 255,
|
||||
placeholder: 'secret key 123',
|
||||
tip: '',
|
||||
},
|
||||
servingEndpoint: {
|
||||
fieldName: 'servingEndpoint',
|
||||
label: 'Serving Endpoint',
|
||||
maxLength: 255,
|
||||
placeholder: 'servingEndpoint 123',
|
||||
tip: '',
|
||||
},
|
||||
};
|
||||
|
||||
@@ -63,50 +63,48 @@ export default function EditInstanceDetails() {
|
||||
}
|
||||
|
||||
return (
|
||||
<div className={`publicDetailsContainer`}>
|
||||
<div className={`textFieldsSection`}>
|
||||
<TextFieldWithSubmit
|
||||
fieldName="streamKey"
|
||||
{...TEXTFIELD_PROPS_STREAM_KEY}
|
||||
value={formDataValues.streamKey}
|
||||
initialValue={streamKey}
|
||||
type={TEXTFIELD_TYPE_PASSWORD}
|
||||
onChange={handleFieldChange}
|
||||
/>
|
||||
<div>
|
||||
<span style={{ fontSize: '0.75em', color: '#ff7777', marginRight: '0.5em' }}>
|
||||
Save this key somewhere safe, you will need it to stream or login to the admin
|
||||
dashboard!
|
||||
</span>
|
||||
<Tooltip className="copy-tooltip" title="Copied!" trigger="" visible={copyIsVisible}>
|
||||
<Button type="primary" icon={<CopyOutlined />} size="small" onClick={copyStreamKey} />
|
||||
</Tooltip>
|
||||
<Button type="primary" icon={<RedoOutlined />} size="small" onClick={generateStreamKey} />
|
||||
</div>
|
||||
<TextFieldWithSubmit
|
||||
fieldName="ffmpegPath"
|
||||
{...TEXTFIELD_PROPS_FFMPEG}
|
||||
value={formDataValues.ffmpegPath}
|
||||
initialValue={ffmpegPath}
|
||||
onChange={handleFieldChange}
|
||||
/>
|
||||
<TextFieldWithSubmit
|
||||
fieldName="webServerPort"
|
||||
{...TEXTFIELD_PROPS_WEB_PORT}
|
||||
value={formDataValues.webServerPort}
|
||||
initialValue={webServerPort}
|
||||
type={TEXTFIELD_TYPE_NUMBER}
|
||||
onChange={handleFieldChange}
|
||||
/>
|
||||
<TextFieldWithSubmit
|
||||
fieldName="rtmpServerPort"
|
||||
{...TEXTFIELD_PROPS_RTMP_PORT}
|
||||
value={formDataValues.rtmpServerPort}
|
||||
initialValue={rtmpServerPort}
|
||||
type={TEXTFIELD_TYPE_NUMBER}
|
||||
onChange={handleFieldChange}
|
||||
/>
|
||||
<div className="edit-public-details-container">
|
||||
<TextFieldWithSubmit
|
||||
fieldName="streamKey"
|
||||
{...TEXTFIELD_PROPS_STREAM_KEY}
|
||||
value={formDataValues.streamKey}
|
||||
initialValue={streamKey}
|
||||
type={TEXTFIELD_TYPE_PASSWORD}
|
||||
onChange={handleFieldChange}
|
||||
/>
|
||||
<div>
|
||||
<span style={{ fontSize: '0.75em', color: '#ff7777', marginRight: '0.5em' }}>
|
||||
Save this key somewhere safe, you will need it to stream or login to the admin
|
||||
dashboard!
|
||||
</span>
|
||||
<Tooltip className="copy-tooltip" title="Copied!" trigger="" visible={copyIsVisible}>
|
||||
<Button type="primary" icon={<CopyOutlined />} size="small" onClick={copyStreamKey} />
|
||||
</Tooltip>
|
||||
<Button type="primary" icon={<RedoOutlined />} size="small" onClick={generateStreamKey} />
|
||||
</div>
|
||||
<TextFieldWithSubmit
|
||||
fieldName="ffmpegPath"
|
||||
{...TEXTFIELD_PROPS_FFMPEG}
|
||||
value={formDataValues.ffmpegPath}
|
||||
initialValue={ffmpegPath}
|
||||
onChange={handleFieldChange}
|
||||
/>
|
||||
<TextFieldWithSubmit
|
||||
fieldName="webServerPort"
|
||||
{...TEXTFIELD_PROPS_WEB_PORT}
|
||||
value={formDataValues.webServerPort}
|
||||
initialValue={webServerPort}
|
||||
type={TEXTFIELD_TYPE_NUMBER}
|
||||
onChange={handleFieldChange}
|
||||
/>
|
||||
<TextFieldWithSubmit
|
||||
fieldName="rtmpServerPort"
|
||||
{...TEXTFIELD_PROPS_RTMP_PORT}
|
||||
value={formDataValues.rtmpServerPort}
|
||||
initialValue={rtmpServerPort}
|
||||
type={TEXTFIELD_TYPE_NUMBER}
|
||||
onChange={handleFieldChange}
|
||||
/>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
@@ -19,7 +19,7 @@ const { Title } = Typography;
|
||||
|
||||
export default function EditInstanceTags() {
|
||||
const [newTagInput, setNewTagInput] = useState<string | number>('');
|
||||
const [fieldStatus, setFieldStatus] = useState<StatusState>(null);
|
||||
const [submitStatus, setSubmitStatus] = useState<StatusState>(null);
|
||||
|
||||
const serverStatusData = useContext(ServerStatusContext);
|
||||
const { serverConfig, setFieldInConfigState } = serverStatusData || {};
|
||||
@@ -38,34 +38,34 @@ export default function EditInstanceTags() {
|
||||
}, []);
|
||||
|
||||
const resetStates = () => {
|
||||
setFieldStatus(null);
|
||||
setSubmitStatus(null);
|
||||
resetTimer = null;
|
||||
clearTimeout(resetTimer);
|
||||
};
|
||||
|
||||
// posts all the tags at once as an array obj
|
||||
const postUpdateToAPI = async (postValue: any) => {
|
||||
setFieldStatus(createInputStatus(STATUS_PROCESSING));
|
||||
setSubmitStatus(createInputStatus(STATUS_PROCESSING));
|
||||
|
||||
await postConfigUpdateToAPI({
|
||||
apiPath,
|
||||
data: { value: postValue },
|
||||
onSuccess: () => {
|
||||
setFieldInConfigState({ fieldName: 'tags', value: postValue, path: configPath });
|
||||
setFieldStatus(createInputStatus(STATUS_SUCCESS, 'Tags updated.'));
|
||||
setSubmitStatus(createInputStatus(STATUS_SUCCESS, 'Tags updated.'));
|
||||
setNewTagInput('');
|
||||
resetTimer = setTimeout(resetStates, RESET_TIMEOUT);
|
||||
},
|
||||
onError: (message: string) => {
|
||||
setFieldStatus(createInputStatus(STATUS_ERROR, message));
|
||||
setSubmitStatus(createInputStatus(STATUS_ERROR, message));
|
||||
resetTimer = setTimeout(resetStates, RESET_TIMEOUT);
|
||||
},
|
||||
});
|
||||
};
|
||||
|
||||
const handleInputChange = ({ value }: UpdateArgs) => {
|
||||
if (!fieldStatus) {
|
||||
setFieldStatus(null);
|
||||
if (!submitStatus) {
|
||||
setSubmitStatus(null);
|
||||
}
|
||||
setNewTagInput(value);
|
||||
};
|
||||
@@ -75,11 +75,11 @@ export default function EditInstanceTags() {
|
||||
resetStates();
|
||||
const newTag = newTagInput.trim();
|
||||
if (newTag === '') {
|
||||
setFieldStatus(createInputStatus(STATUS_WARNING, 'Please enter a tag'));
|
||||
setSubmitStatus(createInputStatus(STATUS_WARNING, 'Please enter a tag'));
|
||||
return;
|
||||
}
|
||||
if (tags.some(tag => tag.toLowerCase() === newTag.toLowerCase())) {
|
||||
setFieldStatus(createInputStatus(STATUS_WARNING, 'This tag is already used!'));
|
||||
setSubmitStatus(createInputStatus(STATUS_WARNING, 'This tag is already used!'));
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -121,7 +121,7 @@ export default function EditInstanceTags() {
|
||||
onPressEnter={handleSubmitNewTag}
|
||||
maxLength={maxLength}
|
||||
placeholder={placeholder}
|
||||
status={fieldStatus}
|
||||
status={submitStatus}
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
Reference in New Issue
Block a user