atom-nuclide
Version:
A unified developer experience for web and mobile development, built as a suite of features on top of Atom to provide hackability and the support of an active community.
223 lines (186 loc) • 9.58 kB
JavaScript
var _createClass = (function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ('value' in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; })();
var _get = function get(_x, _x2, _x3) { var _again = true; _function: while (_again) { var object = _x, property = _x2, receiver = _x3; _again = false; if (object === null) object = Function.prototype; var desc = Object.getOwnPropertyDescriptor(object, property); if (desc === undefined) { var parent = Object.getPrototypeOf(object); if (parent === null) { return undefined; } else { _x = parent; _x2 = property; _x3 = receiver; _again = true; desc = parent = undefined; continue _function; } } else if ('value' in desc) { return desc.value; } else { var getter = desc.get; if (getter === undefined) { return undefined; } return getter.call(receiver); } } };
/*
* Copyright (c) 2015-present, Facebook, Inc.
* All rights reserved.
*
* This source code is licensed under the license found in the LICENSE file in
* the root directory of this source tree.
*/
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError('Cannot call a class as a function'); } }
function _inherits(subClass, superClass) { if (typeof superClass !== 'function' && superClass !== null) { throw new TypeError('Super expression must either be null or a function, not ' + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; }
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj }; }
var _DiagnosticsPane2;
function _DiagnosticsPane() {
return _DiagnosticsPane2 = _interopRequireDefault(require('./DiagnosticsPane'));
}
var _nuclideUiLibCheckbox2;
function _nuclideUiLibCheckbox() {
return _nuclideUiLibCheckbox2 = require('../../nuclide-ui/lib/Checkbox');
}
var _nuclideUiLibPanelComponent2;
function _nuclideUiLibPanelComponent() {
return _nuclideUiLibPanelComponent2 = require('../../nuclide-ui/lib/PanelComponent');
}
var _nuclideUiLibToolbar2;
function _nuclideUiLibToolbar() {
return _nuclideUiLibToolbar2 = require('../../nuclide-ui/lib/Toolbar');
}
var _nuclideUiLibToolbarCenter2;
function _nuclideUiLibToolbarCenter() {
return _nuclideUiLibToolbarCenter2 = require('../../nuclide-ui/lib/ToolbarCenter');
}
var _nuclideUiLibToolbarLeft2;
function _nuclideUiLibToolbarLeft() {
return _nuclideUiLibToolbarLeft2 = require('../../nuclide-ui/lib/ToolbarLeft');
}
var _nuclideUiLibToolbarRight2;
function _nuclideUiLibToolbarRight() {
return _nuclideUiLibToolbarRight2 = require('../../nuclide-ui/lib/ToolbarRight');
}
var _reactForAtom2;
function _reactForAtom() {
return _reactForAtom2 = require('react-for-atom');
}
var _nuclideUiLibButton2;
function _nuclideUiLibButton() {
return _nuclideUiLibButton2 = require('../../nuclide-ui/lib/Button');
}
var _nuclideAnalytics2;
function _nuclideAnalytics() {
return _nuclideAnalytics2 = require('../../nuclide-analytics');
}
/**
* Dismissable panel that displays the diagnostics from nuclide-diagnostics-store.
*/
var DiagnosticsPanel = (function (_React$Component) {
_inherits(DiagnosticsPanel, _React$Component);
function DiagnosticsPanel(props) {
_classCallCheck(this, DiagnosticsPanel);
_get(Object.getPrototypeOf(DiagnosticsPanel.prototype), 'constructor', this).call(this, props);
this._onFilterByActiveTextEditorChange = this._onFilterByActiveTextEditorChange.bind(this);
}
_createClass(DiagnosticsPanel, [{
key: 'render',
value: function render() {
var _this = this;
var warningCount = 0;
var errorCount = 0;
var diagnostics = this.props.diagnostics;
if (this.props.filterByActiveTextEditor && this.props.pathToActiveTextEditor) {
(function () {
var pathToFilterBy = _this.props.pathToActiveTextEditor;
diagnostics = diagnostics.filter(function (diagnostic) {
return diagnostic.scope === 'file' && diagnostic.filePath === pathToFilterBy;
});
})();
}
diagnostics.forEach(function (diagnostic) {
if (diagnostic.type === 'Error') {
++errorCount;
} else if (diagnostic.type === 'Warning') {
++warningCount;
}
});
var linterWarning = null;
if (this.props.warnAboutLinter) {
linterWarning = (_reactForAtom2 || _reactForAtom()).React.createElement(
(_nuclideUiLibToolbar2 || _nuclideUiLibToolbar()).Toolbar,
null,
(_reactForAtom2 || _reactForAtom()).React.createElement(
(_nuclideUiLibToolbarCenter2 || _nuclideUiLibToolbarCenter()).ToolbarCenter,
null,
(_reactForAtom2 || _reactForAtom()).React.createElement(
'span',
{ className: 'inline-block highlight-info' },
'nuclide-diagnostics is not compatible with the linter package. We recommend that you ',
(_reactForAtom2 || _reactForAtom()).React.createElement(
'a',
{ onClick: this.props.disableLinter },
'disable the linter package'
),
'. ',
(_reactForAtom2 || _reactForAtom()).React.createElement(
'a',
{ href: 'http://nuclide.io/docs/advanced-topics/linter-package-compatibility/' },
'Learn More'
),
'.'
)
)
);
}
var errorSpanClassName = 'inline-block ' + (errorCount > 0 ? 'text-error' : '');
var warningSpanClassName = 'inline-block ' + (warningCount > 0 ? 'text-warning' : '');
// We hide the horizontal overflow in the PanelComponent because the presence of the scrollbar
// throws off our height calculations.
return (_reactForAtom2 || _reactForAtom()).React.createElement(
(_nuclideUiLibPanelComponent2 || _nuclideUiLibPanelComponent()).PanelComponent,
{
ref: 'panel',
dock: 'bottom',
initialLength: this.props.height,
noScroll: true,
overflowX: 'hidden' },
(_reactForAtom2 || _reactForAtom()).React.createElement(
'div',
{ style: { display: 'flex', flex: 1, flexDirection: 'column' } },
linterWarning,
(_reactForAtom2 || _reactForAtom()).React.createElement(
(_nuclideUiLibToolbar2 || _nuclideUiLibToolbar()).Toolbar,
{ location: 'top' },
(_reactForAtom2 || _reactForAtom()).React.createElement(
(_nuclideUiLibToolbarLeft2 || _nuclideUiLibToolbarLeft()).ToolbarLeft,
null,
(_reactForAtom2 || _reactForAtom()).React.createElement(
'span',
{ className: errorSpanClassName },
'Errors: ',
errorCount
),
(_reactForAtom2 || _reactForAtom()).React.createElement(
'span',
{ className: warningSpanClassName },
'Warnings: ',
warningCount
)
),
(_reactForAtom2 || _reactForAtom()).React.createElement(
(_nuclideUiLibToolbarRight2 || _nuclideUiLibToolbarRight()).ToolbarRight,
null,
(_reactForAtom2 || _reactForAtom()).React.createElement(
'span',
{ className: 'inline-block' },
(_reactForAtom2 || _reactForAtom()).React.createElement((_nuclideUiLibCheckbox2 || _nuclideUiLibCheckbox()).Checkbox, {
checked: this.props.filterByActiveTextEditor,
label: 'Show only diagnostics for current file',
onChange: this._onFilterByActiveTextEditorChange
})
),
(_reactForAtom2 || _reactForAtom()).React.createElement((_nuclideUiLibButton2 || _nuclideUiLibButton()).Button, {
onClick: this.props.onDismiss,
icon: 'x',
size: (_nuclideUiLibButton2 || _nuclideUiLibButton()).ButtonSizes.SMALL,
className: 'inline-block',
title: 'Close Panel'
})
)
),
(_reactForAtom2 || _reactForAtom()).React.createElement((_DiagnosticsPane2 || _DiagnosticsPane()).default, {
showFileName: !this.props.filterByActiveTextEditor,
diagnostics: diagnostics,
width: this.props.width
})
)
);
}
}, {
key: '_onFilterByActiveTextEditorChange',
value: function _onFilterByActiveTextEditorChange(isChecked) {
(0, (_nuclideAnalytics2 || _nuclideAnalytics()).track)('diagnostics-panel-toggle-current-file', { isChecked: isChecked.toString() });
this.props.onFilterByActiveTextEditorChange.call(null, isChecked);
}
}]);
return DiagnosticsPanel;
})((_reactForAtom2 || _reactForAtom()).React.Component);
module.exports = DiagnosticsPanel;