"Fossies" - the Fresh Open Source Software Archive  

Source code changes of the file "app/src/ui/repositories-list/repository-list-item.tsx" between
desktop-release-2.7.2-linux1.tar.gz and desktop-release-2.8.0-linux1.tar.gz

About: GitHub Desktop (Linux) is an open source Electron-based GitHub app. It is written in TypeScript and uses React. A fork of GitHub Desktop to support various Linux distributions. Release candidate.

repository-list-item.tsx  (desktop-release-2.7.2-linux1):repository-list-item.tsx  (desktop-release-2.8.0-linux1)
skipping to change at line 14 skipping to change at line 14
import { showContextualMenu } from '../main-process-proxy' import { showContextualMenu } from '../main-process-proxy'
import { Repositoryish } from './group-repositories' import { Repositoryish } from './group-repositories'
import { IMenuItem } from '../../lib/menu-item' import { IMenuItem } from '../../lib/menu-item'
import { HighlightText } from '../lib/highlight-text' import { HighlightText } from '../lib/highlight-text'
import { IMatches } from '../../lib/fuzzy-find' import { IMatches } from '../../lib/fuzzy-find'
import { IAheadBehind } from '../../models/branch' import { IAheadBehind } from '../../models/branch'
import { import {
RevealInFileManagerLabel, RevealInFileManagerLabel,
DefaultEditorLabel, DefaultEditorLabel,
} from '../lib/context-menu' } from '../lib/context-menu'
import { enableRepositoryAliases } from '../../lib/feature-flag'
import classNames from 'classnames'
interface IRepositoryListItemProps { interface IRepositoryListItemProps {
readonly repository: Repositoryish readonly repository: Repositoryish
/** Whether the user has enabled the setting to confirm removing a repository from the app */ /** Whether the user has enabled the setting to confirm removing a repository from the app */
readonly askForConfirmationOnRemoveRepository: boolean readonly askForConfirmationOnRemoveRepository: boolean
/** Called when the repository should be removed. */ /** Called when the repository should be removed. */
readonly onRemoveRepository: (repository: Repositoryish) => void readonly onRemoveRepository: (repository: Repositoryish) => void
/** Called when the repository should be shown in Finder/Explorer/File Manager . */ /** Called when the repository should be shown in Finder/Explorer/File Manager . */
readonly onShowRepository: (repository: Repositoryish) => void readonly onShowRepository: (repository: Repositoryish) => void
/** Called when the repository should be shown in the shell. */ /** Called when the repository should be shown in the shell. */
readonly onOpenInShell: (repository: Repositoryish) => void readonly onOpenInShell: (repository: Repositoryish) => void
/** Called when the repository should be opened in an external editor */ /** Called when the repository should be opened in an external editor */
readonly onOpenInExternalEditor: (repository: Repositoryish) => void readonly onOpenInExternalEditor: (repository: Repositoryish) => void
/** Called when the repository alias should be changed */
readonly onChangeRepositoryAlias: (repository: Repository) => void
/** Called when the repository alias should be removed */
readonly onRemoveRepositoryAlias: (repository: Repository) => void
/** The current external editor selected by the user */ /** The current external editor selected by the user */
readonly externalEditorLabel?: string readonly externalEditorLabel?: string
/** Does the repository need to be disambiguated in the list? */ /** Does the repository need to be disambiguated in the list? */
readonly needsDisambiguation: boolean readonly needsDisambiguation: boolean
/** The label for the user's preferred shell. */ /** The label for the user's preferred shell. */
readonly shellLabel: string readonly shellLabel: string
/** The characters in the repository name to highlight */ /** The characters in the repository name to highlight */
skipping to change at line 64 skipping to change at line 72
IRepositoryListItemProps, IRepositoryListItemProps,
{} {}
> { > {
public render() { public render() {
const repository = this.props.repository const repository = this.props.repository
const path = repository.path const path = repository.path
const gitHubRepo = const gitHubRepo =
repository instanceof Repository ? repository.gitHubRepository : null repository instanceof Repository ? repository.gitHubRepository : null
const hasChanges = this.props.changedFilesCount > 0 const hasChanges = this.props.changedFilesCount > 0
const repoTooltip = gitHubRepo const alias: string | null =
? gitHubRepo.fullName + '\n' + gitHubRepo.htmlURL + '\n' + path repository instanceof Repository ? repository.alias : null
: path
const repoTooltipComponents = gitHubRepo
? [gitHubRepo.fullName, gitHubRepo.htmlURL, path]
: [path]
if (alias !== null) {
repoTooltipComponents.unshift(alias)
}
const repoTooltip = repoTooltipComponents.join('\n')
let prefix: string | null = null let prefix: string | null = null
if (this.props.needsDisambiguation && gitHubRepo) { if (this.props.needsDisambiguation && gitHubRepo) {
prefix = `${gitHubRepo.owner.login}/` prefix = `${gitHubRepo.owner.login}/`
} }
const classNameList = classNames('name', {
alias: alias !== null,
})
return ( return (
<div <div
onContextMenu={this.onContextMenu} onContextMenu={this.onContextMenu}
className="repository-list-item" className="repository-list-item"
title={repoTooltip} title={repoTooltip}
> >
<Octicon <Octicon
className="icon-for-repository" className="icon-for-repository"
symbol={iconForRepository(repository)} symbol={iconForRepository(repository)}
/> />
<div className="name">
<div className={classNames(classNameList)}>
{prefix ? <span className="prefix">{prefix}</span> : null} {prefix ? <span className="prefix">{prefix}</span> : null}
<HighlightText <HighlightText
text={repository.name} text={alias ?? repository.name}
highlight={this.props.matches.title} highlight={this.props.matches.title}
/> />
</div> </div>
{repository instanceof Repository && {repository instanceof Repository &&
renderRepoIndicators({ renderRepoIndicators({
aheadBehind: this.props.aheadBehind, aheadBehind: this.props.aheadBehind,
hasChanges: hasChanges, hasChanges: hasChanges,
})} })}
</div> </div>
skipping to change at line 124 skipping to change at line 146
private onContextMenu = (event: React.MouseEvent<any>) => { private onContextMenu = (event: React.MouseEvent<any>) => {
event.preventDefault() event.preventDefault()
const repository = this.props.repository const repository = this.props.repository
const missing = repository instanceof Repository && repository.missing const missing = repository instanceof Repository && repository.missing
const openInExternalEditor = this.props.externalEditorLabel const openInExternalEditor = this.props.externalEditorLabel
? `Open in ${this.props.externalEditorLabel}` ? `Open in ${this.props.externalEditorLabel}`
: DefaultEditorLabel : DefaultEditorLabel
const items: ReadonlyArray<IMenuItem> = [ const items: ReadonlyArray<IMenuItem> = [
...this.buildAliasMenuItems(),
{ {
label: `Open in ${this.props.shellLabel}`, label: `Open in ${this.props.shellLabel}`,
action: this.openInShell, action: this.openInShell,
enabled: !missing, enabled: !missing,
}, },
{ {
label: RevealInFileManagerLabel, label: RevealInFileManagerLabel,
action: this.showRepository, action: this.showRepository,
enabled: !missing, enabled: !missing,
}, },
skipping to change at line 147 skipping to change at line 170
enabled: !missing, enabled: !missing,
}, },
{ type: 'separator' }, { type: 'separator' },
{ {
label: this.props.askForConfirmationOnRemoveRepository label: this.props.askForConfirmationOnRemoveRepository
? 'Remove…' ? 'Remove…'
: 'Remove', : 'Remove',
action: this.removeRepository, action: this.removeRepository,
}, },
] ]
showContextualMenu(items) showContextualMenu(items)
} }
private buildAliasMenuItems(): ReadonlyArray<IMenuItem> {
const repository = this.props.repository
if (!(repository instanceof Repository) || !enableRepositoryAliases()) {
return []
}
const verb = repository.alias == null ? 'Create' : 'Change'
const items: Array<IMenuItem> = [
{
label: __DARWIN__ ? `${verb} Alias` : `${verb} alias`,
action: this.changeAlias,
},
]
if (repository.alias !== null) {
items.push({
label: __DARWIN__ ? 'Remove Alias' : 'Remove alias',
action: this.removeAlias,
})
}
items.push({ type: 'separator' })
return items
}
private removeRepository = () => { private removeRepository = () => {
this.props.onRemoveRepository(this.props.repository) this.props.onRemoveRepository(this.props.repository)
} }
private showRepository = () => { private showRepository = () => {
this.props.onShowRepository(this.props.repository) this.props.onShowRepository(this.props.repository)
} }
private openInShell = () => { private openInShell = () => {
this.props.onOpenInShell(this.props.repository) this.props.onOpenInShell(this.props.repository)
} }
private openInExternalEditor = () => { private openInExternalEditor = () => {
this.props.onOpenInExternalEditor(this.props.repository) this.props.onOpenInExternalEditor(this.props.repository)
} }
private changeAlias = () => {
if (this.props.repository instanceof Repository) {
this.props.onChangeRepositoryAlias(this.props.repository)
}
}
private removeAlias = () => {
if (this.props.repository instanceof Repository) {
this.props.onRemoveRepositoryAlias(this.props.repository)
}
}
} }
const renderRepoIndicators: React.FunctionComponent<{ const renderRepoIndicators: React.FunctionComponent<{
aheadBehind: IAheadBehind | null aheadBehind: IAheadBehind | null
hasChanges: boolean hasChanges: boolean
}> = props => { }> = props => {
return ( return (
<div className="repo-indicators"> <div className="repo-indicators">
{props.aheadBehind && renderAheadBehindIndicator(props.aheadBehind)} {props.aheadBehind && renderAheadBehindIndicator(props.aheadBehind)}
{props.hasChanges && renderChangesIndicator()} {props.hasChanges && renderChangesIndicator()}
 End of changes. 10 change blocks. 
5 lines changed or deleted 68 lines changed or added

Home  |  About  |  Features  |  All  |  Newest  |  Dox  |  Diffs  |  RSS Feeds  |  Screenshots  |  Comments  |  Imprint  |  Privacy  |  HTTP(S)