Add hostname syncing between source url and kapacitor url in kapacitorStep
parent
4ba951dd36
commit
b5eba4d92b
|
@ -57,6 +57,13 @@ const getActiveKapacitor = (source: Source, sources: Source[]): Kapacitor => {
|
|||
return activeKapacitor
|
||||
}
|
||||
|
||||
const syncHostnames = (source: Source, kapacitor: Kapacitor) => {
|
||||
const sourceURL = new URL(source.url)
|
||||
const kapacitorURL = new URL(kapacitor.url)
|
||||
kapacitorURL.hostname = sourceURL.hostname
|
||||
return {...kapacitor, url: kapacitorURL.href}
|
||||
}
|
||||
|
||||
@ErrorHandling
|
||||
class KapacitorStep extends Component<Props, State> {
|
||||
public static defaultProps: Partial<Props> = {
|
||||
|
@ -66,13 +73,15 @@ class KapacitorStep extends Component<Props, State> {
|
|||
constructor(props: Props) {
|
||||
super(props)
|
||||
|
||||
const kapacitor = props.showNewKapacitor
|
||||
? DEFAULT_KAPACITOR
|
||||
: getActiveKapacitor(props.source, props.sources) || DEFAULT_KAPACITOR
|
||||
let kapacitor = getActiveKapacitor(props.source, props.sources)
|
||||
|
||||
this.state = {
|
||||
kapacitor,
|
||||
if (!kapacitor || props.showNewKapacitor) {
|
||||
kapacitor = DEFAULT_KAPACITOR
|
||||
}
|
||||
|
||||
kapacitor = syncHostnames(props.source, kapacitor)
|
||||
|
||||
this.state = {kapacitor}
|
||||
}
|
||||
|
||||
public next = async () => {
|
||||
|
|
Loading…
Reference in New Issue