Skip to content

Commit

Permalink
sonar issues
Browse files Browse the repository at this point in the history
  • Loading branch information
rjpmestre committed Feb 24, 2025
1 parent 1f429fe commit 1ae01d7
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 18 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -29,16 +29,21 @@
import java.util.Collections;
import java.util.HashMap;
import java.util.Map;
import java.util.Objects;
import java.util.Optional;

import javax.persistence.Transient;

/**
* ProxyConfigurationApply - Class representing TYPE_PROXY_CONFIGURATION_APPLY action
*/
public class ProxyConfigurationApplyAction extends Action {

private static final String APPLY_PROXY_CONFIG = "proxy.apply_proxy_config";
private final Pillar pillar;
private final Map<String, Object> proxyConfigFiles;

@Transient
private final transient Map<String, Object> proxyConfigFiles;

/**
* Default constructor
Expand Down Expand Up @@ -75,18 +80,27 @@ public LocalCall<Xor<String, Map<String, State.ApplyResult>>> getApplyProxyConfi
Collections.singletonList(APPLY_PROXY_CONFIG),
Optional.of(data),
Optional.of(false), Optional.of(false),
new TypeToken<Xor<String, Map<String, State.ApplyResult>>>() { }
new TypeToken<>() { }
);
}

public LocalCall<Map<String, State.ApplyResult>> getApplyProxyConfigCallSimple() {
Map<String, Object> data = new HashMap<>();
data.putAll(ProxyConfigUtils.applyProxyConfigDataFromPillar(getPillar()));
data.putAll(getProxyConfigFiles());
@Override
public int hashCode() {
return Objects.hash(pillar, proxyConfigFiles, getOrg());
}

return State.apply(
Collections.singletonList(APPLY_PROXY_CONFIG),
Optional.of(data)
);
@Override
public boolean equals(Object obj) {
if (this == obj) {
return true;
}
if (obj == null || getClass() != obj.getClass()) {
return false;
}
ProxyConfigurationApplyAction that = (ProxyConfigurationApplyAction) obj;
return Objects.equals(pillar, that.pillar) &&
Objects.equals(proxyConfigFiles, that.proxyConfigFiles) &&
Objects.equals(getOrg(), that.getOrg());
}

}
15 changes: 7 additions & 8 deletions web/html/src/manager/minion/proxy/proxy-config.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -181,7 +181,7 @@ export function ProxyConfig({

const fileReaders = Object.keys(model)
.filter((key) => {
const matcher = key.match(/^([a-zA-Z0-9]*[A-Za-z])[0-9]*$/);
const matcher = /^([a-zA-Z\d]*[A-Za-z])\d*$/.exec(key);
const fieldName = matcher ? matcher[1] : key;
return fileFields.includes(fieldName);
})
Expand Down Expand Up @@ -219,9 +219,8 @@ export function ProxyConfig({
};
const registryData =
model.sourceMode === SourceMode.Registry
? Object.assign(
{},
model.registryMode === RegistryMode.Simple
? {
...(model.registryMode === RegistryMode.Simple
? {
registryBaseURL: model.registryBaseURL,
registryBaseTag: model.registryBaseTag,
Expand All @@ -237,8 +236,8 @@ export function ProxyConfig({
registrySshTag: model.registrySshTag,
registryTftpdURL: model.registryTftpdURL,
registryTftpdTag: model.registryTftpdTag,
}
)
}),
}
: {};

const formData = unflattenModel(Object.assign({}, commonData, registryData, ...values));
Expand Down Expand Up @@ -276,12 +275,12 @@ export function ProxyConfig({
};

const onChange = (newModel) => {
setModel(Object.assign({}, newModel));
setModel({ ...newModel });
asyncValidate(newModel);
};

const onAddField = (fieldName: string) => {
return (index: number) => setModel(Object.assign({}, model, { [fieldName + index]: "" }));
return (index: number) => setModel({ ...model, [fieldName + index]: "" });
};

const onRemoveField = (fieldName: string) => {
Expand Down

0 comments on commit 1ae01d7

Please sign in to comment.