fix: issue-2956 (#2957)
This commit is contained in:
@@ -165,7 +165,7 @@ function SharePopover({
|
|||||||
<HelpText>{t("Only team members with permission can view")}</HelpText>
|
<HelpText>{t("Only team members with permission can view")}</HelpText>
|
||||||
)}
|
)}
|
||||||
|
|
||||||
{canPublish && share?.published && (
|
{canPublish && share?.published && !document.isDraft && (
|
||||||
<SwitchWrapper>
|
<SwitchWrapper>
|
||||||
<Switch
|
<Switch
|
||||||
id="includeChildDocuments"
|
id="includeChildDocuments"
|
||||||
|
|||||||
@@ -360,7 +360,7 @@ class Collection extends ParanoidModel {
|
|||||||
direction: "asc",
|
direction: "asc",
|
||||||
};
|
};
|
||||||
|
|
||||||
let result!: NavigationNode;
|
let result!: NavigationNode | undefined;
|
||||||
|
|
||||||
const loopChildren = (documents: NavigationNode[]) => {
|
const loopChildren = (documents: NavigationNode[]) => {
|
||||||
if (result) {
|
if (result) {
|
||||||
@@ -384,6 +384,10 @@ class Collection extends ParanoidModel {
|
|||||||
// but the only place it's used passes straight into an API response
|
// but the only place it's used passes straight into an API response
|
||||||
// so the extra indirection is not worthwhile
|
// so the extra indirection is not worthwhile
|
||||||
loopChildren(this.documentStructure);
|
loopChildren(this.documentStructure);
|
||||||
|
|
||||||
|
// if the document is a draft loopChildren will not find it in the structure
|
||||||
|
if (!result) return null;
|
||||||
|
|
||||||
return {
|
return {
|
||||||
...result,
|
...result,
|
||||||
children: sortNavigationNodes(result.children, sort),
|
children: sortNavigationNodes(result.children, sort),
|
||||||
|
|||||||
@@ -34,7 +34,7 @@ import Fix from "./decorators/Fix";
|
|||||||
return {
|
return {
|
||||||
include: [
|
include: [
|
||||||
{
|
{
|
||||||
model: Document,
|
model: Document.scope("withUnpublished"),
|
||||||
paranoid: true,
|
paranoid: true,
|
||||||
as: "document",
|
as: "document",
|
||||||
include: [
|
include: [
|
||||||
|
|||||||
@@ -10,6 +10,7 @@ allow(User, "update", Share, (user, share) => {
|
|||||||
|
|
||||||
// only the user who can share the document publicly can update the share.
|
// only the user who can share the document publicly can update the share.
|
||||||
if (cannot(user, "share", share.document)) return false;
|
if (cannot(user, "share", share.document)) return false;
|
||||||
|
|
||||||
return user.teamId === share.teamId;
|
return user.teamId === share.teamId;
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|||||||
@@ -168,6 +168,7 @@ router.post("shares.update", auth(), async (ctx) => {
|
|||||||
const { user } = ctx.state;
|
const { user } = ctx.state;
|
||||||
const team = await Team.findByPk(user.teamId);
|
const team = await Team.findByPk(user.teamId);
|
||||||
authorize(user, "share", team);
|
authorize(user, "share", team);
|
||||||
|
|
||||||
// fetch the share with document and collection.
|
// fetch the share with document and collection.
|
||||||
const share = await Share.scope({
|
const share = await Share.scope({
|
||||||
method: ["withCollection", user.id],
|
method: ["withCollection", user.id],
|
||||||
|
|||||||
Reference in New Issue
Block a user