From 3921b8c6b896259fa53f4b5ac5b4fa719082506d Mon Sep 17 00:00:00 2001
From: Awais Ansari <79941147+awais-ansari@users.noreply.github.com>
Date: Mon, 2 Aug 2021 17:26:09 +0500
Subject: [PATCH] =?UTF-8?q?fix:=20calculator=20switch=20click=20issue=20an?=
=?UTF-8?q?d=20save=20button=20animation=20will=20be=20=E2=80=A6=20(#169)?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
* fix: calculator switch click issue and save button animation will be clickable without any changes
* style: remove inline style and fix content display glitch
* style: TNL-8566 add padding top for external link
* style: TNL-8574 fix badge width and height
* fix: resolve console error and remove fix height for modal dialog
---
src/generic/FormSwitchGroup.jsx | 16 +++----
src/generic/FormSwitchGroup.scss | 7 +++
.../app-settings-modal/AppSettingsModal.jsx | 48 ++++++++++++-------
.../app-settings-modal/AppSettingsModal.scss | 4 ++
.../app-settings-modal/messages.js | 18 +++----
.../apps/legacy/LegacyConfigForm.jsx | 15 ++----
.../apps/legacy/LegacyConfigFormProvider.jsx | 11 ++++-
src/pages-and-resources/pages/PageCard.jsx | 26 +++++-----
src/pages-and-resources/pages/PageGrid.jsx | 4 +-
9 files changed, 85 insertions(+), 64 deletions(-)
create mode 100644 src/generic/FormSwitchGroup.scss
create mode 100644 src/pages-and-resources/app-settings-modal/AppSettingsModal.scss
diff --git a/src/generic/FormSwitchGroup.jsx b/src/generic/FormSwitchGroup.jsx
index 5eadc2c94..48c9050e2 100644
--- a/src/generic/FormSwitchGroup.jsx
+++ b/src/generic/FormSwitchGroup.jsx
@@ -1,6 +1,8 @@
-import { Form, SwitchControl } from '@edx/paragon';
-import PropTypes from 'prop-types';
import React from 'react';
+import PropTypes from 'prop-types';
+import { Form, SwitchControl } from '@edx/paragon';
+
+import './FormSwitchGroup.scss';
export default function FormSwitchGroup({
id,
@@ -23,8 +25,8 @@ export default function FormSwitchGroup({
className={className}
>
-
-
);
}
diff --git a/src/generic/FormSwitchGroup.scss b/src/generic/FormSwitchGroup.scss
new file mode 100644
index 000000000..1f222ba46
--- /dev/null
+++ b/src/generic/FormSwitchGroup.scss
@@ -0,0 +1,7 @@
+.helper-text {
+ font-size: 1.125rem !important;
+}
+
+.z-index-3 {
+ z-index: 3;
+}
diff --git a/src/pages-and-resources/app-settings-modal/AppSettingsModal.jsx b/src/pages-and-resources/app-settings-modal/AppSettingsModal.jsx
index fcac1a146..5184c0be5 100644
--- a/src/pages-and-resources/app-settings-modal/AppSettingsModal.jsx
+++ b/src/pages-and-resources/app-settings-modal/AppSettingsModal.jsx
@@ -5,6 +5,7 @@ import {
Form, Hyperlink, ModalDialog, Spinner, TransitionReplace,
StatefulButton, Badge, ActionRow,
} from '@edx/paragon';
+import classNames from 'classnames';
import { Formik } from 'formik';
import { useDispatch, useSelector } from 'react-redux';
import * as Yup from 'yup';
@@ -19,6 +20,8 @@ import { PagesAndResourcesContext } from '../PagesAndResourcesProvider';
import messages from './messages';
import { useIsMobile } from '../../utils';
+import './AppSettingsModal.scss';
+
function AppSettingsForm({ formikProps, children }) {
return children && (
@@ -76,10 +79,7 @@ function AppSettingsModal({
}, [updateSettingsRequestStatus]);
const handleFormSubmit = (values) => {
- // If the app's enabled/disabled loadingStatus has changed, set that first.
- if (appInfo.enabled !== values.enabled) {
- dispatch(updateAppStatus(courseId, appInfo.id, values.enabled, true));
- }
+ dispatch(updateAppStatus(courseId, appInfo.id, values.enabled));
// Call the submit handler for the settings component to save its settings
if (onSettingsSave) {
onSettingsSave();
@@ -99,12 +99,12 @@ function AppSettingsModal({
return (
{
@@ -130,26 +130,31 @@ function AppSettingsModal({
{title}
-
+
formikProps.handleChange(event)}
onBlur={formikProps.handleBlur}
checked={formikProps.values.enabled}
label={(
- <>
- {enableAppLabel}
+
+ {enableAppLabel}
{
formikProps.values.enabled && (
-
+
{intl.formatMessage(messages.enabled)}
)
}
- >
+
+ )}
+ helpText={(
+
+
{enableAppHelp}
+
{learnMoreLink}
+
)}
- helpText={({enableAppHelp}
{learnMoreLink}
)}
/>
{children}
@@ -159,16 +164,23 @@ function AppSettingsModal({
{formikProps.values.enabled && children
&& }
-
+
{intl.formatMessage(messages.cancel)}
{
- dispatch(updateValidationStatus({ hasError: isFormInvalid }));
- }, [isFormInvalid]);
-
const [validDiscussionTopics, setValidDiscussionTopics] = useState(appConfig.discussionTopics);
const legacyFormValidationSchema = Yup.object().shape({
blackoutDates: Yup.string().matches(
@@ -87,9 +78,9 @@ function LegacyConfigForm({
validDiscussionTopics,
setValidDiscussionTopics,
discussionTopicErrors,
+ isFormInvalid: discussionTopicErrors.some((error) => error === true)
+ || Boolean(touched.blackoutDates && errors.blackoutDates),
};
- setIsFormInvalid(discussionTopicErrors.some((error) => error === true)
- || Boolean(touched.blackoutDates && errors.blackoutDates));
return (
diff --git a/src/pages-and-resources/discussions/app-config-form/apps/legacy/LegacyConfigFormProvider.jsx b/src/pages-and-resources/discussions/app-config-form/apps/legacy/LegacyConfigFormProvider.jsx
index 72ac50f82..2d0fcd66e 100644
--- a/src/pages-and-resources/discussions/app-config-form/apps/legacy/LegacyConfigFormProvider.jsx
+++ b/src/pages-and-resources/discussions/app-config-form/apps/legacy/LegacyConfigFormProvider.jsx
@@ -1,9 +1,17 @@
-import React, { createContext } from 'react';
+import React, { createContext, useEffect } from 'react';
import PropTypes from 'prop-types';
+import { useDispatch } from 'react-redux';
+import { updateValidationStatus } from '../../../data/slice';
export const LegacyConfigFormContext = createContext({});
export default function LegacyConfigFormProvider({ children, value }) {
+ const dispatch = useDispatch();
+
+ useEffect(() => {
+ dispatch(updateValidationStatus({ hasError: value.isFormInvalid }));
+ }, [value.isFormInvalid]);
+
return (
{children}
@@ -22,5 +30,6 @@ LegacyConfigFormProvider.propTypes = {
})),
setValidDiscussionTopics: PropTypes.func,
})),
+ isFormInvalid: PropTypes.bool,
}).isRequired,
};
diff --git a/src/pages-and-resources/pages/PageCard.jsx b/src/pages-and-resources/pages/PageCard.jsx
index c5992b28e..194fdbfb7 100644
--- a/src/pages-and-resources/pages/PageCard.jsx
+++ b/src/pages-and-resources/pages/PageCard.jsx
@@ -68,19 +68,19 @@ function PageCard({
)}
>
-
- {page.name}
-
-
-
- {
- page.enabled && (
-
- {intl.formatMessage(messages.enabled)}
-
- )
- }
-
+
+
+ {page.name}
+
+
+ {
+ page.enabled && (
+
+ {intl.formatMessage(messages.enabled)}
+
+ )
+ }
+
{page.description}
diff --git a/src/pages-and-resources/pages/PageGrid.jsx b/src/pages-and-resources/pages/PageGrid.jsx
index cd4a4aded..99531b3ba 100644
--- a/src/pages-and-resources/pages/PageGrid.jsx
+++ b/src/pages-and-resources/pages/PageGrid.jsx
@@ -14,8 +14,8 @@ function PageGrid({ pages }) {
}}
>
{pages.map((page) => (
-