Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
51 commits
Select commit Hold shift + click to select a range
635a13e
:art: cleanup
niik Sep 5, 2019
9d9c78f
Don't need this wrapper
niik Sep 5, 2019
97597f4
Add initial tutorial button
niik Sep 5, 2019
854ab78
Initial take on repo initialization and publishing
niik Sep 6, 2019
2b0b5fb
Add the repository after creating and publishing
niik Sep 6, 2019
4df67ed
Auth tho
niik Sep 9, 2019
053592d
Move creation logic into a dialog
niik Sep 9, 2019
e5c332f
Whoops
niik Sep 9, 2019
dae189e
Loading state
niik Sep 9, 2019
09af0af
Initial error wiring
niik Sep 9, 2019
d59b9c5
:book:
niik Sep 9, 2019
c4e1f44
Play it safe
niik Sep 9, 2019
a79528d
A description
niik Sep 9, 2019
5aed05a
Handle errors
niik Sep 9, 2019
e05428f
Feature flag it
niik Sep 9, 2019
e9981c1
Just a lil' bit of context
niik Sep 9, 2019
1b1afb8
:art: extract
niik Sep 9, 2019
7d868c4
Include the message specifically
niik Sep 9, 2019
0438a86
Fail fast for now
niik Sep 9, 2019
8c1bd2f
Keep Git errors as-is
niik Sep 9, 2019
7564bfb
Update create-tutorial-repository-dialog.tsx
niik Sep 9, 2019
f9a5b62
Fail nicely if the path already exists
niik Sep 9, 2019
aaa5846
We'll get better error messages from init
niik Sep 9, 2019
3c47411
:art:
niik Sep 9, 2019
d6b95e3
face, meet palm
niik Sep 9, 2019
531511d
Perhaps not
niik Sep 9, 2019
9ca6b44
Render some initial progress
niik Sep 9, 2019
c1fbf69
Moar progress
niik Sep 9, 2019
2e1dea9
Push progress
niik Sep 9, 2019
acfea1e
Some styling
niik Sep 9, 2019
909ea74
Use update instead of put
niik Sep 9, 2019
76948f1
Add specialized method for adding a tutorial repository
niik Sep 9, 2019
5a706c5
Whoops, need this
niik Sep 9, 2019
75ddb0a
Persist isTutorialRepository
niik Sep 9, 2019
3573513
Whoopsie, that could have been bad
niik Sep 9, 2019
6053031
:book: addTutorialRepository
niik Sep 10, 2019
a843bdd
:art:
niik Sep 10, 2019
c17933a
:book: addTutorialRepository in dispatcher and app store
niik Sep 10, 2019
64867bd
:book: tis a lie
niik Sep 10, 2019
4128d9c
:book: more docs
niik Sep 10, 2019
258bbd6
:art: shuffle around
niik Sep 10, 2019
a899e61
:art: cleanup
niik Sep 10, 2019
5a61f0e
:book: params
niik Sep 10, 2019
e58bbdc
Merge branch 'development' into tutorial-entry-point
niik Sep 10, 2019
c81eda2
:art: Extract push into its own method
niik Sep 10, 2019
5337b2e
:art: cleanup
niik Sep 10, 2019
9645eae
Thought I had committed this
niik Sep 10, 2019
d6d0c8d
Merge branch 'development' into tutorial-entry-point
niik Sep 10, 2019
6546349
Update app/src/ui/blank-slate/create-tutorial-repository-dialog.tsx
niik Sep 16, 2019
66e75fc
Clarify docs
niik Sep 16, 2019
12f3f07
Merge branch 'development' into tutorial-entry-point
niik Sep 16, 2019
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
8 changes: 8 additions & 0 deletions app/src/lib/databases/repositories-database.ts
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,14 @@ export interface IDatabaseRepository {

/** The last time the stash entries were checked for the repository */
readonly lastStashCheckDate: number | null

/**
* True if the repository is a tutorial repository created as part
* of the onboarding flow. Tutorial repositories trigger a tutorial
* user experience which introduces new users to some core concepts
* of Git and GitHub.
*/
readonly isTutorialRepository?: boolean
}

