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

feat: update codelist config design #14276

Open
wants to merge 11 commits into
base: main
Choose a base branch
from

Conversation

Konrad-Simso
Copy link
Contributor

Description

Update the design of the codelist section of our config page. Earlier discuessed in another PR

Before

image

After

image

Related Issue(s)

Verification

  • Your code builds clean without any errors or warnings
  • Manual testing done (required)
  • Relevant automated test added (if you find this hard, leave it and we'll help out)

@github-actions github-actions bot added area/ui-editor Area: Related to the designer tool for assembling app UI in Altinn Studio. solution/studio/designer Issues related to the Altinn Studio Designer solution. frontend labels Dec 12, 2024
@Konrad-Simso Konrad-Simso added skip-releasenotes Issues that do not make sense to list in our release notes team/studio-domain1 skip-documentation Issues where updating documentation is not relevant solution/studio/designer Issues related to the Altinn Studio Designer solution. and removed solution/studio/designer Issues related to the Altinn Studio Designer solution. labels Dec 12, 2024
@Konrad-Simso Konrad-Simso linked an issue Dec 12, 2024 that may be closed by this pull request
Copy link

codecov bot commented Dec 12, 2024

Codecov Report

Attention: Patch coverage is 98.33333% with 1 line in your changes missing coverage. Please review.

Project coverage is 95.53%. Comparing base (37d92b5) to head (cf2ebbd).
Report is 9 commits behind head on main.

Files with missing lines Patch % Lines
...Editor/ManualOptionsEditor/ManualOptionsEditor.tsx 94.44% 0 Missing and 1 partial ⚠️
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.
📢 Have feedback on the report? Share it here.

@standeren standeren self-assigned this Dec 13, 2024
…during onBlurAny and onClose no longer contains any logic.
@Konrad-Simso
Copy link
Contributor Author

Konrad-Simso commented Dec 13, 2024

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

Copy link
Contributor

@standeren standeren left a 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 🤗

@@ -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.",
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
"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.",

"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.",
Copy link
Contributor

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';
Copy link
Contributor

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 👍

Copy link
Contributor

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 😄

Copy link
Contributor Author

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 {
Copy link
Contributor

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.

Comment on lines 54 to 57
const codeListLabels: string = localOptionList
.slice(0, 3)
.map((option: Option) => `${option.label}`)
.join(' | ');
Copy link
Contributor

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);
Copy link
Contributor

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 🙈

Copy link
Contributor Author

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';
Copy link
Contributor

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}
Copy link
Contributor

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 🤔

Copy link
Contributor Author

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')),
Copy link
Contributor

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.

Copy link
Contributor Author

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!

@standeren standeren assigned Konrad-Simso and unassigned standeren Dec 13, 2024
@standeren
Copy link
Contributor

standeren commented Dec 13, 2024

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.

Skjermbilde 2024-12-13 kl  09 10 57

When there are conflicting sources it is visualized like this in the image component:

Skjermopptak.2024-12-13.kl.09.11.34.mov

Also, when I have connected an optionlist in the Velg kodeliste I get the same codelist id visualized in the Ani referanse-id:

Skjermopptak.2024-12-13.kl.12.53.07.mov

And 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.

Skjermbilde 2024-12-13 kl  12 49 40

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area/ui-editor Area: Related to the designer tool for assembling app UI in Altinn Studio. frontend skip-documentation Issues where updating documentation is not relevant skip-releasenotes Issues that do not make sense to list in our release notes solution/studio/designer Issues related to the Altinn Studio Designer solution. team/studio-domain1
Projects
Status: 🔎 Review
Development

Successfully merging this pull request may close these issues.

Merge "select codelist" and "edit codelist" views
2 participants