Skip to content

Commit

Permalink
MERGING RELEASE branches (#19)
Browse files Browse the repository at this point in the history
* CM-332: fetch tasks only for particular searcher (#14)

* CM-332: fetch tasks only for particular searcher

* CM-332: fix eslint

---------

Co-authored-by: Jan <j.dolkowski@soldevelo.com>

* CM-327: change the way how task updates are fetched (#15)

Co-authored-by: Jan <j.dolkowski@soldevelo.com>

* hotfix: fix parsing schema in task (#16)

Co-authored-by: Jan <j.dolkowski@soldevelo.com>

* CM-327: fetch task only after it is updated (#18)

* CM-327: change the way how task updates are fetched

* CM-327: make sure task is fetched after it is uploaded

---------

Co-authored-by: Jan <j.dolkowski@soldevelo.com>

* hotfix: fix displaying deleted groups (#17)

Co-authored-by: Jan <j.dolkowski@soldevelo.com>

* add-sonar-ci: add sonar files (#20)

Co-authored-by: Jan <j.dolkowski@soldevelo.com>

---------

Co-authored-by: Jan <jdolkowski@soldevelo.com>
Co-authored-by: Jan <j.dolkowski@soldevelo.com>
  • Loading branch information
3 people authored Oct 18, 2023
1 parent 8e96e77 commit f89cc05
Show file tree
Hide file tree
Showing 8 changed files with 84 additions and 17 deletions.
23 changes: 23 additions & 0 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
name: Sonar CI pipeline
on:
push:
branches:
- main
- 'release/**'
- develop
- 'feature/**'
pull_request:
types: [opened, synchronize, reopened]
jobs:
sonarcloud:
name: SonarCloud
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
with:
fetch-depth: 0
- name: SonarCloud Scan
uses: SonarSource/sonarcloud-github-action@master
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
6 changes: 6 additions & 0 deletions sonar-project.properties
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
sonar.projectKey=openimis_openimis-fe-tasks_management_js
sonar.organization=openimis-1
sonar.projectName=openimis-fe-tasks_management_js

sonar.sources=src
sonar.sourceEncoding=UTF-8
6 changes: 6 additions & 0 deletions src/actions.js
Original file line number Diff line number Diff line change
Expand Up @@ -132,6 +132,12 @@ export const clearTaskGroup = () => (dispatch) => {
});
};

export const clearTask = () => (dispatch) => {
dispatch({
type: CLEAR(ACTION_TYPE.GET_TASK),
});
};

export function deleteTaskGroup(taskGroup, clientMutationLabel) {
const taskGroupsUuids = `ids: ["${decodeId(taskGroup?.id)}"]`;
return PERFORM_MUTATION(
Expand Down
2 changes: 0 additions & 2 deletions src/components/TaskApprovementPanel.js
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,6 @@ function TaskApprovementPanel({
mutation,
journalize,
confirmed,
setIsSaved,
}) {
const modulesManager = useModulesManager();
const classes = useStyles();
Expand Down Expand Up @@ -80,7 +79,6 @@ function TaskApprovementPanel({
user,
approveOrFail,
);
setIsSaved(true);
}
}
return () => confirmed && clearConfirm(false);
Expand Down
11 changes: 7 additions & 4 deletions src/components/TaskSearcher.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ function TaskSearcher({
const errorTasks = useSelector((state) => state?.tasksManagement?.errorTasks);
const tasks = useSelector((state) => state?.tasksManagement?.tasks);
const tasksPageInfo = useSelector((state) => state?.tasksManagement?.tasksPageInfo);
const tasksTotalCount = useSelector((state) => state?.tasksManagement?.tasksTotalCount);

const openTask = (task, newTab = false) => historyPush(
modulesManager,
Expand All @@ -45,8 +46,6 @@ function TaskSearcher({

const isRowDisabled = (_, task) => task.status !== TASK_STATUS.ACCEPTED;

const filterTasks = (tasks) => tasks.filter((task) => contribution.taskSource.includes(task.source));

const headers = () => {
const headers = [
'task.source',
Expand Down Expand Up @@ -94,6 +93,10 @@ function TaskSearcher({
value: false,
filter: 'isDeleted: false',
},
source: {
value: contribution.taskSource,
filter: `source: "${contribution.taskSource}"`,
},
});

const taskFilter = (props) => (
Expand All @@ -110,13 +113,13 @@ function TaskSearcher({
module="tasksManagement"
FilterPane={taskFilter}
fetch={fetch}
items={filterTasks(tasks)}
items={tasks}
itemsPageInfo={tasksPageInfo}
fetchingItems={fetchingTasks}
fetchedItems={fetchedTasks}
errorItems={errorTasks}
tableTitle={formatMessageWithValues('task.searcherResultsTitle', {
tasksTotalCount: filterTasks(tasks).length,
tasksTotalCount,
})}
headers={headers}
itemFormatters={itemFormatters}
Expand Down
31 changes: 24 additions & 7 deletions src/pages/TaskDetailsPage.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import React, { useState, useEffect } from 'react';
import React, { useState, useEffect, useRef } from 'react';
import { connect } from 'react-redux';
import { bindActionCreators } from 'redux';
import { makeStyles } from '@material-ui/core/styles';
Expand All @@ -13,7 +13,7 @@ import _ from 'lodash';
import TaskHeadPanel from '../components/TaskHeadPanel';
import TaskPreviewPanel from '../components/TaskPreviewPanel';
import TaskApprovementPanel from '../components/TaskApprovementPanel';
import { fetchTask, updateTask } from '../actions';
import { clearTask, fetchTask, updateTask } from '../actions';
import { TASK_STATUS as taskStatus } from '../constants';

const useStyles = makeStyles((theme) => ({
Expand All @@ -27,28 +27,41 @@ function TaskDetailsPage({
fetchTask,
updateTask,
currentUser,
submittingMutation,
mutation,
clearTask,
}) {
const modulesManager = useModulesManager();
const classes = useStyles();
const history = useHistory();
const { formatMessage } = useTranslations('tasksManagement', modulesManager);
const [editedTask, setEditedTask] = useState({});
const [isSaved, setIsSaved] = useState(false);
const submittingMutationRef = useRef();
const back = () => history.goBack();

useEffect(() => {
if (taskUuid) {
fetchTask(modulesManager, [`id: "${taskUuid}"`]);
setIsSaved(false);
}
}, [taskUuid, isSaved]);
}, [taskUuid]);

useEffect(() => {
if (submittingMutationRef.current && !submittingMutation && mutation?.clientMutationId) {
fetchTask(modulesManager, [`clientMutationId: "${mutation.clientMutationId}"`]);
}
submittingMutationRef.current = submittingMutation;
}, [submittingMutation]);

useEffect(() => {
if (task) {
setEditedTask(task);
}
}, [task]);

useEffect(() => () => {
clearTask();
}, []);

const doesTaskChange = () => {
if (_.isEqual(task, editedTask)) return false;
return true;
Expand All @@ -64,7 +77,6 @@ function TaskDetailsPage({
editedTask,
formatMessage('task.update.mutationLabel'),
);
setIsSaved(true);
}
};

Expand Down Expand Up @@ -98,7 +110,6 @@ function TaskDetailsPage({
HeadPanel={TaskHeadPanel}
formatMessage={formatMessage}
Panels={panels()}
setIsSaved={setIsSaved}
rights={rights}
saveTooltip={formatMessage(
`tasksManagement.saveButton.tooltip.${canSave() ? 'enabled' : 'disabled'}`,
Expand All @@ -111,13 +122,19 @@ function TaskDetailsPage({
const mapDispatchToProps = (dispatch) => bindActionCreators({
fetchTask,
updateTask,
clearTask,
}, dispatch);

const mapStateToProps = (state, props) => ({
rights: !!state.core && !!state.core.user && !!state.core.user.i_user ? state.core.user.i_user.rights : [],
currentUser: !!state.core && !!state?.core?.user ? state.core.user : null,
taskUuid: props.match.params.task_uuid,
submittingMutation: state.tasksManagement.submittingMutation,
mutation: state.tasksManagement.mutation,
task: state.tasksManagement.task,
fetchingTask: state.tasksManagement.fetchingTask,
fetchedTask: state.tasksManagement.fetchedTask,
errorTask: state.tasksManagement.errorTask,
});

export default connect(mapStateToProps, mapDispatchToProps)(TaskDetailsPage);
2 changes: 1 addition & 1 deletion src/pickers/TaskGroupPicker.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ function TaskGroupPicker(props) {
const { isLoading, data, error } = useGraphqlQuery(
`
query TaskGroupPicker ($search: String) {
taskGroup(search: $search, first: 20) {
taskGroup(search: $search, first: 20, isDeleted: false) {
edges {
node {
id
Expand Down
20 changes: 17 additions & 3 deletions src/reducer.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,12 @@ import {
CLEAR, ERROR, REQUEST, SUCCESS,
} from './utils/action-type';

function parseTaskData(object) {
if (object?.beneficiary_data_schema) {
return { ...object, beneficiary_data_schema: JSON.stringify(object.beneficiary_data_schema) };
}
return object;
}
export const ACTION_TYPE = {
MUTATION: 'TASK_MANAGEMENT_MUTATION',
SEARCH_TASK_GROUPS: 'TASK_MANAGEMENT_TASK_GROUPS',
Expand Down Expand Up @@ -109,13 +115,13 @@ function reducer(
task: parseData(action.payload.data.task)?.map((task) => ({
...task,
id: decodeId(task.id),
currentEntityData: JSON.parse((JSON.parse(task.currentEntityData))),
data: JSON.parse(task.data, (key, value) => {
currentEntityData: parseTaskData(JSON.parse((JSON.parse(task.currentEntityData)))),
data: parseTaskData(JSON.parse(task.data, (key, value) => {
if (['date_valid_to', 'date_valid_from'].includes(key)) {
return `${value} 00:00:00`;
}
return value;
}),
})),
}))?.[0],
errorTask: null,
};
Expand Down Expand Up @@ -182,6 +188,14 @@ function reducer(
errorTaskGroup: null,
fetchedTaskGroup: false,
};
case CLEAR(ACTION_TYPE.GET_TASK):
return {
...state,
task: null,
fetchingTask: false,
errorTask: null,
fetchedTask: false,
};
case REQUEST(ACTION_TYPE.MUTATION):
return dispatchMutationReq(state, action);
case ERROR(ACTION_TYPE.MUTATION):
Expand Down

0 comments on commit f89cc05

Please sign in to comment.