Skip to content

Commit

Permalink
feat: Save Config And Restart button visibility toggle (#775)
Browse files Browse the repository at this point in the history
Signed-off-by: Pedro Lamas <[email protected]>
  • Loading branch information
pedrolamas authored Jul 18, 2022
1 parent 6c6c475 commit 869a580
Show file tree
Hide file tree
Showing 5 changed files with 37 additions and 3 deletions.
6 changes: 5 additions & 1 deletion src/components/layout/AppBar.vue
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@

<div class="toolbar-supplemental">
<div
v-if="socketConnected && klippyReady && authenticated && saveConfigPending"
v-if="socketConnected && klippyReady && authenticated && showSaveConfigAndRestart && saveConfigPending"
class="mr-1"
>
<app-save-config-and-restart-btn
Expand Down Expand Up @@ -215,6 +215,10 @@ export default class AppBar extends Mixins(StateMixin, ServicesMixin) {
return (this.$store.state.config.layoutMode)
}
get showSaveConfigAndRestart (): boolean {
return this.$store.state.config.uiSettings.general.showSaveConfigAndRestart
}
get topNavPowerToggle (): null | string {
return this.$store.state.config.uiSettings.general.topNavPowerToggle
}
Expand Down
31 changes: 29 additions & 2 deletions src/components/settings/GeneralSettings.vue
Original file line number Diff line number Diff line change
Expand Up @@ -115,15 +115,30 @@
<v-divider />

<app-setting
:title="$t('app.setting.label.confirm_on_save_config_and_restart')"
:title="$t('app.setting.label.show_save_config_and_restart')"
>
<v-switch
v-model="confirmOnSaveConfigAndRestart"
v-model="showSaveConfigAndRestart"
hide-details
class="mb-5"
@click.native.stop
/>
</app-setting>

<template v-if="showSaveConfigAndRestart">
<v-divider />

<app-setting
:title="$t('app.setting.label.confirm_on_save_config_and_restart')"
>
<v-switch
v-model="confirmOnSaveConfigAndRestart"
hide-details
class="mb-5"
@click.native.stop
/>
</app-setting>
</template>
</v-card>
</div>
</template>
Expand Down Expand Up @@ -240,6 +255,18 @@ export default class GeneralSettings extends Mixins(StateMixin) {
})
}
get showSaveConfigAndRestart () {
return this.$store.state.config.uiSettings.general.showSaveConfigAndRestart
}
set showSaveConfigAndRestart (value: boolean) {
this.$store.dispatch('config/saveByPath', {
path: 'uiSettings.general.showSaveConfigAndRestart',
value,
server: true
})
}
get confirmOnSaveConfigAndRestart () {
return this.$store.state.config.uiSettings.general.confirmOnSaveConfigAndRestart
}
Expand Down
1 change: 1 addition & 0 deletions src/locales/en.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -457,6 +457,7 @@ app:
show_code_lens: Show CodeLens
show_rate_of_change: Show temperature rate of change
show_relative_humidity: Show relative humidity
show_save_config_and_restart: Save Config and Restart button in top navigation
starts_with: Starts with
theme_preset: Community preset
thermal_preset_gcode: GCode
Expand Down
1 change: 1 addition & 0 deletions src/store/config/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@ export const defaultState = (): ConfigState => {
showRateOfChange: false,
showRelativeHumidity: true,
showBarometricPressure: true,
showSaveConfigAndRestart: true,
flipConsoleLayout: false,
cameraFullscreenAction: 'embed',
topNavPowerToggle: null,
Expand Down
1 change: 1 addition & 0 deletions src/store/config/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@ export interface GeneralConfig {
showRateOfChange: boolean;
showRelativeHumidity: boolean;
showBarometricPressure: boolean;
showSaveConfigAndRestart: boolean;
flipConsoleLayout: boolean;
cameraFullscreenAction: CameraFullscreenAction;
topNavPowerToggle: null | string;
Expand Down

0 comments on commit 869a580

Please sign in to comment.