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

PlanQK Token field #41

Closed
wants to merge 8 commits into from
Closed

PlanQK Token field #41

wants to merge 8 commits into from

Conversation

Elscrux
Copy link
Member

@Elscrux Elscrux commented Dec 20, 2023

No description provided.

schweikart and others added 5 commits December 20, 2023 21:34
- Rename SolveRequest to SolveChoice to be in line with the type in SolverPicker
- In ProgressHandler keep track of the underlying SolverChoice of the SolverPicker, then create a SolveRequest when it is time to make a request
@Elscrux Elscrux requested a review from schweikart December 20, 2023 23:45
Copy link

Quality Gate Passed Quality Gate passed

The SonarCloud Quality Gate passed, but some issues were introduced.

4 New issues
0 Security Hotspots
No data about Coverage
0.0% Duplication on New Code

See analysis details on SonarCloud

Copy link
Member

@schweikart schweikart left a comment

Choose a reason for hiding this comment

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

Nice work! The following comments are mostly just notes on code quality

Comment on lines +1 to +6
export interface Authentication {
/**
* The token used to authenticate the solver
*/
token: string;
}
Copy link
Member

Choose a reason for hiding this comment

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

Why use this object instead of a plain string?

Copy link
Member Author

Choose a reason for hiding this comment

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

Because it might not be a token in the future but some other authentication method. I envisioned this to reflect the AuthenticationOptions type. When more boolean options like supportsToken are added, their result will be stored in the Authentication type.

text: string;
}

const urlRegex = /(https?:\/\/\S+|www\.\S+|\b\w+@\w+\.\w+(?:\.\w+)?\b)/;
Copy link
Member

Choose a reason for hiding this comment

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

Did you come up with this regex yourself? If yes, please add a few test cases. If no, please add a source

Copy link
Member Author

Choose a reason for hiding this comment

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

I don't know where this is from anymore. I could use another regex and link the source.

const parts: string[] = props.text.split(urlRegex);

return (
<Box>
Copy link
Member

Choose a reason for hiding this comment

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

Considering that the object is called TextWithLinks, maybe use <Text> here?

return (
<Container>
<Text>This solver requires authentication</Text>
{authenticationOptions.supportsToken ? (
Copy link
Member

Choose a reason for hiding this comment

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

Why do we have a supportsToken field if tokens are currently the only supported way?

Copy link
Member Author

Choose a reason for hiding this comment

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

See my answer for the Authentication type above. My reason is extensibility.

Comment on lines 83 to 93
onChange={(e) => {
let newSolverChoice: SolverChoice = {
...solverChoice,
authentication: {
token: e.target.value,
},
};

setSolverChoice(newSolverChoice);
props.setSolverChoice?.(newSolverChoice);
}}
Copy link
Member

Choose a reason for hiding this comment

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

can you extract this to a function?

{solveRequest.requestedSolverId == undefined ? (
{selectedSolver?.authenticationOptions !== undefined &&
selectedSolver?.authenticationOptions !== null
? Authentication(selectedSolver.authenticationOptions)
Copy link
Member

Choose a reason for hiding this comment

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

Please use JSX (TSX) syntax

Copy link
Member Author

Choose a reason for hiding this comment

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

I'm not sure what you mean

Copy link
Member Author

Choose a reason for hiding this comment

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

Oh, you mean the short circuit way to have optional elements, gotcha. That's a neat trick.

Comment on lines 148 to 161
{solverChoice.requestedSolverId == undefined ? (
<SettingsView
problemType={props.problemType}
settingChanged={(settings) => {
let newSolveRequest: SolverChoice = {
...solveRequest,
let newSolverChoice: SolverChoice = {
...solverChoice,
requestedMetaSolverSettings: settings,
};

setSolveRequest(newSolveRequest);
props.setSolveRequest(newSolveRequest);
setSolverChoice(newSolverChoice);
props.setSolverChoice(newSolverChoice);
}}
/>
) : null}
Copy link
Member

Choose a reason for hiding this comment

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

You can use the conditional and (&&) operator for conditional rendering without an else block (https://react.dev/learn/conditional-rendering#logical-and-operator-)

Copy link

Quality Gate Passed Quality Gate passed

The SonarCloud Quality Gate passed, but some issues were introduced.

4 New issues
0 Security Hotspots
No data about Coverage
0.0% Duplication on New Code

See analysis details on SonarCloud

@Elscrux
Copy link
Member Author

Elscrux commented Jan 23, 2024

@schweikart I'm done with my pass, let me know what you think :)

@Elscrux
Copy link
Member Author

Elscrux commented Jan 14, 2025

Same functionality was merged with #53

@Elscrux Elscrux closed this Jan 14, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants