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

Store options metadata in datamodel (v3) #1611

Merged
merged 10 commits into from
Nov 14, 2023
Merged

Conversation

Magnusrm
Copy link
Contributor

@Magnusrm Magnusrm commented Oct 26, 2023

Description

Allow for storing the metadata from retrieved code-lists in a specific field in the datamodel by introducing the metadata keyword to be used in dataModelBindings for components that use options.
The metada can then be displayed by referencing the datamodel field where the metadata is stored after the options have been retrieved.

"dataModelBindings": {
  "simpleBinding": "Adresse.Kommune",
  "metadata": "Adresse.KommunerMetadata"
},

Related Issue(s)

Verification/QA

  • Manual functionality testing
    • I have tested these changes manually
    • Creator of the original issue (or service owner) has been contacted for manual testing (or will be contacted when released in alpha)
    • No testing done/necessary
  • Automated tests
    • Unit test(s) have been added/updated
    • Cypress E2E test(s) have been added/updated
    • No automatic tests are needed here (no functional changes/additions)
    • I want someone to help me make some tests
  • UU/WCAG (follow these guidelines until we have our own)
    • I have tested with a screen reader/keyboard navigation/automated wcag validator
    • No testing done/necessary (no DOM/visual changes)
    • I want someone to help me perform accessibility testing
  • User documentation @ altinn-studio-docs
  • Support in Altinn Studio
    • Issue(s) created for support in Studio
    • This change/feature does not require any changes to Altinn Studio
  • Sprint board
    • The original issue (or this PR itself) has been added to the Team Apps project and to the current sprint board
    • I don't have permissions to do that, please help me out
  • Labels
    • I have added a kind/* label to this PR for proper release notes grouping
    • I don't have permissions to add labels, please help me out

@Magnusrm Magnusrm added the kind/product-feature Pull requests containing new features label Nov 9, 2023
@Magnusrm Magnusrm requested review from bjosttveit, olemartinorg and lassopicasso and removed request for bjosttveit November 9, 2023 12:08
@Magnusrm Magnusrm marked this pull request as ready for review November 9, 2023 12:08
Copy link
Contributor

@olemartinorg olemartinorg left a comment

Choose a reason for hiding this comment

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

🚀

@@ -144,6 +144,13 @@ const common = {
'Describes the location in the data model where the component should store its value(s). A simple ' +
'binding is used for components that only store a single value, usually a string.',
),
IDataModelBindingsOptionsSimple: () =>
new CG.obj(new CG.prop('simpleBinding', new CG.str()), new CG.prop('metadata', new CG.str().optional()))
Copy link
Contributor

Choose a reason for hiding this comment

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

There should probably also be a description for the metadata prop here as well, although I'm not sure if it's easily visible from vscode that way. I know people will wonder what it's for without any docs! 😊

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'll add some description! 😁

Comment on lines 19 to 26
export async function httpGetWithHeaders(url: string, options?: AxiosRequestConfig): Promise<any> {
const headers = options?.headers as RawAxiosRequestHeaders | undefined;
const response: AxiosResponse = await axios.get(url, {
...options,
headers: { ...headers, Pragma: 'no-cache' },
});
return response.data ? response : null;
}
Copy link
Contributor

Choose a reason for hiding this comment

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

Not sure I like the name all that much.. It's not 'with headers', it's with the whole response object. Frankly I don't like the way we usually pluck out the data from the responses, so if I'm not sure if just renaming it to httpGetRaw() would be better, or if we should just stop wrapping axios entirely. Anyway, it's all fine for v3, no need to be picky there.

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 agree the name is not that satisfying. I like httpGetRaw better atleast 👍. Another option is to rename this one to httpGet and the one that is httpGet today to httpGetResponseData.

Copy link
Contributor

Choose a reason for hiding this comment

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

Yeah, but if you're renaming all usages you might as well just use httpGet(...)?.data and just have one function to rule them all. The same then goes for all the http* functions, so I'd prefer to clean it all up or leave it be.. 😊

Copy link

SonarCloud Quality Gate failed.    Quality Gate failed

Bug A 0 Bugs
Vulnerability A 0 Vulnerabilities
Security Hotspot A 0 Security Hotspots
Code Smell A 0 Code Smells

37.0% 37.0% Coverage
0.0% 0.0% Duplication

idea Catch issues before they fail your Quality Gate with our IDE extension sonarlint SonarLint

@Magnusrm Magnusrm merged commit 321eabc into v3 Nov 14, 2023
@Magnusrm Magnusrm deleted the feat/v3-options-metadata branch November 14, 2023 10:28
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
kind/product-feature Pull requests containing new features
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants