Skip to content

fix(PM-810): tooltip and added empty content text #1618

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Mar 14, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -43,5 +43,11 @@
cursor: pointer;
}
}
.no-artifacts {
@include roboto;

margin-top: 40px;
text-align: center;
}
}
}
4 changes: 4 additions & 0 deletions src/components/ChallengeEditor/ArtifactsListModal/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,10 @@ export const ArtifactsListModal = ({ onClose, submissionId, token, theme }) => {
})
}

{
!loading && artifacts.length === 0 && <div className={styles['no-artifacts']}>No artifacts found</div>
}

{
loading && <Loader />
}
Expand Down
4 changes: 2 additions & 2 deletions src/components/ChallengeEditor/Submissions/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -601,7 +601,7 @@ class SubmissionsComponent extends React.Component {
</button>
</Tooltip>

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

<Tooltip content='Ratings'>
<Tooltip content='Ratings' closeOnClick>
<button
className={styles['download-submission-button']}
onClick={() => {
Expand Down
29 changes: 21 additions & 8 deletions src/components/Tooltip/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ import PropTypes from 'prop-types'
import styles from './Tooltip.module.scss'
import { usePopper } from 'react-popper'

const Tooltip = ({ content, children }) => {
const Tooltip = ({ content, children, closeOnClick }) => {
const [isOpen, setIsOpen] = useState(false)
const [referenceElement, setReferenceElement] = useState(null)
const [popperElement, setPopperElement] = useState(null)
Expand Down Expand Up @@ -69,15 +69,27 @@ const Tooltip = ({ content, children }) => {
setIsOpen(true)
}, [setIsOpen])

const defaultContentProps = {
onMouseEnter: open,
onMouseLeave: close,
innerRef: setReferenceElement,
ref: setReferenceElement
}

const getContentElementProps = child => closeOnClick ? {
...defaultContentProps,
onClick: (event) => {
if (typeof child.props.onClick === 'function') {
child.props.onClick(event)
}
close(event)
}
} : defaultContentProps

return (
<>
{React.Children.map(children, (child) =>
React.cloneElement(child, {
onMouseEnter: open,
onMouseLeave: close,
innerRef: setReferenceElement,
ref: setReferenceElement
})
React.cloneElement(child, getContentElementProps(child))
)}

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

Tooltip.propTypes = {
content: PropTypes.node,
children: PropTypes.node
children: PropTypes.node,
closeOnClick: PropTypes.bool
}

export default Tooltip