fix: dont show free tier in options if no free tier available
fix: free_tier not sent in zoom configs and lti config removed from free_tier fix: bbb all use cases fixed
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
import React, { useState } from 'react';
|
||||
import React, { useEffect, useState } from 'react';
|
||||
import { FormattedMessage, injectIntl, intlShape } from '@edx/frontend-platform/i18n';
|
||||
import { Form, Hyperlink } from '@edx/paragon';
|
||||
import PropTypes from 'prop-types';
|
||||
@@ -14,10 +14,17 @@ function BbbSettings({
|
||||
setFieldValue,
|
||||
}) {
|
||||
const [bbbPlan, setBbbPlan] = useState(values.tierType);
|
||||
|
||||
useEffect(() => {
|
||||
setBbbPlan(values.tierType);
|
||||
}, [values.tierType]);
|
||||
|
||||
const appInfo = useModel('courseApps', 'live');
|
||||
const app = useModel('liveApps', 'big_blue_button');
|
||||
const isPiiDisabled = !values.piiSharingEnable;
|
||||
function getBbbPlanOptions() {
|
||||
const options = ['Select', bbbPlanTypes.free, bbbPlanTypes.commercial];
|
||||
const options = ['Select', bbbPlanTypes.commercial];
|
||||
if (app.hasFreeTier) { options.push(bbbPlanTypes.free); }
|
||||
return options.map(option => (
|
||||
<option
|
||||
key={option}
|
||||
|
||||
@@ -94,13 +94,13 @@ describe('BBB Settings', () => {
|
||||
expect(container.querySelector('select[name="tierType"]')).not.toBeDisabled();
|
||||
});
|
||||
|
||||
it('Plan dropdown should display correct number of options', async () => {
|
||||
await mockStore({ emailSharing: true });
|
||||
test.each([[true, 3], [false, 2]])('Plan dropdown should display correct number of options', async (isFreeTier, noOfOptions) => {
|
||||
await mockStore({ emailSharing: true, isFreeTier });
|
||||
renderComponent();
|
||||
const spinner = getByRole(container, 'status');
|
||||
await waitForElementToBeRemoved(spinner);
|
||||
const dropDown = queryByTestId(container, 'plansDropDown');
|
||||
expect(getAllByRole(dropDown, 'option').length).toBe(3);
|
||||
expect(getAllByRole(dropDown, 'option').length).toBe(noOfOptions);
|
||||
});
|
||||
|
||||
test('Connect to support and PII sharing message is visible and plans selection is disabled, When pii sharing is disabled, ',
|
||||
|
||||
@@ -24,7 +24,7 @@ function LiveSettings({
|
||||
const courseId = useSelector(state => state.courseDetail.courseId);
|
||||
const availableProviders = useSelector((state) => state.live.appIds);
|
||||
const {
|
||||
piiSharingAllowed, selectedAppId, enabled, status, tierType,
|
||||
piiSharingAllowed, selectedAppId, enabled, status,
|
||||
} = useSelector(state => state.live);
|
||||
|
||||
const appConfig = useModel('liveAppConfigs', selectedAppId);
|
||||
@@ -40,7 +40,7 @@ function LiveSettings({
|
||||
piiSharingEnable: piiSharingAllowed || false,
|
||||
piiSharingUsername: app?.piiSharing?.username || false,
|
||||
piiSharingEmail: app?.piiSharing?.email || false,
|
||||
tierType: tierType || '',
|
||||
tierType: appConfig?.tierType || '',
|
||||
};
|
||||
|
||||
const validationSchema = {
|
||||
|
||||
@@ -18,6 +18,7 @@ function normalizeProviders(data) {
|
||||
featureIds: app.features,
|
||||
name: app.name,
|
||||
piiSharing: app.pii_sharing,
|
||||
hasFreeTier: app.has_free_tier,
|
||||
}));
|
||||
|
||||
return {
|
||||
@@ -36,7 +37,8 @@ function normalizeLtiConfig(data) {
|
||||
consumerKey: data.lti_1p1_client_key,
|
||||
consumerSecret: data.lti_1p1_client_secret,
|
||||
launchUrl: data.lti_1p1_launch_url,
|
||||
launchEmail: data.lti_config.additional_parameters?.custom_instructor_email,
|
||||
launchEmail: data.lti_config?.additional_parameters?.custom_instructor_email,
|
||||
tierType: data.tierType,
|
||||
};
|
||||
}
|
||||
|
||||
@@ -48,10 +50,9 @@ export function normalizeSettings(data) {
|
||||
return {
|
||||
enabled: data.enabled,
|
||||
piiSharingAllowed: data.pii_sharing_allowed,
|
||||
tierType: tier,
|
||||
appConfig: {
|
||||
id: data.provider_type,
|
||||
...normalizeLtiConfig(data.lti_configuration),
|
||||
...normalizeLtiConfig({ ...data.lti_configuration, tierType: tier }),
|
||||
},
|
||||
};
|
||||
}
|
||||
@@ -67,12 +68,13 @@ export function deNormalizeSettings(data) {
|
||||
if (data.launchUrl) {
|
||||
ltiConfiguration.lti_1p1_launch_url = data.launchUrl;
|
||||
}
|
||||
if (data.launchEmail) {
|
||||
ltiConfiguration.lti_config = {
|
||||
additional_parameters: {
|
||||
if (data?.provider === 'zoom' || data.tierType !== 'Free') {
|
||||
ltiConfiguration.lti_config = {};
|
||||
if (data.launchEmail) {
|
||||
ltiConfiguration.lti_config.additional_parameters = {
|
||||
custom_instructor_email: data.launchEmail,
|
||||
},
|
||||
};
|
||||
};
|
||||
}
|
||||
}
|
||||
if (Object.keys(ltiConfiguration).length > 0) {
|
||||
// Only add this in if we're sending LTI fields.
|
||||
@@ -82,10 +84,10 @@ export function deNormalizeSettings(data) {
|
||||
|
||||
const apiData = {
|
||||
enabled: data?.enabled || false,
|
||||
lti_configuration: ltiConfiguration,
|
||||
lti_configuration: Object.keys(ltiConfiguration).length ? ltiConfiguration : undefined,
|
||||
provider_type: data?.provider || 'zoom',
|
||||
pii_sharing_allowed: data?.piiSharingEnable || false,
|
||||
free_tier: Boolean(data.tierType === 'Free'),
|
||||
free_tier: data?.provider === 'zoom' ? false : Boolean(data.tierType === 'Free'),
|
||||
};
|
||||
return apiData;
|
||||
}
|
||||
@@ -110,7 +112,6 @@ export async function getLiveProviders(courseId) {
|
||||
export async function getLiveConfiguration(courseId) {
|
||||
const { data } = await getAuthenticatedHttpClient()
|
||||
.get(`${providerConfigurationApiUrl}/${courseId}/`);
|
||||
|
||||
return normalizeSettings(data);
|
||||
}
|
||||
|
||||
@@ -119,6 +120,5 @@ export async function postLiveConfiguration(courseId, config) {
|
||||
`${providerConfigurationApiUrl}/${courseId}/`,
|
||||
deNormalizeSettings(config),
|
||||
);
|
||||
|
||||
return normalizeSettings(data);
|
||||
}
|
||||
|
||||
@@ -37,7 +37,7 @@ export const configurationProviders = (
|
||||
emailSharing,
|
||||
usernameSharing,
|
||||
activeProvider = 'zoom',
|
||||
isFreeTier,
|
||||
hasFreeTier,
|
||||
) => ({
|
||||
providers: {
|
||||
active: activeProvider,
|
||||
@@ -54,7 +54,7 @@ export const configurationProviders = (
|
||||
big_blue_button: {
|
||||
additional_parameters: [],
|
||||
features: [],
|
||||
has_free_tier: isFreeTier,
|
||||
has_free_tier: hasFreeTier,
|
||||
name: 'Big Blue Button',
|
||||
},
|
||||
},
|
||||
|
||||
Reference in New Issue
Block a user