Skip to content

Commit f9e5ac1

Browse files
authored
Merge pull request #1618 from topcoder-platform/pm-810_1
fix(PM-810): tooltip and added empty content text
2 parents b49d3eb + ce462b5 commit f9e5ac1

File tree

4 files changed

+33
-10
lines changed

4 files changed

+33
-10
lines changed

src/components/ChallengeEditor/ArtifactsListModal/ArtifactsListModal.module.scss

+6
Original file line numberDiff line numberDiff line change
@@ -43,5 +43,11 @@
4343
cursor: pointer;
4444
}
4545
}
46+
.no-artifacts {
47+
@include roboto;
48+
49+
margin-top: 40px;
50+
text-align: center;
51+
}
4652
}
4753
}

src/components/ChallengeEditor/ArtifactsListModal/index.js

+4
Original file line numberDiff line numberDiff line change
@@ -87,6 +87,10 @@ export const ArtifactsListModal = ({ onClose, submissionId, token, theme }) => {
8787
})
8888
}
8989

90+
{
91+
!loading && artifacts.length === 0 && <div className={styles['no-artifacts']}>No artifacts found</div>
92+
}
93+
9094
{
9195
loading && <Loader />
9296
}

src/components/ChallengeEditor/Submissions/index.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -601,7 +601,7 @@ class SubmissionsComponent extends React.Component {
601601
</button>
602602
</Tooltip>
603603

604-
<Tooltip content='Download Submission Artifacts'>
604+
<Tooltip content='Download Submission Artifacts' closeOnClick>
605605
<button
606606
className={styles['download-submission-button']}
607607
onClick={async () => {
@@ -612,7 +612,7 @@ class SubmissionsComponent extends React.Component {
612612
</button>
613613
</Tooltip>
614614

615-
<Tooltip content='Ratings'>
615+
<Tooltip content='Ratings' closeOnClick>
616616
<button
617617
className={styles['download-submission-button']}
618618
onClick={() => {

src/components/Tooltip/index.js

+21-8
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ import PropTypes from 'prop-types'
2121
import styles from './Tooltip.module.scss'
2222
import { usePopper } from 'react-popper'
2323

24-
const Tooltip = ({ content, children }) => {
24+
const Tooltip = ({ content, children, closeOnClick }) => {
2525
const [isOpen, setIsOpen] = useState(false)
2626
const [referenceElement, setReferenceElement] = useState(null)
2727
const [popperElement, setPopperElement] = useState(null)
@@ -69,15 +69,27 @@ const Tooltip = ({ content, children }) => {
6969
setIsOpen(true)
7070
}, [setIsOpen])
7171

72+
const defaultContentProps = {
73+
onMouseEnter: open,
74+
onMouseLeave: close,
75+
innerRef: setReferenceElement,
76+
ref: setReferenceElement
77+
}
78+
79+
const getContentElementProps = child => closeOnClick ? {
80+
...defaultContentProps,
81+
onClick: (event) => {
82+
if (typeof child.props.onClick === 'function') {
83+
child.props.onClick(event)
84+
}
85+
close(event)
86+
}
87+
} : defaultContentProps
88+
7289
return (
7390
<>
7491
{React.Children.map(children, (child) =>
75-
React.cloneElement(child, {
76-
onMouseEnter: open,
77-
onMouseLeave: close,
78-
innerRef: setReferenceElement,
79-
ref: setReferenceElement
80-
})
92+
React.cloneElement(child, getContentElementProps(child))
8193
)}
8294

8395
{isOpen && (
@@ -101,7 +113,8 @@ const Tooltip = ({ content, children }) => {
101113

102114
Tooltip.propTypes = {
103115
content: PropTypes.node,
104-
children: PropTypes.node
116+
children: PropTypes.node,
117+
closeOnClick: PropTypes.bool
105118
}
106119

107120
export default Tooltip

0 commit comments

Comments
 (0)