@atlaskit/editor-core
Version:
A package contains Atlassian editor core functionality
80 lines • 4.27 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
var tslib_1 = require("tslib");
var React = require("react");
var react_1 = require("react");
var spinner_1 = require("@atlaskit/spinner");
var analytics_1 = require("../../analytics");
var ToolbarButton_1 = require("../ToolbarButton");
var version_1 = require("../../version");
var JIRA_ISSUE_COLLECTOR_URL = 'https://product-fabric.atlassian.net/s/d41d8cd98f00b204e9800998ecf8427e-T/-j519ub/b/c/78bd26fb4be69a8bdb879359a9397e96/_/download/batch/com.atlassian.jira.collector.plugin.jira-issue-collector-plugin:issuecollector-embededjs/com.atlassian.jira.collector.plugin.jira-issue-collector-plugin:issuecollector-embededjs.js?locale=en-US&collectorId=305d3263';
var ToolbarFeedback = (function (_super) {
tslib_1.__extends(ToolbarFeedback, _super);
function ToolbarFeedback() {
var _this = _super !== null && _super.apply(this, arguments) || this;
_this.state = {
jiraIssueCollectorScriptLoading: false
};
_this.openFeedbackPopup = function () {
if (typeof _this.showJiraCollectorDialogCallback === 'function') {
_this.showJiraCollectorDialogCallback();
return false;
}
_this.setState({ jiraIssueCollectorScriptLoading: true });
// triggerFunction is executed as soon as JIRA issue collector script is loaded
window.ATL_JQ_PAGE_PROPS = {
triggerFunction: function (showCollectorDialog) {
_this.setState({ jiraIssueCollectorScriptLoading: false });
if (typeof showCollectorDialog === 'function') {
// save reference to `showCollectorDialog` for future calls
_this.showJiraCollectorDialogCallback = showCollectorDialog;
// and run it now
// next tick is essential due to JIRA issue collector behaviour
setTimeout(showCollectorDialog, 0);
}
},
fieldValues: {
description: "Please describe the problem you're having or feature you'd like to see:\n\n\n---~---~---~---~---~---~---~---~---~---~---~---~---~---~---\n version: " + _this.props.packageName + "@" + _this.props.packageVersion + " (" + version_1.version + ")\n---~---~---~---~---~---~---~---~---~---~---~---~---~---~---\n\n"
},
environment: {
'Editor Package': _this.props.packageName,
'Editor Version': _this.props.packageVersion,
'Editor Core Version': version_1.version,
}
};
_this.loadJiraIssueCollectorScript();
return true;
};
_this.loadJiraIssueCollectorScript = function () {
if (_this.hasJquery()) {
window.jQuery.ajax({
url: JIRA_ISSUE_COLLECTOR_URL,
type: 'get',
cache: true,
dataType: 'script'
});
}
};
_this.hasJquery = function () {
return (typeof window.jQuery !== 'undefined');
};
return _this;
}
ToolbarFeedback.prototype.handleSpinnerComplete = function () { };
ToolbarFeedback.prototype.render = function () {
var iconBefore = this.state.jiraIssueCollectorScriptLoading
? React.createElement(spinner_1.default, { isCompleting: false, onComplete: this.handleSpinnerComplete })
: undefined;
// JIRA issue collector script is using jQuery internally
return this.hasJquery()
? (React.createElement("span", { style: { display: 'inline-block' } },
React.createElement(ToolbarButton_1.default, { iconBefore: iconBefore, onClick: this.openFeedbackPopup, selected: false, spacing: "compact" }, "Feedback")))
: null;
};
return ToolbarFeedback;
}(react_1.PureComponent));
tslib_1.__decorate([
analytics_1.analyticsDecorator('atlassian.editor.feedback.button')
], ToolbarFeedback.prototype, "openFeedbackPopup", void 0);
exports.default = ToolbarFeedback;
//# sourceMappingURL=index.js.map