Add required root level fields for LTI Key

For manual creation of keys, add the fields
that will be required or needed to create a
new Tool Configuration Manually.

refs PLAT-4248

Test Plan:
 - Go to create a new LTI key, note that the manual
   option now has fields attached

Change-Id: I34afe82ba903cc149a0ba74b245cec0375b029e4
Reviewed-on: https://gerrit.instructure.com/186829
Reviewed-by: Weston Dransfield <wdransfield@instructure.com>
Tested-by: Jenkins
QA-Review: Marc Phillips <mphillips@instructure.com>
Product-Review: Marc Phillips <mphillips@instructure.com>
This commit is contained in:
Marc Phillips 2019-03-25 16:07:55 -06:00
parent f26f880bc2
commit 306c528724
5 changed files with 96 additions and 9 deletions

View File

@ -19,8 +19,13 @@ import I18n from 'i18n!react_developer_keys'
import PropTypes from 'prop-types'
import React from 'react'
import Heading from '@instructure/ui-elements/lib/components/Heading'
import View from '@instructure/ui-layout/lib/components/View'
import { CheckboxGroup } from '@instructure/ui-forms'
import FormFieldGroup from '@instructure/ui-form-field/lib/components/FormFieldGroup';
import TextInput from '@instructure/ui-forms/lib/components/TextInput';
import TextArea from '@instructure/ui-forms/lib/components/TextArea';
import Checkbox from '@instructure/ui-forms/lib/components/Checkbox';
import ScreenReaderContent from '@instructure/ui-a11y/lib/components/ScreenReaderContent';
export default class ManualConfigurationForm extends React.Component {
state = {
@ -32,17 +37,87 @@ export default class ManualConfigurationForm extends React.Component {
}
render() {
const { toolConfiguration } = this.state;
const { validScopes } = this.props;
return (
<View>
<Heading level="h3" as="h3" margin="0 0 x-small">
{I18n.t('Manual Configuration')}
</Heading>
placeholder...
<FormFieldGroup
description={I18n.t('Manual Configuration')}
layout="stacked"
>
<FormFieldGroup
description={<ScreenReaderContent>{I18n.t("Display Values")}</ScreenReaderContent>}
layout="columns"
>
<TextInput
name="title"
value={toolConfiguration.title}
label={I18n.t("Title")}
required
/>
<TextInput
name="icon_url"
value={toolConfiguration.title}
label={I18n.t("Icon Url")}
/>
</FormFieldGroup>
<TextArea
name="description"
value={toolConfiguration.description}
label={I18n.t("Description")}
maxHeight="5rem"
required
/>
<FormFieldGroup
description={<ScreenReaderContent>{I18n.t("OIDC Values")}</ScreenReaderContent>}
layout="columns"
>
<TextInput
name="target_link_uri"
value={toolConfiguration.target_link_uri}
label={I18n.t("Target Link URI")}
required
/>
<TextInput
name="oidc_initiation_url"
value={toolConfiguration.oidc_initiation_url}
label={I18n.t("OpenID Connect Initiation Url")}
required
/>
</FormFieldGroup>
<TextArea
name="public_jwk"
value={toolConfiguration.public_jwk}
label={I18n.t("Public JWK")}
maxHeight="10rem"
required
resize="vertical"
autoGrow
/>
<CheckboxGroup
name="services"
onChange={() => {}}
value={toolConfiguration.scopes}
description={I18n.t("LTI Advantage Services to enable")}
>
{
Object.keys(validScopes).map(key => {
return <Checkbox
key={key}
label={validScopes[key]}
value={key}
variant="toggle"
/>
})
}
</CheckboxGroup>
</FormFieldGroup>
</View>
)
}
}
ManualConfigurationForm.propTypes = {
toolConfiguration: PropTypes.object.isRequired
validScopes: PropTypes.object.isRequired,
validPlacements: PropTypes.arrayOf(PropTypes.string).isRequired
}

View File

@ -29,6 +29,8 @@ export default class ToolConfiguration extends React.Component {
<ToolConfigurationForm
toolConfiguration={this.props.createLtiKeyState.toolConfiguration}
toolConfigurationUrl={this.props.createLtiKeyState.toolConfigurationUrl}
validScopes={ENV.validLtiScopes}
validPlacements={ENV.validLtiPlacements}
/>
)
}

View File

@ -55,7 +55,10 @@ export default class ToolConfigurationForm extends React.Component {
)
} else if (this.state.configurationType === 'manual') {
return (
<ManualConfigurationForm />
<ManualConfigurationForm
validScopes={this.props.validScopes}
validPlacements={this.props.validPlacements}
/>
)
}
return (
@ -91,5 +94,7 @@ export default class ToolConfigurationForm extends React.Component {
ToolConfigurationForm.propTypes = {
toolConfiguration: PropTypes.object.isRequired,
toolConfigurationUrl: PropTypes.string.isRequired
toolConfigurationUrl: PropTypes.string.isRequired,
validScopes: PropTypes.object.isRequired,
validPlacements: PropTypes.arrayOf(PropTypes.string).isRequired
}

View File

@ -23,7 +23,9 @@ import ToolConfigurationForm from '../ToolConfigurationForm'
function newProps() {
return {
toolConfiguration: {name: 'Test Tool', url: 'https://www.test.com/launch'},
toolConfigurationUrl: 'https://www.test.com/config.json'
toolConfigurationUrl: 'https://www.test.com/config.json',
validScopes: {},
validPlacements: []
}
}

View File

@ -36,6 +36,9 @@ module Schemas::Lti
"description" => {
"type" => "string"
}.freeze,
"icon_url" => {
"type" => "string"
}.freeze,
"scopes" => {
"type" => "array",
"items" => {