-
Notifications
You must be signed in to change notification settings - Fork 57
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
Validates client config #1083
Draft
atomicgamedeveloper
wants to merge
10
commits into
INTO-CPS-Association:feature/distributed-demo
Choose a base branch
from
atomicgamedeveloper:658-validate-client-config
base: feature/distributed-demo
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+400
−54
Draft
Validates client config #1083
Changes from all commits
Commits
Show all changes
10 commits
Select commit
Hold shift + click to select a range
a8838bf
Add VerifyConfig.tsx with route
atomicgamedeveloper 89afd3a
Add edge-case for opaque responses
atomicgamedeveloper 740e8b3
Add status code and more useful error messages
atomicgamedeveloper 5092824
Refactor VerifyConfig
atomicgamedeveloper 6976bbf
Reinstate status code information in tool tips
atomicgamedeveloper 3260e98
Integrate verification and sign in
atomicgamedeveloper a2b9df1
Clean up ConfigItems.tsx, Signin.tsx and VerifyConfig.tsx
atomicgamedeveloper b514a82
Merge branch 'feature/distributed-demo' into 658-validate-client-config
atomicgamedeveloper 258aada
Unmemoise ConfigItem
atomicgamedeveloper d18d766
Merge branch '658-validate-client-config' of https://github.com/atomi…
atomicgamedeveloper File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,125 @@ | ||
import CheckCircleIcon from '@mui/icons-material/CheckCircle'; | ||
import ErrorOutlineIcon from '@mui/icons-material/ErrorOutline'; | ||
import { Tooltip } from '@mui/material'; | ||
import React from 'react'; | ||
import { validationType } from './VerifyConfig'; | ||
|
||
const ConfigIcon = (toolTipTitle: string, icon: JSX.Element): JSX.Element => ( | ||
<Tooltip | ||
title={toolTipTitle} | ||
PopperProps={{ container: document.getElementById('root') }} | ||
> | ||
{icon} | ||
</Tooltip> | ||
); | ||
|
||
export const getConfigIcon = ( | ||
validation: validationType, | ||
label: string, | ||
): JSX.Element => { | ||
let icon = <ErrorOutlineIcon color="error" />; | ||
let toolTipTitle = `${label} threw the following error: ${validation.error}`; | ||
const configHasStatus = validation.status !== undefined; | ||
const configHasError = validation.error !== undefined; | ||
if (!configHasError) { | ||
const statusMessage = configHasStatus | ||
? `${validation.value} responded with status code ${validation.status}.` | ||
: ''; | ||
const validationStatusIsOK = | ||
configHasStatus && | ||
((validation.status! >= 200 && validation.status! <= 299) || | ||
validation.status! === 302); | ||
icon = | ||
validationStatusIsOK || !configHasStatus ? ( | ||
<CheckCircleIcon color="success" /> | ||
) : ( | ||
<ErrorOutlineIcon color="warning" /> | ||
); | ||
toolTipTitle = | ||
validationStatusIsOK || !configHasStatus | ||
? `${label} field is configured correctly.` | ||
: `${label} field may not be configured correctly.`; | ||
toolTipTitle += ` ${statusMessage}`; | ||
} | ||
return ConfigIcon(toolTipTitle, icon); | ||
}; | ||
|
||
export const ConfigItem: React.FC<{ | ||
label: string; | ||
value: string; | ||
validation?: validationType; | ||
}> = ({ label, value, validation = { error: 'Validating unavailable' } }) => ( | ||
<div | ||
style={{ | ||
display: 'flex', | ||
alignItems: 'center', | ||
gap: '10px', | ||
margin: '5px 0', | ||
}} | ||
> | ||
{getConfigIcon(validation, label)} | ||
<div> | ||
<strong>{label}:</strong> {value} | ||
</div> | ||
</div> | ||
); | ||
ConfigItem.displayName = 'ConfigItem'; | ||
|
||
export const windowEnvironmentVariables: { value: string; key: string }[] = [ | ||
{ | ||
value: window.env.REACT_APP_ENVIRONMENT, | ||
key: 'environment', | ||
}, | ||
{ | ||
value: window.env.REACT_APP_URL, | ||
key: 'url', | ||
}, | ||
{ | ||
value: window.env.REACT_APP_URL_BASENAME, | ||
key: 'url_basename', | ||
}, | ||
{ | ||
value: window.env.REACT_APP_URL_DTLINK, | ||
key: 'url_dtlink', | ||
}, | ||
{ | ||
value: window.env.REACT_APP_URL_LIBLINK, | ||
key: 'url_liblink', | ||
}, | ||
{ | ||
value: window.env.REACT_APP_WORKBENCHLINK_VNCDESKTOP, | ||
key: 'workbenchlink_vncdesktop', | ||
}, | ||
{ | ||
value: window.env.REACT_APP_WORKBENCHLINK_VSCODE, | ||
key: 'workbenchlink_vscode', | ||
}, | ||
{ | ||
value: window.env.REACT_APP_WORKBENCHLINK_JUPYTERLAB, | ||
key: 'workbenchlink_jupyterlab', | ||
}, | ||
{ | ||
value: window.env.REACT_APP_WORKBENCHLINK_JUPYTERNOTEBOOK, | ||
key: 'workbenchlink_jupyternotebook', | ||
}, | ||
{ | ||
value: window.env.REACT_APP_CLIENT_ID, | ||
key: 'client_id', | ||
}, | ||
{ | ||
value: window.env.REACT_APP_AUTH_AUTHORITY, | ||
key: 'auth_authority', | ||
}, | ||
{ | ||
value: window.env.REACT_APP_REDIRECT_URI, | ||
key: 'redirect_uri', | ||
}, | ||
{ | ||
value: window.env.REACT_APP_LOGOUT_REDIRECT_URI, | ||
key: 'logout_redirect_uri', | ||
}, | ||
{ | ||
value: window.env.REACT_APP_GITLAB_SCOPES, | ||
key: 'gitlab_scopes', | ||
}, | ||
]; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@atomicgamedeveloper
Is this used? Overall, it is better to move the config verification logic into
util/config.ts
. The zod can be used there.