Skip to content

Commit

Permalink
Merge pull request #379 from MuckRock/feature/document-revision-control
Browse files Browse the repository at this point in the history
Document Revisions UI
  • Loading branch information
allanlasser authored Jan 11, 2024
2 parents fe59270 + a7a71e4 commit 7b5e9d6
Show file tree
Hide file tree
Showing 60 changed files with 1,743 additions and 406 deletions.
13 changes: 2 additions & 11 deletions src/addons/browser/AddOnListItem.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,7 @@
import AddOnPin from "../AddOnPin.svelte";
import AddOnPopularity from "../Popularity.svelte";
import type { AddOnListItem } from "../types.js";
import Credit from "../../common/icons/Credit.svelte";
import Badge from "../../common/Badge.svelte";
import PremiumBadge from "../../premium-credits/PremiumBadge.svelte";
export let addon: AddOnListItem;
Expand Down Expand Up @@ -39,15 +38,7 @@
<AddOnPopularity useCount={addon.usage} />
{/if}
{#if isPremium}
<span class="badge"
><Badge
label="Premium"
badgeColor="var(--premium)"
labelColor="var(--darkgray)"
>
<Credit badge slot="icon" color="var(--darkgray)" />
</Badge></span
>
<span class="badge"><PremiumBadge /></span>
{/if}
</div>
</div>
Expand Down
12 changes: 2 additions & 10 deletions src/addons/dispatch/Header.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,7 @@
import { pushToast } from "../../common/Toast.svelte";
import AddOnPin from "../AddOnPin.svelte";
import Badge from "../../common/Badge.svelte";
import Credit from "../../common/icons/Credit.svelte";
import PremiumBadge from "../../premium-credits/PremiumBadge.svelte";
export let addon: AddOnListItem;
Expand Down Expand Up @@ -77,14 +76,7 @@
{/if}
</div>
{#if isPremium}
<a href="#add-ons?premium=true" class="premium"
><Badge
label="Premium"
badgeColor="var(--premium)"
labelColor="var(--darkgray)"
><Credit slot="icon" color="var(--darkgray)" badge /></Badge
></a
>
<a href="#add-ons?premium=true" class="premium"><PremiumBadge /></a>
{/if}
</dl>

Expand Down
16 changes: 16 additions & 0 deletions src/api/document.js
Original file line number Diff line number Diff line change
Expand Up @@ -161,6 +161,19 @@ export async function changeAccess(ids, access) {
);
}

export async function changeRevisionControl(id, revision_control) {
// Enable or disable revision control on specified document
const { data } = await session.patch(
apiUrl(
queryBuilder(`documents/${id}/`, {
expand: [DEFAULT_EXPAND, "revisions"].join(","),
}),
),
{revision_control}
);
return data;
}

export async function reprocessDocument(ids, forceOcr, ocrEngine) {
// Reprocess the documents with the specified ids
await session.post(
Expand Down Expand Up @@ -253,6 +266,7 @@ export async function pollDocument(
* @param {Array<Project>} projects Projects to upload the documents to
* @param {boolean} forceOcr If true, OCRs regardless of embedded text
* @param {string} ocrEngine Select OCR engine
* @param {boolean} revision_control Toggles revision history on document
* @param {Function} createProgressFn A function to call with process progress
* @param {Function} progressFn A function to call with upload progress
* @param {Function} processProgressFn A function to call with process progress
Expand All @@ -265,6 +279,7 @@ export async function uploadDocuments(
language,
forceOcr,
ocrEngine,
revision_control,
projects,
createProgressFn,
progressFn,
Expand Down Expand Up @@ -307,6 +322,7 @@ export async function uploadDocuments(
language,
original_extension: getExtension(doc.file),
projects: projectIds,
revision_control,
})),
);
createCount += subDocs.length;
Expand Down
235 changes: 235 additions & 0 deletions src/api/fixtures/orgAndUser.fixtures.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,235 @@
export const me = {
id: 4,
avatar_url:
"https://cdn.muckrock.com/media/account_images/allan-headshot-2016.jpg",
feature_level: 2,
name: "Allan Lasser",
organization: {
id: 1,
avatar_url:
"https://squarelet-staging.s3.amazonaws.com/media/org_avatars/logo_uEHCMva.png",
individual: false,
name: "MuckRock",
slug: "muckrock",
monthly_credits: 5000,
purchased_credits: 0,
credit_reset_date: "2023-11-28",
monthly_credit_allowance: 5000,
plan: "Organization",
},
organizations: [1, 4],
admin_organizations: [40742],
username: "lasser.allan",
verified_journalist: true,
};

export const users = [
{
next: null,
previous: null,
results: [
{
id: 1,
avatar_url:
"https://cdn.muckrock.com/media/avatars/Michael_Headshot.jpeg",
name: "Michael Morisy",
organization: 1,
organizations: [1, 10],
admin_organizations: [1, 10],
username: "morisy",
verified_journalist: true,
},
{
id: 2,
avatar_url:
"https://cdn.muckrock.com/media/avatars/20140211-0O1A7147-2.jpg",
name: "Chris Amico",
organization: 1,
organizations: [1, 11],
admin_organizations: [11],
username: "chrisamico",
verified_journalist: true,
},
{
id: 3,
avatar_url:
"https://cdn.muckrock.com/media/account_images/22_MuckRock_2018_PRELIMANRY_EDITS_DSC_5387_2018_Derek_Kouyoumjian_preview_SfuGGnJ.jpg",
name: "Mitchell Kotler",
organization: 1,
organizations: [1, 12],
admin_organizations: [1, 12],
username: "mitch",
verified_journalist: true,
},
{
id: 4,
avatar_url:
"https://cdn.muckrock.com/media/account_images/allan-headshot-2016.jpg",
name: "Allan Lasser",
organization: 1,
organizations: [1, 13],
admin_organizations: [13],
username: "lasser.allan",
verified_journalist: true,
},
{
id: 5,
avatar_url:
"https://cdn.muckrock.com/media/avatars/noah_oct2021_vsco_cropped_smaller.gif",
name: "Amanda Hickman",
organization: 1,
organizations: [1, 14],
admin_organizations: [1, 14],
username: "amandabee",
verified_journalist: true,
},
{
id: 6,
avatar_url:
"https://cdn.muckrock.com/media/avatars/derek-crop-square_Rx7mFk8.jpg",
name: "Derek Kravitz",
organization: 1,
organizations: [1, 15],
admin_organizations: [1, 15],
username: "DerekRKravitz",
verified_journalist: true,
},
{
id: 7,
avatar_url: null,
name: "Miranda Carruth",
organization: 1,
organizations: [1, 16],
admin_organizations: [16],
username: "mirandac",
},
{
id: 8,
avatar_url: "https://cdn.muckrock.com/media/avatars/kelly-square.jpg",
name: "Kelly Kauffman",
organization: 1,
organizations: [1, 17],
admin_organizations: [17],
username: "kellykauffman",
verified_journalist: true,
},
{
id: 9,
avatar_url:
"https://cdn.muckrock.com/media/avatars/Albert_Serna_Jr.jpg",
name: "Albert Serna Jr.",
organization: 1,
organizations: [1, 18],
admin_organizations: [18],
username: "AlbertSGJ",
verified_journalist: true,
},
{
id: 10,
avatar_url: "https://cdn.muckrock.com/media/avatars/under.jpg",
name: "JPat Brown",
organization: 1,
organizations: [1, 19],
admin_organizations: [19],
username: "JPatBrown",
verified_journalist: true,
},
{
id: 11,
avatar_url: null,
name: "Scott Klein",
organization: 1,
organizations: [1, 20],
admin_organizations: [20],
username: "ScottKlein",
verified_journalist: true,
},
{
id: 12,
avatar_url:
"https://cdn.muckrock.com/media/account_images/1_Nz2NFvHxTjqw5asaiPKf5w_sssJnjW.jpg",
name: "Aron Pilhofer",
organization: 1,
organizations: [1, 21],
admin_organizations: [22],
username: "Pilhofer",
verified_journalist: true,
},
],
},
];

export const organizations = {
next: null,
previous: null,
results: [
{
id: 1,
avatar_url:
"https://squarelet-staging.s3.amazonaws.com/media/org_avatars/logo_uEHCMva.png",
individual: false,
name: "MuckRock",
slug: "muckrock",
monthly_credits: 5000,
purchased_credits: 0,
credit_reset_date: "2023-11-28",
monthly_credit_allowance: 5000,
plan: "Organization",
},
{
id: 4,
avatar_url:
"https://cdn.muckrock.com/media/account_images/allan-headshot-2016.jpg",
individual: true,
name: "lasser.allan",
slug: "lasserallan",
monthly_credits: 2500,
purchased_credits: 3000,
credit_reset_date: "2023-11-28",
monthly_credit_allowance: 2500,
plan: "Professional",
},
],
};

export const organization = {
id: 1,
avatar_url:
"https://squarelet-staging.s3.amazonaws.com/media/org_avatars/logo_uEHCMva.png",
individual: false,
name: "MuckRock",
slug: "muckrock",
monthly_credits: 5000,
purchased_credits: 0,
credit_reset_date: "2023-11-28",
monthly_credit_allowance: 5000,
plan: "Organization",
};

export const proOrg = {
id: 4,
avatar_url:
"https://cdn.muckrock.com/media/account_images/allan-headshot-2016.jpg",
individual: true,
name: "lasser.allan",
slug: "lasserallan",
monthly_credits: 2500,
purchased_credits: 3000,
credit_reset_date: "2023-11-28",
monthly_credit_allowance: 2500,
plan: "Professional",
};

export const freeOrg = {
id: 4,
avatar_url:
"https://cdn.muckrock.com/media/account_images/allan-headshot-2016.jpg",
individual: true,
name: "lasser.allan",
slug: "lasserallan",
monthly_credits: 0,
purchased_credits: 0,
credit_reset_date: "2023-11-28",
monthly_credit_allowance: 0,
plan: "Free",
};
Loading

0 comments on commit 7b5e9d6

Please sign in to comment.