mirror of
https://github.com/atom/atom.git
synced 2026-01-22 21:38:10 -05:00
Add new status icon to status bar
This commit is contained in:
committed by
Corey Johnson
parent
be533d4342
commit
3772a4ce1b
@@ -125,11 +125,14 @@ describe "StatusBar", ->
|
||||
|
||||
beforeEach ->
|
||||
path = require.resolve('fixtures/git/working-dir/file.txt')
|
||||
newPath = fs.join(require.resolve('fixtures/git/working-dir'), 'new.txt')
|
||||
fs.write(newPath, "I'm new here")
|
||||
originalPathText = fs.read(path)
|
||||
rootView.attachToDom()
|
||||
|
||||
afterEach ->
|
||||
fs.write(path, originalPathText)
|
||||
fs.remove(newPath) if fs.exists(newPath)
|
||||
|
||||
it "displays the modified icon for a changed file", ->
|
||||
fs.write(path, "i've changed for the worse")
|
||||
@@ -139,3 +142,7 @@ describe "StatusBar", ->
|
||||
it "doesn't display the modified icon for an unchanged file", ->
|
||||
rootView.open(path)
|
||||
expect(statusBar.gitStatusIcon).toBeHidden()
|
||||
|
||||
it "displays the new icon for a new file", ->
|
||||
rootView.open(newPath)
|
||||
expect(statusBar.gitStatusIcon).toBeVisible()
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
{View} = require 'space-pen'
|
||||
_ = require 'underscore'
|
||||
{View, $$} = require 'space-pen'
|
||||
Git = require 'git'
|
||||
|
||||
module.exports =
|
||||
@@ -20,7 +20,7 @@ class StatusBar extends View
|
||||
@content: ->
|
||||
@div class: 'status-bar', =>
|
||||
@div class: 'file-info', =>
|
||||
@span '\uf252', class: 'octicons git-status', outlet: 'gitStatusIcon'
|
||||
@span class: 'octicons git-status', outlet: 'gitStatusIcon'
|
||||
@span class: 'current-path', outlet: 'currentPath'
|
||||
@span class: 'buffer-modified', outlet: 'bufferModified'
|
||||
@div class: 'cursor-position', =>
|
||||
@@ -71,13 +71,17 @@ class StatusBar extends View
|
||||
@branchArea.hide()
|
||||
|
||||
updateStatusText: ->
|
||||
if path = @editor.getPath()
|
||||
modified = new Git(path).isPathModified(path)
|
||||
@gitStatusIcon.empty().hide()
|
||||
path = @editor.getPath()
|
||||
return unless path
|
||||
|
||||
if modified
|
||||
git = new Git(path)
|
||||
if git.isPathModified(path)
|
||||
@gitStatusIcon.append $$ -> @span '\uf26d', class: 'modified-status-icon'
|
||||
@gitStatusIcon.show()
|
||||
else if git.isPathNew(path)
|
||||
@gitStatusIcon.append $$ -> @span '\uf26b', class: 'new-status-icon'
|
||||
@gitStatusIcon.show()
|
||||
else
|
||||
@gitStatusIcon.hide()
|
||||
|
||||
updatePathText: ->
|
||||
if path = @editor.getPath()
|
||||
|
||||
@@ -16,8 +16,12 @@
|
||||
top: 5px;
|
||||
}
|
||||
|
||||
.status-bar .file-info .git-status {
|
||||
color: #FAF05C;
|
||||
.status-bar .file-info .modified-status-icon {
|
||||
color: #6C6912;
|
||||
}
|
||||
|
||||
.status-bar .file-info .new-status-icon {
|
||||
color: #269F81;
|
||||
}
|
||||
|
||||
.status-bar .octicons {
|
||||
@@ -25,7 +29,7 @@
|
||||
font-size: 14px;
|
||||
width: 14px;
|
||||
height: 14px;
|
||||
padding-right: 2px;
|
||||
padding-right: 5px;
|
||||
}
|
||||
|
||||
.status-bar .branch-label {
|
||||
|
||||
Reference in New Issue
Block a user