From bbda9b9d03c31fa8bfecf17bd1e37ab36dadd7fb Mon Sep 17 00:00:00 2001 From: ireic Date: Sat, 28 Dec 2019 23:26:04 +0100 Subject: [PATCH] Added withClearValue prop to select component --- client/src/Project/IssueDetails/Priority/index.jsx | 1 + client/src/Project/IssueDetails/Status/index.jsx | 1 + client/src/Project/IssueDetails/Tracking/index.jsx | 8 +++++--- client/src/Project/IssueDetails/Type/index.jsx | 1 + client/src/Project/IssueDetails/Users/index.jsx | 1 + client/src/index.jsx | 12 ++++++------ client/src/shared/components/Select/Dropdown.jsx | 7 ++++--- client/src/shared/components/Select/index.jsx | 4 ++++ client/src/shared/hooks/api/query.js | 4 +++- 9 files changed, 26 insertions(+), 13 deletions(-) diff --git a/client/src/Project/IssueDetails/Priority/index.jsx b/client/src/Project/IssueDetails/Priority/index.jsx index 680b14d..7819f2e 100644 --- a/client/src/Project/IssueDetails/Priority/index.jsx +++ b/client/src/Project/IssueDetails/Priority/index.jsx @@ -25,6 +25,7 @@ const ProjectBoardIssueDetailsPriority = ({ issue, updateIssue }) => { Priority ({ value: status, diff --git a/client/src/Project/IssueDetails/Tracking/index.jsx b/client/src/Project/IssueDetails/Tracking/index.jsx index a758301..0b1a9f1 100644 --- a/client/src/Project/IssueDetails/Tracking/index.jsx +++ b/client/src/Project/IssueDetails/Tracking/index.jsx @@ -51,7 +51,9 @@ const ProjectBoardIssueDetailsTracking = ({ issue, updateIssue }) => { Time Tracking {renderTrackingWidget(modal.open)}} + renderLink={modal => ( + {renderTrackingWidget()} + )} renderContent={modal => ( Time tracking @@ -77,8 +79,8 @@ const ProjectBoardIssueDetailsTracking = ({ issue, updateIssue }) => { ); - const renderTrackingWidget = (onClick = () => {}) => ( - + const renderTrackingWidget = () => ( + diff --git a/client/src/Project/IssueDetails/Type/index.jsx b/client/src/Project/IssueDetails/Type/index.jsx index 9489b4b..0430add 100644 --- a/client/src/Project/IssueDetails/Type/index.jsx +++ b/client/src/Project/IssueDetails/Type/index.jsx @@ -15,6 +15,7 @@ const ProjectBoardIssueDetailsType = ({ issue, updateIssue }) => ( updateIssue({ reporterId: userId })} diff --git a/client/src/index.jsx b/client/src/index.jsx index ec656b6..9220a43 100755 --- a/client/src/index.jsx +++ b/client/src/index.jsx @@ -6,10 +6,10 @@ import ReactDOM from 'react-dom'; import App from 'App'; -// APP IS NOT RESPONSIVE - REDUCE BROWSER HEIGHT, ISSUES DONT SCROLL - -// TODO: UPDATE FORMIK TO FIX SETFIELDVALUE TO EMPTY ARRAY ISSUE https://github.com/jaredpalmer/formik/pull/2144 - -// REFACTOR HTML TO USE SEMANTIC ELEMENTS - ReactDOM.render(, document.getElementById('root')); + +// APP IS NOT RESPONSIVE - REDUCE BROWSER HEIGHT, ISSUES DONT SCROLL +// TODO: UPDATE FORMIK TO FIX SETFIELDVALUE TO EMPTY ARRAY ISSUE https://github.com/jaredpalmer/formik/pull/2144 +// REFACTOR HTML TO USE SEMANTIC ELEMENTS +// MOVE SOME UTILS LIKE API TO SERVICES FOLDER +// RENAME ISSUE DETAILS "USERS" TO ASSIGNEESREPORTER diff --git a/client/src/shared/components/Select/Dropdown.jsx b/client/src/shared/components/Select/Dropdown.jsx index 92d086d..7cb5e8d 100644 --- a/client/src/shared/components/Select/Dropdown.jsx +++ b/client/src/shared/components/Select/Dropdown.jsx @@ -17,7 +17,8 @@ const propTypes = { options: PropTypes.array.isRequired, onChange: PropTypes.func.isRequired, onCreate: PropTypes.func, - isMulti: PropTypes.bool, + isMulti: PropTypes.bool.isRequired, + withClearValue: PropTypes.bool.isRequired, propsRenderOption: PropTypes.func, }; @@ -25,7 +26,6 @@ const defaultProps = { dropdownWidth: undefined, value: undefined, onCreate: undefined, - isMulti: false, propsRenderOption: undefined, }; @@ -41,6 +41,7 @@ const SelectDropdown = ({ onChange, onCreate, isMulti, + withClearValue, propsRenderOption, }) => { const [isCreatingOption, setCreatingOption] = useState(false); @@ -204,7 +205,7 @@ const SelectDropdown = ({ onKeyDown={handleInputKeyDown} onChange={event => setSearchValue(event.target.value)} /> - {!isValueEmpty && } + {!isValueEmpty && withClearValue && } {filteredOptions.map(renderSelectableOption)} {isOptionCreatable && renderCreatableOption()} diff --git a/client/src/shared/components/Select/index.jsx b/client/src/shared/components/Select/index.jsx index c694c84..9d1ed92 100644 --- a/client/src/shared/components/Select/index.jsx +++ b/client/src/shared/components/Select/index.jsx @@ -28,6 +28,7 @@ const propTypes = { onChange: PropTypes.func.isRequired, onCreate: PropTypes.func, isMulti: PropTypes.bool, + withClearValue: PropTypes.bool, renderValue: PropTypes.func, renderOption: PropTypes.func, }; @@ -42,6 +43,7 @@ const defaultProps = { invalid: false, onCreate: undefined, isMulti: false, + withClearValue: true, renderValue: undefined, renderOption: undefined, }; @@ -58,6 +60,7 @@ const Select = ({ onChange, onCreate, isMulti, + withClearValue, renderValue: propsRenderValue, renderOption: propsRenderOption, }) => { @@ -184,6 +187,7 @@ const Select = ({ onChange={handleChange} onCreate={onCreate} isMulti={isMulti} + withClearValue={withClearValue} propsRenderOption={propsRenderOption} /> )} diff --git a/client/src/shared/hooks/api/query.js b/client/src/shared/hooks/api/query.js index af143d7..bc932f5 100644 --- a/client/src/shared/hooks/api/query.js +++ b/client/src/shared/hooks/api/query.js @@ -5,7 +5,9 @@ import api from 'shared/utils/api'; import useMergeState from 'shared/hooks/mergeState'; import useDeepCompareMemoize from 'shared/hooks/deepCompareMemoize'; -const useQuery = (url, propsVariables = {}, { lazy = false, cachePolicy = 'cache-first' } = {}) => { +const useQuery = (url, propsVariables = {}, options = {}) => { + const { lazy = false, cachePolicy = 'cache-first' } = options; + const [state, mergeState] = useMergeState({ data: null, error: null,