-
Notifications
You must be signed in to change notification settings - Fork 9.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Preferences redesign #8813
Preferences redesign #8813
Changes from 19 commits
27532d8
b9be775
feddfad
be54b99
222b8b8
a397784
54eb1c9
74a6408
fe54a35
b89ecbd
a9b202b
a83f84a
e37b78b
77af3a4
ca3d5ba
211f5a0
14fd997
13e7516
ff7cd2c
c97f005
3c72edd
76afcf6
eeb0589
bc7c047
a60d295
4c5ac1d
a5454b0
d7bed4e
4cd70f2
7e50c7d
5bbc79d
3acdd9a
48d3a65
1a56994
77354a6
fe21309
f2aeb50
09e954c
8cee164
6d70d14
564be7f
79dc0d4
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,7 @@ | ||
export enum PreferencesTab { | ||
Accounts = 0, | ||
Git = 1, | ||
Appearance = 2, | ||
Advanced = 3, | ||
Integrations = 1, | ||
Git = 2, | ||
Appearance = 3, | ||
Advanced = 4, | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,11 +1,15 @@ | ||
import { IStashEntry } from './stash-entry' | ||
import { assertNever } from '../lib/fatal-error' | ||
|
||
export enum UncommittedChangesStrategyKind { | ||
AskForConfirmation = 'AskForConfirmation', | ||
StashOnCurrentBranch = 'StashOnCurrentBranch', | ||
MoveToNewBranch = 'MoveToNewBranch', | ||
} | ||
|
||
export const uncommittedChangesStrategyKindDefault: UncommittedChangesStrategyKind = | ||
UncommittedChangesStrategyKind.AskForConfirmation | ||
|
||
export type UncommittedChangesStrategy = | ||
| { kind: UncommittedChangesStrategyKind.AskForConfirmation } | ||
| { kind: UncommittedChangesStrategyKind.StashOnCurrentBranch } | ||
|
@@ -20,3 +24,25 @@ export const askToStash: UncommittedChangesStrategy = { | |
export const stashOnCurrentBranch: UncommittedChangesStrategy = { | ||
kind: UncommittedChangesStrategyKind.StashOnCurrentBranch, | ||
} | ||
export const moveToNewBranch: UncommittedChangesStrategy = { | ||
kind: UncommittedChangesStrategyKind.MoveToNewBranch, | ||
transientStashEntry: null, | ||
} | ||
|
||
export function getUncommittedChangesStrategy( | ||
kind: UncommittedChangesStrategyKind | ||
) { | ||
switch (kind) { | ||
case UncommittedChangesStrategyKind.AskForConfirmation: | ||
return askToStash | ||
case UncommittedChangesStrategyKind.MoveToNewBranch: | ||
return moveToNewBranch | ||
case UncommittedChangesStrategyKind.StashOnCurrentBranch: | ||
return stashOnCurrentBranch | ||
default: | ||
return assertNever( | ||
kind, | ||
`Unknown UncommittedChangesStrategyKind: ${kind}` | ||
) | ||
} | ||
} | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I have some concerns about this function, but I think the core of my concern is that it took me a while to figure out what it was doing. Perhaps documenting this to clarify that its primary purpose is to map a kind to an actual It feels to me like there's a simpler version of this overall approach, but I'm not sure what it is yet...Is the main reason this exists so that we can store an |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'd really like to avoid using
as
here, though I'm not sure of a good alternative approach yet.localStorage.getItem
can returnundefined
if the given key doesn't exist, and this implementation tells the compiler that 'undefined' is a validUncommittedChangesStrategyKind
, which will result in runtime errors.