UNPKG

@atlaskit/editor-core

Version:

A package contains Atlassian editor core functionality

78 lines 4.17 kB
import * as tslib_1 from "tslib"; import * as React from 'react'; import { PureComponent } from 'react'; import Spinner from '@atlaskit/spinner'; import { analyticsDecorator as analytics } from '../../analytics'; import ToolbarButton from '../ToolbarButton'; import { version as coreVersion } from '../../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 + " (" + coreVersion + ")\n---~---~---~---~---~---~---~---~---~---~---~---~---~---~---\n\n" }, environment: { 'Editor Package': _this.props.packageName, 'Editor Version': _this.props.packageVersion, 'Editor Core Version': coreVersion, } }; _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, { 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, { iconBefore: iconBefore, onClick: this.openFeedbackPopup, selected: false, spacing: "compact" }, "Feedback"))) : null; }; return ToolbarFeedback; }(PureComponent)); export default ToolbarFeedback; tslib_1.__decorate([ analytics('atlassian.editor.feedback.button') ], ToolbarFeedback.prototype, "openFeedbackPopup", void 0); //# sourceMappingURL=index.js.map