From ffa179744068ac8f773d09b824c0e9bc83681498 Mon Sep 17 00:00:00 2001 From: vente16 Date: Thu, 7 Mar 2024 17:12:44 -0500 Subject: [PATCH] refactor: removing unnecessary bulk email form and changing paragon dependency --- plugins/communications-app/BodyForm/index.jsx | 2 +- .../communications-app/BodyForm/package.json | 2 +- .../communications-app/CheckBoxForm/index.jsx | 2 +- .../CheckBoxForm/package.json | 2 +- .../communications-app/InputForm/index.jsx | 2 +- .../communications-app/InputForm/package.json | 2 +- .../InstructionsProfreading/package.json | 2 +- .../RecipientsForm/index.jsx | 30 +++++++++++++++++-- .../RecipientsForm/package.json | 2 +- .../ScheduleSection/index.jsx | 4 +-- .../ScheduleSection/package.json | 2 +- .../communications-app/SubjectForm/index.jsx | 2 +- .../SubjectForm/package.json | 2 +- .../TaskAlertModalForm/package.json | 2 +- .../TestComponent/package.json | 2 +- .../bulk-email-tool/BulkEmailTool.jsx | 6 ++-- .../BuildEmailFormExtensible/index.jsx | 13 ++++++-- 17 files changed, 57 insertions(+), 22 deletions(-) diff --git a/plugins/communications-app/BodyForm/index.jsx b/plugins/communications-app/BodyForm/index.jsx index ace9eb49..ad7f3027 100644 --- a/plugins/communications-app/BodyForm/index.jsx +++ b/plugins/communications-app/BodyForm/index.jsx @@ -1,5 +1,5 @@ import React from 'react'; -import { Form } from '@edx/paragon'; +import { Form } from '@openedx/paragon'; import { useIntl } from '@edx/frontend-platform/i18n'; import TextEditor from '@communications-app/src/components/bulk-email-tool/text-editor/TextEditor'; import { useSelector, useDispatch } from '@communications-app/src/components/bulk-email-tool/bulk-email-form/BuildEmailFormExtensible/context'; diff --git a/plugins/communications-app/BodyForm/package.json b/plugins/communications-app/BodyForm/package.json index 0ea35414..21b5a755 100644 --- a/plugins/communications-app/BodyForm/package.json +++ b/plugins/communications-app/BodyForm/package.json @@ -8,7 +8,7 @@ "peerDependencies": { "@edx/frontend-app-communications": "*", "@edx/frontend-platform": "*", - "@edx/paragon": "*", + "@openedx/paragon": "*", "prop-types": "*", "react": "*" }, diff --git a/plugins/communications-app/CheckBoxForm/index.jsx b/plugins/communications-app/CheckBoxForm/index.jsx index 2ff8087c..c1918ca8 100644 --- a/plugins/communications-app/CheckBoxForm/index.jsx +++ b/plugins/communications-app/CheckBoxForm/index.jsx @@ -1,5 +1,5 @@ import PropTypes from 'prop-types'; -import { Form, Container } from '@edx/paragon'; +import { Form, Container } from '@openedx/paragon'; const CheckBoxForm = ({ isChecked, handleChange, label }) => ( diff --git a/plugins/communications-app/CheckBoxForm/package.json b/plugins/communications-app/CheckBoxForm/package.json index c975cc54..95f49097 100644 --- a/plugins/communications-app/CheckBoxForm/package.json +++ b/plugins/communications-app/CheckBoxForm/package.json @@ -8,7 +8,7 @@ "peerDependencies": { "@edx/frontend-app-communications": "*", "@edx/frontend-platform": "*", - "@edx/paragon": "*", + "@openedx/paragon": "*", "prop-types": "*", "react": "*" }, diff --git a/plugins/communications-app/InputForm/index.jsx b/plugins/communications-app/InputForm/index.jsx index d3ea0052..15a9f471 100644 --- a/plugins/communications-app/InputForm/index.jsx +++ b/plugins/communications-app/InputForm/index.jsx @@ -1,5 +1,5 @@ import PropTypes from 'prop-types'; -import { Form, Container } from '@edx/paragon'; +import { Form, Container } from '@openedx/paragon'; const InputForm = ({ isValid, diff --git a/plugins/communications-app/InputForm/package.json b/plugins/communications-app/InputForm/package.json index f2c24b38..93e5cd74 100644 --- a/plugins/communications-app/InputForm/package.json +++ b/plugins/communications-app/InputForm/package.json @@ -8,7 +8,7 @@ "peerDependencies": { "@edx/frontend-app-communications": "*", "@edx/frontend-platform": "*", - "@edx/paragon": "*", + "@openedx/paragon": "*", "prop-types": "*", "react": "*" }, diff --git a/plugins/communications-app/InstructionsProfreading/package.json b/plugins/communications-app/InstructionsProfreading/package.json index 128df89c..42c579fb 100644 --- a/plugins/communications-app/InstructionsProfreading/package.json +++ b/plugins/communications-app/InstructionsProfreading/package.json @@ -8,7 +8,7 @@ "peerDependencies": { "@edx/frontend-app-communications": "*", "@edx/frontend-platform": "*", - "@edx/paragon": "*", + "@openedx/paragon": "*", "prop-types": "*", "react": "*" }, diff --git a/plugins/communications-app/RecipientsForm/index.jsx b/plugins/communications-app/RecipientsForm/index.jsx index 4644cc94..6a9463d8 100644 --- a/plugins/communications-app/RecipientsForm/index.jsx +++ b/plugins/communications-app/RecipientsForm/index.jsx @@ -1,6 +1,6 @@ import React, { useEffect, useState } from 'react'; import PropTypes from 'prop-types'; -import { Form } from '@edx/paragon'; +import { Form } from '@openedx/paragon'; import { FormattedMessage } from '@edx/frontend-platform/i18n'; import { useSelector, useDispatch } from '@communications-app/src/components/bulk-email-tool/bulk-email-form/BuildEmailFormExtensible/context'; import { actionCreators as formActions } from '@communications-app/src/components/bulk-email-tool/bulk-email-form/BuildEmailFormExtensible/context/reducer'; @@ -10,10 +10,11 @@ import './styles.scss'; const disableIsHasLearners = ['track', 'cohort']; const recipientsFormDescription = 'A selectable choice from a list of potential email recipients'; -const RecipientsForm = ({ cohorts: additionalCohorts }) => { +const RecipientsForm = ({ cohorts: additionalCohorts, courseModes }) => { const formData = useSelector((state) => state.form); const dispatch = useDispatch(); const { isEditMode, emailRecipients, isFormSubmitted } = formData; + const hasCourseModes = courseModes.length > 1; const [selectedGroups, setSelectedGroups] = useState([]); const hasAllLearnersSelected = selectedGroups.some((group) => group === 'learners'); @@ -91,6 +92,24 @@ const RecipientsForm = ({ cohorts: additionalCohorts }) => { description={recipientsFormDescription} /> + { + // additional modes + hasCourseModes + && courseModes.map((courseMode) => ( + + + + )) + } { // additional cohorts additionalCohorts @@ -152,10 +171,17 @@ const RecipientsForm = ({ cohorts: additionalCohorts }) => { RecipientsForm.defaultProps = { cohorts: [], + courseModes: [], }; RecipientsForm.propTypes = { cohorts: PropTypes.arrayOf(PropTypes.string), + courseModes: PropTypes.arrayOf( + PropTypes.shape({ + slug: PropTypes.string.isRequired, + name: PropTypes.string.isRequired, + }), + ), }; export default RecipientsForm; diff --git a/plugins/communications-app/RecipientsForm/package.json b/plugins/communications-app/RecipientsForm/package.json index 2b033cca..50f961e9 100644 --- a/plugins/communications-app/RecipientsForm/package.json +++ b/plugins/communications-app/RecipientsForm/package.json @@ -8,7 +8,7 @@ "peerDependencies": { "@edx/frontend-app-communications": "*", "@edx/frontend-platform": "*", - "@edx/paragon": "*", + "@openedx/paragon": "*", "prop-types": "*", "react": "*" }, diff --git a/plugins/communications-app/ScheduleSection/index.jsx b/plugins/communications-app/ScheduleSection/index.jsx index 05f87883..428b0305 100644 --- a/plugins/communications-app/ScheduleSection/index.jsx +++ b/plugins/communications-app/ScheduleSection/index.jsx @@ -7,14 +7,14 @@ import { Form, Icon, Toast, -} from '@edx/paragon'; +} from '@openedx/paragon'; import { SpinnerSimple, Cancel, Send, Event, Check, -} from '@edx/paragon/icons'; +} from '@openedx/paragon/icons'; import { getConfig } from '@edx/frontend-platform'; import { useIntl } from '@edx/frontend-platform/i18n'; import ScheduleEmailForm from '@communications-app/src/components/bulk-email-tool/bulk-email-form/ScheduleEmailForm'; diff --git a/plugins/communications-app/ScheduleSection/package.json b/plugins/communications-app/ScheduleSection/package.json index 01e75963..10593432 100644 --- a/plugins/communications-app/ScheduleSection/package.json +++ b/plugins/communications-app/ScheduleSection/package.json @@ -8,7 +8,7 @@ "peerDependencies": { "@edx/frontend-app-communications": "*", "@edx/frontend-platform": "*", - "@edx/paragon": "*", + "@openedx/paragon": "*", "prop-types": "*", "react": "*" }, diff --git a/plugins/communications-app/SubjectForm/index.jsx b/plugins/communications-app/SubjectForm/index.jsx index 36be7894..c7512ced 100644 --- a/plugins/communications-app/SubjectForm/index.jsx +++ b/plugins/communications-app/SubjectForm/index.jsx @@ -1,5 +1,5 @@ import React from 'react'; -import { Form } from '@edx/paragon'; +import { Form } from '@openedx/paragon'; import { useIntl } from '@edx/frontend-platform/i18n'; import { useSelector, useDispatch } from '@communications-app/src/components/bulk-email-tool/bulk-email-form/BuildEmailFormExtensible/context'; import { actionCreators as formActions } from '@communications-app/src/components/bulk-email-tool/bulk-email-form/BuildEmailFormExtensible/context/reducer'; diff --git a/plugins/communications-app/SubjectForm/package.json b/plugins/communications-app/SubjectForm/package.json index a172927c..f72bc5eb 100644 --- a/plugins/communications-app/SubjectForm/package.json +++ b/plugins/communications-app/SubjectForm/package.json @@ -8,7 +8,7 @@ "peerDependencies": { "@edx/frontend-app-communications": "*", "@edx/frontend-platform": "*", - "@edx/paragon": "*", + "@openedx/paragon": "*", "prop-types": "*", "react": "*" }, diff --git a/plugins/communications-app/TaskAlertModalForm/package.json b/plugins/communications-app/TaskAlertModalForm/package.json index 9640863e..acbe905d 100644 --- a/plugins/communications-app/TaskAlertModalForm/package.json +++ b/plugins/communications-app/TaskAlertModalForm/package.json @@ -8,7 +8,7 @@ "peerDependencies": { "@edx/frontend-app-communications": "*", "@edx/frontend-platform": "*", - "@edx/paragon": "*", + "@openedx/paragon": "*", "prop-types": "*", "react": "*" }, diff --git a/plugins/communications-app/TestComponent/package.json b/plugins/communications-app/TestComponent/package.json index 185c4fa3..eec40ff0 100644 --- a/plugins/communications-app/TestComponent/package.json +++ b/plugins/communications-app/TestComponent/package.json @@ -8,7 +8,7 @@ "peerDependencies": { "@edx/frontend-app-communications": "*", "@edx/frontend-platform": "*", - "@edx/paragon": "*", + "@openedx/paragon": "*", "prop-types": "*", "react": "*" }, diff --git a/src/components/bulk-email-tool/BulkEmailTool.jsx b/src/components/bulk-email-tool/BulkEmailTool.jsx index a6fc44d5..ca9f15c7 100644 --- a/src/components/bulk-email-tool/BulkEmailTool.jsx +++ b/src/components/bulk-email-tool/BulkEmailTool.jsx @@ -34,9 +34,9 @@ export default function BulkEmailTool() {
-
diff --git a/src/components/bulk-email-tool/bulk-email-form/BuildEmailFormExtensible/index.jsx b/src/components/bulk-email-tool/bulk-email-form/BuildEmailFormExtensible/index.jsx index cac27fd3..c28b5cff 100644 --- a/src/components/bulk-email-tool/bulk-email-form/BuildEmailFormExtensible/index.jsx +++ b/src/components/bulk-email-tool/bulk-email-form/BuildEmailFormExtensible/index.jsx @@ -6,7 +6,7 @@ import { Form, Spinner, useToggle, -} from '@edx/paragon'; +} from '@openedx/paragon'; import { BulkEmailContext } from '../../bulk-email-context'; import useMobileResponsive from '../../../../utils/useMobileResponsive'; import PluggableComponent from '../../../PluggableComponent'; @@ -14,13 +14,14 @@ import PluggableComponent from '../../../PluggableComponent'; import { withContextProvider, useDispatch } from './context'; import { actionCreators as formActions } from './context/reducer'; -const BuildEmailFormExtensible = ({ courseId, cohorts }) => { +const BuildEmailFormExtensible = ({ courseId, cohorts, courseModes }) => { const isMobile = useMobileResponsive(); const [{ editor }] = useContext(BulkEmailContext); const [isTaskAlertOpen, openTaskAlert, closeTaskAlert] = useToggle(false); const dispatch = useDispatch(); useDeepCompareEffect(() => { + /* istanbul ignore next */ if (editor.editMode) { const newRecipientsValue = editor.emailRecipients; const newSubjectValue = editor.emailSubject; @@ -61,6 +62,7 @@ const BuildEmailFormExtensible = ({ courseId, cohorts }) => { as="communications-app-recipients-checks" cohorts={cohorts} courseId={courseId} + courseModes={courseModes} /> { BuildEmailFormExtensible.defaultProps = { cohorts: [], + courseModes: [], }; BuildEmailFormExtensible.propTypes = { courseId: PropTypes.string.isRequired, cohorts: PropTypes.arrayOf(PropTypes.string), + courseModes: PropTypes.arrayOf( + PropTypes.shape({ + slug: PropTypes.string.isRequired, + name: PropTypes.string.isRequired, + }), + ), }; export default withContextProvider(BuildEmailFormExtensible);