Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
35 changes: 26 additions & 9 deletions src/advanced-settings/AdvancedSettings.jsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
import React, { useEffect, useState } from 'react';
import PropTypes from 'prop-types';
import { useDispatch, useSelector } from 'react-redux';
import { Container, Button, Layout } from '@edx/paragon';
import {
Container, Button, Layout, StatefulButton,
} from '@edx/paragon';
import { CheckCircle, Info, Warning } from '@edx/paragon/icons';
import { FormattedMessage, injectIntl, intlShape } from '@edx/frontend-platform/i18n';

Expand Down Expand Up @@ -35,8 +37,16 @@ const AdvancedSettings = ({ intl, courseId }) => {
const [showSuccessAlert, setShowSuccessAlert] = useState(false);
const loadingSettingsStatus = useSelector(getLoadingStatus);
const [isQueryPending, setIsQueryPending] = useState(false);
const [isEditableState, setIsEditableState] = useState(false);
const [showOverrideInternetConnectionAlert, setOverrideInternetConnectionAlert] = useState(false);
const isLoading = loadingSettingsStatus === RequestStatus.IN_PROGRESS;
const updateSettingsButtonState = {
labels: {
default: intl.formatMessage(messages.buttonSaveText),
pending: intl.formatMessage(messages.buttonSavingText),
},
disabledStates: ['pending'],
};

useEffect(() => {
dispatch(fetchCourseAppSettings(courseId));
Expand All @@ -45,8 +55,13 @@ const AdvancedSettings = ({ intl, courseId }) => {

useEffect(() => {
if (savingStatus === RequestStatus.SUCCESSFUL) {
setShowSuccessAlert(true);
window.scrollTo({ top: 0, behavior: 'smooth' });
setIsQueryPending(false);

if (!isEditableState) {
showSaveSettingsPrompt(false);
setShowSuccessAlert(true);
window.scrollTo({ top: 0, behavior: 'smooth' });
}
} else if (savingStatus === RequestStatus.FAILED) {
setErrorFields(settingsWithSendErrors);
showErrorModal(true);
Expand All @@ -63,6 +78,7 @@ const AdvancedSettings = ({ intl, courseId }) => {
if (!saveSettingsPrompt) {
showSaveSettingsPrompt(true);
}
setIsEditableState(true);
setOverrideInternetConnectionAlert(false);
setShowSuccessAlert(false);
setEditedSettings((prevEditedSettings) => ({
Expand All @@ -72,6 +88,7 @@ const AdvancedSettings = ({ intl, courseId }) => {
};

const handleResetSettingsValues = () => {
setIsEditableState(false);
showErrorModal(false);
setEditedSettings({});
showSaveSettingsPrompt(false);
Expand All @@ -85,9 +102,9 @@ const AdvancedSettings = ({ intl, courseId }) => {
const handleUpdateAdvancedSettingsData = () => {
const isValid = validateAdvancedSettingsData(editedSettings, setErrorFields, setEditedSettings);
if (isValid) {
setIsEditableState(false);
setIsQueryPending(true);
setOverrideInternetConnectionAlert(true);
showSaveSettingsPrompt(!saveSettingsPrompt);
} else {
setIsQueryPending(false);
showSaveSettingsPrompt(false);
Expand All @@ -103,8 +120,6 @@ const AdvancedSettings = ({ intl, courseId }) => {
};

const handleDispatchMethodCall = () => {
setIsQueryPending(false);
showSaveSettingsPrompt(false);
setOverrideInternetConnectionAlert(false);
};

Expand Down Expand Up @@ -221,9 +236,11 @@ const AdvancedSettings = ({ intl, courseId }) => {
<Button variant="tertiary" onClick={handleResetSettingsValues}>
{intl.formatMessage(messages.buttonCancelText)}
</Button>,
<Button onClick={handleUpdateAdvancedSettingsData}>
{intl.formatMessage(messages.buttonSaveText)}
</Button>,
<StatefulButton
onClick={handleUpdateAdvancedSettingsData}
state={isQueryPending && 'pending'}
{...updateSettingsButtonState}
/>,
]}
variant="warning"
icon={Warning}
Expand Down
4 changes: 4 additions & 0 deletions src/advanced-settings/messages.js
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,10 @@ const messages = defineMessages({
id: 'course-authoring.advanced-settings.alert.button.save',
defaultMessage: 'Save changes',
},
buttonSavingText: {
id: 'course-authoring.advanced-settings.alert.button.saving',
defaultMessage: 'Saving',
},
buttonCancelText: {
id: 'course-authoring.advanced-settings.alert.button.cancel',
defaultMessage: 'Cancel',
Expand Down
10 changes: 10 additions & 0 deletions src/assets/scss/_form.scss
Original file line number Diff line number Diff line change
Expand Up @@ -16,4 +16,14 @@
width: 100%;
justify-content: space-between;
}

.form-group-custom_isInvalid {
input {
border-color: $form-feedback-invalid-color;
}
}

.feedback-error {
color: $form-feedback-invalid-color;
}
}
3 changes: 3 additions & 0 deletions src/generic/ApplyWrapper.jsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
const ApplyWrapper = ({ condition, wrapper, children }) => (condition ? wrapper(children) : children);

export default ApplyWrapper;
47 changes: 46 additions & 1 deletion src/i18n/messages/ar.json
Original file line number Diff line number Diff line change
Expand Up @@ -553,5 +553,50 @@
"course-authoring.generic.alert.warning.offline.title": "Studio's having trouble saving your work",
"course-authoring.generic.alert.warning.offline.description": "This may be happening because of an error with our server or your internet connection. Try refreshing the page or making sure you are online.",
"course-authoring.generic.alert.warning.offline.title.aria.labelled-by": "alert-internet-error-title",
"course-authoring.generic.alert.warning.offline.subtitle.aria.described-by": "alert-internet-error-description"
"course-authoring.generic.alert.warning.offline.subtitle.aria.described-by": "alert-internet-error-description",
"course-authoring.schedule-section.requirements.entrance.label": "Entrance exam",
"course-authoring.schedule-section.requirements.entrance.collapse.title": "Require students to pass an exam before beginning the course.",
"course-authoring.schedule-section.requirements.entrance.collapse.paragraph": "You can now view and author your course entrance exam from the {hyperlink}.",
"course-authoring.schedule-section.requirements.entrance.collapse.hyperlink": "course outline",
"course-authoring.schedule-section.requirements.entrance.collapse.label": "Grade requirements",
"course-authoring.schedule-section.requirements.entrance.collapse.help-text": "The score student must meet in order to successfully complete the entrance exam.",
"course-authoring.schedule-section.requirements.title": "Requirements",
"course-authoring.schedule-section.requirements.description": "Expectations of the students taking this course",
"course-authoring.schedule-section.requirements.timepicker.label": "Hours of effort per week",
"course-authoring.schedule-section.requirements.timepicker.help-text": "Time spent on all course work",
"course-authoring.schedule-section.requirements.dropdown.label": "Prerequisite course",
"course-authoring.schedule-section.requirements.dropdown.help-text": "Course that students must complete before beginning this course",
"course-authoring.schedule-section.requirements.dropdown.empty-text": "None",
"course-authoring.schedule-section.license.title": "Course content license",
"course-authoring.schedule-section.license.description": "Select the default license for course content",
"course-authoring.schedule-section.license.creative-commons.option.1.label": "Attribution",
"course-authoring.schedule-section.license.creative-commons.option.1.description": "Allow others to copy, distribute, display and perform your copyrighted work but only if they give credit the way you request. Currently, this option is required.",
"course-authoring.schedule-section.license.creative-commons.option.2.label": "Noncommercial",
"course-authoring.schedule-section.license.creative-commons.option.2.description": "Allow others to copy, distribute, display and perform your work - and derivative works based upon it - but for noncommercial purposes only.",
"course-authoring.schedule-section.license.creative-commons.option.3.label": "No derivatives",
"course-authoring.schedule-section.license.creative-commons.option.3.description": "Allow others to copy, distribute, display and perform only verbatim copies of your work, not derivative works based upon it. This option is incompatible with 'Share Alike'.",
"course-authoring.schedule-section.license.creative-commons.option.4.label": "Share alike",
"course-authoring.schedule-section.license.creative-commons.option.4.description": "Allow others to distribute derivative works only under a license identical to the license that governs your work. This option is incompatible with 'No Derivatives'.",
"course-authoring.schedule-section.license.type": "License type",
"course-authoring.schedule-section.license.choice-1": "All rights reserved",
"course-authoring.schedule-section.license.choice-2": "Creative commons",
"course-authoring.schedule-section.license.tooltip-1": "You reserve all rights for your work",
"course-authoring.schedule-section.license.tooltip-2": "You waive some rights for your work, such that others can use it too",
"course-authoring.schedule-section.license.creative-commons.url": "Learn more about creative commons",
"course-authoring.schedule-section.license.all-right-reserved.label": "All rights reserved",
"course-authoring.schedule-section.license.creative-commons.label": "Some rights reserved",
"course-authoring.schedule-section.license.license-display.label": "License display",
"course-authoring.schedule-section.license.license-display.paragraph": "The following message will be displayed at the bottom of the courseware pages within your course:",
"course-authoring.schedule-section.license.creative-commons.options.label": "Options for creative commons",
"course-authoring.schedule-section.license.creative-commons.options.help-text": "The following options are available for the creative commons license.",
"course-authoring.schedule-section.license.creative-commons.option.BY.label": "Attribution",
"course-authoring.schedule-section.license.creative-commons.option.BY.description": "Allow others to copy, distribute, display and perform your copyrighted work but only if they give credit the way you request. Currently, this option is required.",
"course-authoring.schedule-section.license.creative-commons.option.NC.label": "Noncommercial",
"course-authoring.schedule-section.license.creative-commons.option.NC.description": "Allow others to copy, distribute, display and perform your work - and derivative works based upon it - but for noncommercial purposes only.",
"course-authoring.schedule-section.license.creative-commons.option.ND.label": "No derivatives",
"course-authoring.schedule-section.license.creative-commons.option.ND.description": "Allow others to copy, distribute, display and perform only verbatim copies of your work, not derivative works based upon it. This option is incompatible with 'Share Alike'.",
"course-authoring.schedule-section.license.creative-commons.option.SA.label": "Share alike",
"course-authoring.schedule-section.license.creative-commons.option.SA.description": "Allow others to distribute derivative works only under a license identical to the license that governs your work. This option is incompatible with 'No Derivatives'.",
"course-authoring.schedule.alert.button.saving": "Saving",
"course-authoring.advanced-settings.alert.button.saving": "Saving"
}
47 changes: 46 additions & 1 deletion src/i18n/messages/de.json
Original file line number Diff line number Diff line change
Expand Up @@ -553,5 +553,50 @@
"course-authoring.generic.alert.warning.offline.title": "Studio's having trouble saving your work",
"course-authoring.generic.alert.warning.offline.description": "This may be happening because of an error with our server or your internet connection. Try refreshing the page or making sure you are online.",
"course-authoring.generic.alert.warning.offline.title.aria.labelled-by": "alert-internet-error-title",
"course-authoring.generic.alert.warning.offline.subtitle.aria.described-by": "alert-internet-error-description"
"course-authoring.generic.alert.warning.offline.subtitle.aria.described-by": "alert-internet-error-description",
"course-authoring.schedule-section.requirements.entrance.label": "Entrance exam",
"course-authoring.schedule-section.requirements.entrance.collapse.title": "Require students to pass an exam before beginning the course.",
"course-authoring.schedule-section.requirements.entrance.collapse.paragraph": "You can now view and author your course entrance exam from the {hyperlink}.",
"course-authoring.schedule-section.requirements.entrance.collapse.hyperlink": "course outline",
"course-authoring.schedule-section.requirements.entrance.collapse.label": "Grade requirements",
"course-authoring.schedule-section.requirements.entrance.collapse.help-text": "The score student must meet in order to successfully complete the entrance exam.",
"course-authoring.schedule-section.requirements.title": "Requirements",
"course-authoring.schedule-section.requirements.description": "Expectations of the students taking this course",
"course-authoring.schedule-section.requirements.timepicker.label": "Hours of effort per week",
"course-authoring.schedule-section.requirements.timepicker.help-text": "Time spent on all course work",
"course-authoring.schedule-section.requirements.dropdown.label": "Prerequisite course",
"course-authoring.schedule-section.requirements.dropdown.help-text": "Course that students must complete before beginning this course",
"course-authoring.schedule-section.requirements.dropdown.empty-text": "None",
"course-authoring.schedule-section.license.title": "Course content license",
"course-authoring.schedule-section.license.description": "Select the default license for course content",
"course-authoring.schedule-section.license.creative-commons.option.1.label": "Attribution",
"course-authoring.schedule-section.license.creative-commons.option.1.description": "Allow others to copy, distribute, display and perform your copyrighted work but only if they give credit the way you request. Currently, this option is required.",
"course-authoring.schedule-section.license.creative-commons.option.2.label": "Noncommercial",
"course-authoring.schedule-section.license.creative-commons.option.2.description": "Allow others to copy, distribute, display and perform your work - and derivative works based upon it - but for noncommercial purposes only.",
"course-authoring.schedule-section.license.creative-commons.option.3.label": "No derivatives",
"course-authoring.schedule-section.license.creative-commons.option.3.description": "Allow others to copy, distribute, display and perform only verbatim copies of your work, not derivative works based upon it. This option is incompatible with 'Share Alike'.",
"course-authoring.schedule-section.license.creative-commons.option.4.label": "Share alike",
"course-authoring.schedule-section.license.creative-commons.option.4.description": "Allow others to distribute derivative works only under a license identical to the license that governs your work. This option is incompatible with 'No Derivatives'.",
"course-authoring.schedule-section.license.type": "License type",
"course-authoring.schedule-section.license.choice-1": "All rights reserved",
"course-authoring.schedule-section.license.choice-2": "Creative commons",
"course-authoring.schedule-section.license.tooltip-1": "You reserve all rights for your work",
"course-authoring.schedule-section.license.tooltip-2": "You waive some rights for your work, such that others can use it too",
"course-authoring.schedule-section.license.creative-commons.url": "Learn more about creative commons",
"course-authoring.schedule-section.license.all-right-reserved.label": "All rights reserved",
"course-authoring.schedule-section.license.creative-commons.label": "Some rights reserved",
"course-authoring.schedule-section.license.license-display.label": "License display",
"course-authoring.schedule-section.license.license-display.paragraph": "The following message will be displayed at the bottom of the courseware pages within your course:",
"course-authoring.schedule-section.license.creative-commons.options.label": "Options for creative commons",
"course-authoring.schedule-section.license.creative-commons.options.help-text": "The following options are available for the creative commons license.",
"course-authoring.schedule-section.license.creative-commons.option.BY.label": "Attribution",
"course-authoring.schedule-section.license.creative-commons.option.BY.description": "Allow others to copy, distribute, display and perform your copyrighted work but only if they give credit the way you request. Currently, this option is required.",
"course-authoring.schedule-section.license.creative-commons.option.NC.label": "Noncommercial",
"course-authoring.schedule-section.license.creative-commons.option.NC.description": "Allow others to copy, distribute, display and perform your work - and derivative works based upon it - but for noncommercial purposes only.",
"course-authoring.schedule-section.license.creative-commons.option.ND.label": "No derivatives",
"course-authoring.schedule-section.license.creative-commons.option.ND.description": "Allow others to copy, distribute, display and perform only verbatim copies of your work, not derivative works based upon it. This option is incompatible with 'Share Alike'.",
"course-authoring.schedule-section.license.creative-commons.option.SA.label": "Share alike",
"course-authoring.schedule-section.license.creative-commons.option.SA.description": "Allow others to distribute derivative works only under a license identical to the license that governs your work. This option is incompatible with 'No Derivatives'.",
"course-authoring.schedule.alert.button.saving": "Saving",
"course-authoring.advanced-settings.alert.button.saving": "Saving"
}
Loading