Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
get upstreamJSON() {
const settings = this.settings;
const maxBytesNumber = get(settings, 'queue.max_bytes.number');
const maxBytesUnits = get(settings, 'queue.max_bytes.units');
const upstreamSettings = { ...settings };
if (maxBytesNumber && maxBytesUnits) {
delete upstreamSettings['queue.max_bytes.number'];
delete upstreamSettings['queue.max_bytes.units'];
upstreamSettings['queue.max_bytes'] = `${maxBytesNumber}${maxBytesUnits}`;
}
return {
description: this.description,
pipeline: this.pipeline,
username: this.username,
settings: upstreamSettings,
};
}
static fromUpstreamJSON(pipeline) {
const settings = pipeline.settings;
const maxBytesStr = get(settings, 'queue.max_bytes', '');
const maxBytesParts = maxBytesStr.match(/(\d+)(\w+)/);
if (Array.isArray(maxBytesParts) && maxBytesParts.length === 3) {
const maxBytesNumber = maxBytesParts[1];
const maxBytesUnits = maxBytesParts[2];
if (maxBytesNumber && maxBytesUnits) {
delete settings['queue.max_bytes'];
settings['queue.max_bytes.number'] = parseInt(maxBytesNumber);
settings['queue.max_bytes.units'] = maxBytesUnits;
}
}
return new Pipeline({
id: pipeline.id,
description: pipeline.description,
pipeline: pipeline.pipeline,
username: pipeline.username,
settings,
});
}
})}
formRowTooltipText={TOOLTIPS.settings['queue.type']}
>
this.handleSettingChange('queue.type', e.target.value)}
options={PIPELINE_EDITOR.QUEUE_TYPES}
value={this.state.pipeline.settings['queue.type']}
/>
this.handleMaxByteNumberChange(e.target.value)}
value={this.state.maxBytesNumber}
/>
this.handleMaxByteUnitChange(e.target.value)}
options={PIPELINE_EDITOR.UNITS}
value={this.state.maxBytesUnit}
/>
})}
formRowTooltipText={TOOLTIPS.settings['queue.type']}
>
this.handleSettingChange('queue.type', e.target.value)}
options={PIPELINE_EDITOR.QUEUE_TYPES}
value={this.state.pipeline.settings['queue.type']}
/>
this.handleMaxByteNumberChange(e.target.value)}
value={this.state.maxBytesNumber}
/>
this.handleMaxByteUnitChange(e.target.value)}
options={PIPELINE_EDITOR.UNITS}
value={this.state.maxBytesUnit}
/>