Skip to content

Commit

Permalink
Merge pull request #520 from EyeSeeTea/development
Browse files Browse the repository at this point in the history
Release 1.6.0
  • Loading branch information
adrianq authored Nov 28, 2023
2 parents d3ad6d9 + 88073c8 commit 2af6e9a
Show file tree
Hide file tree
Showing 31 changed files with 1,724 additions and 113 deletions.
71 changes: 35 additions & 36 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
@@ -1,43 +1,42 @@
name: Application testing
on:
push:
workflow_dispatch:
push:
workflow_dispatch:
jobs:
unit-tests:
name: Unit tests
runs-on: self-hosted
steps:
- name: Checkout repository
uses: actions/checkout@v2

- name: Setup Node
uses: actions/setup-node@v1
with:
node-version: "12.x"

- name: Install yarn
run: npm install -g yarn
unit-tests:
name: Unit tests
steps:
- name: Checkout repository
uses: actions/checkout@v2

- name: Get yarn cache directory path
id: yarn-cache-dir-path
run: echo "::set-output name=dir::$(yarn cache dir)"
- name: Setup Node
uses: actions/setup-node@v1
with:
node-version: "12.x"

- name: Cache yarn dependencies
uses: actions/cache@v2
id: yarn-cache
with:
path: ${{ steps.yarn-cache-dir-path.outputs.dir }}
key: ${{ runner.os }}-yarn-${{ hashFiles('**/yarn.lock') }}
restore-keys: |
${{ runner.os }}-yarn-
- name: Installing Dependencies
run: yarn install --frozen-lockfile --silent
- name: Install yarn
run: npm install -g yarn

- name: Install translations
run: yarn localize

- name: Run jest tests
run: yarn test
- name: Get yarn cache directory path
id: yarn-cache-dir-path
run: echo "::set-output name=dir::$(yarn cache dir)"

- name: Run typescript tests
run: npx tsc
- name: Cache yarn dependencies
uses: actions/cache@v2
id: yarn-cache
with:
path: ${{ steps.yarn-cache-dir-path.outputs.dir }}
key: ${{ runner.os }}-yarn-${{ hashFiles('**/yarn.lock') }}
restore-keys: |
${{ runner.os }}-yarn-
- name: Installing Dependencies
run: yarn install --frozen-lockfile --silent

- name: Install translations
run: yarn localize

- name: Run jest tests
run: yarn test

- name: Run typescript tests
run: npx tsc
100 changes: 74 additions & 26 deletions i18n/en.pot
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,29 @@ 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: 2023-09-13T11:54:43.059Z\n"
"PO-Revision-Date: 2023-09-13T11:54:43.059Z\n"
"POT-Creation-Date: 2023-11-27T10:33:09.454Z\n"
"PO-Revision-Date: 2023-11-27T10:33:09.455Z\n"

msgid "Validating Project"
msgstr ""

msgid "Saving Project"
msgstr ""

msgid "Project updated"
msgstr ""

msgid "Unknown error"
msgstr ""

msgid "Files"
msgstr ""

msgid "Cancel"
msgstr ""

msgid "Save"
msgstr ""

msgid "Name"
msgstr ""
Expand Down Expand Up @@ -74,6 +95,22 @@ msgid ""
"approval?"
msgstr ""

msgid "Apply to all months"
msgstr ""

msgid ""
"This action is going to unapprove all the periods. You will have to approve "
"the data again on the Data Approval section. Are you sure you want to apply "
"the current values to all months? The existing data in other months will be "
"overwritten."
msgstr ""

msgid "Applying values to all months..."
msgstr ""

msgid "Values applied to all months"
msgstr ""

msgid "Project closed for this period, please contact the administrators"
msgstr ""

Expand All @@ -92,9 +129,6 @@ msgstr ""
msgid "Close"
msgstr ""

msgid "Save"
msgstr ""

msgid "Comments saved"
msgstr ""

Expand All @@ -119,9 +153,6 @@ msgstr ""
msgid "Proceed"
msgstr ""

msgid "Cancel"
msgstr ""

msgid "<No value>"
msgstr ""

Expand Down Expand Up @@ -184,6 +215,24 @@ msgstr ""
msgid "{{n}} matches"
msgstr ""

msgid "Drag and drop a file (no more than 5MB)"
msgstr ""

msgid "Attached Files"
msgstr ""

msgid "Download"
msgstr ""

msgid "Delete"
msgstr ""

msgid "File is larger than {{maxSizeInMb}}MB"
msgstr ""

msgid "reportable sub"
msgstr ""

msgid "Indicator Type"
msgstr ""

Expand Down Expand Up @@ -265,21 +314,12 @@ msgstr ""
msgid "Before saving, please explain why these indicators have been removed"
msgstr ""

msgid "Validating Project"
msgstr ""

msgid "Checking Existing Data"
msgstr ""

msgid "Saving Project"
msgstr ""

msgid "Project created"
msgstr ""

msgid "Project updated"
msgstr ""

msgid ""
"Note: only users with permissions in the selected country ({{country}}) can "
"be added to this project"
Expand Down Expand Up @@ -471,12 +511,21 @@ msgstr ""
msgid "Sharing"
msgstr ""

msgid "Documents"
msgstr ""

msgid "Is this DART applicable?"
msgstr ""

msgid "Award Number should be a number of 5 digits"
msgstr ""

msgid "One Organisation Unit should be selected"
msgstr ""

