From ab3c5326b66c680c43a12183e02a2a5b1462f646 Mon Sep 17 00:00:00 2001 From: Simona Domnisoru Date: Mon, 14 Oct 2024 15:50:08 +0200 Subject: [PATCH] chore: [DHIS2-17915] remove opt-in functionality (#3796) --- .../EnrollmentAddEventPageForm.feature | 1 - .../BreakingTheGlass/BreakingTheGlass.feature | 1 - cypress/e2e/MainPage/MainPage.feature | 9 --- cypress/e2e/NewPage/NewPage.feature | 6 -- cypress/e2e/SearchPage/SearchPage.feature | 4 -- .../step_definitions/common/baseSteps.js | 30 -------- docs/user/using-the-capture-app.md | 14 ---- i18n/en.pot | 48 ------------- .../navigateToEnrollmentOverview.constants.js | 6 -- .../navigateToEnrollmentOverview.epics.js | 54 +++----------- .../components/DataStore/DataStore.actions.js | 6 -- .../components/DataStore/DataStore.epics.js | 61 ---------------- .../components/DataStore/DataStore.types.js | 9 --- .../components/DataStore/index.js | 1 - .../OptInOut/OptIn/OptIn.component.js | 71 ------------------- .../OptInOut/OptIn/OptIn.container.js | 57 --------------- .../components/OptInOut/OptIn/index.js | 2 - .../components/OptInOut/OptIn/optIn.types.js | 12 ---- .../OptInOut/OptOut/OptOut.component.js | 44 ------------ .../OptInOut/OptOut/OptOut.container.js | 36 ---------- .../components/OptInOut/OptOut/index.js | 2 - .../OptInOut/OptOut/optOut.types.js | 12 ---- .../capture-core/components/OptInOut/index.js | 3 - .../WorkingListsType.component.js | 3 - .../RegistrationDataEntry.epics.js | 6 +- .../getStageWithOpenAfterEnrollment.js | 3 +- .../ConnectedEntity/TrackedEntityInstance.js | 39 +++------- .../useNewDashboard.reducerDescription.js | 17 ----- .../capture-core/utils/routing/index.js | 1 - .../utils/routing/newDashboard.js | 16 ----- src/epics/trackerCapture.epics.js | 7 -- .../trackerCapture.reducerDescriptions.js | 2 - 32 files changed, 19 insertions(+), 564 deletions(-) delete mode 100644 src/core_modules/capture-core/actions/navigateToEnrollmentOverview/navigateToEnrollmentOverview.constants.js delete mode 100644 src/core_modules/capture-core/components/DataStore/DataStore.actions.js delete mode 100644 src/core_modules/capture-core/components/DataStore/DataStore.epics.js delete mode 100644 src/core_modules/capture-core/components/DataStore/DataStore.types.js delete mode 100644 src/core_modules/capture-core/components/DataStore/index.js delete mode 100644 src/core_modules/capture-core/components/OptInOut/OptIn/OptIn.component.js delete mode 100644 src/core_modules/capture-core/components/OptInOut/OptIn/OptIn.container.js delete mode 100644 src/core_modules/capture-core/components/OptInOut/OptIn/index.js delete mode 100644 src/core_modules/capture-core/components/OptInOut/OptIn/optIn.types.js delete mode 100644 src/core_modules/capture-core/components/OptInOut/OptOut/OptOut.component.js delete mode 100644 src/core_modules/capture-core/components/OptInOut/OptOut/OptOut.container.js delete mode 100644 src/core_modules/capture-core/components/OptInOut/OptOut/index.js delete mode 100644 src/core_modules/capture-core/components/OptInOut/OptOut/optOut.types.js delete mode 100644 src/core_modules/capture-core/components/OptInOut/index.js delete mode 100644 src/core_modules/capture-core/reducers/descriptions/useNewDashboard.reducerDescription.js delete mode 100644 src/core_modules/capture-core/utils/routing/newDashboard.js diff --git a/cypress/e2e/EnrollmentAddEventPage/EnrollmentAddEventPageForm/EnrollmentAddEventPageForm.feature b/cypress/e2e/EnrollmentAddEventPage/EnrollmentAddEventPageForm/EnrollmentAddEventPageForm.feature index 47bacdbe8a..869b837615 100644 --- a/cypress/e2e/EnrollmentAddEventPage/EnrollmentAddEventPageForm/EnrollmentAddEventPageForm.feature +++ b/cypress/e2e/EnrollmentAddEventPage/EnrollmentAddEventPageForm/EnrollmentAddEventPageForm.feature @@ -50,7 +50,6 @@ Feature: User interacts with the Enrollment New Event Workspace Scenario: User should be asked to create new event after completing a stage and choose to cancel Given you land on the enrollment new event page by having typed #/enrollmentEventNew?enrollmentId=zRfAPUpjoG3&orgUnitId=DiszpKrYNg8&programId=M3xtLkYBlKI&stageId=CWaAcQYKVpq&teiId=S3JjTA4QMNe - And the data store is clean Then you see the following Enrollment: New Event And you see the widget header Foci investigation & classification And you type 2022-01-01 in the input number 0 diff --git a/cypress/e2e/EnrollmentPage/BreakingTheGlass/BreakingTheGlass.feature b/cypress/e2e/EnrollmentPage/BreakingTheGlass/BreakingTheGlass.feature index 8f20612a24..40ed7aac7c 100644 --- a/cypress/e2e/EnrollmentPage/BreakingTheGlass/BreakingTheGlass.feature +++ b/cypress/e2e/EnrollmentPage/BreakingTheGlass/BreakingTheGlass.feature @@ -4,7 +4,6 @@ Feature: Breaking the glass page @skip Scenario: User with search scope access tries to access an enrollment in a protected program Given the tei created by this test is cleared from the database - And the data store is clean And you create a new tei in Child programme from Ngelehun CHC And you change program to WHO RMNCH Tracker And you enroll the tei from Njandama MCHP diff --git a/cypress/e2e/MainPage/MainPage.feature b/cypress/e2e/MainPage/MainPage.feature index cb10b479fb..8f29db3697 100644 --- a/cypress/e2e/MainPage/MainPage.feature +++ b/cypress/e2e/MainPage/MainPage.feature @@ -35,15 +35,6 @@ Feature: User interacts with Main page Then the current url is /#/?orgUnitId=DiszpKrYNg8&programId=uy2gU8kT1jF&selectedTemplateId=uy2gU8kT1jF-default And the TEI working list is displayed - Scenario: The admin user can optout from using the new Enrollment Dashboard - Given you open the main page with Ngelehun and child programme context - And the data store is clean - And you see the opt out component for Child Programme - When you opt out to use the new enrollment Dashboard for Child Programme - Then you see the opt in component for Child Programme - When you opt in to use the new enrollment Dashboard for Child Programme - Then you see the opt out component for Child Programme - @v<41 Scenario: The icon is rendered as an svg Given you are in the main page with no selections made diff --git a/cypress/e2e/NewPage/NewPage.feature b/cypress/e2e/NewPage/NewPage.feature index b6a7907dee..29b5ffc199 100644 --- a/cypress/e2e/NewPage/NewPage.feature +++ b/cypress/e2e/NewPage/NewPage.feature @@ -7,7 +7,6 @@ Feature: User creates a new entries from the registration page @v>=41 Scenario: New person in Tracker Program > Filling the Allergies with multiple options Given you are in the WHO RMNCH program registration page - And the data store is clean When you fill in multiple Allergies options Then you can see the multiple selections in the form And you fill the WHO RMNCH program registration form with its required unique values @@ -103,14 +102,12 @@ Feature: User creates a new entries from the registration page Scenario: New person > Submitting the form with unique name navigates you to the user dashboard Given you are in the Person registration page - And the data store is clean When you fill in a unique first name And you click the save person submit button Then you are navigated to the enrollment dashboard page without enrollment Scenario: New person > Submitting the form from the duplicates modal navigates you to the user dashboard Given you are in the Person registration page - And the data store is clean When you fill in the first name with value that has duplicates And you click the save person submit button And you see the possible duplicates modal @@ -152,7 +149,6 @@ Feature: User creates a new entries from the registration page Scenario: New person in Tracker Program > Submitting the form with unique values navigates you to the user dashboard Given you are in the WHO RMNCH program registration page - And the data store is clean When you fill the WHO RMNCH program registration form with its required unique values And you click the save person submit button Then you see the enrollment event Edit page @@ -166,7 +162,6 @@ Feature: User creates a new entries from the registration page Scenario: New person in Tracker Program > Submitting the form from the duplicates modal navigates you to the user dashboard Given you are in the WHO RMNCH program registration page - And the data store is clean When you fill the WHO RMNCH program registration form with its required values And you click the save person submit button And you see the possible duplicates modal @@ -192,7 +187,6 @@ Feature: User creates a new entries from the registration page Scenario: Go to enrollment event when Open data entry form after enrollment is checked Given you are in the Malaria case diagnosis, treatment and investigation program registration page - And the data store is clean And you fill the Malaria case diagnosis registration form with values And you click the save malaria entity submit button Then you see the enrollment event Edit page diff --git a/cypress/e2e/SearchPage/SearchPage.feature b/cypress/e2e/SearchPage/SearchPage.feature index b1a2a58741..afc2f9e035 100644 --- a/cypress/e2e/SearchPage/SearchPage.feature +++ b/cypress/e2e/SearchPage/SearchPage.feature @@ -24,7 +24,6 @@ Feature: User interacts with Search page Scenario: Searching using unique identifier returns results Given you are on the default search page - And the data store is clean When you select the search domain WHO RMNCH Tracker And you fill in the unique identifier field with values that will return a tracked entity instance And you click find @@ -97,7 +96,6 @@ Feature: User interacts with Search page Scenario: Searching using attributes in Tracker Program navigates user to the dashboard view Given you are on the default search page - And the data store is clean When you select the search domain WHO RMNCH Tracker And you expand the attributes search area And you fill in the last name with values that will return results @@ -108,7 +106,6 @@ Feature: User interacts with Search page Scenario: Searching using attributes in TEType navigates user to dashboard view Given you are on the default search page - And the data store is clean When you select the search domain Person And you expand the attributes search area And you fill in the the form with first name value: Cla @@ -165,7 +162,6 @@ Feature: User interacts with Search page Scenario: Pressing enter should trigger search unique identifier returns results Given you are on the default search page - And the data store is clean When you select the search domain WHO RMNCH Tracker And you press enter after filling in the unique identifier field with values that will return a tracked entity instance Then you are navigated to the enrollment dashboard page diff --git a/cypress/support/step_definitions/common/baseSteps.js b/cypress/support/step_definitions/common/baseSteps.js index 42c19ad164..a4db6e4a30 100644 --- a/cypress/support/step_definitions/common/baseSteps.js +++ b/cypress/support/step_definitions/common/baseSteps.js @@ -181,33 +181,3 @@ When(/^the user selects the org unit (.*)$/, (orgUnit) => { cy.contains(orgUnit) .click(); }); - -When(/^you opt in to use the new enrollment Dashboard for (.*)$/, (program) => { - cy.get('[data-test="main-page-working-list"]').then(($wrapper) => { - if ($wrapper.find('[data-test="dhis2-uicore-button"]').length > 0) { - cy.contains('[data-test="dhis2-uicore-button"]', `Opt in for ${program}`).click(); - cy.contains('[data-test="opt-in-button"]', 'Yes, opt in').click(); - cy.contains('[data-test="opt-out-button"]', `Opt out for ${program}`); - } - }); -}); - -Then(/^you see the opt out component for (.*)$/, (program) => { - cy.contains('[data-test="opt-out-button"]', `Opt out for ${program}`); -}); - -When(/^you opt out to use the new enrollment Dashboard for (.*)$/, (program) => { - cy.intercept('PUT', '**/dataStore/capture/useNewDashboard').as('optOutEnrollmentDashboard'); - cy.contains('[data-test="opt-out-button"]', `Opt out for ${program}`).click(); - cy.wait('@optOutEnrollmentDashboard', { timeout: 30000 }); -}); - -Then(/^you see the opt in component for (.*)$/, (program) => { - cy.contains('[data-test="dhis2-uicore-button"]', `Opt in for ${program}`); -}); - -And('the data store is clean', () => { - cy.buildApiUrl('dataStore/capture/useNewDashboard') - .then(dataStoreUrl => - cy.request({ method: 'DELETE', url: dataStoreUrl, failOnStatusCode: false })); -}); diff --git a/docs/user/using-the-capture-app.md b/docs/user/using-the-capture-app.md index 651e9f7eb0..fab4c41175 100644 --- a/docs/user/using-the-capture-app.md +++ b/docs/user/using-the-capture-app.md @@ -821,20 +821,6 @@ For performance reasons the Capture app caches metadata in the client browser. W ## Enrollment dashboard -### Enabling the enrollment dashboard - -#### Opt in - -Enable the enrollment dashboard for a Tracker program for all the users. The dialog is visible for users with program write access. - -![](resources/images/enrollment-dash-opt-in.png) - -#### Opt out - -Disable the enrollment dashboard for a Tracker program for all the users. - -![](resources/images/enrollment-dash-opt-out.png) - ### Reaching the enrollment dashboard via url You reach the enrollment dashboard either by typing in the address bar of your browser or using the user interface of the capture app. diff --git a/i18n/en.pot b/i18n/en.pot index d299bcedcf..c098e29ad6 100644 --- a/i18n/en.pot +++ b/i18n/en.pot @@ -616,54 +616,6 @@ msgstr "Notice" msgid "Close the notice" msgstr "Close the notice" -msgid "Use new Enrollment dashboard for {{programName}}" -msgstr "Use new Enrollment dashboard for {{programName}}" - -msgid "Opt in for {{programName}}" -msgstr "Opt in for {{programName}}" - -msgid "" -"By clicking opt-in below, you will start using the new enrollment dashboard " -"in the Capture app for this Tracker program. At the moment, there is " -"certain functionality from Tracker Capture that has not yet been added, " -"including relationship and referral functionality. The work on including " -"this Tracker functionality in Capture is ongoing and will be added in " -"upcoming app releases." -msgstr "" -"By clicking opt-in below, you will start using the new enrollment dashboard " -"in the Capture app for this Tracker program. At the moment, there is " -"certain functionality from Tracker Capture that has not yet been added, " -"including relationship and referral functionality. The work on including " -"this Tracker functionality in Capture is ongoing and will be added in " -"upcoming app releases." - -msgid "" -"The core team appreciates any feedback on this new functionality which is " -"currently being beta tested, please report any issues and feedback in the " -"DHIS2 JIRA project." -msgstr "" -"The core team appreciates any feedback on this new functionality which is " -"currently being beta tested, please report any issues and feedback in the " -"DHIS2 JIRA project." - -msgid "" -"Click the button below to opt-in to the new enrollment dashboard " -"functionality in the Capture app (beta) for this Tracker program for all " -"users." -msgstr "" -"Click the button below to opt-in to the new enrollment dashboard " -"functionality in the Capture app (beta) for this Tracker program for all " -"users." - -msgid "Yes, opt in" -msgstr "Yes, opt in" - -msgid "Stop using new Enrollment dashboard for {{programName}}" -msgstr "Stop using new Enrollment dashboard for {{programName}}" - -msgid "Opt out for {{programName}}" -msgstr "Opt out for {{programName}}" - msgid "Enrollment with id \"{{enrollmentId}}\" does not exist" msgstr "Enrollment with id \"{{enrollmentId}}\" does not exist" diff --git a/src/core_modules/capture-core/actions/navigateToEnrollmentOverview/navigateToEnrollmentOverview.constants.js b/src/core_modules/capture-core/actions/navigateToEnrollmentOverview/navigateToEnrollmentOverview.constants.js deleted file mode 100644 index 435c2824ac..0000000000 --- a/src/core_modules/capture-core/actions/navigateToEnrollmentOverview/navigateToEnrollmentOverview.constants.js +++ /dev/null @@ -1,6 +0,0 @@ -// @flow - -export const scopeHierarchyTypes = { - PROGRAM: 'PROGRAM', - TRACKED_ENTITY_TYPE: 'TRACKED_ENTITY_TYPE', -}; diff --git a/src/core_modules/capture-core/actions/navigateToEnrollmentOverview/navigateToEnrollmentOverview.epics.js b/src/core_modules/capture-core/actions/navigateToEnrollmentOverview/navigateToEnrollmentOverview.epics.js index 32f7d066e2..8b413b70a4 100644 --- a/src/core_modules/capture-core/actions/navigateToEnrollmentOverview/navigateToEnrollmentOverview.epics.js +++ b/src/core_modules/capture-core/actions/navigateToEnrollmentOverview/navigateToEnrollmentOverview.epics.js @@ -4,58 +4,22 @@ import { ofType } from 'redux-observable'; import { switchMap } from 'rxjs/operators'; import { EMPTY } from 'rxjs'; import { actionTypes as NavigateToEnrollmentOverviewActionTypes } from './navigateToEnrollmentOverview.actions'; -import { buildUrlQueryString, getLocationQuery, shouldUseNewDashboard } from '../../utils/routing'; -import { scopeHierarchyTypes } from './navigateToEnrollmentOverview.constants'; +import { buildUrlQueryString } from '../../utils/routing'; -// TODO This will be removed when the link between capture and tracker capture is not relevant -const redirectToTracker = ({ teiId, orgUnitId, dependencies }) => { - const baseUrl = dependencies.absoluteApiPath; - const { search, pathname } = dependencies.history.location; - const { programId: queryProgramId, trackedEntityTypeId: queryTrackedEntityTypeId } = getLocationQuery(); - - const instanceBaseUrl = baseUrl.split('/api')[0]; - const scopeHierarchy = queryProgramId ? scopeHierarchyTypes.PROGRAM : scopeHierarchyTypes.TRACKED_ENTITY_TYPE; - const selectedScopeId = queryTrackedEntityTypeId || queryProgramId; - const scopeSearchParam = `${scopeHierarchy.toLowerCase()}=${selectedScopeId}`; - const base64Url = btoa(`/dhis-web-capture/#${pathname}${search}`); - setTimeout(() => { - window.location.href = `${instanceBaseUrl}/dhis-web-tracker-capture/#/dashboard?tei=${teiId}&ou=${orgUnitId}&${scopeSearchParam}&returnUrl=${base64Url}`; - }, 50); -}; - -const redirectToEnrollmentDashboard = ({ dependencies, teiId, programId, orgUnitId, enrollmentId }) => { - dependencies.history.push( - `/enrollment?${buildUrlQueryString({ - teiId, - programId, - orgUnitId, - enrollmentId, - })}`, - ); -}; - -export const navigateToEnrollmentOverviewEpic = (action$: InputObservable, store: ReduxStore, dependencies: any) => +export const navigateToEnrollmentOverviewEpic = (action$: InputObservable, store: ReduxStore, { history }: ApiUtils) => action$.pipe( ofType(NavigateToEnrollmentOverviewActionTypes.NAVIGATE_TO_ENROLLMENT_OVERVIEW), switchMap((action) => { const { teiId, programId, orgUnitId } = action.payload; const enrollmentId = programId && (action.payload?.enrollmentId || 'AUTO'); - const { dataStore, userDataStore } = store.value.useNewDashboard; - - if (dataStore || userDataStore) { - const shouldRedirectToEnrollmentDashboard = shouldUseNewDashboard({ - userDataStore, - dataStore, - programId, + history.push( + `/enrollment?${buildUrlQueryString({ teiId, - }); - if (shouldRedirectToEnrollmentDashboard) { - redirectToEnrollmentDashboard({ dependencies, teiId, programId, orgUnitId, enrollmentId }); - return EMPTY; - } - } - - redirectToTracker({ dependencies, store, teiId, orgUnitId }); + programId, + orgUnitId, + enrollmentId, + })}`, + ); return EMPTY; }), ); diff --git a/src/core_modules/capture-core/components/DataStore/DataStore.actions.js b/src/core_modules/capture-core/components/DataStore/DataStore.actions.js deleted file mode 100644 index a06c83561d..0000000000 --- a/src/core_modules/capture-core/components/DataStore/DataStore.actions.js +++ /dev/null @@ -1,6 +0,0 @@ -// @flow -import { actionCreator } from '../../actions/actions.utils'; -import { type UseNewDashboard, actionTypes as dataStoreActionTypes } from './DataStore.types'; - -export const saveDataStore = ({ dataStore, userDataStore }: UseNewDashboard) => - actionCreator(dataStoreActionTypes.SAVE_DATA_STORE)({ dataStore, userDataStore }); diff --git a/src/core_modules/capture-core/components/DataStore/DataStore.epics.js b/src/core_modules/capture-core/components/DataStore/DataStore.epics.js deleted file mode 100644 index 71c1cee90c..0000000000 --- a/src/core_modules/capture-core/components/DataStore/DataStore.epics.js +++ /dev/null @@ -1,61 +0,0 @@ -// @flow -import { ofType } from 'redux-observable'; -import { flatMap, catchError } from 'rxjs/operators'; -import { EMPTY } from 'rxjs'; -import { saveDataStore } from './DataStore.actions'; -import { type UseNewDashboard } from './DataStore.types'; -import { appStartActionTypes } from '../../../../components/AppStart'; -import { programCollection } from '../../metaDataMemoryStores'; - -const setNewDashboardByDefault = (key: string, dataStoreValues) => { - if (!dataStoreValues) { - return {}; - } - const programs = [...programCollection.keys()]; - const valuesWithDefault = programs.reduce((acc, program) => { - const dataStoreValue = dataStoreValues[program]; - acc[program] = dataStoreValue === undefined ? true : dataStoreValue; - return acc; - }, {}); - - return { [key]: valuesWithDefault }; -}; - -const getDataStoreFromApi = async querySingleResource => - querySingleResource({ - resource: 'dataStore/capture/useNewDashboard', - }); - -const getUserDataStoreFromApi = async querySingleResource => - querySingleResource({ - resource: 'userDataStore/capture/useNewDashboard', - }); - -export const fetchDataStoreEpic = (action$: InputObservable, _: ReduxStore, { querySingleResource }: ApiUtils) => - action$.pipe( - ofType(appStartActionTypes.APP_LOAD_SUCESS), - flatMap(async () => { - const apiDataStore: ?UseNewDashboard = await getDataStoreFromApi(querySingleResource) - .catch((error) => { - if (error.details.httpStatusCode === 404) { - return {}; - } - return undefined; - }); - - return saveDataStore(setNewDashboardByDefault('dataStore', apiDataStore)); - }), - catchError(() => EMPTY), - ); - -export const fetchUserDataStoreEpic = (action$: InputObservable, _: ReduxStore, { querySingleResource }: ApiUtils) => - action$.pipe( - ofType(appStartActionTypes.APP_LOAD_SUCESS), - flatMap(async () => { - const apiUserDataStore: UseNewDashboard = await getUserDataStoreFromApi(querySingleResource); - // $FlowFixMe - return saveDataStore(setNewDashboardByDefault('userDataStore', apiUserDataStore)); - }), - catchError(() => EMPTY), - ); - diff --git a/src/core_modules/capture-core/components/DataStore/DataStore.types.js b/src/core_modules/capture-core/components/DataStore/DataStore.types.js deleted file mode 100644 index ffa2641abb..0000000000 --- a/src/core_modules/capture-core/components/DataStore/DataStore.types.js +++ /dev/null @@ -1,9 +0,0 @@ -// @flow - -export const actionTypes = { - SAVE_DATA_STORE: 'useNewDashboard.SaveDataStore', -}; - -export type UseNewDashboard = {| - [key: string]: string, -|} diff --git a/src/core_modules/capture-core/components/DataStore/index.js b/src/core_modules/capture-core/components/DataStore/index.js deleted file mode 100644 index e6359f21f1..0000000000 --- a/src/core_modules/capture-core/components/DataStore/index.js +++ /dev/null @@ -1 +0,0 @@ -export { saveDataStore } from './DataStore.actions'; diff --git a/src/core_modules/capture-core/components/OptInOut/OptIn/OptIn.component.js b/src/core_modules/capture-core/components/OptInOut/OptIn/OptIn.component.js deleted file mode 100644 index 81a541bf82..0000000000 --- a/src/core_modules/capture-core/components/OptInOut/OptIn/OptIn.component.js +++ /dev/null @@ -1,71 +0,0 @@ -// @flow -import React, { useState, type ComponentType } from 'react'; -import { NoticeBox, Button, Modal, ModalTitle, ModalContent, ModalActions, ButtonStrip } from '@dhis2/ui'; -import i18n from '@dhis2/d2-i18n'; -import { withStyles } from '@material-ui/core'; -import type { PlainProps } from './optIn.types'; - -const styles = { - container: { - width: '80%', - margin: '0 auto', - }, -}; - -export const OptInPlain = ({ classes, programName, handleOptIn, loading }: PlainProps) => { - const [toggle, setToggle] = useState(false); - - const title = i18n.t('Use new Enrollment dashboard for {{programName}}', { - programName, - interpolation: { escapeValue: false }, - }); - const button = i18n.t('Opt in for {{programName}}', { - programName, - interpolation: { escapeValue: false }, - }); - - const modalContent = i18n.t('By clicking opt-in below, you will start using the new enrollment dashboard in the Capture app for this Tracker program. At the moment, there is certain functionality from Tracker Capture that has not yet been added, including relationship and referral functionality. The work on including this Tracker functionality in Capture is ongoing and will be added in upcoming app releases.'); - - const modalContentFeedback = i18n.t('The core team appreciates any feedback on this new functionality which is currently being beta tested, please report any issues and feedback in the DHIS2 JIRA project.'); - - return ( -
- -

- {i18n.t('Click the button below to opt-in to the new enrollment dashboard functionality in the Capture app (beta) for this Tracker program for all users.')} -

- -
-
- {toggle && ( - setToggle(false)} dataTest="opt-in-modal"> - {title} - -

{modalContent}

-

{modalContentFeedback}

-
- - - - - - -
- )} -
- ); -}; - -export const OptIn: ComponentType<$Diff> = withStyles(styles)(OptInPlain); diff --git a/src/core_modules/capture-core/components/OptInOut/OptIn/OptIn.container.js b/src/core_modules/capture-core/components/OptInOut/OptIn/OptIn.container.js deleted file mode 100644 index 7bea988d28..0000000000 --- a/src/core_modules/capture-core/components/OptInOut/OptIn/OptIn.container.js +++ /dev/null @@ -1,57 +0,0 @@ -// @flow -import React, { useCallback } from 'react'; -import { useDataMutation } from '@dhis2/app-runtime'; -import { useSelector, useDispatch } from 'react-redux'; -import { OptIn as OptInComponent } from './OptIn.component'; -import type { Props } from './optIn.types'; -import { useTrackerProgram } from '../../../hooks/useTrackerProgram'; -import { saveDataStore } from '../../DataStore'; - -const dataStoreUpdate = { - resource: 'dataStore/capture/useNewDashboard', - type: 'update', - data: ({ data }) => data, -}; - -const dataStoreCreate = { - resource: 'dataStore/capture/useNewDashboard', - type: 'create', - data: ({ data }) => data, -}; - -export const OptIn = ({ programId }: Props) => { - const dispatch = useDispatch(); - const program = useTrackerProgram(programId); - const newDashboard = useSelector(({ useNewDashboard }) => useNewDashboard); - const { dataStore } = newDashboard; - const showOptIn = program?.access?.write && !dataStore?.[programId]; - - const [updateMutation, { loading: loadingUpdate }] = useDataMutation(dataStoreUpdate, { - onComplete: () => { - dispatch(saveDataStore({ dataStore: { ...dataStore, [programId]: true } })); - }, - }); - const [createMutation, { loading: loadingCreate }] = useDataMutation(dataStoreCreate, { - onComplete: () => { - dispatch(saveDataStore({ dataStore: { ...dataStore, [programId]: true } })); - }, - }); - - const handleOptIn = useCallback(() => { - if (dataStore) { - const data = { ...dataStore, [programId]: true }; - updateMutation({ data }); - } else { - const data = { [programId]: true }; - createMutation({ data }); - } - }, [programId, updateMutation, createMutation, dataStore]); - - return showOptIn ? ( - - ) : null; -}; diff --git a/src/core_modules/capture-core/components/OptInOut/OptIn/index.js b/src/core_modules/capture-core/components/OptInOut/OptIn/index.js deleted file mode 100644 index 3d26d28715..0000000000 --- a/src/core_modules/capture-core/components/OptInOut/OptIn/index.js +++ /dev/null @@ -1,2 +0,0 @@ -// @flow -export { OptIn } from './OptIn.container'; diff --git a/src/core_modules/capture-core/components/OptInOut/OptIn/optIn.types.js b/src/core_modules/capture-core/components/OptInOut/OptIn/optIn.types.js deleted file mode 100644 index e105d399ce..0000000000 --- a/src/core_modules/capture-core/components/OptInOut/OptIn/optIn.types.js +++ /dev/null @@ -1,12 +0,0 @@ -// @flow - -export type Props = {| - programId: string, -|}; - -export type PlainProps = {| - handleOptIn: () => void, - programName: string, - loading: boolean, - ...CssClasses -|}; diff --git a/src/core_modules/capture-core/components/OptInOut/OptOut/OptOut.component.js b/src/core_modules/capture-core/components/OptInOut/OptOut/OptOut.component.js deleted file mode 100644 index 3639694228..0000000000 --- a/src/core_modules/capture-core/components/OptInOut/OptOut/OptOut.component.js +++ /dev/null @@ -1,44 +0,0 @@ -// @flow -import React, { type ComponentType } from 'react'; -import { NoticeBox, Button } from '@dhis2/ui'; -import i18n from '@dhis2/d2-i18n'; -import { withStyles } from '@material-ui/core'; -import type { PlainProps } from './optOut.types'; - -const styles = { - container: { - width: '80%', - margin: '0 auto', - }, -}; - -export const OptOutPlain = ({ classes, programName, handleOptOut, loading }: PlainProps) => { - const title = i18n.t('Stop using new Enrollment dashboard for {{programName}}', { - programName, - interpolation: { escapeValue: false }, - }); - const button = i18n.t('Opt out for {{programName}}', { - programName, - interpolation: { escapeValue: false }, - }); - - return ( -
-
- -

