Skip to content
This repository was archived by the owner on Oct 5, 2022. It is now read-only.

Commit

Permalink
Eslint
Browse files Browse the repository at this point in the history
  • Loading branch information
lierdakil committed Mar 11, 2017
1 parent 818512d commit 6b80790
Show file tree
Hide file tree
Showing 10 changed files with 250 additions and 278 deletions.
12 changes: 11 additions & 1 deletion .eslintrc.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,14 @@
# extends: standard
extends:
- standard
- "plugin:react/recommended"
plugins:
- standard
- promise
- react
env:
node: true
globals:
atom: true
parserOptions:
ecmaVersion: 8
ecmaFeatures:
Expand Down
165 changes: 81 additions & 84 deletions lib/output-panel/output-panel.js
Original file line number Diff line number Diff line change
@@ -1,37 +1,38 @@
"use babel"
'use babel'
/** @jsx etch.dom */

import etch from 'etch'
import {Emitter, Disposable, CompositeDisposable} from 'atom'
import {Disposable, CompositeDisposable} from 'atom'
import {OutputPanelButtons} from './views/output-panel-buttons'
import {OutputPanelCheckbox} from './views/output-panel-checkbox'
import {ProgressBar} from './views/progress-bar'
import {OutputPanelItems} from './views/output-panel-items'
const $ = etch.dom;
const $ = etch.dom

