Skip to content
Snippets Groups Projects
Commit 08474936 authored by Lauri Himanen's avatar Lauri Himanen
Browse files

Merge branch '1407-question-nomad-yaml-set-default-units-to-si' into 'develop'

Resolve "Question: nomad.yaml set default units to SI"

Closes #1407

See merge request !1192
parents 546983e8 476427b8
Branches
Tags
1 merge request!1192Resolve "Question: nomad.yaml set default units to SI"
Pipeline #161276 failed
...@@ -132,7 +132,7 @@ const UnitSelector = React.memo(({ ...@@ -132,7 +132,7 @@ const UnitSelector = React.memo(({
classes={{root: styles.systems}} classes={{root: styles.systems}}
> >
<FormLabel component="legend">Unit system</FormLabel> <FormLabel component="legend">Unit system</FormLabel>
<RadioGroup aria-label="gender" name="gender1" value={units.label} onChange={handleSystemChange}> <RadioGroup name="unit-system" value={units.label} onChange={handleSystemChange}>
{Object.values(unitSystems).map(system => { {Object.values(unitSystems).map(system => {
return <Tooltip key={system.label} title={system.description}> return <Tooltip key={system.label} title={system.description}>
<FormControlLabel value={system.label} control={<Radio />} label={system.label} /> <FormControlLabel value={system.label} control={<Radio />} label={system.label} />
......
/*
* Copyright The NOMAD Authors.
*
* This file is part of NOMAD. See https://nomad-lab.eu for further info.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import React from 'react'
import { renderNoAPI, screen } from './conftest.spec'
import userEvent from '@testing-library/user-event'
import UnitSelector from './UnitSelector'
test('initial unit selection is read correctly from config', async () => {
const selection = window.nomadEnv.ui.unit_systems.selected
renderNoAPI(<UnitSelector />)
const button = screen.getByButtonText("Units")
await userEvent.click(button)
const optionSI = screen.getByLabelText(selection)
expect(optionSI).toBeChecked()
})
...@@ -194,7 +194,7 @@ for (const [systemName, system] of Object.entries(unitSystems)) { ...@@ -194,7 +194,7 @@ for (const [systemName, system] of Object.entries(unitSystems)) {
// A state containing the currently configured unit system. // A state containing the currently configured unit system.
export const unitsState = atom({ export const unitsState = atom({
key: 'units', key: 'units',
default: unitSystems[ui?.unitsystems?.selected || 'Custom'] || unitSystems.Custom default: unitSystems[ui?.unit_systems?.selected || 'Custom'] || unitSystems.Custom
}) })
/** /**
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment