fix: Remove old policies from frontend when collection sharing permission changes

This commit is contained in:
Tom Moor
2023-05-22 22:30:53 -04:00
parent fbd16d4b9a
commit bb0cd891bd
2 changed files with 21 additions and 2 deletions

View File

@@ -43,7 +43,7 @@ function SharePopover({
}: Props) {
const team = useCurrentTeam();
const { t } = useTranslation();
const { shares } = useStores();
const { shares, collections } = useStores();
const { showToast } = useToasts();
const [expandedOptions, setExpandedOptions] = React.useState(false);
const [isEditMode, setIsEditMode] = React.useState(false);
@@ -53,10 +53,14 @@ function SharePopover({
const buttonRef = React.useRef<HTMLButtonElement>(null);
const can = usePolicy(share ? share.id : "");
const documentAbilities = usePolicy(document);
const collection = document.collectionId
? collections.get(document.collectionId)
: undefined;
const canPublish =
can.update &&
!document.isTemplate &&
team.sharing &&
collection?.sharing &&
documentAbilities.share;
const isPubliclyShared =
team.sharing &&