msgid "Files cannot be bigger than {{maxSizeProjectInMb}}MB"
msgstr ""

msgid "There is a project with the same code '{{code}}' -> {{orgUnit}}"
msgstr ""

Expand Down Expand Up @@ -705,6 +754,11 @@ msgstr ""
msgid "[only for admin users]"
msgstr ""

msgid ""
"Indicator {{deCode}} cannot be selected because is selected in another "
"sector ({{sector}})"
msgstr ""

msgid "Global indicators with selected sub-indicators cannot be unselected"
msgstr ""

Expand Down Expand Up @@ -878,6 +932,9 @@ msgstr ""
msgid "Define Sharing settings for project data."
msgstr ""

msgid "Attach files for the project"
msgstr ""

msgid "Summary and Save"
msgstr ""

Expand Down Expand Up @@ -976,9 +1033,6 @@ msgstr ""
msgid "Edit"
msgstr ""

msgid "Delete"
msgstr ""

msgid "User groups"
msgstr ""

Expand All @@ -991,9 +1045,6 @@ msgstr ""
msgid "[COVID-19]"
msgstr ""

msgid "Unknown error"
msgstr ""

msgid "Error saving report"
msgstr ""

Expand Down Expand Up @@ -1027,9 +1078,6 @@ msgstr ""
msgid "Projected Activities for the next month"
msgstr ""

msgid "Download"
msgstr ""

msgid ""
"Please choose the month of data you wish to extract for the MER report.\n"
" Please make sure you choose your country for reporting.\n"
Expand Down
6 changes: 4 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "data-management-app",
"description": "DHIS2 Data Management App",
"version": "1.5.1",
"version": "1.6.0",
"license": "GPL-3.0",
"author": "EyeSeeTea team",
"homepage": ".",
Expand All @@ -28,7 +28,8 @@
"axios": "0.21.1",
"axios-retry": "^3.1.9",
"classnames": "2.3.2",
"csv-writer": "^1.6.0",
"csv-writer": "1.6.0",
"csvtojson": "2.0.10",
"d2": "31.9.0",
"d2-manifest": "^1.0.0",
"exceljs": "4.3.0",
Expand All @@ -42,6 +43,7 @@
"query-string": "^4.3.4",
"react": "17.0.1",
"react-dom": "17.0.1",
"react-dropzone": "14.2.3",
"react-is": "16.8.0",
"react-router-dom": "^5.1.2",
"react-router-last-location": "^2.0.1",
Expand Down
92 changes: 92 additions & 0 deletions src/components/attach-files-dialog/AttachFilesDialog.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,92 @@
import _ from "lodash";
import React from "react";

import Button from "@material-ui/core/Button";
import Dialog from "@material-ui/core/Dialog";
import DialogActions from "@material-ui/core/DialogActions";
import DialogContent from "@material-ui/core/DialogContent";
import DialogTitle from "@material-ui/core/DialogTitle";
import { AttachFiles } from "../steps/attach-files/AttachFiles";
import Project from "../../models/Project";
import { ProjectDocument } from "../../models/ProjectDocument";
import { useAppContext } from "../../contexts/api-context";
import { useLoading, useSnackbar } from "@eyeseetea/d2-ui-components";

import { Maybe } from "../../types/utils";
import i18n from "./../../locales";

type AttachFilesDialogProps = {
projectId: Maybe<string>;
onClose: () => void;
};

export const AttachFilesDialog: React.FC<AttachFilesDialogProps> = props => {
const { api, config } = useAppContext();
const loading = useLoading();
const snackbar = useSnackbar();
const { onClose, projectId } = props;
const [documents, setDocuments] = React.useState<ProjectDocument[]>();
const [projectDetails, setProjectDetails] = React.useState<Project>();

React.useEffect(() => {
async function fetchProject() {
if (projectId) {
const project = await Project.get(api, config, projectId);
setProjectDetails(project);
}
}

fetchProject();
}, [api, config, projectId]);

if (!projectDetails) return null;

const onChangeProject = (projectDocuments: ProjectDocument[]) => {
setDocuments(projectDocuments);
};

const onSaveProject = async () => {
if (!documents) {
onClose();
return;
}
loading.show(true, i18n.t("Validating Project"));
const newProject = projectDetails.setObj({ documents });
const validation = await newProject.validate(["documents"]);
const error = _(validation).values().flatten().join("\n");
if (error) {
snackbar.error(error);
loading.hide();
return;
}

loading.show(true, i18n.t("Saving Project"));
try {
await newProject.saveFiles();
snackbar.success(i18n.t("Project updated"));
onClose();
} catch (err: any) {
const message = err?.response?.data?.message || i18n.t("Unknown error");
snackbar.error(i18n.t("Error uploading files: {{message}}", { message }));
} finally {
loading.hide();
}
};

return (
<Dialog onClose={onClose} open maxWidth={"lg"}>
<DialogTitle>
{i18n.t("Files")} - {`${projectDetails.name} (${projectDetails.code})`}
</DialogTitle>
<DialogContent>
<AttachFiles onChange={onChangeProject} project={projectDetails} />
<DialogActions>
<Button onClick={onClose}>{i18n.t("Cancel")}</Button>
<Button color="primary" variant="contained" onClick={onSaveProject}>
{i18n.t("Save")}
</Button>
</DialogActions>
</DialogContent>
</Dialog>
);
};
Loading

0 comments on commit 2af6e9a

Please sign in to comment.