/**
Expand Down
37 changes: 36 additions & 1 deletion app/src/lib/stores/app-store.ts
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,7 @@ import {
getDotComAPIEndpoint,
IAPIOrganization,
IAPIBranch,
IAPIRepository,
} from '../api'
import { shell } from '../app-shell'
import {
Expand Down Expand Up @@ -3072,7 +3073,8 @@ export class AppStore extends TypedBaseStore<IAppState> {
repository.path,
repository.id,
skeletonGitHubRepository,
repository.missing
repository.missing,
false
)

const account = getAccountForEndpoint(
Expand Down Expand Up @@ -4527,6 +4529,39 @@ export class AppStore extends TypedBaseStore<IAppState> {
return this.repositoriesStore.updateRepositoryMissing(repository, missing)
}

/**
* Add a tutorial repository.
*
* This method differs from the `_addRepositories` method in that it
* requires that the repository has been created on the remote and
* set up to track it. Given that tutorial repositories are created
* from the no-repositories blank slate it shouldn't be possible for

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

from the no-repositories blank slate it shouldn't be possible for another repository with the same path to exist

Is it true that we could be in a no-repositories blank slate (ex: Desktop just installed) but the user could still have a repo with the tutorial name convention in their home folder...?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm sorry, what I meant was that it shouldn't be possible for another repository with the same path to exist in the repositories table given that the no-repositories blank slate is only ever shown when that table is empty. I'll clarify in the documentation.

* another repository with the same path to exist in the repositories
* table but in case that hanges in the future this method will set
* the tutorial flag on the existing repository at the given path.
*/
public async _addTutorialRepository(
path: string,
endpoint: string,
apiRepository: IAPIRepository
) {
const validatedPath = await validatedRepositoryPath(path)
if (validatedPath) {
log.info(
`[AppStore] adding tutorial repository at ${validatedPath} to store`
)

await this.repositoriesStore.addTutorialRepository(
validatedPath,
endpoint,
apiRepository
)
} else {
const error = new Error(`${path} isn't a git repository.`)
this.emitError(error)
}
}

public async _addRepositories(
paths: ReadonlyArray<string>
): Promise<ReadonlyArray<Repository>> {
Expand Down
86 changes: 57 additions & 29 deletions app/src/lib/stores/repositories-store.ts
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,8 @@ export class RepositoriesStore extends BaseStore {
repo.path,
repo.id!,
gitHubRepository,
repo.missing
repo.missing,
repo.isTutorialRepository
)
inflatedRepos.push(inflatedRepo)
}
Expand All @@ -134,6 +135,53 @@ export class RepositoriesStore extends BaseStore {
)
}

/**
* Add a tutorial repository.
*
* This method differs from the `addRepository` method in that it
* requires that the repository has been created on the remote and
* set up to track it. Given that tutorial repositories are created
* from the no-repositories blank slate it shouldn't be possible for
* another repository with the same path to exist but in case that
* changes in the future this method will set the tutorial flag on
* the existing repository at the given path.
*/
public async addTutorialRepository(
path: string,
endpoint: string,
apiRepository: IAPIRepository
) {
await this.db.transaction(
'rw',
this.db.repositories,
this.db.gitHubRepositories,
this.db.owners,
async () => {
const gitHubRepository = await this.upsertGitHubRepository(
endpoint,
apiRepository
)

const existingRepo = await this.db.repositories.get({ path })
const existingRepoId =
existingRepo && existingRepo.id !== null ? existingRepo.id : undefined

return await this.db.repositories.put(
{
path,
gitHubRepositoryID: gitHubRepository.dbID,
missing: false,
lastStashCheckDate: null,
isTutorialRepository: true,
},
existingRepoId
)
}
)

this.emitUpdate()
}

