Skip to content

Commit

Permalink
Add deactivated AddProposalButton tooltip (Joystream#3909)
Browse files Browse the repository at this point in the history
  • Loading branch information
Joystream Stats committed Dec 2, 2022
1 parent 3373ce8 commit 1a0645b
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 3 deletions.
4 changes: 3 additions & 1 deletion packages/ui/src/common/components/Tooltip/Tooltip.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ export interface TooltipPopupProps {
forBig?: boolean
hideOnComponentLeave?: boolean
boundaryClassName?: string
placement?: string
}

export interface DarkTooltipInnerItemProps {
Expand All @@ -52,14 +53,15 @@ export const Tooltip = ({
offset,
hideOnComponentLeave,
boundaryClassName,
placement = 'bottom-start',
}: TooltipProps) => {
const [isTooltipActive, setTooltipActive] = useState(tooltipOpen)
const [referenceElementRef, setReferenceElementRef] = useState<HTMLElement | null>(null)
const [popperElementRef, setPopperElementRef] = useState<HTMLDivElement | null>(null)
const [boundaryElement, setBoundaryElement] = useState<HTMLElement | null>(null)

const { styles, attributes } = usePopper(referenceElementRef, popperElementRef, {
placement: 'bottom-start',
placement,
modifiers: [
{
name: 'offset',
Expand Down
20 changes: 18 additions & 2 deletions packages/ui/src/proposals/components/AddProposalButton.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import React, { useCallback } from 'react'
import { useApi } from '@/api/hooks/useApi'
import { TransactionButton } from '@/common/components/buttons/TransactionButton'
import { PlusIcon } from '@/common/components/icons/PlusIcon'
import { Tooltip } from '@/common/components/Tooltip'
import { useFirstObservableValue } from '@/common/hooks/useFirstObservableValue'
import { useModal } from '@/common/hooks/useModal'
import { AddNewProposalModalCall } from '@/proposals/modals/AddNewProposal'
Expand All @@ -21,9 +22,9 @@ export const AddProposalButton = () => {
() => api?.query.proposalsEngine.activeProposalCount(),
[api?.isConnected]
)
const areProposalSlotsAvailable = api && maxProposals && currentProposals?.lt(maxProposals)
const areProposalSlotsAvailable = false //api && maxProposals && currentProposals?.lt(maxProposals)

return (
const txButton = () => (
<TransactionButton
style="primary"
size="medium"
Expand All @@ -34,4 +35,19 @@ export const AddProposalButton = () => {
Add new proposal
</TransactionButton>
)

if (!areProposalSlotsAvailable)
return (
<Tooltip
tooltipTitle="MAX_ACTIVE_PROPOSALS"
tooltipText="The creation of new proposals is currently disabled because the number of deciding or gracing proposals is restricted to 20."
tooltipLinkText="Proposal System Constants"
tooltipLinkURL="https://joystream.gitbook.io/testnet-workspace/system/proposal-system#constants"
placement="bottom-end"
>
{txButton()}
</Tooltip>
)

return txButton()
}

0 comments on commit 1a0645b

Please sign in to comment.