-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #520 from EyeSeeTea/development
Release 1.6.0
- Loading branch information
Showing
31 changed files
with
1,724 additions
and
113 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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> | ||
); | ||
}; |
Oops, something went wrong.