-
Notifications
You must be signed in to change notification settings - Fork 9.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #12000 from desktop/repository-alias
- Loading branch information
Showing
13 changed files
with
223 additions
and
9 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
78 changes: 78 additions & 0 deletions
78
app/src/ui/change-repository-alias/change-repository-alias-dialog.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,78 @@ | ||
import * as React from 'react' | ||
|
||
import { Dispatcher } from '../dispatcher' | ||
import { nameOf, Repository } from '../../models/repository' | ||
import { Dialog, DialogContent, DialogFooter } from '../dialog' | ||
import { OkCancelButtonGroup } from '../dialog/ok-cancel-button-group' | ||
import { TextBox } from '../lib/text-box' | ||
|
||
interface IChangeRepositoryAliasProps { | ||
readonly dispatcher: Dispatcher | ||
readonly onDismissed: () => void | ||
readonly repository: Repository | ||
} | ||
|
||
interface IChangeRepositoryAliasState { | ||
readonly newAlias: string | ||
} | ||
|
||
export class ChangeRepositoryAlias extends React.Component< | ||
IChangeRepositoryAliasProps, | ||
IChangeRepositoryAliasState | ||
> { | ||
public constructor(props: IChangeRepositoryAliasProps) { | ||
super(props) | ||
|
||
this.state = { newAlias: props.repository.alias ?? props.repository.name } | ||
} | ||
|
||
public render() { | ||
const repository = this.props.repository | ||
const verb = repository.alias === null ? 'Create' : 'Change' | ||
|
||
return ( | ||
<Dialog | ||
id="change-repository-alias" | ||
title={ | ||
__DARWIN__ ? `${verb} Repository Alias` : `${verb} repository alias` | ||
} | ||
onDismissed={this.props.onDismissed} | ||
onSubmit={this.changeAlias} | ||
> | ||
<DialogContent> | ||
<p>Choose a new alias for the repository "{nameOf(repository)}". </p> | ||
<p> | ||
<TextBox | ||
value={this.state.newAlias} | ||
onValueChanged={this.onNameChanged} | ||
/> | ||
</p> | ||
{repository.gitHubRepository !== null && ( | ||
<p className="description"> | ||
This will not affect the original repository name on GitHub. | ||
</p> | ||
)} | ||
</DialogContent> | ||
|
||
<DialogFooter> | ||
<OkCancelButtonGroup | ||
okButtonText={__DARWIN__ ? `${verb} Alias` : `${verb} alias`} | ||
okButtonDisabled={this.state.newAlias.length === 0} | ||
/> | ||
</DialogFooter> | ||
</Dialog> | ||
) | ||
} | ||
|
||
private onNameChanged = (newAlias: string) => { | ||
this.setState({ newAlias }) | ||
} | ||
|
||
private changeAlias = () => { | ||
this.props.dispatcher.changeRepositoryAlias( | ||
this.props.repository, | ||
this.state.newAlias | ||
) | ||
this.props.onDismissed() | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.