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

Make FormData type stable, and add/improve lots of related Typescirpt typings #7718

Merged
merged 8 commits into from
Jan 20, 2022

Conversation

ivarne
Copy link
Member

@ivarne ivarne commented Dec 21, 2021

When working with Altinn/app-frontend-react#789 I had some problems working around the issue that the existence of dataModelBindings.simpleBinding changed the type of formData to string and prevents me from reading the other dataModelBindings. This pull request fixes that issue, so that formData is always an object that usually has a single property simpleBinding.

Description

In fixing this, I also had to fix lots of typescript types and renamed a function isSimpleComponent -> componentRendersItsOwnValidationErrors. I have tried to group related changes into separate commits, so most likely a reviewer should consider reviewing each commit separately (ps: I know i screwed up so intermediate commits does not all compile).

Fixes

  • n/a

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)
  • All tests run green

Documentation

@lorang92
Copy link
Contributor

/AzurePipelines run

@azure-pipelines
Copy link

You have several pipelines (over 10) configured to build pull requests in this repository. Specify which pipelines you would like to run by using /azp run [pipelines] command. You can specify multiple pipelines using a comma separated list.

Copy link
Contributor

@lorang92 lorang92 left a comment

Choose a reason for hiding this comment

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

Good stuff 🦖 I have some minor comments and a "question".

Copy link
Contributor

@haakemon haakemon 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! Thanks for the improvements!

Would like to clarify the change for index as key (see other comment) before approval.

@lorang92 lorang92 added the community-contribution-❤️ Contributions from developers outside the Altinn teams. label Dec 22, 2021
Explains better how the function is used.
Also fix some minor type issues.

New interface IComponentProps

Previously all components had their own interface. It is better when
all share the common props from GenericComponent

```
export interface  IComponentProps extends IGenericComponentProps {
  handleDataChange: (value: string, key?:string) => void,
  handleFocusUpdate: (componentId: string, step?: number) => void,
  getTextResource: (key: string) => React.ReactNode,
  getTextResourceAsString: (key: string) => string,
  formData: any,
  isValid: boolean,
  language: any,
  shouldFocus: boolean,
  text: React.ReactNode,
  label: ()=>JSX.Element,
  legend: ()=>JSX.Element,
};
```

Make formData type stable and use .simpleBinding everywhere

Use React.ReactNode as type for getTextResource

Apply formatting corrections from code review

Co-authored-by: Steffen Lorang Ekeberg <steffen.ekeberg@gmail.com>

Use a proper key for AltinnMobileTable

Rename componentRendersItsOwnValidationErrors => componentValidationsHandledByGenericComponent

Fix missing `?.simpleBinding` in Components

Remove ITextAreaComponentProps to fix @typescript-eslint/no-empty-interface
@ivarne ivarne force-pushed the formData-typeStable branch from 5ddebd5 to 25c8529 Compare January 4, 2022 07:55
@ivarne
Copy link
Member Author

ivarne commented Jan 4, 2022

I fixed merge conflicts with #7721 and squashed commits.

@lorang92
Copy link
Contributor

@jeevananthank would you run regression tests for this branch?

@lorang92
Copy link
Contributor

/azp run

@azure-pipelines
Copy link

You have several pipelines (over 10) configured to build pull requests in this repository. Specify which pipelines you would like to run by using /azp run [pipelines] command. You can specify multiple pipelines using a comma separated list.

@ivarne
Copy link
Member Author

ivarne commented Jan 18, 2022

@jeevananthank I took the freedom to merge #7843 into this, so that I likely would get my first "green PR"

@jeevananthank
Copy link
Contributor

@ivarne the failed test is the same as i mentioned here

@ivarne
Copy link
Member Author

ivarne commented Jan 18, 2022

Yea, I can see that, but strangely the change I picked out as responsible is not part of this PR. I'll need too look into it later this week. Is the tests or screenshots available somewhere, so I can get some more insight into what is failing.

@jeevananthank
Copy link
Contributor

jeevananthank commented Jan 18, 2022

Yea, I can see that, but strangely the change I picked out as responsible is not part of this PR. I'll need too look into it later this week. Is the tests or screenshots available somewhere, so I can get some more insight into what is failing.

you can find the test results here. Screenshots are not available for runs from fork PR (unfortunately to enable test runs on fork PR, we had to give up the recording feature)

@ivarne
Copy link
Member Author

ivarne commented Jan 18, 2022

Is there anything more than this screenshot I should look at in the log you linked to?
image

@jeevananthank
Copy link
Contributor

@ivarne no, you just get to see the test results in the logs of a github action run. from the name of the test failed, you can find the test script here

@ivarne
Copy link
Member Author

ivarne commented Jan 19, 2022

Yey, 💚

So much time wasted on the assumption that this was a different issue than the one in #7843, and a quick look at the diff to (wrongly) confirm that this change was not part of the first PR.

Anyway. This is green now. 🥳 🎉

@jeevananthank
Copy link
Contributor

@jeevananthank would you run regression tests for this branch?

automated tests have run green 😀

@lorang92
Copy link
Contributor

/azp run

@azure-pipelines
Copy link

You have several pipelines (over 10) configured to build pull requests in this repository. Specify which pipelines you would like to run by using /azp run [pipelines] command. You can specify multiple pipelines using a comma separated list.

@lorang92
Copy link
Contributor

/azp run

@azure-pipelines
Copy link

You have several pipelines (over 10) configured to build pull requests in this repository. Specify which pipelines you would like to run by using /azp run [pipelines] command. You can specify multiple pipelines using a comma separated list.

@lorang92 lorang92 merged commit ddb259c into Altinn:master Jan 20, 2022
@lorang92
Copy link
Contributor

Yey, 💚

So much time wasted on the assumption that this was a different issue than the one in #7843, and a quick look at the diff to (wrongly) confirm that this change was not part of the first PR.

Anyway. This is green now. 🥳 🎉

@ivarne and merged ❤️ much appreciated!

@ivarne ivarne deleted the formData-typeStable branch February 9, 2025 07:25
@ivarne ivarne restored the formData-typeStable branch February 9, 2025 07:25
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
community-contribution-❤️ Contributions from developers outside the Altinn teams.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants