From 9d8635ee763bcb2292aa43697e68506d76a2313c Mon Sep 17 00:00:00 2001 From: Gang Li Date: Thu, 7 Dec 2023 10:28:41 +0800 Subject: [PATCH] RemoteEdit: add controle of proxy, auth and x509 input --- .../components/content/remote/RemoteEdit.jsx | 86 ++++++++++--------- 1 file changed, 46 insertions(+), 40 deletions(-) diff --git a/src/main/webui/src/app/components/content/remote/RemoteEdit.jsx b/src/main/webui/src/app/components/content/remote/RemoteEdit.jsx index fa0a66d..aeff95f 100644 --- a/src/main/webui/src/app/components/content/remote/RemoteEdit.jsx +++ b/src/main/webui/src/app/components/content/remote/RemoteEdit.jsx @@ -18,7 +18,7 @@ import React, {useState, useEffect} from 'react'; import {useLocation, useParams} from 'react-router-dom'; import {PropTypes} from 'prop-types'; import {StoreEditControlPanel as EditControlPanel} from '../common/StoreControlPanels.jsx'; -import {DisableTimeoutHint, DurationHint, PrefetchHint, Hint} from '../common/Hints.jsx'; +import {DisableTimeoutHint, DurationHint, Hint} from '../common/Hints.jsx'; import {PackageTypeSelect} from '../common/PackageTypeSelect.jsx'; // import ViewJsonDebugger from './Debugger.jsx'; import {Utils} from '#utils/AppUtils.js'; @@ -31,7 +31,7 @@ const CertificateSection = ({store, handleValueChange}) =>
- handleValueChange(e, "key_password")}/> + handleValueChange(e, "key_password")}/>
}
@@ -44,7 +44,7 @@ const CertificateSection = ({store, handleValueChange}) =>
handleValueChange(e, "key_certificate_pem")}> +
}
@@ -54,7 +54,7 @@ const CertificateSection = ({store, handleValueChange}) =>
handleValueChange(e, "server_certificate_pem")}> +
; @@ -69,8 +69,12 @@ export default function RemoteEdit() { store: {}, storeView: {} }); + const [useProxy, setUseProxy] = useState(false); + const [useAuth, setUseAuth] = useState(false); + const [useX509, setUseX509] = useState(false); const location = useLocation(); const {packageType, name} = useParams(); + const path = location.pathname; const mode = path.match(/.*\/new$/u)? 'new':'edit'; let [pkgType, storeName] = ["",""]; @@ -105,6 +109,9 @@ export default function RemoteEdit() { storeView: cloned, store: raw }); + setUseProxy(storeView.useProxy); + setUseAuth(storeView.useAuth); + setUseX509(storeView.useX509); }else{ // TODO: find another way to do error handling response.text().then(error=>setState({ @@ -131,18 +138,15 @@ export default function RemoteEdit() { const handleValueChange = (event, field) => { store[field] = event.target.value; }; - const handleRadioChange = (event, field) => { - store[field] = event.target.value; - }; const handleUseProxy = event=>{ - // TODO: need to implement + setUseProxy(event.target.checked); }; const handleUseAuth = event => { - // TODO: need to implement + setUseAuth(event.target.checked); }; const handleUseX509 = event => { - // TODO: need to implement + setUseX509(event.target.checked); }; return ( @@ -170,13 +174,15 @@ export default function RemoteEdit() { { mode==='new'? - handleValueChange(e, "name")} />: + + handleValueChange(e, "name")} /> + : {store.name} }
- handleCheckChange(e, "disabled")} />{' '} + handleCheckChange(e, "disabled")}/>{' '} { store.disabled && store.disableExpiration && @@ -184,7 +190,7 @@ export default function RemoteEdit() { }
- handleCheckChange(e, "authoritative_index")} />{' '} + handleCheckChange(e, "authoritative_index")} />{' '} Make the content index authoritative to this repository
@@ -192,53 +198,53 @@ export default function RemoteEdit() {
- handleValueChange(e, "disable_timeout")} /> + handleValueChange(e, "disable_timeout")} />
- + handleValueChange(e, "url")}/>
- handleCheckChange(e, "is_passthrough")} />{' '} + handleCheckChange(e, "is_passthrough")} />{' '}
{!store.is_passthrough &&
- handleValueChange(e, "cache_timeout_seconds")} /> + handleValueChange(e, "cache_timeout_seconds")} />
- handleValueChange(e, "metadata_timeout_seconds")} /> + handleValueChange(e, "metadata_timeout_seconds")} /> {'24h 36m 00s. Negative means never timeout, 0 means using default timeout by Indy settings.'}
}
- -
+ {/* prefetch support has been disabled in new Indy. +
- handleValueChange(e,"prefetch_priority")} size="5"/> + handleValueChange(e,"prefetch_priority")} size="5"/>
- handleCheckChange(e,"prefetch_rescan")} />{' '} + handleCheckChange(e,"prefetch_rescan")} />{' '}
- handleRadioChange(e, "prefetch_listing_type")} value="html"/> html{' '} - handleRadioChange(e, "prefetch_listing_type")} value="koji"/> koji + handleRadioChange(e, "prefetch_listing_type")} defaultValue="html"/> html{' '} + handleRadioChange(e, "prefetch_listing_type")} defaultValue="koji"/> koji
-
+
*/} @@ -250,11 +256,11 @@ export default function RemoteEdit() {
Capabilities
- handleCheckChange(e, "allow_releases")}/>{' '} + handleCheckChange(e, "allow_releases")}/>{' '}
- handleCheckChange(e, "allow_snapshots")}/>{' '} + handleCheckChange(e, "allow_snapshots")}/>{' '}
@@ -263,7 +269,7 @@ export default function RemoteEdit() {
- handleValueChange(e, "timeout_seconds")}/> + handleValueChange(e, "timeout_seconds")}/>
@@ -274,19 +280,19 @@ export default function RemoteEdit() { // HTTP Proxy }
- handleUseProxy(e)} />{' '} + handleUseProxy(e)} />{' '}
{ - store.useProxy&& + useProxy&&
- handleValueChange(e,"proxy_host")} size="20"/> + handleValueChange(e,"proxy_host")} size="20"/>
- handleValueChange(e,"proxy_port")} size="6"/> + handleValueChange(e,"proxy_port")} size="6"/>
} @@ -294,40 +300,40 @@ export default function RemoteEdit() { // X.509 / auth }
- handleUseAuth(e)} />{' '} + handleUseAuth(e)} />{' '}
{ - store.useAuth && + useAuth &&
- handleValueChange(e, "user")} size="25"/> + handleValueChange(e, "user")} size="25"/>
- handleValueChange(e, "password")} size="25"/> + handleValueChange(e, "password")} size="25"/>
{ store.use_proxy &&
- handleValueChange(e, "proxy_user")} size="20"/> + handleValueChange(e, "proxy_user")} size="20"/>
- handleValueChange(e, "proxy_password")} size="20"/> + handleValueChange(e, "proxy_password")} size="20"/>
}
}
- handleUseX509(e)} />{' '} + handleUseX509(e)} />{' '}
{ - store.useX509 && + useX509 && }