-
Notifications
You must be signed in to change notification settings - Fork 361
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
add method of redress to DSA tenant settings
- Loading branch information
Showing
8 changed files
with
178 additions
and
9 deletions.
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