Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Enable pinning based on logged-in status, not project.edit_access #889

Merged
merged 1 commit into from
Nov 25, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 11 additions & 12 deletions src/lib/components/projects/ProjectPin.svelte
Original file line number Diff line number Diff line change
@@ -1,11 +1,7 @@
<script lang="ts" context="module">
import { writable, type Writable } from "svelte/store";

import { invalidate } from "$app/navigation";

import { canonicalUrl } from "$lib/api/projects";
import type { Project } from "$lib/api/types";
import { getCsrfToken } from "$lib/utils/api";

import { writable, type Writable } from "svelte/store";

export const pinned: Writable<Project[]> = writable([]);

Expand All @@ -19,12 +15,20 @@
</script>

<script lang="ts">
import { invalidate } from "$app/navigation";

import { canonicalUrl } from "$lib/api/projects";
import { getCsrfToken } from "$lib/utils/api";
import { getCurrentUser } from "$lib/utils/permissions";

import Pin from "@/lib/components/common/Pin.svelte";
import { pinProject } from "$lib/api/projects";

export let project: Project;
export let size = 1;

const me = getCurrentUser();

async function toggle(e) {
e.preventDefault();
const csrf_token = getCsrfToken();
Expand Down Expand Up @@ -55,9 +59,4 @@
}
</script>

<Pin
active={project.pinned}
{size}
disabled={!project.edit_access}
on:click={toggle}
/>
<Pin active={project.pinned} {size} disabled={!$me} on:click={toggle} />