-
Notifications
You must be signed in to change notification settings - Fork 70
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
feat: update codelist config design #14276
base: main
Are you sure you want to change the base?
Conversation
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #14276 +/- ##
=======================================
Coverage 95.52% 95.53%
=======================================
Files 1826 1830 +4
Lines 23757 23772 +15
Branches 2752 2752
=======================================
+ Hits 22695 22710 +15
Misses 807 807
Partials 255 255 ☔ View full report in Codecov by Sentry. |
…during onBlurAny and onClose no longer contains any logic.
Sorry for the late commit, i saw it when doing review of your code @standeren in this PR and thought it could be changed here as your PR is not related to the component itself |
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.
Nice cleanup, but I have some suggestions 🤗
frontend/language/src/nb.json
Outdated
@@ -1560,7 +1560,7 @@ | |||
"ux_editor.modal_new_option": "Legg til alternativ", | |||
"ux_editor.modal_properties_add_radio_button_options": "Hvordan vil du legge til radioknapper?", | |||
"ux_editor.modal_properties_code_list": "Velg fra biblioteket", | |||
"ux_editor.modal_properties_code_list_alert_title": "Du redigerer nå en kodeliste i biblioteket.", | |||
"ux_editor.modal_properties_code_list_alert_title": "Du er i ferd med å endre en kodeliste i biblioteket. Da endrer du også kodelisten for alle andre steder der den blir brukt.", |
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.
"ux_editor.modal_properties_code_list_alert_title": "Du er i ferd med å endre en kodeliste i biblioteket. Da endrer du også kodelisten for alle andre steder der den blir brukt.", | |
"ux_editor.modal_properties_code_list_alert_title": "Du er i ferd med å endre en kodeliste i biblioteket. Da endrer du også kodelisten alle andre steder der den blir brukt.", |
frontend/language/src/nb.json
Outdated
"ux_editor.options.multiple": "{{value}} alternativer", | ||
"ux_editor.options.option_edit_text": "Rediger kodeliste", | ||
"ux_editor.options.option_remove_text": "Fjern valgt kodeliste", | ||
"ux_editor.options.section_heading": "Valg for kodelister", | ||
"ux_editor.options.single": "{{value}} alternativ", | ||
"ux_editor.options.tab_code_list": "Velg kodeliste", | ||
"ux_editor.options.tab_code_list_alert_title": "Kan ikke åpne Velg kodeliste fordi det er oppgitt en ID på fanen Angi referanse-ID. Fjern denne referansen og gå tilbake for å velge kodeliste fra biblioteket.", |
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.
Should this text key maybe be ux_editor.options.tab_option_list_alert_title
?
} from '@studio/components'; | ||
import type { CodeListEditorTexts } from '@studio/components'; | ||
import { PencilIcon, TrashIcon } from '@studio/icons'; | ||
import { usePreviewContext } from 'app-development/contexts/PreviewContext'; |
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.
This one should not be imported from app-development. But we can create a separate PR that moves the usePreviewContext
into shared 👍
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 know this is not a part of your changes, but I still think it would be relevant to include in this PR;
I noticed that handleComponentChange
has a default value jest.fn()
when it should be defined in the top as a mock. And then I also discovered that there is no test that tests this property, which it should be 😄
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.
Hmm, in OptionTabs.tsx
handleComponentChange
is passed along to the child components and not used or altered. Which is a pattern in some files, could it be an option to make a context higher up in the structure to not require prop drilling as much?
It eventually goes all the way up to Text.tsx
, but placing the context there would make the context very large
/> | ||
); | ||
} else { |
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.
All these conditions should not be in the success
case from the optionListQuery as only the LibraryOptionEditor
is depending on it.
const codeListLabels: string = localOptionList | ||
.slice(0, 3) | ||
.map((option: Option) => `${option.label}`) | ||
.join(' | '); |
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.
Same comment here as for the manualOtpions
const { org, app } = useStudioEnvironmentParams(); | ||
const { doReloadPreview } = usePreviewContext(); | ||
const { mutate: updateOptionList } = useUpdateOptionListMutation(org, app); | ||
const [localOptionList, setLocalOptionList] = useState<Option[]>(optionsList); |
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.
Is this state necessary?
And nitpicking, but it should be [localOptionsList, setLocalOptionsList]
as in the variable in the initial state 🙈
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.
After testing, likely no it is no longer needed
import { usePreviewContext } from 'app-development/contexts/PreviewContext'; | ||
import { useStudioEnvironmentParams } from 'app-shared/hooks/useStudioEnvironmentParams'; | ||
import { useUpdateOptionListMutation } from 'app-shared/hooks/mutations'; | ||
import { useOptionListEditorTexts } from '@altinn/ux-editor/components/config/editModal/EditOptions/OptionTabs/hooks'; |
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.
Should be relative import 🙈
optionsId={component.optionsId} | ||
component={component} | ||
handleComponentChange={handleComponentChange} | ||
setComponentHasOptionList={setComponentHasOptionList} |
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.
If this value is defined by the incoming components fields, should we not be able to evaluate this in a const used only where it is needed? And any changes to the component that would affect this value would anyway be noticed due to rerendring affected by changing the component-prop 🤔
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 added the useState to make sure we continue to render the modals while the user is making changes. Removing it results in the modals being closed because they are no longer being rendered as they get replaced with SelectedOptionList
If you have a better idea for how to fix this, then i'm happy to change it
@@ -18,7 +18,7 @@ describe('EditTab', () => { | |||
it('should render DisplayChosenOption', async () => { | |||
renderEditTab(); | |||
expect( | |||
screen.getByRole('button', { name: textMock('ux_editor.options.option_remove_text') }), | |||
await screen.findByText(textMock('ux_editor.modal_properties_code_list_custom_list')), |
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.
Why does this test have to be awaited and not use getByText
? If there is due to some data needed from queries, it is better to adapt the tests to test for the spinner being there when waiting and for the data being there when the required data is on the cache.
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.
thank you for spotting it!
And I also have a general comment concerning the delete-functionality, as well as the conflicted-sources (trying to set a library id if manual options are set and vice versa). We should sync the design here along with the image-component. For the image component the delete-choices are separated between deleting the ref and deleting the actual source. When there are conflicting sources it is visualized like this in the image component: Skjermopptak.2024-12-13.kl.09.11.34.movAlso, when I have connected an optionlist in the Skjermopptak.2024-12-13.kl.12.53.07.movAnd one last small thing I noticed, when I have a faulty codeList I cant remove it. Might be that this can be fixed easier when the other PR that fetches only the specified code list is implemented tho. |
Description
Update the design of the codelist section of our config page. Earlier discuessed in another PR
Before
After
Related Issue(s)
Verification