/**
* Add a new local repository.
*
Expand Down Expand Up @@ -196,28 +244,16 @@ export class RepositoriesStore extends BaseStore {
)
}

const gitHubRepositoryID = repository.gitHubRepository
? repository.gitHubRepository.dbID
: null
const oldRecord = await this.db.repositories.get(repoID)
const lastStashCheckDate =
oldRecord !== undefined ? oldRecord.lastStashCheckDate : null

await this.db.repositories.put({
id: repository.id,
path: repository.path,
missing,
gitHubRepositoryID,
lastStashCheckDate,
})
await this.db.repositories.update(repoID, { missing })

this.emitUpdate()

return new Repository(
repository.path,
repository.id,
repository.gitHubRepository,
missing
missing,
repository.isTutorialRepository
)
}

Expand All @@ -233,19 +269,9 @@ export class RepositoriesStore extends BaseStore {
)
}

const gitHubRepositoryID = repository.gitHubRepository
? repository.gitHubRepository.dbID
: null
const oldRecord = await this.db.repositories.get(repoID)
const lastStashCheckDate =
oldRecord !== undefined ? oldRecord.lastStashCheckDate : null

await this.db.repositories.put({
id: repository.id,
await this.db.repositories.update(repoID, {
missing: false,
path,
gitHubRepositoryID,
lastStashCheckDate,
})

this.emitUpdate()
Expand All @@ -254,7 +280,8 @@ export class RepositoriesStore extends BaseStore {
path,
repository.id,
repository.gitHubRepository,
false
false,
repository.isTutorialRepository
)
}

Expand Down Expand Up @@ -423,7 +450,8 @@ export class RepositoriesStore extends BaseStore {
repository.path,
repository.id,
updatedGitHubRepo,
repository.missing
repository.missing,
repository.isTutorialRepository
)
}

Expand Down
6 changes: 6 additions & 0 deletions app/src/models/popup.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import { WorkingDirectoryFileChange } from './status'
import { PreferencesTab } from './preferences'
import { ICommitContext } from './commit'
import { IStashEntry } from './stash-entry'
import { Account } from '../models/account'

export enum PopupType {
RenameBranch = 1,
Expand Down Expand Up @@ -49,6 +50,7 @@ export enum PopupType {
StashAndSwitchBranch,
ConfirmOverwriteStash,
ConfirmDiscardStash,
CreateTutorialRepository,
}

export type Popup =
Expand Down Expand Up @@ -195,3 +197,7 @@ export type Popup =
repository: Repository
stash: IStashEntry
}
| {
type: PopupType.CreateTutorialRepository
account: Account
}
19 changes: 9 additions & 10 deletions app/src/models/repository.ts
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,8 @@ export class Repository {
path: string,
public readonly id: number,
public readonly gitHubRepository: GitHubRepository | null,
public readonly missing: boolean
public readonly missing: boolean,
private readonly _isTutorialRepository?: boolean
) {
this.mainWorkTree = { path }
this.name = (gitHubRepository && gitHubRepository.name) || getBaseName(path)
Expand All @@ -56,19 +57,17 @@ export class Repository {
public get hash(): string {
return `${this.id}+${this.gitHubRepository && this.gitHubRepository.hash}+${
this.path
}+${this.missing}+${this.name}`
}+${this.missing}+${this.name}+${this.isTutorialRepository}`
}

/**
* Whether or not this repository is set up as the onboarding
* tutorial repository.
* True if the repository is a tutorial repository created as part
* of the onboarding flow. Tutorial repositories trigger a tutorial
* user experience which introduces new users to some core concepts
* of Git and GitHub.
*/
public get isTutorialRepository(): boolean {
return (
enableTutorial() &&
this.name.startsWith('desktop-tutorial') &&
this.gitHubRepository !== null
)
public get isTutorialRepository() {
return enableTutorial() && this._isTutorialRepository === true
}
}

Expand Down
50 changes: 49 additions & 1 deletion app/src/ui/app.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ import { updateStore, UpdateStatus } from './lib/update-store'
import { RetryAction } from '../models/retry-actions'
import { shouldRenderApplicationMenu } from './lib/features'
import { matchExistingRepository } from '../lib/repository-matching'
import { getDotComAPIEndpoint } from '../lib/api'
import { getDotComAPIEndpoint, IAPIRepository } from '../lib/api'
import { ILaunchStats, SamplesURL } from '../lib/stats'
import { getVersion, getName } from './lib/app-proxy'
import { getOS } from '../lib/get-os'
Expand Down Expand Up @@ -103,6 +103,8 @@ import { BannerType } from '../models/banner'
import { StashAndSwitchBranch } from './stash-changes/stash-and-switch-branch-dialog'
import { OverwriteStash } from './stash-changes/overwrite-stashed-changes-dialog'
import { ConfirmDiscardStashDialog } from './stashing/confirm-discard-stash'
import { CreateTutorialRepositoryDialog } from './blank-slate/create-tutorial-repository-dialog'
import { enableTutorial } from '../lib/feature-flag'

