mirror of
https://github.com/atom/atom.git
synced 2026-02-19 02:44:29 -05:00
Previously the status was fetched twice, once for if modified and once for if new. Now the flags are fetched once and Git now provides helpers to check the status flags directly for modified and new status.
48 lines
1.1 KiB
CoffeeScript
48 lines
1.1 KiB
CoffeeScript
{View} = require 'space-pen'
|
|
$ = require 'jquery'
|
|
Git = require 'git'
|
|
fs = require 'fs'
|
|
|
|
module.exports =
|
|
class FileView extends View
|
|
|
|
@content: ({file} = {}) ->
|
|
@li class: 'file entry', =>
|
|
@span file.getBaseName(), class: 'name', outlet: 'fileName'
|
|
@span '', class: 'highlight'
|
|
|
|
file: null
|
|
|
|
initialize: ({@file, @project} = {}) ->
|
|
@subscribe $(window), 'focus', => @updateStatus()
|
|
|
|
extension = fs.extension(@getPath())
|
|
if fs.isCompressedExtension(extension)
|
|
@fileName.addClass('compressed-icon')
|
|
else if fs.isImageExtension(extension)
|
|
@fileName.addClass('image-icon')
|
|
else if fs.isPdfExtension(extension)
|
|
@fileName.addClass('pdf-icon')
|
|
else
|
|
@fileName.addClass('text-icon')
|
|
|
|
@updateStatus()
|
|
|
|
updateStatus: ->
|
|
@removeClass('ignored modified new')
|
|
repo = @project.repo
|
|
return unless repo?
|
|
|
|
path = @getPath()
|
|
if repo.isPathIgnored(path)
|
|
@addClass('ignored')
|
|
else
|
|
status = repo.getPathStatus(path)
|
|
if repo.isStatusModified(status)
|
|
@addClass('modified')
|
|
else if repo.isStatusNew(status)
|
|
@addClass('new')
|
|
|
|
getPath: ->
|
|
@file.path
|