feeles-ide
Version:
The hackable and serializable IDE to make learning material
66 lines (59 loc) • 1.52 kB
JavaScript
import _Object$assign from 'babel-runtime/core-js/object/assign';
import _Object$freeze from 'babel-runtime/core-js/object/freeze';
import _classCallCheck from 'babel-runtime/helpers/classCallCheck';
import _createClass from 'babel-runtime/helpers/createClass';
import { SourceFile } from '../File/';
var getUniqueId = function (id) {
return function () {
return 'Tab__' + ++id;
};
}(0);
var Tab = function () {
function Tab(props) {
_classCallCheck(this, Tab);
this.props = _Object$freeze(props);
this.key = props.key || getUniqueId();
}
_createClass(Tab, [{
key: 'is',
value: function is(tab) {
if (!tab.file || !this.file) {
return false;
}
return tab.key === this.key || tab.file.key === this.file.key;
}
}, {
key: 'select',
value: function select(isSelected) {
var props = _Object$assign({}, this.props, {
key: this.key,
isSelected: isSelected
});
return new Tab(props);
}
}, {
key: 'file',
get: function get() {
return this.props.getFile() || new SourceFile({
name: 'Not Found',
type: 'text/plain',
text: 'File Not Found :-/'
});
}
}, {
key: 'label',
get: function get() {
var _file = this.file,
plane = _file.plane,
ext = _file.ext;
return plane + ext;
}
}, {
key: 'isSelected',
get: function get() {
return !!this.props.isSelected;
}
}]);
return Tab;
}();
export default Tab;