mirror of
https://github.com/hedgedoc/hedgedoc.git
synced 2024-11-28 16:11:00 -05:00
fix(settings): use correct name instead of hardcoded 'dark-mode'
Signed-off-by: Erik Michelson <github@erik.michelson.eu>
This commit is contained in:
parent
395305dcb7
commit
0a64b32024
9 changed files with 19 additions and 14 deletions
|
@ -16,6 +16,7 @@ export const IndentWithTabsSettingButtonGroup: React.FC = () => {
|
||||||
return (
|
return (
|
||||||
<OnOffButtonGroup
|
<OnOffButtonGroup
|
||||||
value={enabled}
|
value={enabled}
|
||||||
|
name={'settings-indent-with-tabs'}
|
||||||
onSelect={setEditorIndentWithTabs}
|
onSelect={setEditorIndentWithTabs}
|
||||||
overrideButtonOnI18nKey={'settings.editor.indentWithTabs.tabs'}
|
overrideButtonOnI18nKey={'settings.editor.indentWithTabs.tabs'}
|
||||||
overrideButtonOffI18nKey={'settings.editor.indentWithTabs.spaces'}
|
overrideButtonOffI18nKey={'settings.editor.indentWithTabs.spaces'}
|
||||||
|
|
|
@ -13,5 +13,5 @@ import React from 'react'
|
||||||
*/
|
*/
|
||||||
export const LigatureSettingButtonGroup: React.FC = () => {
|
export const LigatureSettingButtonGroup: React.FC = () => {
|
||||||
const enabled = useApplicationState((state) => state.editorConfig.ligatures)
|
const enabled = useApplicationState((state) => state.editorConfig.ligatures)
|
||||||
return <OnOffButtonGroup value={enabled} onSelect={setEditorLigatures} />
|
return <OnOffButtonGroup value={enabled} onSelect={setEditorLigatures} name={'settings-ligatures'} />
|
||||||
}
|
}
|
||||||
|
|
|
@ -13,5 +13,5 @@ import React from 'react'
|
||||||
*/
|
*/
|
||||||
export const LineWrappingSettingButtonGroup: React.FC = () => {
|
export const LineWrappingSettingButtonGroup: React.FC = () => {
|
||||||
const enabled = useApplicationState((state) => state.editorConfig.lineWrapping)
|
const enabled = useApplicationState((state) => state.editorConfig.lineWrapping)
|
||||||
return <OnOffButtonGroup value={enabled} onSelect={setEditorLineWrapping} />
|
return <OnOffButtonGroup value={enabled} onSelect={setEditorLineWrapping} name={'settings-line-wrapping'} />
|
||||||
}
|
}
|
||||||
|
|
|
@ -13,5 +13,5 @@ import React from 'react'
|
||||||
*/
|
*/
|
||||||
export const SmartPasteSettingButtonGroup: React.FC = () => {
|
export const SmartPasteSettingButtonGroup: React.FC = () => {
|
||||||
const enabled = useApplicationState((state) => state.editorConfig.smartPaste)
|
const enabled = useApplicationState((state) => state.editorConfig.smartPaste)
|
||||||
return <OnOffButtonGroup value={enabled} onSelect={setEditorSmartPaste} />
|
return <OnOffButtonGroup value={enabled} onSelect={setEditorSmartPaste} name={'settings-smart-paste'} />
|
||||||
}
|
}
|
||||||
|
|
|
@ -13,5 +13,5 @@ import React from 'react'
|
||||||
*/
|
*/
|
||||||
export const SpellcheckSettingButtonGroup: React.FC = () => {
|
export const SpellcheckSettingButtonGroup: React.FC = () => {
|
||||||
const enabled = useApplicationState((state) => state.editorConfig.spellCheck)
|
const enabled = useApplicationState((state) => state.editorConfig.spellCheck)
|
||||||
return <OnOffButtonGroup value={enabled} onSelect={setEditorSpellCheck} />
|
return <OnOffButtonGroup value={enabled} onSelect={setEditorSpellCheck} name={'settings-spell-check'} />
|
||||||
}
|
}
|
||||||
|
|
|
@ -13,5 +13,5 @@ import React from 'react'
|
||||||
*/
|
*/
|
||||||
export const SyncScrollSettingButtonGroup: React.FC = () => {
|
export const SyncScrollSettingButtonGroup: React.FC = () => {
|
||||||
const enabled = useApplicationState((state) => state.editorConfig.syncScroll)
|
const enabled = useApplicationState((state) => state.editorConfig.syncScroll)
|
||||||
return <OnOffButtonGroup value={enabled} onSelect={setEditorSyncScroll} />
|
return <OnOffButtonGroup value={enabled} onSelect={setEditorSyncScroll} name={'settings-sync-scroll'} />
|
||||||
}
|
}
|
||||||
|
|
|
@ -9,7 +9,7 @@ exports[`Settings On-Off Button Group accepts custom labels 1`] = `
|
||||||
<button
|
<button
|
||||||
class="btn btn-secondary"
|
class="btn btn-secondary"
|
||||||
data-testid="onOffButtonGroupOn"
|
data-testid="onOffButtonGroupOn"
|
||||||
name="dark-mode"
|
name="test"
|
||||||
title="test.custom-on"
|
title="test.custom-on"
|
||||||
type="radio"
|
type="radio"
|
||||||
>
|
>
|
||||||
|
@ -18,7 +18,7 @@ exports[`Settings On-Off Button Group accepts custom labels 1`] = `
|
||||||
<button
|
<button
|
||||||
class="btn btn-outline-secondary"
|
class="btn btn-outline-secondary"
|
||||||
data-testid="onOffButtonGroupOff"
|
data-testid="onOffButtonGroupOff"
|
||||||
name="dark-mode"
|
name="test"
|
||||||
title="test.custom-off"
|
title="test.custom-off"
|
||||||
type="radio"
|
type="radio"
|
||||||
>
|
>
|
||||||
|
@ -37,7 +37,7 @@ exports[`Settings On-Off Button Group can switch value 1`] = `
|
||||||
<button
|
<button
|
||||||
class="btn btn-outline-secondary"
|
class="btn btn-outline-secondary"
|
||||||
data-testid="onOffButtonGroupOn"
|
data-testid="onOffButtonGroupOn"
|
||||||
name="dark-mode"
|
name="test"
|
||||||
title="common.on"
|
title="common.on"
|
||||||
type="radio"
|
type="radio"
|
||||||
>
|
>
|
||||||
|
@ -46,7 +46,7 @@ exports[`Settings On-Off Button Group can switch value 1`] = `
|
||||||
<button
|
<button
|
||||||
class="btn btn-secondary"
|
class="btn btn-secondary"
|
||||||
data-testid="onOffButtonGroupOff"
|
data-testid="onOffButtonGroupOff"
|
||||||
name="dark-mode"
|
name="test"
|
||||||
title="common.off"
|
title="common.off"
|
||||||
type="radio"
|
type="radio"
|
||||||
>
|
>
|
||||||
|
@ -65,7 +65,7 @@ exports[`Settings On-Off Button Group can switch value 2`] = `
|
||||||
<button
|
<button
|
||||||
class="btn btn-secondary"
|
class="btn btn-secondary"
|
||||||
data-testid="onOffButtonGroupOn"
|
data-testid="onOffButtonGroupOn"
|
||||||
name="dark-mode"
|
name="test"
|
||||||
title="common.on"
|
title="common.on"
|
||||||
type="radio"
|
type="radio"
|
||||||
>
|
>
|
||||||
|
@ -74,7 +74,7 @@ exports[`Settings On-Off Button Group can switch value 2`] = `
|
||||||
<button
|
<button
|
||||||
class="btn btn-outline-secondary"
|
class="btn btn-outline-secondary"
|
||||||
data-testid="onOffButtonGroupOff"
|
data-testid="onOffButtonGroupOff"
|
||||||
name="dark-mode"
|
name="test"
|
||||||
title="common.off"
|
title="common.off"
|
||||||
type="radio"
|
type="radio"
|
||||||
>
|
>
|
||||||
|
|
|
@ -14,7 +14,7 @@ describe('Settings On-Off Button Group', () => {
|
||||||
let value = false
|
let value = false
|
||||||
const onSelect = (newValue: boolean) => (value = newValue)
|
const onSelect = (newValue: boolean) => (value = newValue)
|
||||||
|
|
||||||
const view = render(<OnOffButtonGroup value={value} onSelect={onSelect} />)
|
const view = render(<OnOffButtonGroup name={'test'} value={value} onSelect={onSelect} />)
|
||||||
expect(view.container).toMatchSnapshot()
|
expect(view.container).toMatchSnapshot()
|
||||||
const onButton = await screen.findByTestId('onOffButtonGroupOn')
|
const onButton = await screen.findByTestId('onOffButtonGroupOn')
|
||||||
await act<void>(() => {
|
await act<void>(() => {
|
||||||
|
@ -22,7 +22,7 @@ describe('Settings On-Off Button Group', () => {
|
||||||
})
|
})
|
||||||
expect(value).toBeTruthy()
|
expect(value).toBeTruthy()
|
||||||
|
|
||||||
view.rerender(<OnOffButtonGroup value={value} onSelect={onSelect} />)
|
view.rerender(<OnOffButtonGroup name={'test'} value={value} onSelect={onSelect} />)
|
||||||
expect(view.container).toMatchSnapshot()
|
expect(view.container).toMatchSnapshot()
|
||||||
const offButton = await screen.findByTestId('onOffButtonGroupOff')
|
const offButton = await screen.findByTestId('onOffButtonGroupOff')
|
||||||
await act<void>(() => {
|
await act<void>(() => {
|
||||||
|
@ -34,6 +34,7 @@ describe('Settings On-Off Button Group', () => {
|
||||||
it('accepts custom labels', () => {
|
it('accepts custom labels', () => {
|
||||||
const view = render(
|
const view = render(
|
||||||
<OnOffButtonGroup
|
<OnOffButtonGroup
|
||||||
|
name={'test'}
|
||||||
value={true}
|
value={true}
|
||||||
onSelect={() => {}}
|
onSelect={() => {}}
|
||||||
overrideButtonOnI18nKey={'test.custom-on'}
|
overrideButtonOnI18nKey={'test.custom-on'}
|
||||||
|
|
|
@ -16,6 +16,7 @@ enum OnOffState {
|
||||||
export interface OnOffButtonGroupProps {
|
export interface OnOffButtonGroupProps {
|
||||||
value: boolean
|
value: boolean
|
||||||
onSelect: (value: boolean) => void
|
onSelect: (value: boolean) => void
|
||||||
|
name: string
|
||||||
overrideButtonOnI18nKey?: string
|
overrideButtonOnI18nKey?: string
|
||||||
overrideButtonOffI18nKey?: string
|
overrideButtonOffI18nKey?: string
|
||||||
}
|
}
|
||||||
|
@ -25,12 +26,14 @@ export interface OnOffButtonGroupProps {
|
||||||
*
|
*
|
||||||
* @param onSelect callback that is executed if the on/off value has changed
|
* @param onSelect callback that is executed if the on/off value has changed
|
||||||
* @param value the current on/off value that should be visible
|
* @param value the current on/off value that should be visible
|
||||||
|
* @param name A unique name for the button group to allow the browser to distinguish between multiple ones
|
||||||
* @param overrideButtonOnI18nKey Set to override the i18n key for the on-button
|
* @param overrideButtonOnI18nKey Set to override the i18n key for the on-button
|
||||||
* @param overrideButtonOffI18nKey Set to override the i18n key for the off-button
|
* @param overrideButtonOffI18nKey Set to override the i18n key for the off-button
|
||||||
*/
|
*/
|
||||||
export const OnOffButtonGroup: React.FC<OnOffButtonGroupProps> = ({
|
export const OnOffButtonGroup: React.FC<OnOffButtonGroupProps> = ({
|
||||||
onSelect,
|
onSelect,
|
||||||
value,
|
value,
|
||||||
|
name,
|
||||||
overrideButtonOffI18nKey,
|
overrideButtonOffI18nKey,
|
||||||
overrideButtonOnI18nKey
|
overrideButtonOnI18nKey
|
||||||
}) => {
|
}) => {
|
||||||
|
@ -43,7 +46,7 @@ export const OnOffButtonGroup: React.FC<OnOffButtonGroupProps> = ({
|
||||||
)
|
)
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<ToggleButtonGroup type='radio' name='dark-mode' value={buttonGroupValue}>
|
<ToggleButtonGroup type='radio' name={name} value={buttonGroupValue}>
|
||||||
<SettingsToggleButton
|
<SettingsToggleButton
|
||||||
onSelect={onButtonSelect}
|
onSelect={onButtonSelect}
|
||||||
selected={buttonGroupValue === OnOffState.ON}
|
selected={buttonGroupValue === OnOffState.ON}
|
||||||
|
|
Loading…
Reference in a new issue