-
Notifications
You must be signed in to change notification settings - Fork 361
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
Add methodOfRedress
to DSA tenant settings
#4395
Merged
kabeaty
merged 1 commit into
feat/dsa-launch-pad
from
feat/DSA-config-method-of-redress
Nov 15, 2023
+178
−9
Merged
Changes from all commits
Commits
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
100 changes: 100 additions & 0 deletions
100
client/src/core/client/admin/routes/Configure/sections/General/DSAMethodOfRedressOptions.tsx
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,100 @@ | ||
import { Localized } from "@fluent/react/compat"; | ||
import React, { FunctionComponent } from "react"; | ||
import { Field } from "react-final-form"; | ||
|
||
import { Validator } from "coral-framework/lib/validation"; | ||
import { RadioButton } from "coral-ui/components/v2"; | ||
|
||
interface Props { | ||
validate?: Validator; | ||
name: string; | ||
disabled: boolean; | ||
format?: (value: any, name: string) => any; | ||
testIDs?: { | ||
on: string; | ||
off: string; | ||
}; | ||
className?: string; | ||
} | ||
|
||
export enum DSAMethodOfRedress { | ||
None = "NONE", | ||
Email = "EMAIL", | ||
URL = "URL", | ||
} | ||
|
||
export const parseVal = (v: any, name: string) => { | ||
if (v === DSAMethodOfRedress.None) { | ||
return DSAMethodOfRedress.None; | ||
} | ||
if (v === DSAMethodOfRedress.Email) { | ||
return DSAMethodOfRedress.Email; | ||
} | ||
if (v === DSAMethodOfRedress.URL) { | ||
return DSAMethodOfRedress.URL; | ||
} | ||
|
||
return DSAMethodOfRedress.None; | ||
}; | ||
|
||
export const format = (v: string, name: string) => { | ||
return v; | ||
}; | ||
|
||
const DSAMethodOfRedressOptions: FunctionComponent<Props> = ({ | ||
name, | ||
disabled, | ||
className, | ||
}) => ( | ||
<div className={className}> | ||
<Field | ||
name={name} | ||
type="radio" | ||
value={DSAMethodOfRedress.None} | ||
parse={parseVal} | ||
format={format} | ||
> | ||
{({ input }) => ( | ||
<RadioButton {...input} id={`${input.name}-none`} disabled={disabled}> | ||
<Localized id="configure-general-dsaConfig-methodOfRedress-none"> | ||
<span>None</span> | ||
</Localized> | ||
</RadioButton> | ||
)} | ||
</Field> | ||
<Field | ||
name={name} | ||
type="radio" | ||
value={DSAMethodOfRedress.Email} | ||
parse={parseVal} | ||
format={format} | ||
> | ||
{({ input }) => ( | ||
<RadioButton {...input} id={`${input.name}-email`} disabled={disabled}> | ||
<Localized id="configure-general-dsaConfig-methodOfRedress-email"> | ||
<span>Email</span> | ||
</Localized> | ||
</RadioButton> | ||
)} | ||
</Field> | ||
<Field | ||
name={name} | ||
type="radio" | ||
parse={parseVal} | ||
value={DSAMethodOfRedress.URL} | ||
format={format} | ||
> | ||
{({ input }) => { | ||
return ( | ||
<RadioButton {...input} id={`${input.name}-url`} disabled={disabled}> | ||
<Localized id="configure-general-dsaConfig-methodOfRedress-url"> | ||
<span>URL</span> | ||
</Localized> | ||
</RadioButton> | ||
); | ||
}} | ||
</Field> | ||
</div> | ||
); | ||
|
||
export default DSAMethodOfRedressOptions; |
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 |
---|---|---|
@@ -1,9 +1,16 @@ | ||
import * as settings from "coral-server/models/settings"; | ||
|
||
import { GQLDSAConfigurationTypeResolver } from "coral-server/graph/schema/__generated__/types"; | ||
import { | ||
GQLDSA_METHOD_OF_REDRESS, | ||
GQLDSAConfigurationTypeResolver, | ||
} from "coral-server/graph/schema/__generated__/types"; | ||
|
||
export const DSAConfiguration: GQLDSAConfigurationTypeResolver<settings.RTEConfiguration> = | ||
{ | ||
enabled: (config, args, { tenant }) => | ||
tenant.dsa && tenant.dsa.enabled ? tenant.dsa.enabled : false, | ||
methodOfRedress: (config, args, { tenant }) => | ||
tenant.dsa && tenant.dsa.methodOfRedress | ||
? tenant.dsa.methodOfRedress | ||
: GQLDSA_METHOD_OF_REDRESS.NONE, | ||
}; |
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
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.
Do we need this
parseVal
andformat
? Seems like it works fine without them?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.
it wasn't working for me without them, but I can try again