Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
export default function debounce(fn) {
// noop during testing
if (process.env.NODE_ENV === 'test') {
return fn;
}
return _debounce(fn, 300);
}
];
this.activeTab = null;
this.fileHistory = [];
this.events.on('deploy:endpoint:update', endpoints => {
this.persistEndpoints(endpoints);
});
this.events.on('deploy', (payload, done) => {
this.triggerAction('deploy', payload, done);
});
this.events.on('workspace:changed', debounce((done) => {
this.persistWorkspace((err) => {
debug('workspace persisted?', err);
// this is to prevent a race condition when quitting the app
if (done) {
done(err);
}
});
}, 100));
this.events.on('tools:state-changed', (tab, newState) => {
var button, selectedEditor;
if (this.activeTab !== tab) {
];
// remember the original App#checkFileChanged version
// for testing purposes
this.__checkFileChanged = this.checkFileChanged;
// ensure we do not accidently execute the method recursively
// cf. https://github.com/camunda/camunda-modeler/issues/1118
this.checkFileChanged = executeOnce(
(tab) => this.__checkFileChanged(tab),
(tab) => tab.id
);
if (process.env.NODE_ENV !== 'test') {
this.workspaceChanged = debounce(this.workspaceChanged, 1500);
this.updateMenu = debounce(this.updateMenu, 50);
this.resizeTab = debounce(this.resizeTab, 50);
}
this.currentNotificationId = 0;
}
// remember the original App#checkFileChanged version
// for testing purposes
this.__checkFileChanged = this.checkFileChanged;
// ensure we do not accidently execute the method recursively
// cf. https://github.com/camunda/camunda-modeler/issues/1118
this.checkFileChanged = executeOnce(
(tab) => this.__checkFileChanged(tab),
(tab) => tab.id
);
if (process.env.NODE_ENV !== 'test') {
this.workspaceChanged = debounce(this.workspaceChanged, 1500);
this.updateMenu = debounce(this.updateMenu, 50);
this.resizeTab = debounce(this.resizeTab, 50);
}
this.currentNotificationId = 0;
}
constructor(options={}) {
this._eventBus = new EventBus();
this._viewsChanged = debounce(this._viewsChanged, 0);
this._views = [];
this._viewers = {};
this._init(options);
}
}
this.setState({
checkingConnection: true,
connectionHint: null,
lastUsername: values.username,
lastPassword: values.password,
lastAuthType: values.authType
});
const connectionError = await this.props.checkConnection(values);
this.mounted && this.setState({ connectionError, checkingConnection: false });
}
lazilyCheckConnection = debounce(this.checkConnection, 1000);
moreLazilyCheckConnection = debounce(this.checkConnection, 2000);
validate = values => {
const errors = this.props.validate(values);
this.checkConnectionIfNeeded(values, errors);
return errors;
}
checkConnectionIfNeeded(values, errors, immediately = false) {
const {
authType,
username,
});
function setEncoded(link, name, data) {
var encodedData = encodeURIComponent(data);
if (data) {
link.addClass('active').attr({
'href': 'data:application/bpmn20-xml;charset=UTF-8,' + encodedData,
'download': name
});
} else {
link.removeClass('active');
}
}
var exportArtifacts = debounce(function() {
saveSVG(function(err, svg) {
setEncoded(downloadSvgLink, 'diagram.svg', err ? null : svg);
});
saveDiagram(function(err, xml) {
setEncoded(downloadLink, 'diagram.bpmn', err ? null : xml);
});
}, 500);
bpmnModeler.on('commandStack.changed', exportArtifacts);
});
return function _debounceInput(fn) {
if (shouldDebounce !== false) {
var debounceTime =
isNumber(shouldDebounce) ?
shouldDebounce :
DEFAULT_DEBOUNCE_TIME;
return debounce(fn, debounceTime);
} else {
return fn;
}
};
}
});
function setEncoded(link, name, data) {
var encodedData = encodeURIComponent(data);
if (data) {
link.addClass('active').attr({
'href': 'data:application/bpmn20-xml;charset=UTF-8,' + encodedData,
'download': name
});
} else {
link.removeClass('active');
}
}
var exportArtifacts = debounce(function() {
saveSVG(function(err, svg) {
setEncoded(downloadSvgLink, 'diagram.svg', err ? null : svg);
});
saveDiagram(function(err, xml) {
setEncoded(downloadLink, 'diagram.bpmn', err ? null : xml);
});
}, 500);
bpmnModeler.on('commandStack.changed', exportArtifacts);
});
});
function setEncoded(link, name, data) {
var encodedData = encodeURIComponent(data);
if (data) {
link.addClass('active').attr({
'href': 'data:application/bpmn20-xml;charset=UTF-8,' + encodedData,
'download': name
});
} else {
link.removeClass('active');
}
}
var exportArtifacts = debounce(function() {
saveSVG(function(err, svg) {
setEncoded(downloadSvgLink, 'diagram.svg', err ? null : svg);
});
saveDiagram(function(err, xml) {
setEncoded(downloadLink, 'diagram.bpmn', err ? null : xml);
});
}, 500);
bpmnModeler.on('commandStack.changed', exportArtifacts);
});