From 40d500949b98a3c9afefda8f0e06e0650858482a Mon Sep 17 00:00:00 2001 From: Corey Johnson & Kevin Sawicki Date: Tue, 9 Jul 2013 15:08:53 -0700 Subject: [PATCH] Remove presence from collaboration package. --- .../collaboration/lib/buddy-list.coffee | 56 -------------- .../collaboration/lib/buddy-view.coffee | 27 ------- .../lib/collaboration-view.coffee | 38 ++++++++++ .../collaboration/lib/collaboration.coffee | 12 +-- .../collaboration/lib/presence.coffee | 76 ------------------- .../stylesheets/collaboration.less | 37 +++------ themes/atom-dark-ui/buddy-list.less | 2 +- 7 files changed, 50 insertions(+), 198 deletions(-) delete mode 100644 src/packages/collaboration/lib/buddy-list.coffee delete mode 100644 src/packages/collaboration/lib/buddy-view.coffee create mode 100644 src/packages/collaboration/lib/collaboration-view.coffee delete mode 100644 src/packages/collaboration/lib/presence.coffee diff --git a/src/packages/collaboration/lib/buddy-list.coffee b/src/packages/collaboration/lib/buddy-list.coffee deleted file mode 100644 index b681530b0..000000000 --- a/src/packages/collaboration/lib/buddy-list.coffee +++ /dev/null @@ -1,56 +0,0 @@ -url = require 'url' -{$$} = require 'space-pen' -ScrollView = require 'scroll-view' -BuddyView = require './buddy-view' - -module.exports = -class BuddyList extends ScrollView - @content: -> - @div class: 'buddy-list', tabindex: -1, => - @button outlet: 'shareButton', type: 'button', class: 'btn btn-default' - @div outlet: 'buddies' - - presence: null - sharingSession: null - - initialize: (@presence, @sharingSession) -> - super - - if @sharingSession.isSharing() - @shareButton.text('Stop') - else - @shareButton.text('Start') - - @presence.on 'person-added', => @updateBuddies() - @presence.on 'person-removed', => @updateBuddies() - @presence.on 'person-status-changed', => @updateBuddies() - @shareButton.on 'click', => - @shareButton.disable() - - if @sharingSession.isSharing() - @shareButton.text('Stopping...') - @sharingSession.stop() - else - @shareButton.text('Starting...') - @sharingSession.start() - - @sharingSession.on 'started', => - @shareButton.text('Stop').enable() - - @sharingSession.on 'stopped', => - @shareButton.text('Start').enable() - - toggle: -> - if @hasParent() - @detach() - else - @attach() - - attach: -> - rootView.horizontal.append(this) - @focus() - @updateBuddies() - - updateBuddies: -> - @buddies.empty() - @buddies.append(new BuddyView(buddy)) for buddy in @presence.getPeople() diff --git a/src/packages/collaboration/lib/buddy-view.coffee b/src/packages/collaboration/lib/buddy-view.coffee deleted file mode 100644 index 974b3497e..000000000 --- a/src/packages/collaboration/lib/buddy-view.coffee +++ /dev/null @@ -1,27 +0,0 @@ -url = require 'url' -{View} = require 'space-pen' - -module.exports = -class BuddyView extends View - @content: ({user, windows}) -> - @div => - @div class: 'buddy-name', => - @img class: 'avatar', outlet: 'avatar' - @span user.login - - for id, windowState of windows - {repository} = windowState - continue unless repository? - [owner, name] = url.parse(repository.url).path.split('/')[-2..] - name = name.replace(/\.git$/, '') - @div class: 'repo-name', => - @span name - if repository.branch - @div class: 'branch-name', => - @span repository.branch - - initialize: (@buddy) -> - if @buddy.user.avatarUrl - @avatar.attr('src', @buddy.user.avatarUrl) - else - @avatar.hide() diff --git a/src/packages/collaboration/lib/collaboration-view.coffee b/src/packages/collaboration/lib/collaboration-view.coffee new file mode 100644 index 000000000..e527d3d57 --- /dev/null +++ b/src/packages/collaboration/lib/collaboration-view.coffee @@ -0,0 +1,38 @@ +url = require 'url' +{$$, View} = require 'space-pen' + +module.exports = +class CollaborationView extends View + @content: -> + @div class: 'collaboration', tabindex: -1, => + @div outlet: 'share', type: 'button', class: 'share' + @div outlet: 'participants' + + sharingSession: null + + initialize: (@sharingSession) -> + if @sharingSession.isSharing() + @share.addClass('running') + + @share.on 'click', => + @share.disable() + + if @sharingSession.isSharing() + @sharingSession.stop() + else + @sharingSession.start() + + @sharingSession.on 'started stopped', => + @share.toggleClass('running').enable() + + @attach() + + toggle: -> + if @hasParent() + @detach() + else + @attach() + + attach: -> + rootView.horizontal.append(this) + @focus() diff --git a/src/packages/collaboration/lib/collaboration.coffee b/src/packages/collaboration/lib/collaboration.coffee index a1ac1ab73..92bfd7278 100644 --- a/src/packages/collaboration/lib/collaboration.coffee +++ b/src/packages/collaboration/lib/collaboration.coffee @@ -1,23 +1,17 @@ -Presence = require './presence' +CollaborationView = require './collaboration-view' SharingSession = require './sharing-session' -BuddyList = require './buddy-list' JoinPromptView = require './join-prompt-view' module.exports = activate: -> - presence = new Presence() sharingSession = new SharingSession() - buddyList = null - - rootView.command 'collaboration:toggle-buddy-list', -> - buddyList ?= new BuddyList(presence, sharingSession) - buddyList.toggle() rootView.command 'collaboration:copy-session-id', -> sessionId = sharingSession.getId() pasteboard.write(sessionId) if sessionId rootView.command 'collaboration:start-session', -> + new CollaborationView(sharingSession) if sessionId = sharingSession.start() pasteboard.write(sessionId) @@ -28,5 +22,3 @@ module.exports = resourcePath: window.resourcePath sessionId: id atom.openWindow(windowSettings) - - rootView.trigger 'collaboration:toggle-buddy-list' # TEMP diff --git a/src/packages/collaboration/lib/presence.coffee b/src/packages/collaboration/lib/presence.coffee deleted file mode 100644 index bf025aed2..000000000 --- a/src/packages/collaboration/lib/presence.coffee +++ /dev/null @@ -1,76 +0,0 @@ -guid = require 'guid' -$ = require 'jquery' -keytar = require 'keytar' -_ = require 'underscore' -Pusher = require '../vendor/pusher.js' - -module.exports = -class Presence - _.extend @prototype, require('event-emitter') - - people: null - personId: null - windowId: null - - constructor: -> - @people = {} - @windowId = guid.create().toString() - @connect() - - connect: -> - token = keytar.getPassword('github.com', 'github') - return unless token - - pusher = new Pusher '490be67c75616316d386', - encrypted: true - authEndpoint: 'https://fierce-caverns-8387.herokuapp.com/pusher/auth' - auth: - params: - oauth_token: token - channel = pusher.subscribe('presence-atom') - channel.bind 'pusher:subscription_succeeded', (members) => - console.log 'subscribed to presence channel' - @personId = members.me.id - event = id: @personId - event.window = id: @windowId - if git? - event.window.repository = - branch: git.getShortHead() - url: git.getConfigValue('remote.origin.url') - channel.trigger('client-window-opened', event) - - # List self as available for debugging UI when no one else is around - self = - id: @personId - user: members.me.info - windows: {} - self.windows[@windowId] = event.window - @people[self.id] = self - @trigger 'person-status-changed', self - - channel.bind 'pusher:member_added', (member) => - console.log 'member added', member - @people[member.id] = {user: member.info, windows: {}} - @trigger 'person-added', @people[member.id] - - channel.bind 'pusher:member_removed', (member) => - console.log 'member removed', member - @people.delete(member.id) - @trigger 'person-removed' - - channel.bind 'client-window-opened', (event) => - console.log 'window opened', event - if person = @people[event.id] - person.windows[event.window.id] = event.window - @trigger 'person-status-changed', person - - channel.bind 'client-window-closed', (event) => - console.log 'window closed', event - if person = @people[event.id] - delete person.windows[event.windowId] - @trigger 'person-status-changed', person - - $(window).on 'beforeunload', => - channel.trigger 'client-window-closed', {id: @personId, @windowId} - - getPeople: -> _.values(@people) diff --git a/src/packages/collaboration/stylesheets/collaboration.less b/src/packages/collaboration/stylesheets/collaboration.less index eff44e42f..c0e0aa047 100644 --- a/src/packages/collaboration/stylesheets/collaboration.less +++ b/src/packages/collaboration/stylesheets/collaboration.less @@ -1,42 +1,23 @@ @import "bootstrap/less/variables.less"; @import "octicon-mixins.less"; +@runningColor: #99CC99; -.buddy-list { + +.collaboration { @item-line-height: @line-height-base * 1.25; padding: 10px; -webkit-user-select: none; cursor: pointer; - .buddy-name { - line-height: 30px; - margin-bottom: 5px; - - .avatar { - border-radius: 3px; - height: 30px; - width: 30px; - float: left; - margin-right: 5px; - } + .share { + .mini-icon(notifications); } - .repo-name { - margin-left: 5px; - line-height: @item-line-height; - .mini-icon(public-repo); + .running { + color: @runningColor; - span { - padding-left: 5px; - } - } - - .branch-name { - margin-left: 5px; - line-height: @item-line-height; - .mini-icon(branch); - - span { - padding-left: 5px; + &:hover { + color: lighten(@runningColor, 15%); } } } diff --git a/themes/atom-dark-ui/buddy-list.less b/themes/atom-dark-ui/buddy-list.less index b3f0a1862..c63508993 100644 --- a/themes/atom-dark-ui/buddy-list.less +++ b/themes/atom-dark-ui/buddy-list.less @@ -1,4 +1,4 @@ -.buddy-list { +.collaboration { background: #1b1c1e; box-shadow: 1px 0 0 #131516,