Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
const pipelineWorkersSet = typeof settings['pipeline.workers'] === 'number';
const pipelineWorkers = pipelineWorkersSet ? settings['pipeline.workers'] : 1;
this.state = {
maxBytesNumber: settings['queue.max_bytes.number'],
maxBytesUnit: settings['queue.max_bytes.units'],
pipeline: {
id,
description,
pipeline,
settings: {
'pipeline.batch.delay': settings['pipeline.batch.delay'],
'pipeline.batch.size': settings['pipeline.batch.size'],
'pipeline.workers': pipelineWorkers,
'queue.checkpoint.writes': settings['queue.checkpoint.writes'],
'queue.max_bytes': settings['queue.max_bytes.number'] + settings['queue.max_bytes.units'],
'queue.type': settings['queue.type'],
},
username,
},
pipelineIdErrors: [],
pipelineIdPattern: /^[A-Za-z\_][A-Za-z0-9\-\_]*$/,
showConfirmDeleteModal: false,
showPipelineIdError: false,
};
}
const pipelineWorkersSet = typeof settings['pipeline.workers'] === 'number';
const pipelineWorkers = pipelineWorkersSet ? settings['pipeline.workers'] : 1;
this.state = {
maxBytesNumber: settings['queue.max_bytes.number'],
maxBytesUnit: settings['queue.max_bytes.units'],
pipeline: {
id,
description,
pipeline,
settings: {
'pipeline.batch.delay': settings['pipeline.batch.delay'],
'pipeline.batch.size': settings['pipeline.batch.size'],
'pipeline.workers': pipelineWorkers,
'queue.checkpoint.writes': settings['queue.checkpoint.writes'],
'queue.max_bytes': settings['queue.max_bytes.number'] + settings['queue.max_bytes.units'],
'queue.type': settings['queue.type'],
},
username,
},
pipelineIdErrors: [],
pipelineIdPattern: /^[A-Za-z\_][A-Za-z0-9\-\_]*$/,
showConfirmDeleteModal: false,
showPipelineIdError: false,
};
}
constructor(props) {
super(props);
const {
pipeline: { id, description, pipeline, settings },
username,
} = this.props;
const pipelineWorkersSet = typeof settings['pipeline.workers'] === 'number';
const pipelineWorkers = pipelineWorkersSet ? settings['pipeline.workers'] : 1;
this.state = {
maxBytesNumber: settings['queue.max_bytes.number'],
maxBytesUnit: settings['queue.max_bytes.units'],
pipeline: {
id,
description,
pipeline,
settings: {
'pipeline.batch.delay': settings['pipeline.batch.delay'],
'pipeline.batch.size': settings['pipeline.batch.size'],
'pipeline.workers': pipelineWorkers,
'queue.checkpoint.writes': settings['queue.checkpoint.writes'],
'queue.max_bytes': settings['queue.max_bytes.number'] + settings['queue.max_bytes.units'],
'queue.type': settings['queue.type'],
},
username,
},
pipelineIdErrors: [],
pipelineIdPattern: /^[A-Za-z\_][A-Za-z0-9\-\_]*$/,
constructor(props) {
super(props);
const {
pipeline: { id, description, pipeline, settings },
username,
} = this.props;
const pipelineWorkersSet = typeof settings['pipeline.workers'] === 'number';
const pipelineWorkers = pipelineWorkersSet ? settings['pipeline.workers'] : 1;
this.state = {
maxBytesNumber: settings['queue.max_bytes.number'],
maxBytesUnit: settings['queue.max_bytes.units'],
pipeline: {
id,
description,
pipeline,
settings: {
'pipeline.batch.delay': settings['pipeline.batch.delay'],
'pipeline.batch.size': settings['pipeline.batch.size'],
'pipeline.workers': pipelineWorkers,
'queue.checkpoint.writes': settings['queue.checkpoint.writes'],
'queue.max_bytes': settings['queue.max_bytes.number'] + settings['queue.max_bytes.units'],
'queue.type': settings['queue.type'],
},
username,
},
pipelineIdErrors: [],
pipelineIdPattern: /^[A-Za-z\_][A-Za-z0-9\-\_]*$/,
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,
});
}
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,
};
}