Skip to content
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

[Proposition] Allow user to reset setting to default values #630

Merged
merged 3 commits into from
Dec 18, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
1 change: 1 addition & 0 deletions src/client/fsharp/FantomasOnline/Model.fs
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ type Msg =
| ChangeMode of FantomasMode
| CopySettings
| UpdateSettingsFilter of string
| ResetSettings

[<RequireQualifiedAccess>]
type FantomasTabState =
Expand Down
8 changes: 8 additions & 0 deletions src/client/fsharp/FantomasOnline/State.fs
Original file line number Diff line number Diff line change
Expand Up @@ -196,6 +196,14 @@ let update isActiveTab (bubble: BubbleModel) msg model =
UserOptions = userOptions
State = FantomasTabState.OptionsLoaded },
cmd

| ResetSettings ->
showSuccess "Settings reset to default values"

{ model with
UserOptions = optionsListToMap model.DefaultOptions },
Cmd.none

| Format ->
let cmd =
Cmd.batch
Expand Down
10 changes: 10 additions & 0 deletions src/client/fsharp/FantomasOnline/View.fs
Original file line number Diff line number Diff line change
Expand Up @@ -341,11 +341,21 @@ let settings isFsi model dispatch =
]
]

let resetSettings =
div [ ClassName Style.ResetSettings ] [
button [ ClassName Style.Secondary; OnClick(fun _ -> ResetSettings |> dispatch) ] [
str "Reset settings"
]
]

fragment [] [
VersionBar.versionBar (sprintf "Version: %s" model.Version)
fantomasMode
fileExtension
hr []
if userChangedSettings model then
nojaf marked this conversation as resolved.
Show resolved Hide resolved
resetSettings
hr []
searchBox
options
]
Expand Down
8 changes: 8 additions & 0 deletions src/client/src/styles/style.css
Original file line number Diff line number Diff line change
Expand Up @@ -787,6 +787,14 @@ nav > div #docs-btn .long-text {
margin: 0;
}

.reset-settings {
display: flex;
}

.reset-settings > button {
margin: auto;
}

/* dark mode */
@media (prefers-color-scheme: dark) {
:root {
Expand Down
Loading