Skip to content

Commit

Permalink
ui: fix export path for dev environment
Browse files Browse the repository at this point in the history
  • Loading branch information
Georgia Moldovan committed Sep 23, 2021
1 parent 3eb1232 commit f53981b
Show file tree
Hide file tree
Showing 6 changed files with 49 additions and 44 deletions.
42 changes: 21 additions & 21 deletions frontend/src/api.js
Original file line number Diff line number Diff line change
Expand Up @@ -63,9 +63,9 @@ class Api {
* @param {*} urlSlug tail segment of the URL
* @param {*} devModePrefix prefixes urlSlug with additional string, if needed
*/
getExportServiceUrl = (urlSlug, devModePrefix = "") => {
getExportServiceUrl = (urlSlug, devModeEnvironment = "") => {
const baseURL = devMode
? `http://localhost:${PORT_EXPORT_SVC}${!devModePrefix.length ? "" : `/${devModePrefix}`}`
? `http://localhost:${PORT_EXPORT_SVC}${!devModeEnvironment.length ? "" : `/${devModeEnvironment.toLowerCase()}`}`
: "/export/xlsx";
return `${baseURL}/${urlSlug}`;
};
Expand Down Expand Up @@ -307,11 +307,11 @@ class Api {
payload.amountType === "N/A"
? minimalPayload
: {
...minimalPayload,
currency,
amount,
exchangeRate: exchangeRate.toString()
};
...minimalPayload,
currency,
amount,
exchangeRate: exchangeRate.toString()
};
return instance.post(`/subproject.createWorkflowitem`, {
...payloadToSend
});
Expand Down Expand Up @@ -345,11 +345,11 @@ class Api {
changes.amountType === "N/A"
? minimalChanges
: {
...minimalChanges,
currency,
amount,
exchangeRate: exchangeRate ? exchangeRate.toString() : undefined
};
...minimalChanges,
currency,
amount,
exchangeRate: exchangeRate ? exchangeRate.toString() : undefined
};
return instance.post(`/workflowitem.update`, {
projectId,
subprojectId,
Expand Down Expand Up @@ -429,19 +429,19 @@ class Api {
});

closeWorkflowItem = (projectId, subprojectId, workflowitemId, rejectReason) => {
if(rejectReason === "")
if (rejectReason === "")
return instance.post(`/workflowitem.close`, {
projectId,
subprojectId,
workflowitemId
});
else
return instance.post(`/workflowitem.close`, {
projectId,
subprojectId,
workflowitemId,
rejectReason
});
return instance.post(`/workflowitem.close`, {
projectId,
subprojectId,
workflowitemId,
rejectReason
});
}

fetchNotifications = (offset, limit) => {
Expand Down Expand Up @@ -473,8 +473,8 @@ class Api {
});
return response;
};
export = () => {
const path = this.getExportServiceUrl(`download?lang=${strings.getLanguage()}`, "test/api/export/xlsx");
export = (devModeEnvironment) => {
const path = this.getExportServiceUrl(`download?lang=${strings.getLanguage()}`, devModeEnvironment);
return instance.get(path, { responseType: "blob" });
};
fetchExportServiceVersion = () => {
Expand Down
1 change: 1 addition & 0 deletions frontend/src/pages/Navbar/Navbar.js
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,7 @@ const Navbar = ({
createBackup={createBackup}
restoreBackup={restoreBackup}
exportData={exportData}
environment={environment}
showUserProfile={showUserProfile}
fetchEmailAddress={fetchEmailAddress}
{...props}
Expand Down
36 changes: 19 additions & 17 deletions frontend/src/pages/Navbar/NavbarContainer.js
Original file line number Diff line number Diff line change
Expand Up @@ -54,23 +54,25 @@ class NavbarContainer extends Component {
}
}

const mapDispatchToProps = {
toggleSidebar,
logout,
fetchActivePeers,
createBackup,
restoreBackup,
exportData,
storeSearchTerm,
storeSearchBarDisplayed,
setIsRoot,
showUserProfile,
fetchEmailAddress,
saveEmailAddress,
storeTempEmailAddress,
setValidEmailAddressInput,
enableUserProfileEdit,
hideUserProfile
const mapDispatchToProps = (dispatch) => {
return {
toggleSidebar: () => dispatch(toggleSidebar()),
logout: () => dispatch(logout()),
fetchActivePeers: () => dispatch(fetchActivePeers()),
createBackup: () => dispatch(createBackup()),
restoreBackup: (file) => dispatch(restoreBackup(file)),
exportData: (devModeEnvironment) => dispatch(exportData(devModeEnvironment)),
storeSearchTerm: (searchTerm) => dispatch(storeSearchTerm(searchTerm)),
storeSearchBarDisplayed: (searchBarDisplayed) => dispatch(storeSearchBarDisplayed(searchBarDisplayed)),
setIsRoot: (isRoot) => dispatch(setIsRoot(isRoot)),
showUserProfile: () => dispatch(showUserProfile()),
fetchEmailAddress: () => dispatch(fetchEmailAddress()),
saveEmailAddress: (emailAddress) => dispatch(saveEmailAddress(emailAddress)),
storeTempEmailAddress: (emailAddress) => dispatch(storeTempEmailAddress(emailAddress)),
setValidEmailAddressInput: (valid) => dispatch(setValidEmailAddressInput(valid)),
enableUserProfileEdit: () => dispatch(enableUserProfileEdit()),
hideUserProfile: () => dispatch(hideUserProfile())
};
};

const mapStateToProps = state => {
Expand Down
5 changes: 3 additions & 2 deletions frontend/src/pages/Navbar/SideNavCard.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,8 @@ const SideNavCard = ({
exportData,
showUserProfile,
fetchEmailAddress,
exportServiceAvailable
exportServiceAvailable,
environment
}) => {
const openUserProfile = () => {
fetchEmailAddress();
Expand Down Expand Up @@ -118,7 +119,7 @@ const SideNavCard = ({
</ListItem>
) : null}
{exportServiceAvailable ? (
<ListItem button onClick={exportData} data-test="side-navigation-export">
<ListItem button onClick={() => exportData(environment)} data-test="side-navigation-export">
<ListItemIcon>
<ExportIcon />
</ListItemIcon>
Expand Down
5 changes: 3 additions & 2 deletions frontend/src/pages/Navbar/actions.js
Original file line number Diff line number Diff line change
Expand Up @@ -73,9 +73,10 @@ export function createBackup() {
type: CREATE_BACKUP
};
}
export function exportData() {
export function exportData(devModeEnvironment) {
return {
type: EXPORT_DATA
type: EXPORT_DATA,
devModeEnvironment
};
}

Expand Down
4 changes: 2 additions & 2 deletions frontend/src/sagas.js
Original file line number Diff line number Diff line change
Expand Up @@ -2927,10 +2927,10 @@ export function* getExchangeRatesSaga({ baseCurrency, showLoading = true }) {
}, showLoading);
}

function* exportDataSaga() {
function* exportDataSaga({ devModeEnvironment }) {
yield execute(
function* () {
const data = yield callApi(api.export);
const data = yield callApi(api.export, devModeEnvironment);
saveAs(data, strings.login.frontend_name + "_Export.xlsx");
yield put({
type: EXPORT_DATA_SUCCESS
Expand Down

0 comments on commit f53981b

Please sign in to comment.