mirror of
https://github.com/outline/outline.git
synced 2026-11-25 07:04:37 +03:00
fix: Created by me tab filters by document creator (#13988)
This commit is contained in:
1 parent
6e6eaf6b69
commit
06991791df
3 files changed
+40
-1
No files matched your search
+3
-1
@@ -140,7 +140,9 @@ function Home() {
|
||||
documents={documents.createdByUser(userId)}
|
||||
fetch={documents.fetchOwned}
|
||||
options={{
|
||||
userId,
|
||||
filters: [
|
||||
{ field: "createdById", operator: "eq", value: userId },
|
||||
],
|
||||
}}
|
||||
empty={
|
||||
<Empty>{t("You haven’t created any documents yet")}</Empty>
|
||||
|
||||
@@ -1381,6 +1381,42 @@ describe("#documents.list", () => {
|
||||
expect(body.data).toHaveLength(2);
|
||||
});
|
||||
|
||||
it("should match documents created by a user, excluding collaborations", async () => {
|
||||
const user = await buildUser();
|
||||
const otherUser = await buildUser({ teamId: user.teamId });
|
||||
const created = await buildDocument({
|
||||
userId: user.id,
|
||||
teamId: user.teamId,
|
||||
});
|
||||
const collaborated = await buildDocument({
|
||||
userId: otherUser.id,
|
||||
teamId: user.teamId,
|
||||
});
|
||||
collaborated.lastModifiedById = user.id;
|
||||
await collaborated.save();
|
||||
expect(collaborated.collaboratorIds).toContain(user.id);
|
||||
|
||||
const res = await server.post("/api/documents.list", user, {
|
||||
body: {
|
||||
filters: [{ field: "createdById", operator: "eq", value: user.id }],
|
||||
},
|
||||
});
|
||||
const body = await res.json();
|
||||
expect(res.status).toEqual(200);
|
||||
const ids = body.data.map((d: { id: string }) => d.id);
|
||||
expect(ids).toEqual([created.id]);
|
||||
});
|
||||
|
||||
it("should reject unsupported operators for createdById", async () => {
|
||||
const user = await buildUser();
|
||||
const res = await server.post("/api/documents.list", user, {
|
||||
body: {
|
||||
filters: [{ field: "createdById", operator: "isNotNull" }],
|
||||
},
|
||||
});
|
||||
expect(res.status).toEqual(400);
|
||||
});
|
||||
|
||||
it("should reject an unknown field", async () => {
|
||||
const user = await buildUser();
|
||||
const res = await server.post("/api/documents.list", user, {
|
||||
|
||||
@@ -23,6 +23,7 @@ const documentFilterFields = {
|
||||
title: "string",
|
||||
templateId: "uuid",
|
||||
collectionId: "uuid",
|
||||
createdById: { kind: "uuid", operators: ["eq", "in"] },
|
||||
// `userId` maps to the collaboratorIds array column and only supports
|
||||
// membership checks.
|
||||
userId: { kind: "uuid", operators: ["eq", "in"] },
|
||||
|
||||
Reference in new issue
Block a user