Revert "fix: remove PII sharing flag from live configuration (#296)" (#297)

This reverts commit 648ffe5884.
This commit is contained in:
Awais Ansari
2022-04-26 22:44:00 +05:00
committed by GitHub
parent 648ffe5884
commit fc16dfcb85
5 changed files with 75 additions and 35 deletions

View File

@@ -74,39 +74,45 @@ function LiveSettings({
</SelectableBox>
))}
</SelectableBox.Set>
<>
<p data-testid="helper-text">
{intl.formatMessage(messages.providerHelperText, { providerName: values.provider })}
{values.piiSharingEnable ? (
<>
<p data-testid="helper-text">
{intl.formatMessage(messages.providerHelperText, { providerName: values.provider })}
</p>
<p className="pb-2">{intl.formatMessage(messages.formInstructions)}</p>
<FormikControl
name="consumerKey"
value={values.consumerKey}
floatingLabel={intl.formatMessage(messages.consumerKey)}
className="pb-1"
type="input"
/>
<FormikControl
name="consumerSecret"
value={values.consumerSecret}
floatingLabel={intl.formatMessage(messages.consumerSecret)}
className="pb-1"
type="input"
/>
<FormikControl
name="launchUrl"
value={values.launchUrl}
floatingLabel={intl.formatMessage(messages.launchUrl)}
className="pb-1"
type="input"
/>
<FormikControl
name="launchEmail"
value={values.launchEmail}
floatingLabel={intl.formatMessage(messages.launchEmail)}
type="input"
/>
</>
) : (
<p data-testid="request-pii-sharing">
{intl.formatMessage(messages.requestPiiSharingEnable, { provider: values.provider })}
</p>
<p className="pb-2">{intl.formatMessage(messages.formInstructions)}</p>
<FormikControl
name="consumerKey"
value={values.consumerKey}
floatingLabel={intl.formatMessage(messages.consumerKey)}
className="pb-1"
type="input"
/>
<FormikControl
name="consumerSecret"
value={values.consumerSecret}
floatingLabel={intl.formatMessage(messages.consumerSecret)}
className="pb-1"
type="input"
/>
<FormikControl
name="launchUrl"
value={values.launchUrl}
floatingLabel={intl.formatMessage(messages.launchUrl)}
className="pb-1"
type="input"
/>
<FormikControl
name="launchEmail"
value={values.launchEmail}
floatingLabel={intl.formatMessage(messages.launchEmail)}
type="input"
/>
</>
)}
</>
)
}

View File

@@ -97,7 +97,7 @@ describe('LiveSettings', () => {
const fetchProviderConfigUrl = `${providerConfigurationApiUrl}/${courseId}/`;
axiosMock.onGet(fetchProviderConfigUrl).reply(
200,
generateLiveConfigurationApiResponse(false),
generateLiveConfigurationApiResponse(false, false),
);
await executeThunk(fetchLiveConfiguration(courseId), store.dispatch);
renderComponent();
@@ -114,7 +114,7 @@ describe('LiveSettings', () => {
const fetchProviderConfigUrl = `${providerConfigurationApiUrl}/${courseId}/`;
axiosMock.onGet(fetchProviderConfigUrl).reply(
200,
generateLiveConfigurationApiResponse(false),
generateLiveConfigurationApiResponse(false, true),
);
await executeThunk(fetchLiveConfiguration(courseId), store.dispatch);
renderComponent();
@@ -129,7 +129,7 @@ describe('LiveSettings', () => {
);
});
test('Displays helper text and lti fields for selected provider', async () => {
test('Only helper text and lti fields are visible when pii sharing is enabled', async () => {
const fetchProviderConfigUrl = `${providerConfigurationApiUrl}/${courseId}/`;
axiosMock.onGet(fetchProviderConfigUrl).reply(
200,
@@ -153,6 +153,30 @@ describe('LiveSettings', () => {
expect(launchEmail.lastChild).toHaveTextContent(messages.launchEmail.defaultMessage);
});
test('Only connect to support is visible when pii sharing is disabled', async () => {
const fetchProviderConfigUrl = `${providerConfigurationApiUrl}/${courseId}/`;
axiosMock.onGet(fetchProviderConfigUrl).reply(
200,
generateLiveConfigurationApiResponse(false, false),
);
await executeThunk(fetchLiveConfiguration(courseId), store.dispatch);
renderComponent();
const requestPiiText = queryByTestId(container, 'request-pii-sharing');
const consumerKey = container.querySelector('input[name="consumerKey"]');
const consumerSecret = container.querySelector('input[name="consumerSecret"]');
const launchUrl = container.querySelector('input[name="launchUrl"]');
const launchEmail = container.querySelector('input[name="launchEmail"]');
expect(requestPiiText).toHaveTextContent(
messages.requestPiiSharingEnable.defaultMessage.replaceAll('{provider}', 'zoom'),
);
expect(consumerKey).not.toBeInTheDocument();
expect(consumerSecret).not.toBeInTheDocument();
expect(launchUrl).not.toBeInTheDocument();
expect(launchEmail).not.toBeInTheDocument();
});
test('Form should be submitted and closed when valid data is provided', async () => {
const fetchProviderConfigUrl = `${providerConfigurationApiUrl}/${courseId}/`;
const apiDefaultResponse = generateLiveConfigurationApiResponse();

View File

@@ -15,6 +15,7 @@ function normalizeLiveConfig(config) {
configuration.launchUrl = config?.ltiConfiguration?.lti1P1LaunchUrl || '';
configuration.launchEmail = config?.ltiConfiguration?.ltiConfig?.additionalParameters?.customInstructorEmail || '';
configuration.provider = config?.providerType || 'zoom';
configuration.piiSharingEnable = config?.piiSharingAllowed || false;
return configuration;
}
@@ -34,6 +35,7 @@ function deNormalizeLiveConfig(config) {
},
},
};
configuration.pii_sharing_allowed = config?.piiSharingEnable || false;
return configuration;
}

View File

@@ -56,6 +56,7 @@ export const initialState = {
launchUrl: '',
launchEmail: '',
provider: 'zoom',
piiSharingEnable: true,
},
saveStatus: 'successful',
configuredProvider: 'zoom',
@@ -64,6 +65,7 @@ export const initialState = {
export const generateLiveConfigurationApiResponse = (
enabled = true,
piiSharingAllowed = true,
) => ({
course_key: courseId,
provider_type: 'zoom',
@@ -79,4 +81,5 @@ export const generateLiveConfigurationApiResponse = (
},
},
},
pii_sharing_allowed: piiSharingAllowed,
});

View File

@@ -91,6 +91,11 @@ const messages = defineMessages({
defaultMessage: 'This configuration will require sharing username and emails of learners and the course team with {providerName}.',
description: 'Tells the user that sharing username and email is required for configuration',
},
requestPiiSharingEnable: {
id: 'authoring.live.requestPiiSharingEnable',
defaultMessage: 'This configuration will require sharing usernames and emails of learners and the course team with {provider}. To access the LTI configuration for {provider}, please request your edX project coordinator to get PII sharing enabled for this course.',
description: 'Tells the user that request edx project coordinator to enable the PII sharing to access the LTI configuration for a provider.',
},
general: {
id: 'authoring.live.appDocInstructions.documentationLink',
defaultMessage: 'General documentation',