Allo creators to unlist markets
This commit is contained in:
parent
370edec890
commit
f92f098f82
|
@ -64,6 +64,7 @@ export type Contract<T extends AnyContractType = AnyContractType> = {
|
||||||
likedByUserCount?: number
|
likedByUserCount?: number
|
||||||
flaggedByUsernames?: string[]
|
flaggedByUsernames?: string[]
|
||||||
openCommentBounties?: number
|
openCommentBounties?: number
|
||||||
|
unlistedById?: string
|
||||||
} & T
|
} & T
|
||||||
|
|
||||||
export type BinaryContract = Contract & Binary
|
export type BinaryContract = Contract & Binary
|
||||||
|
|
|
@ -102,7 +102,7 @@ service cloud.firestore {
|
||||||
allow update: if request.resource.data.diff(resource.data).affectedKeys()
|
allow update: if request.resource.data.diff(resource.data).affectedKeys()
|
||||||
.hasOnly(['tags', 'lowercaseTags', 'groupSlugs', 'groupLinks']);
|
.hasOnly(['tags', 'lowercaseTags', 'groupSlugs', 'groupLinks']);
|
||||||
allow update: if request.resource.data.diff(resource.data).affectedKeys()
|
allow update: if request.resource.data.diff(resource.data).affectedKeys()
|
||||||
.hasOnly(['description', 'closeTime', 'question'])
|
.hasOnly(['description', 'closeTime', 'question', 'visibility', 'unlistedById'])
|
||||||
&& resource.data.creatorId == request.auth.uid;
|
&& resource.data.creatorId == request.auth.uid;
|
||||||
allow update: if isAdmin();
|
allow update: if isAdmin();
|
||||||
match /comments/{commentId} {
|
match /comments/{commentId} {
|
||||||
|
|
|
@ -19,7 +19,7 @@ import { deleteField } from 'firebase/firestore'
|
||||||
import ShortToggle from '../widgets/short-toggle'
|
import ShortToggle from '../widgets/short-toggle'
|
||||||
import { DuplicateContractButton } from '../copy-contract-button'
|
import { DuplicateContractButton } from '../copy-contract-button'
|
||||||
import { Row } from '../layout/row'
|
import { Row } from '../layout/row'
|
||||||
import { BETTORS } from 'common/user'
|
import { BETTORS, User } from 'common/user'
|
||||||
import { Button } from '../button'
|
import { Button } from '../button'
|
||||||
|
|
||||||
export const contractDetailsButtonClassName =
|
export const contractDetailsButtonClassName =
|
||||||
|
@ -27,9 +27,10 @@ export const contractDetailsButtonClassName =
|
||||||
|
|
||||||
export function ContractInfoDialog(props: {
|
export function ContractInfoDialog(props: {
|
||||||
contract: Contract
|
contract: Contract
|
||||||
|
user: User | null | undefined
|
||||||
className?: string
|
className?: string
|
||||||
}) {
|
}) {
|
||||||
const { contract, className } = props
|
const { contract, className, user } = props
|
||||||
|
|
||||||
const [open, setOpen] = useState(false)
|
const [open, setOpen] = useState(false)
|
||||||
const [featured, setFeatured] = useState(
|
const [featured, setFeatured] = useState(
|
||||||
|
@ -37,6 +38,10 @@ export function ContractInfoDialog(props: {
|
||||||
)
|
)
|
||||||
const isDev = useDev()
|
const isDev = useDev()
|
||||||
const isAdmin = useAdmin()
|
const isAdmin = useAdmin()
|
||||||
|
const isCreator = user?.id === contract.creatorId
|
||||||
|
const isUnlisted = contract.visibility === 'unlisted'
|
||||||
|
const wasUnlistedByCreator =
|
||||||
|
contract.unlistedById && contract.unlistedById === contract.creatorId
|
||||||
|
|
||||||
const formatTime = (dt: number) => dayjs(dt).format('MMM DD, YYYY hh:mm a')
|
const formatTime = (dt: number) => dayjs(dt).format('MMM DD, YYYY hh:mm a')
|
||||||
|
|
||||||
|
@ -175,21 +180,25 @@ export function ContractInfoDialog(props: {
|
||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
)}
|
)}
|
||||||
{isAdmin && (
|
{user &&
|
||||||
<tr>
|
(isAdmin ||
|
||||||
<td>[ADMIN] Unlisted</td>
|
(isCreator &&
|
||||||
<td>
|
(isUnlisted ? wasUnlistedByCreator : true))) && (
|
||||||
<ShortToggle
|
<tr>
|
||||||
enabled={contract.visibility === 'unlisted'}
|
<td>{isAdmin ? '[ADMIN]' : ''} Unlisted</td>
|
||||||
setEnabled={(b) =>
|
<td>
|
||||||
updateContract(id, {
|
<ShortToggle
|
||||||
visibility: b ? 'unlisted' : 'public',
|
enabled={contract.visibility === 'unlisted'}
|
||||||
})
|
setEnabled={(b) =>
|
||||||
}
|
updateContract(id, {
|
||||||
/>
|
visibility: b ? 'unlisted' : 'public',
|
||||||
</td>
|
unlistedById: b ? user.id : '',
|
||||||
</tr>
|
})
|
||||||
)}
|
}
|
||||||
|
/>
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
)}
|
||||||
</tbody>
|
</tbody>
|
||||||
</table>
|
</table>
|
||||||
|
|
||||||
|
|
|
@ -35,7 +35,7 @@ export function ExtraContractActionsRow(props: { contract: Contract }) {
|
||||||
/>
|
/>
|
||||||
</Button>
|
</Button>
|
||||||
</Tooltip>
|
</Tooltip>
|
||||||
<ContractInfoDialog contract={contract} />
|
<ContractInfoDialog contract={contract} user={user} />
|
||||||
</Row>
|
</Row>
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue
Block a user