@ -190,9 +190,19 @@ class DocumentMenu extends React.Component<Props> {
|
|||||||
<DropdownMenuItem onClick={this.handleMove}>Move…</DropdownMenuItem>
|
<DropdownMenuItem onClick={this.handleMove}>Move…</DropdownMenuItem>
|
||||||
</React.Fragment>
|
</React.Fragment>
|
||||||
) : (
|
) : (
|
||||||
|
<React.Fragment>
|
||||||
|
{canShareDocuments && (
|
||||||
|
<DropdownMenuItem
|
||||||
|
onClick={this.handleShareLink}
|
||||||
|
title="Create a public share link"
|
||||||
|
>
|
||||||
|
Share link…
|
||||||
|
</DropdownMenuItem>
|
||||||
|
)}
|
||||||
<DropdownMenuItem onClick={this.handleDelete}>
|
<DropdownMenuItem onClick={this.handleDelete}>
|
||||||
Delete…
|
Delete…
|
||||||
</DropdownMenuItem>
|
</DropdownMenuItem>
|
||||||
|
</React.Fragment>
|
||||||
)}
|
)}
|
||||||
<hr />
|
<hr />
|
||||||
<DropdownMenuItem onClick={this.handleExport}>
|
<DropdownMenuItem onClick={this.handleExport}>
|
||||||
|
@ -17,6 +17,7 @@ import {
|
|||||||
View,
|
View,
|
||||||
Revision,
|
Revision,
|
||||||
Backlink,
|
Backlink,
|
||||||
|
User,
|
||||||
} from '../models';
|
} from '../models';
|
||||||
import { InvalidRequestError } from '../errors';
|
import { InvalidRequestError } from '../errors';
|
||||||
import events from '../events';
|
import events from '../events';
|
||||||
@ -286,7 +287,12 @@ router.post('documents.info', auth({ required: false }), async ctx => {
|
|||||||
},
|
},
|
||||||
include: [
|
include: [
|
||||||
{
|
{
|
||||||
model: Document,
|
// unscoping here allows us to return unpublished documents
|
||||||
|
model: Document.unscoped(),
|
||||||
|
include: [
|
||||||
|
{ model: User, as: 'createdBy', paranoid: false },
|
||||||
|
{ model: User, as: 'updatedBy', paranoid: false },
|
||||||
|
],
|
||||||
required: true,
|
required: true,
|
||||||
as: 'document',
|
as: 'document',
|
||||||
},
|
},
|
||||||
|
@ -133,6 +133,28 @@ describe('#documents.info', async () => {
|
|||||||
expect(body.data.updatedBy.id).toEqual(user.id);
|
expect(body.data.updatedBy.id).toEqual(user.id);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
it('should return draft document from shareId with token', async () => {
|
||||||
|
const { user, document } = await seed();
|
||||||
|
document.publishedAt = null;
|
||||||
|
await document.save();
|
||||||
|
|
||||||
|
const share = await buildShare({
|
||||||
|
documentId: document.id,
|
||||||
|
teamId: document.teamId,
|
||||||
|
userId: user.id,
|
||||||
|
});
|
||||||
|
|
||||||
|
const res = await server.post('/api/documents.info', {
|
||||||
|
body: { token: user.getJwtToken(), shareId: share.id },
|
||||||
|
});
|
||||||
|
const body = await res.json();
|
||||||
|
|
||||||
|
expect(res.status).toEqual(200);
|
||||||
|
expect(body.data.id).toEqual(document.id);
|
||||||
|
expect(body.data.createdBy.id).toEqual(user.id);
|
||||||
|
expect(body.data.updatedBy.id).toEqual(user.id);
|
||||||
|
});
|
||||||
|
|
||||||
it('should return document from shareId in collection not a member of', async () => {
|
it('should return document from shareId in collection not a member of', async () => {
|
||||||
const { user, document, collection } = await seed();
|
const { user, document, collection } = await seed();
|
||||||
const share = await buildShare({
|
const share = await buildShare({
|
||||||
|
Reference in New Issue
Block a user