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

Validation type functionality #153

Merged
merged 8 commits into from
Oct 31, 2023
Merged

Validation type functionality #153

merged 8 commits into from
Oct 31, 2023

Conversation

roshan-gh
Copy link
Contributor

No description provided.

@roshan-gh roshan-gh self-assigned this Oct 30, 2023
@vercel
Copy link

vercel bot commented Oct 30, 2023

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
otelbin 🔄 Building (Inspect) Visit Preview 💬 Add feedback Oct 31, 2023 9:56am

@@ -0,0 +1,6 @@
{
Copy link
Member

Choose a reason for hiding this comment

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

Issue: This file can be deleted.


const fetcher = (url: string) => fetch(url).then((res) => res.json());

preload(`https://www.otelbin.io/validation/supported-distributions`, fetcher);
Copy link
Member

Choose a reason for hiding this comment

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

Issue: This can now be removed as we are preloading the distros using an instruction in the root layout (has better performance characteristics).

version: "",
distro: "",
const [{ distro, distroVersion }] = useUrlState([distroBinding, distroVersionBinding]);
const [currentDistro, setCurrentDistro] = useState<ICurrentValidation>({
Copy link
Member

Choose a reason for hiding this comment

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

Question: Why do we need this state?

I would expect that the combination of URL state and the result of useDistributions is sufficient to generate the right label. This would also avoid the need for useMemo and useEffect.

Copy link
Contributor Author

@roshan-gh roshan-gh Oct 30, 2023

Choose a reason for hiding this comment

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

Exactly today I tried the approach without useState, but at final step, without useState and useEffect, for the first state change, useUrlState couldn't change the whole state of the app, (ex: display current flag, or button title). If you're sure useUrlState is enough, I'll try again. @bripkens

current: ICurrentValidation;
setCurrent: (current: ICurrentValidation) => void;
currentDistro: ICurrentValidation;
setCurrentDistro: (current: ICurrentValidation) => void;
Copy link
Member

Choose a reason for hiding this comment

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

Question: Why do we need setCurrentDistro here? We already have getUrl accessible within the file that we can use to change the distro.

<Button
onClick={() => setCurrent({ provider: "Browser-only", version: "", distro: "" })}
onClick={() => {
setCurrentDistro({ ...currentDistro, title: { provider: "Browser-only", version: "", distro: "" } });
Copy link
Member

Choose a reason for hiding this comment

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

Issue: There should only be one source of truth for state, i.e. the URL.

version: (data && Array.isArray(data[key]?.releases) && data[key]?.releases[0]?.version) || "",
}))
: [];
const [{}, getUrl] = useUrlState([distroBinding, distroVersionBinding]);
Copy link
Member

Choose a reason for hiding this comment

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

Suggestion: See the SonarCloud bug report on this one. The empty destructuring should be avoided (also in the other location in which useUrlState is used):

image

Copy link
Member

@bripkens bripkens left a comment

Choose a reason for hiding this comment

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

LGTM 👍

@sonarcloud
Copy link

sonarcloud bot commented Oct 31, 2023

Kudos, SonarCloud Quality Gate passed!    Quality Gate passed

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

No Coverage information No Coverage information
0.0% 0.0% Duplication

@bripkens bripkens merged commit bddc032 into main Oct 31, 2023
6 of 7 checks passed
@bripkens bripkens deleted the validationType-functionality branch October 31, 2023 09:56
@github-actions github-actions bot locked and limited conversation to collaborators Oct 31, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants