enzostvs HF staff commited on
Commit
d9ecfe6
β€’
1 Parent(s): 0c4ac69

staff only is public

Browse files
src/routes/+page.svelte CHANGED
@@ -15,6 +15,9 @@
15
  import Drawer from "$lib/components/models/drawer/Drawer.svelte";
16
  import { onMount } from "svelte";
17
  import type { ModelCard } from "$lib/type";
 
 
 
18
 
19
  let data: {
20
  models: ModelCard[],
@@ -23,9 +26,11 @@
23
  models: [],
24
  total_items: 0,
25
  }
 
 
26
  let form: Record<string, string> = {
27
  filter: $page.url.searchParams.get('filter') ?? "hotest",
28
- search: "",
29
  page: "0"
30
  }
31
  let submitModelDialog = false;
@@ -85,7 +90,21 @@
85
  Explore Models ({data?.total_items ?? 0})
86
  </h1>
87
  <div class="flex items-start sm:items-center justify-between mt-5 flex-col sm:flex-row gap-5 sm:justify-between">
88
- <Radio options={MODELS_FILTER_OPTIONS} value="{form.filter}" onChange={handleChangeFilter} />
 
 
 
 
 
 
 
 
 
 
 
 
 
 
89
  <div class="items-center justify-end gap-5 hidden lg:flex">
90
  <Button href="https://huggingface.co/new/stable-diffusion-lora" target="_blank" icon="ic:round-plus" theme="dark" size="lg">Create</Button>
91
  <!-- <UserIsLogged> -->
 
15
  import Drawer from "$lib/components/models/drawer/Drawer.svelte";
16
  import { onMount } from "svelte";
17
  import type { ModelCard } from "$lib/type";
18
+ import { get } from "svelte/store";
19
+ import { userStore } from "$lib/stores/use-user";
20
+ import Add from "$lib/components/community/reactions/Add.svelte";
21
 
22
  let data: {
23
  models: ModelCard[],
 
26
  models: [],
27
  total_items: 0,
28
  }
29
+ let user = get(userStore);
30
+
31
  let form: Record<string, string> = {
32
  filter: $page.url.searchParams.get('filter') ?? "hotest",
33
+ search: $page.url.searchParams.get('search') ?? "",
34
  page: "0"
35
  }
36
  let submitModelDialog = false;
 
90
  Explore Models ({data?.total_items ?? 0})
91
  </h1>
92
  <div class="flex items-start sm:items-center justify-between mt-5 flex-col sm:flex-row gap-5 sm:justify-between">
93
+ <Radio
94
+ options={[
95
+ ...MODELS_FILTER_OPTIONS,
96
+ ...(user?.is_admin ? [
97
+ {
98
+ label: "Staff only",
99
+ value: "staff_only",
100
+ icon: "lets-icons:view-hide-fill",
101
+ iconColor: "text-yellow-500"
102
+ }
103
+ ] : [])
104
+ ]}
105
+ value="{form.filter}"
106
+ onChange={handleChangeFilter}
107
+ />
108
  <div class="items-center justify-end gap-5 hidden lg:flex">
109
  <Button href="https://huggingface.co/new/stable-diffusion-lora" target="_blank" icon="ic:round-plus" theme="dark" size="lg">Create</Button>
110
  <!-- <UserIsLogged> -->
src/routes/api/models/+server.ts CHANGED
@@ -30,9 +30,13 @@ export async function GET(request : RequestEvent) {
30
  orderBy['createdAt'] = 'desc'
31
  }
32
 
 
 
33
  const cards = await prisma.model.findMany({
34
  where: {
35
- ...(IS_ADMIN ? {} : { isPublic: true }),
 
 
36
  OR: [
37
  { id: { contains: search } },
38
  ]
 
30
  orderBy['createdAt'] = 'desc'
31
  }
32
 
33
+ const only_not_public = filter === 'staff_only';
34
+
35
  const cards = await prisma.model.findMany({
36
  where: {
37
+ ...(
38
+ (IS_ADMIN && only_not_public) ? { isPublic: false } : !only_not_public ? {} : { isPublic: true }
39
+ ),
40
  OR: [
41
  { id: { contains: search } },
42
  ]