Skip to content

Add progressbar for Git Push and Git Commit #366

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Aug 16, 2018
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
6 changes: 6 additions & 0 deletions app/components/Git/actions.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import { createAction } from 'redux-actions'

import Clipboard from 'clipboard'
import i18n from 'utils/createI18n'
import statusBarState from '../StatusBar/state'

export const GIT_STATUS = 'GIT_STATUS'
export const updateStatus = createAction(GIT_STATUS)
Expand All @@ -14,6 +15,7 @@ export const GIT_UPDATE_COMMIT_MESSAGE = 'GIT_UPDATE_COMMIT_MESSAGE'
export const updateCommitMessage = createAction(GIT_UPDATE_COMMIT_MESSAGE)

export function commit () {
statusBarState.displayBar = true
return (dispatch, getState) => {
const GitState = getState().GitState
const stagedFiles = GitState.statusFiles.filter(file => file.isStaged)
Expand All @@ -23,6 +25,7 @@ export function commit () {
files: stagedFilesPathList,
message: GitState.commitMessage || initialCommitMessage,
}).then((filetreeDelta) => {
statusBarState.displayBar = false
if (filetreeDelta.code) {
notify({ notifyType: NOTIFY_TYPE.ERROR, message: filetreeDelta.msg });
return;
Expand Down Expand Up @@ -143,7 +146,9 @@ export function pull () {

export function push () {
return (dispatch) => {
statusBarState.displayBar = true
api.gitPushAll().then((res) => {
statusBarState.displayBar = false
if (res.nothingToPush) {
notify({ message: 'Git push fail: nothing to push.' });
return;
Expand All @@ -154,6 +159,7 @@ export function push () {
notify({ message: `Git push fail: ${res.updates[0].status}` });
}
}).catch((res) => {
statusBarState.displayBar = false
notify({ message: `Git push fail: ${res.response.data.msg}` })
})
}
Expand Down
4 changes: 4 additions & 0 deletions app/components/StatusBar/StatusBar.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import { observer } from 'mobx-react'
import languageState from 'components/Tab/LanguageClientState'
import configState from '../../config'
import UploadWidgets from './UploadWidgets'
import state from './state'

const StatusBar = observer(({ messages=[] }) => {
return (
Expand All @@ -19,6 +20,9 @@ const StatusBar = observer(({ messages=[] }) => {
<div className='status-messages'>
{messages.map(message => <div className='status-message'>{message}</div>)}
</div>
{state.displayBar && <div className='status-progress'>
<span></span>
</div>}
<div className='status-widget-container right'>
<EditorWidgets />
<GitBranchWidget ref={ com => window.refs.GitBranchWidget = com}
Expand Down
1 change: 1 addition & 0 deletions app/components/StatusBar/state.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import { observable, autorun } from 'mobx'

const state = observable({
messages: observable.map(),
displayBar: false,
uploadList: observable.map({
// 'aaa.txt': { percentCompleted: 0, size: 100020303 },
// 'bbb.txt': { percentCompleted: 50, size: 200020303 },
Expand Down
8 changes: 8 additions & 0 deletions app/styles/base-theme/styles/bars.styl
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,14 @@
.status-bar {
border-color: $base-border-color;
background-color: $base-top-menu-bar-background;

.status-progress {
span {
background-image: linear-gradient(135deg, rgba(0, 0, 0, .15) 25%, transparent 25%,
transparent 50%, rgba(0, 0, 0, .15) 50%, rgba(0, 0, 0, .15) 75%,
transparent 75%, transparent);
}
}
}

.breadcrumbs {
Expand Down
25 changes: 25 additions & 0 deletions app/styles/core-ui/StatusBar.styl
Original file line number Diff line number Diff line change
Expand Up @@ -64,4 +64,29 @@ $bar-height = 30px;
align-items: center;
}
}

.status-progress {
align-self: center;
flex-grow: 1;
display: flex;
justify-content: center;

span {
width: 10vw;
display: inline-block;
height: 5px;
border-radius: 3px;
background-size: 30px 30px;
animation: animate-stripes 3s linear infinite;
}
}
}

@keyframes animate-stripes {
0% {
background-position: 0 0;
}
100% {
background-position: 60px 0;
}
}
8 changes: 8 additions & 0 deletions app/styles/dark/styles/bars.styl
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,14 @@
background-color: $base-background-color;
color: $text-color;
}

.status-progress {
span {
background-image: linear-gradient(135deg, rgba(255, 255, 255, .15) 25%, transparent 25%,
transparent 50%, rgba(255, 255, 255, .15) 50%, rgba(255, 255, 255, .15) 75%,
transparent 75%, transparent);
}
}
}

.breadcrumbs {
Expand Down