Skip to content
Draft
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
1 change: 1 addition & 0 deletions .env
Original file line number Diff line number Diff line change
Expand Up @@ -42,5 +42,6 @@ CAREER_LINK_URL=''
ENABLE_EDX_PERSONAL_DASHBOARD=false
ENABLE_PROGRAMS=false
NON_BROWSABLE_COURSES=false
SHOW_UNENROLL_SURVEY=true
# Fallback in local style files
PARAGON_THEME_URLS={}
1 change: 1 addition & 0 deletions .env.development
Original file line number Diff line number Diff line change
Expand Up @@ -48,5 +48,6 @@ CAREER_LINK_URL=''
ENABLE_EDX_PERSONAL_DASHBOARD=false
ENABLE_PROGRAMS=false
NON_BROWSABLE_COURSES=false
SHOW_UNENROLL_SURVEY=true
# Fallback in local style files
PARAGON_THEME_URLS={}
1 change: 1 addition & 0 deletions .env.test
Original file line number Diff line number Diff line change
Expand Up @@ -47,4 +47,5 @@ CAREER_LINK_URL=''
ENABLE_EDX_PERSONAL_DASHBOARD=true
ENABLE_PROGRAMS=false
NON_BROWSABLE_COURSES=false
SHOW_UNENROLL_SURVEY=true
PARAGON_THEME_URLS={}
1 change: 1 addition & 0 deletions example.env.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -70,4 +70,5 @@ module.exports = {
ENABLE_NOTICES: '',
CAREER_LINK_URL: '',
EXPERIMENT_08_23_VAN_PAINTED_DOOR: true,
SHOW_UNENROLL_SURVEY: true
};
1 change: 1 addition & 0 deletions src/config/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ const configuration = {
SEARCH_CATALOG_URL: process.env.SEARCH_CATALOG_URL || null,
ENABLE_PROGRAMS: process.env.ENABLE_PROGRAMS === 'true',
NON_BROWSABLE_COURSES: process.env.NON_BROWSABLE_COURSES === 'true',
SHOW_UNENROLL_SURVEY: process.env.SHOW_UNENROLL_SURVEY === 'true',
};

const features = {};
Expand Down
9 changes: 6 additions & 3 deletions src/containers/UnenrollConfirmModal/components/ReasonPane.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -50,8 +50,8 @@ export const ReasonPane = ({
</>
);
};
ReasonPane.propTypes = {
reason: PropTypes.shape({

export const reasonShape = PropTypes.shape({
value: PropTypes.string,
hasReason: PropTypes.bool,
selectOption: PropTypes.func,
Expand All @@ -61,7 +61,10 @@ ReasonPane.propTypes = {
}),
selected: PropTypes.string,
handleSubmit: PropTypes.func.isRequired,
}).isRequired,
})

ReasonPane.propTypes = {
reason: reasonShape.isRequired,
handleClose: PropTypes.func.isRequired,
};

Expand Down
15 changes: 13 additions & 2 deletions src/containers/UnenrollConfirmModal/hooks/index.js
Original file line number Diff line number Diff line change
@@ -1,10 +1,13 @@
import { getConfig } from '@edx/frontend-platform';

import React from 'react';

import { StrictDict } from 'utils';
import { apiHooks } from 'hooks';

import { useUnenrollReasons } from './reasons';
import * as module from '.';
import { configuration } from 'config';

export const state = StrictDict({
confirmed: (val) => React.useState(val), // eslint-disable-line
Expand All @@ -18,13 +21,21 @@ export const modalStates = StrictDict({

export const useUnenrollData = ({ closeModal, cardId }) => {
const [isConfirmed, setIsConfirmed] = module.state.confirmed(false);
const confirm = () => setIsConfirmed(true);
const reason = useUnenrollReasons({ cardId });
const refreshList = apiHooks.useInitializeApp();

const unenrollFromCourse = apiHooks.useUnenrollFromCourse(cardId);

const confirm = () => {
if (!configuration.SHOW_UNENROLL_SURVEY) {
unenrollFromCourse();
}
setIsConfirmed(true);
};

let modalState;
if (isConfirmed) {
modalState = (reason.isSubmitted)
modalState = (reason.isSubmitted || !configuration.SHOW_UNENROLL_SURVEY)
? modalStates.finished : modalStates.reason;
} else {
modalState = modalStates.confirm;
Expand Down
4 changes: 2 additions & 2 deletions src/containers/UnenrollConfirmModal/index.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,10 @@ import { ModalDialog } from '@openedx/paragon';
import { nullMethod } from 'utils';

import ConfirmPane from './components/ConfirmPane';
import ReasonPane from './components/ReasonPane';
import FinishedPane from './components/FinishedPane';

import { useUnenrollData, modalStates } from './hooks';
import CourseUnenrollReasonSlot from 'plugin-slots/CourseUnenrollReasonSlot';

export const UnenrollConfirmModal = ({
closeModal,
Expand Down Expand Up @@ -44,7 +44,7 @@ export const UnenrollConfirmModal = ({
<FinishedPane handleClose={closeAndRefresh} cardId={cardId} />
)}
{(modalState === modalStates.reason) && (
<ReasonPane reason={reason} handleClose={close} />
<CourseUnenrollReasonSlot reason={reason} close={close} />
)}
</div>
</ModalDialog>
Expand Down
4 changes: 2 additions & 2 deletions src/plugin-slots/CourseListSlot/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ This slot is used for replacing or adding content around the `CourseList` compon

## Example

The space will show the `CourseList` component by default. This can be disabled in the configuration with the `keepDefault` boolean.
The space will show the `CourseList` component by default. This can be disabled in the configuration with the `keepDefault` boolean.

![Screenshot of the CourseListSlot](./images/course_list_slot.png)

Expand Down Expand Up @@ -60,4 +60,4 @@ const config = {
}

export default config;
```
```
1 change: 1 addition & 0 deletions src/plugin-slots/CourseUnenrollReasonSlot/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
# Course Unenroll Slot
22 changes: 22 additions & 0 deletions src/plugin-slots/CourseUnenrollReasonSlot/index.jsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
import React from 'react'
import PropTypes from 'prop-types';

import { PluginSlot } from '@openedx/frontend-plugin-framework'
import ReasonPane, { reasonShape } from 'containers/UnenrollConfirmModal/components/ReasonPane'

const CourseUnenrollReasonSlot = ({ reason, close }) => (
<PluginSlot
id="org.openedx.frontend.learner_dashboard.course_unenroll.v1"
idAliases={["course_unenroll_slot"]}
pluginProps={{ reason, close }}
>
<ReasonPane reason={reason} handleClose={close} />
</PluginSlot>
);

CourseUnenrollReasonSlot.propTypes = {
reason: reasonShape.isRequired,
close: PropTypes.func.isRequired,
};

export default CourseUnenrollReasonSlot;
Empty file added webpack.dev-tutor.config.js
Empty file.