const MinuteInMilliseconds = 1000 * 60
const HourInMilliseconds = MinuteInMilliseconds * 60
Expand Down Expand Up @@ -679,6 +681,23 @@ export class App extends React.Component<IAppProps, IAppState> {
})
}

private onCreateTutorialRepository = () => {
if (!enableTutorial()) {
return
}

const account = this.getDotComAccount() || this.getEnterpriseAccount()

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What extra considerations are there for supporting enterprise accounts? #8148 (comment)

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I attempted to answer this in the referenced issue #8148 (comment)


if (account === null) {
return
}

this.props.dispatcher.showPopup({
type: PopupType.CreateTutorialRepository,
account,
})

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I noticed that we don't provide feedback to the users in the cases where we return early from this method. Which could mean we leave the user hanging in an confusing/awkward way.

It looks like for now we'll never return early from this (because account is null or enableTutorial is false) because we don't even display the button to create a tutorial repo if those conditions aren't met (https://github.com/desktop/desktop/pull/8244/files#diff-90d158a911410430c657d180c2557931R344-R355).

However, I'm wondering if it's still worth providing some feedback because there's always the chance that the code changes such that we hit these cases (ex: we add a keyboard shortcut). It could be worthwhile to display a message or something (ex: letting them know that they need to set up a dotcom or enterprise account) just for good measure.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It looks like for now we'll never return early from this (because account is null or enableTutorial is false) because we don't even display the button to create a tutorial repo if those conditions aren't met

Correct

I'm wondering if it's still worth providing some feedback because there's always the chance that the code changes such that we hit these cases (ex: we add a keyboard shortcut). It could be worthwhile to display a message or something (ex: letting them know that they need to set up a dotcom or enterprise account) just for good measure.

Yeah, this is always a balance that can be argued either way. In this case I'm happy with the risk as-is but if we end up adding a menu item or keyboard shortcut which itself is still enabled when the user isn't signed in I agree that we should add such a message.

Staying hypothetical here, if I were do to something to future-proof this it would be leveraging the type system to ensure that we don't call this method unless we do have an account. I'd do this by making a non-nullable Account instance a required parameter to this method and passing it along from the blank slate (where we do the initial assertion and type-narrowing on Account). For me to do that now, however, would require me to create a small wrapper component instead of the renderButtonGroupButton method which feels, to me, a bit overkill for the risk involved and the time pressure we're under to get the tutorial out on time.

}

private showAbout() {
this.props.dispatcher.showPopup({ type: PopupType.About })
}
Expand Down Expand Up @@ -1781,11 +1800,39 @@ export class App extends React.Component<IAppProps, IAppState> {
/>
)
}
case PopupType.CreateTutorialRepository: {
return (
<CreateTutorialRepositoryDialog
key="create-tutorial-repository-dialog"
account={popup.account}
onDismissed={this.onPopupDismissed}
onTutorialRepositoryCreated={this.onTutorialRepositoryCreated}
onError={this.onTutorialRepositoryError}
/>
)
}
default:
return assertNever(popup, `Unknown popup type: ${popup}`)
}
}

private onTutorialRepositoryError = (error: Error) => {
this.props.dispatcher.closePopup(PopupType.CreateTutorialRepository)
this.props.dispatcher.postError(error)
}

private onTutorialRepositoryCreated = (
path: string,
account: Account,
apiRepository: IAPIRepository
) => {
this.props.dispatcher.addTutorialRepository(
path,
account.endpoint,
apiRepository
)
}

private onShowRebaseConflictsBanner = (
repository: Repository,
targetBranch: string
Expand Down Expand Up @@ -2291,6 +2338,7 @@ export class App extends React.Component<IAppProps, IAppState> {
onCreate={this.showCreateRepository}
onClone={this.showCloneRepo}
onAdd={this.showAddLocalRepo}
onCreateTutorialRepository={this.onCreateTutorialRepository}
apiRepositories={this.state.apiRepositories}
onRefreshRepositories={this.onRefreshRepositories}
/>
Expand Down
Loading