Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
constructor(mainWindow) {
this.mainWindow = mainWindow
this.channels = []
this.view = gui.Container.create()
this.view.setMouseDownCanMoveWindow(false)
this.view.setBackgroundColor('#FFF')
this.view.setStyle({flex: 1, padding: 20})
this.entry = gui.Entry.create()
this.entry.setStyle({width: '100%', marginBottom: 20})
this.entry.onTextChange = this.onTextChange.bind(this)
this.view.addChildView(this.entry)
this.scroll = gui.Scroll.create()
this.scroll.setStyle({flex: 1})
this.scroll.setScrollbarPolicy('never', 'automatic')
this.contentView = gui.Container.create()
this.contentView.onDraw = this.draw.bind(this)
this.scroll.setContentView(this.contentView)
this.view.addChildView(this.scroll)
this.hoverItem = null
this.contentView.onMouseMove = this.onMouse.bind(this)
this.contentView.onMouseEnter = this.onMouse.bind(this)
this.contentView.onMouseLeave = this.onMouse.bind(this)
createLoginWindow() {
this.loginWindow = gui.Window.create({})
this.loginWindow.setTitle('Login to Slack')
this.loginWindow.onClose = () => this.loginWindow = null
const contentView = gui.Container.create()
contentView.setStyle({padding: 10})
this.loginWindow.setContentView(contentView)
const row1 = this.createRow(contentView)
const label11 = gui.Label.create('Workspace')
row1.addChildView(label11)
const labelWidth = label11.getBounds().width + 5
label11.setAlign('start')
label11.setStyle({minWidth: labelWidth})
const teamInput = gui.Entry.create()
teamInput.setStyle({flex: 1})
row1.addChildView(teamInput)
const label12 = gui.Label.create('.slack.com')
row1.addChildView(label12)
const row2 = this.createRow(contentView)
const label21 = gui.Label.create('E-mail')
label21.setAlign('start')
label21.setStyle({minWidth: labelWidth})
row2.addChildView(label21)
const emailInput = gui.Entry.create()
emailInput.setStyle({flex: 1})
row2.addChildView(emailInput)
const row3 = this.createRow(contentView)
const label31 = gui.Label.create('Password')
const row2 = this.createRow(contentView)
const label21 = gui.Label.create('E-mail')
label21.setAlign('start')
label21.setStyle({minWidth: labelWidth})
row2.addChildView(label21)
const emailInput = gui.Entry.create()
emailInput.setStyle({flex: 1})
row2.addChildView(emailInput)
const row3 = this.createRow(contentView)
const label31 = gui.Label.create('Password')
label31.setAlign('start')
label31.setStyle({minWidth: labelWidth})
row3.addChildView(label31)
const passInput = gui.Entry.createType('password')
passInput.setStyle({flex: 1})
row3.addChildView(passInput)
const loginButton = gui.Button.create('Login')
loginButton.setStyle({marginBottom: 10})
loginButton.onClick = this.exchangeToken.bind(this, teamInput, emailInput, passInput)
passInput.onActivate = this.exchangeToken.bind(this, teamInput, emailInput, passInput, loginButton)
contentView.addChildView(loginButton)
contentView.addChildView(gui.Label.create('----------- OR -----------'))
const fetchButton = gui.Button.create(FETCH_BUTTON_TEXT)
fetchButton.setStyle({marginTop: 10})
fetchButton.onClick = this.fetchSlackTokens.bind(this)
contentView.addChildView(fetchButton)
this.adujstLoginWindowSize()