Skip to content

Commit

Permalink
Merge pull request #17807 from jeclrsg/hpcc-30313-remote-copy-replicate
Browse files Browse the repository at this point in the history
HPCC-30313 ECL Watch v9 fix Files remote copy dialog replicate checkbox

Reviewed-by: Gordon Smith <[email protected]>
Merged-by: Gavin Halliday <[email protected]>
  • Loading branch information
ghalliday authored Oct 4, 2023
2 parents bf1ce49 + 872736f commit 478e657
Showing 1 changed file with 25 additions and 2 deletions.
27 changes: 25 additions & 2 deletions esp/src/src-react/components/forms/RemoteCopy.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import { Controller, useForm } from "react-hook-form";
import { scopedLogger } from "@hpcc-js/util";
import nlsHPCC from "src/nlsHPCC";
import * as FileSpray from "src/FileSpray";
import * as WsTopology from "src/WsTopology";
import * as FormStyles from "./landing-zone/styles";
import { TargetGroupTextField } from "./Fields";
import { MessageBox } from "../../layouts/MessageBox";
Expand Down Expand Up @@ -58,6 +59,9 @@ export const RemoteCopy: React.FunctionComponent<RemoteCopyProps> = ({
const [showError, setShowError] = React.useState(false);
const [errorMessage, setErrorMessage] = React.useState("");

const [selectedDestGroup, setSelectedDestGroup] = React.useState("");
const [replicateDisabled, setReplicateDisabled] = React.useState(true);

const onSubmit = React.useCallback(() => {
handleSubmit(
(data, evt) => {
Expand Down Expand Up @@ -89,6 +93,24 @@ export const RemoteCopy: React.FunctionComponent<RemoteCopyProps> = ({
}
);

React.useEffect(() => {
WsTopology.TpGroupQuery({
request: {}
}).then(response => {
const groups = response.TpGroupQueryResponse.TpGroups?.TpGroup ?? [];
for (const index in groups) {
if (groups[index].Name === selectedDestGroup) {
if (groups[index].ReplicateOutputs === true) {
setReplicateDisabled(false);
break;
}
setReplicateDisabled(true);
break;
}
}
}).catch(err => logger.error(err));
}, [selectedDestGroup]);

return <MessageBox title={nlsHPCC.RemoteCopy} show={showForm} setShow={setShowForm}
footer={<>
<PrimaryButton text={nlsHPCC.Copy} onClick={handleSubmit(onSubmit)} />
Expand Down Expand Up @@ -164,13 +186,14 @@ export const RemoteCopy: React.FunctionComponent<RemoteCopyProps> = ({
<Controller
control={control} name="destGroup"
render={({
field: { onChange, name: fieldName, value },
field: { onChange, name: fieldName },
fieldState: { error }
}) => <TargetGroupTextField
key={fieldName}
label={nlsHPCC.Group}
required={true}
onChange={(evt, option) => {
setSelectedDestGroup(option.key.toString());
onChange(option.key);
}}
errorMessage={error && error.message}
Expand Down Expand Up @@ -233,7 +256,7 @@ export const RemoteCopy: React.FunctionComponent<RemoteCopyProps> = ({
control={control} name="replicate"
render={({
field: { onChange, name: fieldName, value }
}) => <Checkbox name={fieldName} checked={value} onChange={onChange} label={nlsHPCC.Replicate} disabled={true} />}
}) => <Checkbox name={fieldName} checked={value} onChange={onChange} label={nlsHPCC.Replicate} disabled={replicateDisabled} />}
/></td>
<td><Controller
control={control} name="superCopy"
Expand Down

0 comments on commit 478e657

Please sign in to comment.