-
-
Notifications
You must be signed in to change notification settings - Fork 270
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Request mappers to read invalidated task comments:
- add info svg icon - add banner request to view task history comments - conditional render of banner if task was invalidated and has comments
- Loading branch information
Showing
9 changed files
with
109 additions
and
0 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
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,15 @@ | ||
import React from 'react'; | ||
|
||
export class InfoIcon extends React.PureComponent { | ||
render() { | ||
return ( | ||
<svg class="w1" data-icon="info" viewBox="0 0 32 32" {...this.props}> | ||
<title>info icon</title> | ||
<path | ||
fill="currentColor" | ||
d="M16 0 A16 16 0 0 1 16 32 A16 16 0 0 1 16 0 M19 15 L13 15 L13 26 L19 26 z M16 6 A3 3 0 0 0 16 12 A3 3 0 0 0 16 6" | ||
/> | ||
</svg> | ||
); | ||
} | ||
} |
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
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,29 @@ | ||
import { renderHook } from '@testing-library/react-hooks'; | ||
import { invalidatedTaskHistory, history } from '../../network/tests/mockData/taskHistory'; | ||
import useReadTaskComments from '../useReadTaskComments'; | ||
|
||
describe('test useReadTaskComments hook', () => { | ||
it('returns false when there is no task history', () => { | ||
const { result } = renderHook(() => useReadTaskComments({})); | ||
const readTaskComments = result.current; | ||
expect(readTaskComments).toBe(false); | ||
}); | ||
|
||
it('returns false if task has not been previously invalidated', () => { | ||
const { result } = renderHook(() => useReadTaskComments(history)); | ||
const readTaskComments = result.current; | ||
expect(readTaskComments).toBe(false); | ||
}); | ||
|
||
it('returns false if task history does not have comments', () => { | ||
const { result } = renderHook(() => useReadTaskComments(history)); | ||
const readTaskComments = result.current; | ||
expect(readTaskComments).toBe(false); | ||
}); | ||
|
||
it('returns true if was invalidated and has comments', () => { | ||
const { result } = renderHook(() => useReadTaskComments(invalidatedTaskHistory)); | ||
const readTaskComments = result.current; | ||
expect(readTaskComments).toBe(true); | ||
}); | ||
}); |
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,21 @@ | ||
import { useState, useEffect } from 'react'; | ||
|
||
const useReadTaskComments = (history) => { | ||
const [readTaskComments, setReadTaskComments] = useState(false); | ||
|
||
useEffect(() => { | ||
if (history && history.taskHistory && history.taskHistory.length > 1) { | ||
const invalidatedTaskHistory = history.taskHistory.filter( | ||
(task) => task.actionText === 'INVALIDATED', | ||
); | ||
const taskComments = history.taskHistory.filter((task) => task.action === 'COMMENT'); | ||
|
||
if (invalidatedTaskHistory.length > 0 && taskComments.length > 0) { | ||
setReadTaskComments(true); | ||
} | ||
} | ||
}, [history]); | ||
return readTaskComments; | ||
}; | ||
|
||
export default useReadTaskComments; |
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