Make custom INI file required

This commit is contained in:
Piotr Rogowski 2022-11-02 20:44:35 +01:00
parent f3fb37eb8d
commit 84312052d5
No known key found for this signature in database
GPG Key ID: 4A842D702D9C6F8F
1 changed files with 19 additions and 1 deletions

View File

@ -138,6 +138,7 @@ const UploadPage = () => {
const [logsTouched, setLogsTouched] = useState(false);
const [toothLogsTouched, setToothLogsTouched] = useState(false);
const [customIniRequired, setCustomIniRequired] = useState(false);
const shareSupported = 'share' in navigator;
const { currentUser, refreshUser } = useAuth();
@ -336,9 +337,17 @@ const UploadPage = () => {
try {
await fetchINIFile(signature);
} catch (e) {
setCustomIniRequired(true);
signatureNotSupportedWarning((e as Error).message);
return {
result: true,
message: '',
};
}
setCustomIniRequired(false);
return {
result: true,
message: '',
@ -560,6 +569,14 @@ const UploadPage = () => {
</Space>
);
const publishButtonText = () => {
if (customIniRequired) {
return 'Custom INI file required!';
}
return isEditMode ? 'Update' : 'Publish';
};
const publishButton = (
<Row style={{ marginTop: 10 }} {...rowProps}>
<Col {...colProps}>
@ -582,8 +599,9 @@ const UploadPage = () => {
loading={isLoading}
htmlType="submit"
icon={isEditMode ? <EditOutlined /> : <CheckOutlined />}
disabled={customIniRequired}
>
{isEditMode ? 'Update' : 'Publish'}
{publishButtonText()}
</Button>
</Item>
</Col>