- {i18n.t( - 'This program uses the new enrollment dashboard functionality ' + - 'in the Capture app (beta). Click this button to opt-out and direct ' + - 'all users to the Tracker capture app for this program.', - )} -

- -
-
- ); -}; - -export const OptOut: ComponentType<$Diff> = withStyles(styles)(OptOutPlain); diff --git a/src/core_modules/capture-core/components/OptInOut/OptOut/OptOut.container.js b/src/core_modules/capture-core/components/OptInOut/OptOut/OptOut.container.js deleted file mode 100644 index c9ba767866..0000000000 --- a/src/core_modules/capture-core/components/OptInOut/OptOut/OptOut.container.js +++ /dev/null @@ -1,36 +0,0 @@ -// @flow -import React, { useCallback } from 'react'; -import { useDataMutation } from '@dhis2/app-runtime'; -import { useSelector, useDispatch } from 'react-redux'; -import { OptOut as OptOutComponent } from './OptOut.component'; -import type { Props } from './optOut.types'; -import { useTrackerProgram } from '../../../hooks/useTrackerProgram'; -import { saveDataStore } from '../../DataStore'; - -const dataStoreUpdate = { - resource: 'dataStore/capture/useNewDashboard', - type: 'update', - data: ({ data }) => data, -}; - -export const OptOut = ({ programId }: Props) => { - const dispatch = useDispatch(); - const program = useTrackerProgram(programId); - const newDashboard = useSelector(({ useNewDashboard }) => useNewDashboard); - const { dataStore } = newDashboard; - - const [updateMutation, { loading: loadingUpdate }] = useDataMutation(dataStoreUpdate, { - onComplete: () => { - dispatch(saveDataStore({ dataStore: { ...dataStore, [programId]: false } })); - }, - }); - const handleOptOut = useCallback(() => { - const data = { ...dataStore, [programId]: false }; - updateMutation({ data }); - }, [programId, updateMutation, dataStore]); - const showOptOut = program?.access?.write && dataStore?.[programId]; - - return showOptOut ? ( - - ) : null; -}; diff --git a/src/core_modules/capture-core/components/OptInOut/OptOut/index.js b/src/core_modules/capture-core/components/OptInOut/OptOut/index.js deleted file mode 100644 index b89207bf49..0000000000 --- a/src/core_modules/capture-core/components/OptInOut/OptOut/index.js +++ /dev/null @@ -1,2 +0,0 @@ -// @flow -export { OptOut } from './OptOut.container'; diff --git a/src/core_modules/capture-core/components/OptInOut/OptOut/optOut.types.js b/src/core_modules/capture-core/components/OptInOut/OptOut/optOut.types.js deleted file mode 100644 index 3f4a4c244e..0000000000 --- a/src/core_modules/capture-core/components/OptInOut/OptOut/optOut.types.js +++ /dev/null @@ -1,12 +0,0 @@ -// @flow - -export type Props = {| - programId: string, -|}; - -export type PlainProps = {| - handleOptOut: () => void, - programName: string, - loading: boolean, - ...CssClasses, -|}; diff --git a/src/core_modules/capture-core/components/OptInOut/index.js b/src/core_modules/capture-core/components/OptInOut/index.js deleted file mode 100644 index cc2949649c..0000000000 --- a/src/core_modules/capture-core/components/OptInOut/index.js +++ /dev/null @@ -1,3 +0,0 @@ -// @flow -export { OptIn } from './OptIn'; -export { OptOut } from './OptOut'; diff --git a/src/core_modules/capture-core/components/Pages/MainPage/WorkingListsType/WorkingListsType.component.js b/src/core_modules/capture-core/components/Pages/MainPage/WorkingListsType/WorkingListsType.component.js index dea90e1485..732f0d07d5 100644 --- a/src/core_modules/capture-core/components/Pages/MainPage/WorkingListsType/WorkingListsType.component.js +++ b/src/core_modules/capture-core/components/Pages/MainPage/WorkingListsType/WorkingListsType.component.js @@ -3,7 +3,6 @@ import React from 'react'; import { useProgramInfo, programTypes } from '../../../../hooks/useProgramInfo'; import { EventWorkingListsInit } from '../EventWorkingListsInit'; import { TeiWorkingLists } from '../../../WorkingLists/TeiWorkingLists'; -import { OptIn, OptOut } from '../../../OptInOut'; import type { Props } from './workingListsType.types'; export const WorkingListsType = ({ programId, orgUnitId, selectedTemplateId, onChangeTemplate }: Props) => { @@ -15,14 +14,12 @@ export const WorkingListsType = ({ programId, orgUnitId, selectedTemplateId, onC if (programType === programTypes.TRACKER_PROGRAM) { return ( <> - - ); } diff --git a/src/core_modules/capture-core/components/Pages/New/RegistrationDataEntry/RegistrationDataEntry.epics.js b/src/core_modules/capture-core/components/Pages/New/RegistrationDataEntry/RegistrationDataEntry.epics.js index d14df1119e..4ee21bd46c 100644 --- a/src/core_modules/capture-core/components/Pages/New/RegistrationDataEntry/RegistrationDataEntry.epics.js +++ b/src/core_modules/capture-core/components/Pages/New/RegistrationDataEntry/RegistrationDataEntry.epics.js @@ -12,7 +12,7 @@ import { getTrackerProgramThrowIfNotFound } from '../../../../metaData'; import { navigateToEnrollmentOverview, } from '../../../../actions/navigateToEnrollmentOverview/navigateToEnrollmentOverview.actions'; -import { buildUrlQueryString, shouldUseNewDashboard } from '../../../../utils/routing'; +import { buildUrlQueryString } from '../../../../utils/routing'; import { getStageWithOpenAfterEnrollment, PAGES, @@ -54,15 +54,11 @@ export const startSavingNewTrackedEntityInstanceWithEnrollmentEpic: Epic = ( ofType(registrationFormActionTypes.NEW_TRACKED_ENTITY_INSTANCE_WITH_ENROLLMENT_SAVE_START), map((action) => { const { currentSelections: { programId } } = store.value; - const { dataStore, userDataStore } = store.value.useNewDashboard; const { enrollmentPayload, uid } = action.payload; const { stages, useFirstStageDuringRegistration } = getTrackerProgramThrowIfNotFound(programId); - - const shouldRedirect = shouldUseNewDashboard({ userDataStore, dataStore, programId }); const { stageWithOpenAfterEnrollment, redirectTo } = getStageWithOpenAfterEnrollment( stages, useFirstStageDuringRegistration, - shouldRedirect, ); const eventIndex = enrollmentPayload.enrollments[0]?.events.findIndex( diff --git a/src/core_modules/capture-core/components/Pages/New/RegistrationDataEntry/helpers/getStageWithOpenAfterEnrollment.js b/src/core_modules/capture-core/components/Pages/New/RegistrationDataEntry/helpers/getStageWithOpenAfterEnrollment.js index 23d9d1a610..3688d29b4c 100644 --- a/src/core_modules/capture-core/components/Pages/New/RegistrationDataEntry/helpers/getStageWithOpenAfterEnrollment.js +++ b/src/core_modules/capture-core/components/Pages/New/RegistrationDataEntry/helpers/getStageWithOpenAfterEnrollment.js @@ -13,13 +13,12 @@ export const PAGES = { export const getStageWithOpenAfterEnrollment = ( stages: Map, useFirstStageDuringRegistration: boolean, - shouldRedirect: boolean, ) => { const stagesArray = [...stages.values()]; const [firstStageWithOpenAfterEnrollment] = stagesArray.filter(({ openAfterEnrollment }) => openAfterEnrollment); const redirectTo = (() => { - if (shouldRedirect && firstStageWithOpenAfterEnrollment) { + if (firstStageWithOpenAfterEnrollment) { // event will be created during first stage registration if ( useFirstStageDuringRegistration diff --git a/src/core_modules/capture-core/components/Pages/ViewEvent/RightColumn/RelationshipsSection/ConnectedEntity/TrackedEntityInstance.js b/src/core_modules/capture-core/components/Pages/ViewEvent/RightColumn/RelationshipsSection/ConnectedEntity/TrackedEntityInstance.js index e02de9b1e9..16f0197068 100644 --- a/src/core_modules/capture-core/components/Pages/ViewEvent/RightColumn/RelationshipsSection/ConnectedEntity/TrackedEntityInstance.js +++ b/src/core_modules/capture-core/components/Pages/ViewEvent/RightColumn/RelationshipsSection/ConnectedEntity/TrackedEntityInstance.js @@ -1,10 +1,6 @@ // @flow import React, { useCallback } from 'react'; -import { useConfig } from '@dhis2/app-runtime'; -import { useSelector } from 'react-redux'; -import { buildUrl } from 'capture-core-utils'; -import { systemSettingsStore } from '../../../../../../metaDataMemoryStores'; -import { buildUrlQueryString, shouldUseNewDashboard } from '../../../../../../utils/routing'; +import { buildUrlQueryString } from '../../../../../../utils/routing'; type Props = { name: string, @@ -14,39 +10,20 @@ type Props = { }; export const TrackedEntityInstance = ({ name, id, orgUnitId, linkProgramId }: Props) => { - const { baseUrl } = useConfig(); - const { dataStore, userDataStore } = useSelector(({ useNewDashboard }) => useNewDashboard); - - const getUrl = useCallback(() => { - if (shouldUseNewDashboard({ userDataStore, dataStore, programId: linkProgramId, teiId: id })) { - return `/#/enrollment?${buildUrlQueryString({ + const getUrl = useCallback( + () => + `/#/enrollment?${buildUrlQueryString({ teiId: id, programId: linkProgramId, orgUnitId, enrollmentId: 'AUTO', - })}`; - } - const trackerBaseUrl = buildUrl(baseUrl, systemSettingsStore.get().trackerAppRelativePath, '/#/dashboard?'); - const baseParams = `tei=${id}&ou=${orgUnitId}`; - const params = linkProgramId ? `${baseParams}&program=${linkProgramId}` : baseParams; - return trackerBaseUrl + params; - }, [ - baseUrl, - id, - orgUnitId, - linkProgramId, - dataStore, - userDataStore, - ]); + })}`, + [id, orgUnitId, linkProgramId], + ); return ( - + {name} ); }; - diff --git a/src/core_modules/capture-core/reducers/descriptions/useNewDashboard.reducerDescription.js b/src/core_modules/capture-core/reducers/descriptions/useNewDashboard.reducerDescription.js deleted file mode 100644 index a2bd768063..0000000000 --- a/src/core_modules/capture-core/reducers/descriptions/useNewDashboard.reducerDescription.js +++ /dev/null @@ -1,17 +0,0 @@ -// @flow -import { createReducerDescription } from '../../trackerRedux/trackerReducer'; -import { actionTypes as dataStoreActionTypes } from '../../components/DataStore/DataStore.types'; - -export const useNewDashboardDesc = createReducerDescription({ - [dataStoreActionTypes.SAVE_DATA_STORE]: (state, action) => { - const newState = { ...state }; - const { dataStore, userDataStore } = action.payload; - newState.dataStore = dataStore; - newState.userDataStore = userDataStore; - - return newState; - }, -}, 'useNewDashboard', { - dataStore: undefined, - userDataStore: undefined, -}); diff --git a/src/core_modules/capture-core/utils/routing/index.js b/src/core_modules/capture-core/utils/routing/index.js index 3b533bc3cd..3131c7c491 100644 --- a/src/core_modules/capture-core/utils/routing/index.js +++ b/src/core_modules/capture-core/utils/routing/index.js @@ -2,4 +2,3 @@ export { useLocationQuery } from './useLocationQuery'; export { getLocationQuery } from './getLocationQuery'; export { buildUrlQueryString } from './buildUrlQueryString'; -export { shouldUseNewDashboard } from './newDashboard'; diff --git a/src/core_modules/capture-core/utils/routing/newDashboard.js b/src/core_modules/capture-core/utils/routing/newDashboard.js deleted file mode 100644 index c81265f93e..0000000000 --- a/src/core_modules/capture-core/utils/routing/newDashboard.js +++ /dev/null @@ -1,16 +0,0 @@ -// @flow - -export const shouldUseNewDashboard = ({ - userDataStore, - dataStore, - programId, - teiId, -}: { - userDataStore: any, - dataStore: any, - programId: ?string, - teiId?: ?string, -}): boolean => - Boolean(!programId && teiId) || // Check for when a TEI is created/searched without being enrolled in any program. In this case the URL has the enrollmentId set to 'AUTO'. - userDataStore?.[programId] || - (userDataStore?.[programId] !== false && dataStore?.[programId]); diff --git a/src/epics/trackerCapture.epics.js b/src/epics/trackerCapture.epics.js index f0bdf3bc7e..48836ddc46 100644 --- a/src/epics/trackerCapture.epics.js +++ b/src/epics/trackerCapture.epics.js @@ -35,11 +35,6 @@ import { deleteTemplateEpic, } from 'capture-core/components/WorkingLists/EventWorkingLists'; -import { - fetchDataStoreEpic, - fetchUserDataStoreEpic, -} from 'capture-core/components/DataStore/DataStore.epics'; - import { getEventFromUrlEpic, } from 'capture-core/components/Pages/ViewEvent/epics/editEvent.epics'; @@ -245,8 +240,6 @@ export const epics = combineEpics( resetProgramAfterSettingOrgUnitIfApplicableEpic, calculateSelectionsCompletenessEpic, triggerLoadCoreEpic, - fetchDataStoreEpic, - fetchUserDataStoreEpic, loadAppEpic, initEventListEpic, initTeiViewEpic, diff --git a/src/reducers/descriptions/trackerCapture.reducerDescriptions.js b/src/reducers/descriptions/trackerCapture.reducerDescriptions.js index 6f6ad63d84..ac35a29082 100644 --- a/src/reducers/descriptions/trackerCapture.reducerDescriptions.js +++ b/src/reducers/descriptions/trackerCapture.reducerDescriptions.js @@ -40,7 +40,6 @@ import { workingListsListRecordsDesc, } from 'capture-core/reducers/descriptions/workingLists'; import { mainPageDesc } from 'capture-core/reducers/descriptions/mainPage.reducerDescription'; -import { useNewDashboardDesc } from 'capture-core/reducers/descriptions/useNewDashboard.reducerDescription'; import { newEventPageDesc } from 'capture-core/reducers/descriptions/newEvent.reducerDescription'; import { editEventPageDesc } from 'capture-core/reducers/descriptions/editEvent.reducerDescription'; import { viewEventPageDesc } from 'capture-core/reducers/descriptions/viewEvent.reducerDescription'; @@ -129,7 +128,6 @@ export const reducerDescriptions = [ searchDomainDesc, teiSearchDesc, trackedEntityInstanceDesc, - useNewDashboardDesc, viewEventPageDesc, workingListsDesc, workingListsMetaDesc,