export class OutputPanel {
constructor(state, results) {
constructor (state, results) {
this.state = state || {}
this.results = results

this.hiddenOutput = true

this.elements = new Set
this.elements = new Set()

this.statusMap = new Map

this.disposables = new CompositeDisposable

etch.initialize(this);
etch.initialize(this)

atom.config.observe('ide-haskell.panelPosition',(value) => {
atom.config.observe('ide-haskell.panelPosition', (value) => {
this.pos = value
this.panel = atom.workspace.addPanel(this.pos, {
item: this,
visible: this.state.visibility || true,
visible: this.state.visibility || true
})
if(this.element)
if (this.element) {
this.update()
}
})

this.disposables.add(atom.tooltips.add(this.refs.status, {
Expand All @@ -51,34 +52,37 @@ export class OutputPanel {

this.disposables.add(this.results.onDidUpdate(({types}) => {
this.currentResult = null
if(atom.config.get('ide-haskell.autoHideOutput') &&
types.map((type) => this.results.filter({severity: type}).length).every((l) => l == 0))
if (atom.config.get('ide-haskell.autoHideOutput') &&
types.map((type) => this.results.filter({severity: type}).length).every((l) => l === 0)) {
this.buttons.disableAll()
else
if(atom.config.get('ide-haskell.switchTabOnCheck'))
} else {
if (atom.config.get('ide-haskell.switchTabOnCheck')) {
this.activateFirstNonEmptyTab(types)
}
}
this.updateItems()
}));
}))

this.refs.progressBar.setProgress(0)

this.disposables.add(this.refs.buttons.onButtonClicked(() => this.updateItems()))
this.disposables.add(this.refs.checkboxUriFilter.onCheckboxSwitched(() => this.updateItems()))
this.disposables.add(atom.workspace.onDidChangeActivePaneItem(() => {
if(this.refs.checkboxUriFilter.getFileFilter()) this.updateItems() } ))
if (this.refs.checkboxUriFilter.getFileFilter()) this.updateItems()
}))
}

render() {
render () {
let orientMap = {
'top': 'horizontal',
'bottom': 'horizontal',
'left': 'vertical',
'right': 'vertical',
'right': 'vertical'
}
return (
<ide-haskell-panel style={{width: this.state.width, height: this.state.height}}
dataset={{pos: this.pos}}
class={this.hiddenOutput?'hidden-output':''}>
class={this.hiddenOutput ? 'hidden-output' : ''}>
<resize-handle on={{mousedown: this.resizeStart}} />
<ide-haskell-panel-heading ref='heading'>
<ide-haskell-status-icon ref='status' id='status' dataset={{status: 'ready'}}/>
Expand All @@ -91,15 +95,15 @@ export class OutputPanel {
</ide-haskell-panel-heading>
<OutputPanelItems model={this.results} ref='items' id='items'/>
</ide-haskell-panel>
);
)
}

resizeStart(e) {
resizeStart (e) {
let varsMap = {
'top': {axis: 'Y', param: 'height', dir: 1},
'bottom': {axis: 'Y', param: 'height', dir: -1},
'left': {axis: 'X', param: 'width', dir: 1},
'right': {axis: 'X', param: 'width', dir: -1},
'right': {axis: 'X', param: 'width', dir: -1}
}

let vars = varsMap[this.pos]
Expand All @@ -110,7 +114,7 @@ export class OutputPanel {

let doDrag = (e) => {
this.state[vars.param] =
(startParam + vars.dir * (e[vars.axis] - startAxis)) + 'px';
(startParam + vars.dir * (e[vars.axis] - startAxis)) + 'px'
this.update()
}
let stopDrag = () => {
Expand All @@ -122,38 +126,34 @@ export class OutputPanel {
document.documentElement.addEventListener('mouseup', stopDrag)
}

update() {
update () {
return etch.update(this)
}

async destroy() {
async destroy () {
await etch.destroy(this)
this.disposables.dispose()
this.panel.destroy()
this.statusMap.clear()
this.statusMap = null
}

addPanelControl(element, opts) {
if(typeof element == 'string') {
addPanelControl (element, opts) {
if (typeof element === 'string') {
let {events, classes, style, attrs} = opts
let props = {}
if(classes)
props.class = classes.join(' ')
if(style)
props.style = style
if(attrs)
props.attributes=attrs
if(events)
props.on = events
if (classes) props.class = classes.join(' ')
if (style) props.style = style
if (attrs) props.attributes = attrs
if (events) props.on = events

element = $(element, props)
this.elements.add(element)
this.update();
this.update()
return new Disposable(() => {
this.elements.delete(element)
this.update();
});
this.update()
})
} else {
opts.ref = `${opts.pluginName}.${opts.name}.${Date.now()}`
element = $(element, opts)
Expand All @@ -163,99 +163,96 @@ export class OutputPanel {
let ref = this.refs[opts.ref]
ref.disposables.add(new Disposable(() => {
this.elements.delete(element)
this.update();
}));
return ref;
this.update()
}))
return ref
})
}
}

setHideParameterValues(value) {
setHideParameterValues (value) {
Array.prototype.slice.call(this.refs.heading.querySelectorAll('ide-haskell-param')).forEach((el) => {
if(value)
el.classList.add('hidden-value')
else
el.classList.remove('hidden-value')
})
if (value) el.classList.add('hidden-value')
else el.classList.remove('hidden-value')
})
}

updateItems() {
activeTab = this.getActiveTab()
updateItems () {
let activeTab = this.getActiveTab()
let uri
if(activeTab) {
if (activeTab) {
this.hiddenOutput = false
let filter = {severity: activeTab}
if(this.refs.checkboxUriFilter.getFileFilter()) {
if (this.refs.checkboxUriFilter.getFileFilter()) {
uri = atom.workspace.getActiveTextEditor().getPath()
if(uri && this.refs.buttons.options(activeTab).uriFilter)
if (uri && this.refs.buttons.options(activeTab).uriFilter) {
filter.uri = uri
}
}
scroll = this.refs.buttons.options(activeTab).autoScroll && this.refs.items.atEnd()
let scroll = this.refs.buttons.options(activeTab).autoScroll && this.refs.items.atEnd()
this.refs.items.filter(filter)
if(scroll) this.refs.items.scrollToEnd()
if (scroll) this.refs.items.scrollToEnd()
} else {
this.hiddenOutput = true
}

this.refs.buttons.buttonNames().forEach((btn) => {
let f = {severity: btn}
if(uri && this.refs.buttons.options(btn).uriFilter)
f.uri = uri
if (uri && this.refs.buttons.options(btn).uriFilter) f.uri = uri
this.refs.buttons.setCount(btn, this.results.filter(f).length)
})
this.update()
}

activateTab(tab) {
activateTab (tab) {
this.refs.buttons.clickButton(tab, true)
}

activateFirstNonEmptyTab(types) {
activateFirstNonEmptyTab (types) {
let names = this.refs.buttons.buttonNames()
for(i in names) {
for (let i in names) {
let name = names[i]
if(! types || types.includes(name)) {
if((this.results.filter({severity: name})).length > 0)
if (!types || types.includes(name)) {
if ((this.results.filter({severity: name})).length > 0) {
this.activateTab(name)
break
}
}
}
}

showItem(item) {
showItem (item) {
this.activateTab(item.severity)
this.refs.items.showItem(item)
}

getActiveTab() {
getActiveTab () {
return this.refs.buttons.getActive()
}

createTab(name, opts) {
if(!this.refs.buttons.buttonNames().includes(name)) {
createTab (name, opts) {
if (!this.refs.buttons.buttonNames().includes(name)) {
this.refs.buttons.createButton(name, opts)
this.activateTab(this.state.activeTab)
}
}

setProgress(progress) {
setProgress (progress) {
this.refs.progressBar.setProgress(progress)
}

toggle() {
if(this.panel.isVisible())
this.panel.hide()
else
this.panel.show()
toggle () {
if (this.panel.isVisible()) this.panel.hide()
else this.panel.show()
}

serialize() {
serialize () {
return {
visibility: this.panel.isVisible(),
height: this.element.style.height,
width: this.element.style.width,
activeTab: this.getActiveTab(),
fileFilter: this.refs.checkboxUriFilter.getFileFilter(),
fileFilter: this.refs.checkboxUriFilter.getFileFilter()
}
}

Expand All @@ -274,30 +271,30 @@ export class OutputPanel {
this.setProgress(progress)
}

showNextError() {
showNextError () {
let rs = this.results.resultsWithURI()
if(rs.length == 0) return
if (rs.length === 0) return

if(this.currentResult !== null && this.currentResult !== undefined)
if (this.currentResult !== null && this.currentResult !== undefined) {
this.currentResult++
else
this.currentResult = 0
if(this.currentResult >= rs.length)
} else {
this.currentResult = 0
}
if (this.currentResult >= rs.length) this.currentResult = 0

this.showItem(rs[this.currentResult])
}

showPrevError() {
showPrevError () {
let rs = this.results.resultsWithURI()
if(rs.length == 0) return
if (rs.length === 0) return

if(this.currentResult !== null && this.currentResult !== undefined)
if (this.currentResult !== null && this.currentResult !== undefined) {
this.currentResult--
else
this.currentResult = rs.length - 1
if (this.currentResult < 0)
} else {
this.currentResult = rs.length - 1
}
if (this.currentResult < 0) this.currentResult = rs.length - 1

this.showItem(rs[this.currentResult])
}
Expand Down
Loading

0 comments on commit 6b80790

Please sign in to comment.