Skip to content
This repository was archived by the owner on Dec 15, 2022. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 14 additions & 1 deletion lib/views/push-pull-menu-view.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ export default class PushPullMenuView {
this.push = this.push.bind(this)
this.pull = this.pull.bind(this)
this.fetch = this.fetch.bind(this)
this.inProgress = false
etch.initialize(this)
}

Expand All @@ -31,7 +32,7 @@ export default class PushPullMenuView {

render () {
return (
<div className='git-PushPullMenuView'>
<div className={'git-PushPullMenuView' + (this.inProgress ? ' in-progress' : '')}>
<div className='git-PushPullMenuView-selector'>
<span className='git-PushPullMenuView-item icon icon-mark-github'/>
<button className='git-PushPullMenuView-item btn' ref='fetchButton' onclick={this.fetch} disabled={!this.props.remoteName}>Fetch</button>
Expand All @@ -55,26 +56,36 @@ export default class PushPullMenuView {
}

async fetch () {
this.inProgress = true
etch.update(this)
try {
await this.props.fetch()
} catch (error) {
if (!(error instanceof GitError)) throw error
this.errorMessage = error.stdErr
} finally {
this.inProgress = false
return etch.update(this)
}
}

async pull () {
this.inProgress = true
etch.update(this)
try {
await this.props.pull()
} catch (error) {
if (!(error instanceof GitError)) throw error
this.errorMessage = error.stdErr
} finally {
this.inProgress = false
return etch.update(this)
}
}

async push (event) {
this.inProgress = true
etch.update(this)
try {
await this.props.push({force: event.metaKey, setUpstream: !this.props.remoteName})
} catch (error) {
Expand All @@ -84,6 +95,8 @@ export default class PushPullMenuView {
} else {
this.errorMessage = error.stdErr
}
} finally {
this.inProgress = false
return etch.update(this)
}
}
Expand Down
35 changes: 35 additions & 0 deletions styles/push-pull-menu-view.less
Original file line number Diff line number Diff line change
Expand Up @@ -51,4 +51,39 @@
display: none;
}
}


// Progress indicator
&.in-progress {
.icon-mark-github {
position: relative;
color: @text-color;
&:before {
color: inherit;
}
&:after {
content: "";
position: absolute;
top: -4px;
left: -4px;
width: 24px;
height: 24px;
border-top: 2px dotted;
border-right: 2px dotted;
border-bottom: 2px dotted transparent;
border-radius: 16px;

// To limit CPU usage, the animation plays for some time at normal speed,
// then slows down frame-rate for a while and stops at some point
-webkit-animation: git-PushPullMenuView-animation 2s linear 12,
git-PushPullMenuView-animation 4s 24s steps(12) 100;
}
}
}
}


// Animations
@-webkit-keyframes git-PushPullMenuView-animation {
100% { transform: rotate(360deg); }
}
3 changes: 2 additions & 1 deletion test/controllers/status-bar-tile-controller.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -275,7 +275,8 @@ describe('StatusBarTileController', () => {
assert.equal(pullButton.textContent, 'Pull (2)')

pushButton.dispatchEvent(new MouseEvent('click'))
await etch.getScheduler().getNextUpdatePromise()
await etch.getScheduler().getNextUpdatePromise() // update for loading
await etch.getScheduler().getNextUpdatePromise() // update for error message
assert.match(message.innerHTML, /Push rejected/)

pushButton.dispatchEvent(new MouseEvent('click', {metaKey: true}))
Expand Down