diff --git a/cypress/e2e/EnrollmentAddEventPage/EnrollmentAddEventPageForm.feature b/cypress/e2e/EnrollmentAddEventPage/EnrollmentAddEventPageForm.feature index 966cd9083f..5964f07644 100644 --- a/cypress/e2e/EnrollmentAddEventPage/EnrollmentAddEventPageForm.feature +++ b/cypress/e2e/EnrollmentAddEventPage/EnrollmentAddEventPageForm.feature @@ -47,9 +47,8 @@ Feature: User interacts with the Enrollment New Event Workspace Then the input should throw an error with error-message Please provide a positive integer Scenario: User should be asked to create new event after completing a stage and choose to cancel - Given you open the main page with Ngelehun and Malaria focus investigation context - And you opt in to use the new enrollment Dashboard for Malaria focus investigation - Then you land on the enrollment new event page by having typed #/enrollmentEventNew?enrollmentId=zRfAPUpjoG3&orgUnitId=DiszpKrYNg8&programId=M3xtLkYBlKI&stageId=CWaAcQYKVpq&teiId=S3JjTA4QMNe + 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/EnrollmentAddEventPage/EnrollmentAddEventPageForm/index.js b/cypress/e2e/EnrollmentAddEventPage/EnrollmentAddEventPageForm/index.js index d4b2f403a9..4438466f15 100644 --- a/cypress/e2e/EnrollmentAddEventPage/EnrollmentAddEventPageForm/index.js +++ b/cypress/e2e/EnrollmentAddEventPage/EnrollmentAddEventPageForm/index.js @@ -1,5 +1,6 @@ import { Given, When, Then, defineStep as And } from '@badeball/cypress-cucumber-preprocessor'; import '../sharedSteps'; +import '../../sharedSteps'; const showAllEventsInProgramStage = () => { cy.get('[data-test="dhis2-uicore-tablefoot"]') @@ -16,16 +17,6 @@ Given('you open the main page with Ngelehun and Malaria focus investigation cont cy.visit('/#/?orgUnitId=DiszpKrYNg8&programId=M3xtLkYBlKI'); }); -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="opt-in"]').length > 0) { - cy.contains('[data-test="dhis2-uicore-button"]', `Opt in for ${program}`).click(); - cy.contains('[data-test="dhis2-uicore-button"]', 'Yes, opt in').click(); - cy.contains('[data-test="dhis2-uicore-button"]', `Opt out for ${program}`); - } - }); -}); - Given(/^you land on the enrollment new event page by having typed (.*)$/, (url) => { cy.visit(url); }); diff --git a/cypress/e2e/EnrollmentPage/BreakingTheGlass.feature b/cypress/e2e/EnrollmentPage/BreakingTheGlass.feature index ac67d53256..a00ec363c1 100644 --- a/cypress/e2e/EnrollmentPage/BreakingTheGlass.feature +++ b/cypress/e2e/EnrollmentPage/BreakingTheGlass.feature @@ -4,13 +4,12 @@ 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 you opt temporarily in on new enrollment dashboard in Child programme and WHO RMNCH Tracker + 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 And you log out And you log in as tracker2 user - And you opt temporarily in on new enrollment dashboard in Child programme and WHO RMNCH Tracker And you select the new tei And you change program to WHO RMNCH Tracker Then you see the breaking the glass page diff --git a/cypress/e2e/EnrollmentPage/BreakingTheGlass/index.js b/cypress/e2e/EnrollmentPage/BreakingTheGlass/index.js index 120dc0a0dc..f8385c2fa7 100644 --- a/cypress/e2e/EnrollmentPage/BreakingTheGlass/index.js +++ b/cypress/e2e/EnrollmentPage/BreakingTheGlass/index.js @@ -1,5 +1,6 @@ import { Given, When, Then, defineStep as And } from '@badeball/cypress-cucumber-preprocessor'; import '../sharedSteps'; +import '../../sharedSteps'; Given('the tei created by this test is cleared from the database', () => { cy.buildApiUrl('tracker', 'trackedEntities?filter=w75KJ2mc4zz:like:Breaking&filter=zDhUuAYrxNC:like:TheGlass&trackedEntityType=nEenWmSyUEp&page=1&pageSize=5&ouMode=ACCESSIBLE') @@ -12,10 +13,6 @@ Given('the tei created by this test is cleared from the database', () => { )); }); -And('you opt temporarily in on new enrollment dashboard in Child programme and WHO RMNCH Tracker', () => { - cy.visit('/#/?newDashboard=IpHINAT79UW,WSGAb5XwJ3Y'); -}); - And('you create a new tei in Child programme from Ngelehun CHC', () => { cy.visit('/#/new?orgUnitId=DiszpKrYNg8&programId=IpHINAT79UW'); cy.get('[data-test="capture-ui-input"]') diff --git a/cypress/e2e/MainPage.feature b/cypress/e2e/MainPage.feature index 980d9fd1e2..cb10b479fb 100644 --- a/cypress/e2e/MainPage.feature +++ b/cypress/e2e/MainPage.feature @@ -35,13 +35,14 @@ 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 optin to use the new Enrollment Dashboard + 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 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 + 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 diff --git a/cypress/e2e/NewPage.feature b/cypress/e2e/NewPage.feature index afbc13720c..7c814e0c4b 100644 --- a/cypress/e2e/NewPage.feature +++ b/cypress/e2e/NewPage.feature @@ -8,11 +8,12 @@ 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 And you click the save person submit button - Then you are navigated to the WHO RMNCH program in Tracker Capture app + Then you see the enrollment event Edit page Scenario: Viewing the registration page with incomplete program categories selection Given you are in the main page with no selections made @@ -126,17 +127,19 @@ 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 Tracker Capture + 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 And you submit the form again from the duplicates modal - Then you are navigated to the Tracker Capture + Then you are navigated to the enrollment dashboard page without enrollment Scenario: New person > Submitting the form shows a list with duplicates Given you are in the Person registration page @@ -171,17 +174,19 @@ 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 are navigated to the WHO RMNCH program in Tracker Capture app + Then you see the enrollment event Edit 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 When you submit the form again from the duplicates modal - Then you are navigated to the WHO RMNCH program in Tracker Capture app + Then you see the enrollment event Edit page Scenario: New person in Tracker Program > Submitting the form shows a list with duplicates @@ -201,16 +206,11 @@ Feature: User creates a new entries from the registration page Then you see validation errors on the WHO RMNCH program registration page Scenario: Go to enrollment event when Open data entry form after enrollment is checked - Given you open the main page with Ngelehun and Malaria case diagnosis, treatment and investigation context - And you opt in to use the new enrollment Dashboard for Malaria case diagnosis, treatment and investigation - And you see the opt out component for Malaria case diagnosis, treatment and investigation - When you are in the Malaria case diagnosis, treatment and investigation program registration page + 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 - When you open the main page with Ngelehun and Malaria case diagnosis, treatment and investigation context - And you opt out to use the new enrollment Dashboard for Malaria case diagnosis, treatment and investigation - Then you see the opt in component for Malaria case diagnosis, treatment and investigation ## New enrollment of existing TEI diff --git a/cypress/e2e/NewPage/index.js b/cypress/e2e/NewPage/index.js index 901452f440..1bde1eb509 100644 --- a/cypress/e2e/NewPage/index.js +++ b/cypress/e2e/NewPage/index.js @@ -487,10 +487,6 @@ And('you fill in child programme first name with value that has duplicates', () .blur(); }); -Then('you are navigated to the WHO RMNCH program in Tracker Capture app', () => { - cy.url().should('include', 'dashboard?tei='); - cy.url().should('include', 'ou=DiszpKrYNg8&program=WSGAb5XwJ3Y'); -}); And('you fill the Child programme registration form with a first name with value that has duplicates', () => { cy.get('[data-test="capture-ui-input"]') diff --git a/cypress/e2e/SearchPage.feature b/cypress/e2e/SearchPage.feature index 0f98fdfdfc..1c4591802f 100644 --- a/cypress/e2e/SearchPage.feature +++ b/cypress/e2e/SearchPage.feature @@ -24,10 +24,11 @@ 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 - Then you are navigated to the Tracker Capture + Then you are navigated to the enrollment dashboard page # Scenario: Searching using attributes in Tracker Program returns no results # Given you are on the default search page @@ -96,23 +97,25 @@ 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 And you click search And you can see the first page of the results And you click the view dashboard button - Then you are navigated to the Tracker Capture + Then you are navigated to the enrollment dashboard 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 And you click search And you can see the first page of the results And you click the view dashboard button - Then you are navigated to the Tracker Capture without program + Then you are navigated to the enrollment dashboard page without enrollment Scenario: Searching using attributes in Tracker Program domain has disabled pagination Given you are on the default search page @@ -162,9 +165,10 @@ 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 Tracker Capture + Then you are navigated to the enrollment dashboard page Scenario: Pressing enter should trigger search attributes returns results Given you are in the search page with the Child Programme being preselected from the url diff --git a/cypress/e2e/SearchPage/index.js b/cypress/e2e/SearchPage/index.js index 644ff73111..322dc9d377 100644 --- a/cypress/e2e/SearchPage/index.js +++ b/cypress/e2e/SearchPage/index.js @@ -93,19 +93,6 @@ When('you fill in the unique identifier field with values that will return a tra .blur(); }); -Then('you are navigated to the Tracker Capture', () => { - cy.url() - .should('include', 'dhis-web-tracker-capture/') - .should('include', 'dashboard?tei=') - .should('include', 'program=WSGAb5XwJ3Y'); -}); - -Then('you are navigated to the Tracker Capture without program', () => { - cy.url() - .should('include', 'dhis-web-tracker-capture/') - .should('include', 'dashboard?tei=') - .should('include', 'tracked_entity_type=nEenWmSyUEp'); -}); When('you fill in the first name with values that will return no results', () => { cy.get('[data-test="form-attributes"]') diff --git a/cypress/e2e/sharedSteps.js b/cypress/e2e/sharedSteps.js index 16967a0c21..6fa9febef3 100644 --- a/cypress/e2e/sharedSteps.js +++ b/cypress/e2e/sharedSteps.js @@ -155,12 +155,15 @@ Then(/^the user ?(.*) see the following text: (.*)$/, (not, message) => cy.contains(message).should(not ? 'not.exist' : 'exist'), ); -And('you navigated to the enrollment dashboard page', () => { - cy.url().should('include', 'enrollment?enrollmentId'); +And('you are navigated to the enrollment dashboard page', () => { + cy.url().should('include', 'enrollment?'); + cy.url().should('include', 'enrollmentId'); }); -And('you navigated to the enrollment dashboard page without enrollment', () => { - cy.url().should('include', 'enrollment?orgUnit'); +And('you are navigated to the enrollment dashboard page without enrollment', () => { + cy.url().should('include', 'enrollment?'); + cy.url().should('not.include', 'enrollmentId'); + cy.url().should('include', 'teiId'); }); Then('you should see no results found', () => { @@ -209,3 +212,9 @@ When(/^you opt out to use the new enrollment Dashboard for (.*)$/, (program) => 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/i18n/en.pot b/i18n/en.pot index cfe2c464c0..b3d7ea8796 100644 --- a/i18n/en.pot +++ b/i18n/en.pot @@ -5,8 +5,8 @@ msgstr "" "Content-Type: text/plain; charset=utf-8\n" "Content-Transfer-Encoding: 8bit\n" "Plural-Forms: nplurals=2; plural=(n != 1)\n" -"POT-Creation-Date: 2024-01-22T13:52:51.172Z\n" -"PO-Revision-Date: 2024-01-22T13:52:51.172Z\n" +"POT-Creation-Date: 2024-01-25T12:12:47.253Z\n" +"PO-Revision-Date: 2024-01-25T12:12:47.253Z\n" msgid "Choose one or more dates..." msgstr "Choose one or more dates..." @@ -1092,12 +1092,6 @@ msgstr "New {{trackedEntityName}} in {{programName}}" msgid "Search for a {{trackedEntityName}} in {{programName}}" msgstr "Search for a {{trackedEntityName}} in {{programName}}" -msgid "To work with the selected program," -msgstr "To work with the selected program," - -msgid "open the Tracker Capture app" -msgstr "open the Tracker Capture app" - msgid "Assigned to" msgstr "Assigned to" diff --git a/src/core_modules/capture-core/actions/navigateToEnrollmentOverview/navigateToEnrollmentOverview.actions.js b/src/core_modules/capture-core/actions/navigateToEnrollmentOverview/navigateToEnrollmentOverview.actions.js index bdbf975c72..d7cdfcba80 100644 --- a/src/core_modules/capture-core/actions/navigateToEnrollmentOverview/navigateToEnrollmentOverview.actions.js +++ b/src/core_modules/capture-core/actions/navigateToEnrollmentOverview/navigateToEnrollmentOverview.actions.js @@ -7,5 +7,10 @@ export const actionTypes = Object.freeze({ NAVIGATE_TO_ENROLLMENT_OVERVIEW: 'enrollmentNavigation.navigateToEnrollmentOverview', }); -export const navigateToEnrollmentOverview = ({ teiId, programId, orgUnitId, enrollmentId }: NavigateToEnrollmentOverviewProps) => +export const navigateToEnrollmentOverview = ({ + teiId, + programId, + orgUnitId, + enrollmentId, +}: NavigateToEnrollmentOverviewProps) => actionCreator(actionTypes.NAVIGATE_TO_ENROLLMENT_OVERVIEW)({ teiId, programId, orgUnitId, enrollmentId }); 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 f0f6f55506..32f7d066e2 100644 --- a/src/core_modules/capture-core/actions/navigateToEnrollmentOverview/navigateToEnrollmentOverview.epics.js +++ b/src/core_modules/capture-core/actions/navigateToEnrollmentOverview/navigateToEnrollmentOverview.epics.js @@ -40,10 +40,15 @@ export const navigateToEnrollmentOverviewEpic = (action$: InputObservable, store switchMap((action) => { const { teiId, programId, orgUnitId } = action.payload; const enrollmentId = programId && (action.payload?.enrollmentId || 'AUTO'); - const { dataStore, userDataStore, temp } = store.value.useNewDashboard; + const { dataStore, userDataStore } = store.value.useNewDashboard; if (dataStore || userDataStore) { - const shouldRedirectToEnrollmentDashboard = shouldUseNewDashboard(userDataStore, dataStore, temp, programId); + const shouldRedirectToEnrollmentDashboard = shouldUseNewDashboard({ + userDataStore, + dataStore, + programId, + teiId, + }); if (shouldRedirectToEnrollmentDashboard) { redirectToEnrollmentDashboard({ dependencies, teiId, programId, orgUnitId, enrollmentId }); return EMPTY; diff --git a/src/core_modules/capture-core/components/DataStore/DataStore.epics.js b/src/core_modules/capture-core/components/DataStore/DataStore.epics.js index 3462b63994..71c1cee90c 100644 --- a/src/core_modules/capture-core/components/DataStore/DataStore.epics.js +++ b/src/core_modules/capture-core/components/DataStore/DataStore.epics.js @@ -1,10 +1,25 @@ // @flow import { ofType } from 'redux-observable'; -import { mergeMap, catchError } from 'rxjs/operators'; +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({ @@ -19,10 +34,16 @@ const getUserDataStoreFromApi = async querySingleResource => export const fetchDataStoreEpic = (action$: InputObservable, _: ReduxStore, { querySingleResource }: ApiUtils) => action$.pipe( ofType(appStartActionTypes.APP_LOAD_SUCESS), - mergeMap(async () => { - const apiDataStore: UseNewDashboard = await getDataStoreFromApi(querySingleResource); - // $FlowFixMe - return saveDataStore({ dataStore: apiDataStore }); + 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), ); @@ -30,10 +51,10 @@ export const fetchDataStoreEpic = (action$: InputObservable, _: ReduxStore, { qu export const fetchUserDataStoreEpic = (action$: InputObservable, _: ReduxStore, { querySingleResource }: ApiUtils) => action$.pipe( ofType(appStartActionTypes.APP_LOAD_SUCESS), - mergeMap(async () => { + flatMap(async () => { const apiUserDataStore: UseNewDashboard = await getUserDataStoreFromApi(querySingleResource); // $FlowFixMe - return saveDataStore({ userDataStore: apiUserDataStore }); + return saveDataStore(setNewDashboardByDefault('userDataStore', apiUserDataStore)); }), catchError(() => EMPTY), ); diff --git a/src/core_modules/capture-core/components/Pages/MainPage/MainPage.container.js b/src/core_modules/capture-core/components/Pages/MainPage/MainPage.container.js index 0f307053c7..976ce35e57 100644 --- a/src/core_modules/capture-core/components/Pages/MainPage/MainPage.container.js +++ b/src/core_modules/capture-core/components/Pages/MainPage/MainPage.container.js @@ -7,7 +7,6 @@ import { programCollection } from 'capture-core/metaDataMemoryStores/programColl import { MainPageComponent } from './MainPage.component'; import { withLoadingIndicator } from '../../../HOC'; import { updateShowAccessibleStatus } from '../actions/crossPage.actions'; -import { enableNewDashboardsTemporarily } from '../../../utils/routing/newDashboard.actions'; import { buildUrlQueryString, useLocationQuery } from '../../../utils/routing'; import { MainPageStatuses } from './MainPage.constants'; import { OrgUnitFetcher } from '../../OrgUnitFetcher'; @@ -87,7 +86,7 @@ const useCallbackMainPage = ({ orgUnitId, programId, showAllAccessible, history const MainPageContainer = () => { const dispatch = useDispatch(); const history = useHistory(); - const { all, programId, orgUnitId, selectedTemplateId, newDashboard } = useLocationQuery(); + const { all, programId, orgUnitId, selectedTemplateId } = useLocationQuery(); const showAllAccessible = all !== undefined; const { @@ -112,12 +111,6 @@ const MainPageContainer = () => { dispatch(updateShowAccessibleStatus(showAllAccessible)); }, [showAllAccessible, dispatch]); - useEffect(() => { - if (newDashboard) { - dispatch(enableNewDashboardsTemporarily(newDashboard.split(','))); - } - }, [dispatch, newDashboard]); - useEffect(() => { if (programId && trackedEntityTypeId && displayFrontPageList && selectedTemplateId === undefined) { handleChangeTemplateUrl({ 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 be02acbcb5..686fa6b24e 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 @@ -53,11 +53,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, temp } = store.value.useNewDashboard; + const { dataStore, userDataStore } = store.value.useNewDashboard; const { enrollmentPayload, uid } = action.payload; const { stages, useFirstStageDuringRegistration } = getTrackerProgramThrowIfNotFound(programId); - const shouldRedirect = shouldUseNewDashboard(userDataStore, dataStore, temp, programId); + const shouldRedirect = shouldUseNewDashboard({ userDataStore, dataStore, programId }); const { stageWithOpenAfterEnrollment, redirectTo } = getStageWithOpenAfterEnrollment( stages, 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 c4472cf677..e02de9b1e9 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 @@ -15,11 +15,16 @@ type Props = { export const TrackedEntityInstance = ({ name, id, orgUnitId, linkProgramId }: Props) => { const { baseUrl } = useConfig(); - const { dataStore, userDataStore, temp } = useSelector(({ useNewDashboard }) => useNewDashboard); + const { dataStore, userDataStore } = useSelector(({ useNewDashboard }) => useNewDashboard); const getUrl = useCallback(() => { - if (linkProgramId && shouldUseNewDashboard(userDataStore, dataStore, temp, linkProgramId)) { - return `/#/enrollment?${buildUrlQueryString({ teiId: id, programId: linkProgramId, orgUnitId })}`; + if (shouldUseNewDashboard({ userDataStore, dataStore, programId: linkProgramId, teiId: id })) { + return `/#/enrollment?${buildUrlQueryString({ + teiId: id, + programId: linkProgramId, + orgUnitId, + enrollmentId: 'AUTO', + })}`; } const trackerBaseUrl = buildUrl(baseUrl, systemSettingsStore.get().trackerAppRelativePath, '/#/dashboard?'); const baseParams = `tei=${id}&ou=${orgUnitId}`; @@ -32,7 +37,6 @@ export const TrackedEntityInstance = ({ name, id, orgUnitId, linkProgramId }: Pr linkProgramId, dataStore, userDataStore, - temp, ]); return ( diff --git a/src/core_modules/capture-core/components/TrackerProgramHandler/TrackerProgramHandler.component.js b/src/core_modules/capture-core/components/TrackerProgramHandler/TrackerProgramHandler.component.js deleted file mode 100644 index 9df786c6e0..0000000000 --- a/src/core_modules/capture-core/components/TrackerProgramHandler/TrackerProgramHandler.component.js +++ /dev/null @@ -1,77 +0,0 @@ -// @flow -import React, { useCallback } from 'react'; -import { withStyles } from '@material-ui/core/styles'; -import Paper from '@material-ui/core/Paper'; -import { useConfig } from '@dhis2/app-runtime'; -import i18n from '@dhis2/d2-i18n'; -import { buildUrl } from 'capture-core-utils'; -import { getProgramFromProgramIdThrowIfNotFound, TrackerProgram } from '../../metaData'; -import { systemSettingsStore } from '../../metaDataMemoryStores'; - -const getStyles = () => ({ - container: { - padding: 24, - }, - contents: { - display: 'flex', - justifyContent: 'center', - alignItems: 'center', - paddingTop: 50, - paddingBottom: 50, - }, - linkContainer: { - paddingLeft: 5, - }, -}); - -type Props = { - programId: string, - orgUnitId: string, - classes: Object, - children: React$Node, -}; - -const TrackerProgramHandler = ({ programId, orgUnitId, classes, children }: Props) => { - const { baseUrl } = useConfig(); - const getUrl = useCallback(() => { - const trackerBaseUrl = buildUrl(baseUrl, systemSettingsStore.get().trackerAppRelativePath, '/#/?'); - const params = `program=${programId}&ou=${orgUnitId}`; - return trackerBaseUrl + params; - }, [ - baseUrl, - programId, - orgUnitId, - ]); - - const program = getProgramFromProgramIdThrowIfNotFound(programId); - if (program instanceof TrackerProgram) { - return ( -
- -
- {i18n.t('To work with the selected program,')} - - - {i18n.t('open the Tracker Capture app')} - - -
-
-
- ); - } - - return children; -}; - -export const TrackerProgramHandlerComponent = withStyles(getStyles)(TrackerProgramHandler); diff --git a/src/core_modules/capture-core/components/TrackerProgramHandler/TrackerProgramHandler.container.js b/src/core_modules/capture-core/components/TrackerProgramHandler/TrackerProgramHandler.container.js deleted file mode 100644 index c95217bcba..0000000000 --- a/src/core_modules/capture-core/components/TrackerProgramHandler/TrackerProgramHandler.container.js +++ /dev/null @@ -1,12 +0,0 @@ -// @flow -import { connect } from 'react-redux'; -import { TrackerProgramHandlerComponent } from './TrackerProgramHandler.component'; - -const mapStateToProps = (state: ReduxState) => ({ - programId: state.currentSelections.programId, - orgUnitId: state.currentSelections.orgUnitId, -}); - -// $FlowSuppress -// $FlowFixMe[missing-annot] automated comment -export const TrackerProgramHandler = connect(mapStateToProps, () => ({}))(TrackerProgramHandlerComponent); diff --git a/src/core_modules/capture-core/components/TrackerProgramHandler/index.js b/src/core_modules/capture-core/components/TrackerProgramHandler/index.js deleted file mode 100644 index 3e231ffee6..0000000000 --- a/src/core_modules/capture-core/components/TrackerProgramHandler/index.js +++ /dev/null @@ -1,2 +0,0 @@ -// @flow -export { TrackerProgramHandler } from './TrackerProgramHandler.container'; diff --git a/src/core_modules/capture-core/components/WidgetEventEdit/EditEventDataEntry/editEventDataEntry.epics.js b/src/core_modules/capture-core/components/WidgetEventEdit/EditEventDataEntry/editEventDataEntry.epics.js index 999beb1aa7..7a518b9bfd 100644 --- a/src/core_modules/capture-core/components/WidgetEventEdit/EditEventDataEntry/editEventDataEntry.epics.js +++ b/src/core_modules/capture-core/components/WidgetEventEdit/EditEventDataEntry/editEventDataEntry.epics.js @@ -4,7 +4,7 @@ import { map, filter, flatMap } from 'rxjs/operators'; import { batchActions } from 'redux-batched-actions'; import { dataEntryKeys, dataEntryIds } from 'capture-core/constants'; import moment from 'moment'; -import { EMPTY, of } from 'rxjs'; +import { EMPTY } from 'rxjs'; import { getFormattedStringFromMomentUsingEuropeanGlyphs } from 'capture-core-utils/date'; import { convertCategoryOptionsToServer, convertValue as convertToServerValue } from '../../../converters/clientToServer'; import { getProgramAndStageFromEvent, scopeTypes, getScopeInfo } from '../../../metaData'; @@ -38,7 +38,6 @@ import { buildUrlQueryString } from '../../../utils/routing/buildUrlQueryString' import { updateEventContainer, } from '../../Pages/ViewEvent/ViewEventComponent/viewEvent.actions'; -import { navigateToEnrollmentOverview } from '../../../actions/navigateToEnrollmentOverview/navigateToEnrollmentOverview.actions'; import { newEventWidgetActionTypes } from '../../WidgetEnrollmentEventNew/Validated/validated.actions'; const getDataEntryId = (event): string => ( @@ -220,6 +219,7 @@ export const startCreateNewAfterCompletingEpic = ( return EMPTY; } - return of(navigateToEnrollmentOverview(params)); + history.push(`/enrollment?${buildUrlQueryString(params)}`); + return EMPTY; })); diff --git a/src/core_modules/capture-core/components/WidgetProfile/DataEntry/helpers/isNotValidOptionSet.js b/src/core_modules/capture-core/components/WidgetProfile/DataEntry/helpers/isNotValidOptionSet.js index ef970a412d..375e134dd6 100644 --- a/src/core_modules/capture-core/components/WidgetProfile/DataEntry/helpers/isNotValidOptionSet.js +++ b/src/core_modules/capture-core/components/WidgetProfile/DataEntry/helpers/isNotValidOptionSet.js @@ -6,4 +6,4 @@ export const isNotValidOptionSet = ( optionSet?: ?{ +options: Array