Skip to content

Commit 9049e5d

Browse files
authored
Merge pull request #72 from devxoul/auto-enable-worktrees
Auto-enable worktrees setting from Show Worktrees List menu
2 parents 82595a4 + cac456e commit 9049e5d

3 files changed

Lines changed: 35 additions & 0 deletions

File tree

app/src/models/banner.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ export enum BannerType {
1717
SuccessfulReorder = 'SuccessfulReorder',
1818
ConflictsFound = 'ConflictsFound',
1919
OSVersionNoLongerSupported = 'OSVersionNoLongerSupported',
20+
WorktreesEnabled = 'WorktreesEnabled',
2021
}
2122

2223
export type Banner =
@@ -122,3 +123,4 @@ export type Banner =
122123
readonly onOpenConflictsDialog: () => void
123124
}
124125
| { readonly type: BannerType.OSVersionNoLongerSupported }
126+
| { readonly type: BannerType.WorktreesEnabled }

app/src/ui/app.tsx

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -966,6 +966,11 @@ export class App extends React.Component<IAppProps, IAppState> {
966966
return
967967
}
968968

969+
if (!this.state.showWorktrees) {
970+
this.props.dispatcher.setShowWorktrees(true)
971+
this.setBanner({ type: BannerType.WorktreesEnabled })
972+
}
973+
969974
if (
970975
this.state.currentFoldout &&
971976
this.state.currentFoldout.type === FoldoutType.Worktree

app/src/ui/banners/render-banner.tsx

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@ import * as React from 'react'
33
import { assertNever } from '../../lib/fatal-error'
44

55
import { Banner, BannerType } from '../../models/banner'
6+
import { PopupType } from '../../models/popup'
7+
import { PreferencesTab } from '../../models/preferences'
68

79
import { Dispatcher } from '../dispatcher'
810
import { MergeConflictsBanner } from './merge-conflicts-banner'
@@ -19,6 +21,7 @@ import { SuccessfulSquash } from './successful-squash'
1921
import { SuccessBanner } from './success-banner'
2022
import { ConflictsFoundBanner } from './conflicts-found-banner'
2123
import { OSVersionNoLongerSupportedBanner } from './os-version-no-longer-supported-banner'
24+
import { LinkButton } from '../lib/link-button'
2225

2326
export function renderBanner(
2427
banner: Banner,
@@ -171,6 +174,31 @@ export function renderBanner(
171174
)
172175
case BannerType.OSVersionNoLongerSupported:
173176
return <OSVersionNoLongerSupportedBanner onDismissed={onDismissed} />
177+
case BannerType.WorktreesEnabled: {
178+
const label = __DARWIN__
179+
? 'Appearance Settings'
180+
: 'Appearance Options'
181+
return (
182+
<SuccessBanner
183+
key="worktrees-enabled"
184+
timeout={8000}
185+
onDismissed={onDismissed}
186+
>
187+
Worktrees enabled. You can change this in{' '}
188+
<LinkButton
189+
onClick={() =>
190+
dispatcher.showPopup({
191+
type: PopupType.Preferences,
192+
initialSelectedTab: PreferencesTab.Appearance,
193+
})
194+
}
195+
>
196+
{label}
197+
</LinkButton>
198+
.
199+
</SuccessBanner>
200+
)
201+
}
174202
default:
175203
return assertNever(banner, `Unknown popup type: ${banner}`)
176204
}

0 commit comments

Comments
 (0)