fix: make notImported studio filter work independently of import status
This commit is contained in:
1 parent
4b7cb519df
commit
92b0ba3b18
1 file changed
+12
-7
@@ -151,17 +151,16 @@ export function StudioClient({
|
|||||||
result = result.filter((i) => i.category === categoryFilter);
|
result = result.filter((i) => i.category === categoryFilter);
|
||||||
}
|
}
|
||||||
if (statusFilter !== "all") {
|
if (statusFilter !== "all") {
|
||||||
if (statusFilter === "new")
|
if (statusFilter === "imported")
|
||||||
result = result.filter((i) => !i.alreadyImported);
|
|
||||||
else if (statusFilter === "imported")
|
|
||||||
result = result.filter((i) => i.alreadyImported);
|
result = result.filter((i) => i.alreadyImported);
|
||||||
else if (statusFilter === "inCatalog")
|
else if (statusFilter === "inCatalog")
|
||||||
result = result.filter((i) => i.alreadyImported && i.nitroExists);
|
result = result.filter((i) => i.alreadyImported && i.nitroExists);
|
||||||
else if (statusFilter === "missingNitro")
|
else if (statusFilter === "missingNitro")
|
||||||
result = result.filter((i) => i.alreadyImported && !i.nitroExists);
|
result = result.filter((i) => i.alreadyImported && !i.nitroExists);
|
||||||
else if (statusFilter === "notImported")
|
|
||||||
result = result.filter((i) => !i.alreadyImported);
|
|
||||||
}
|
}
|
||||||
|
// Not imported filter - works independently (also with statusFilter === "all")
|
||||||
|
if (statusFilter === "notImported" || statusFilter === "all")
|
||||||
|
result = result.filter((i) => i.alreadyImported === false);
|
||||||
const sorted = [...result];
|
const sorted = [...result];
|
||||||
if (sortBy === "name") sorted.sort((a, b) => a.name.localeCompare(b.name));
|
if (sortBy === "name") sorted.sort((a, b) => a.name.localeCompare(b.name));
|
||||||
else if (sortBy === "classname")
|
else if (sortBy === "classname")
|
||||||
@@ -597,6 +596,11 @@ export function StudioClient({
|
|||||||
[filteredItems],
|
[filteredItems],
|
||||||
);
|
);
|
||||||
|
|
||||||
|
const notImportedCount = useMemo(
|
||||||
|
() => filteredItems.filter((i) => i.alreadyImported === false).length,
|
||||||
|
[filteredItems],
|
||||||
|
);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div
|
<div
|
||||||
className="flex h-[calc(100dvh-7rem)] min-h-[520px] flex-col overflow-hidden rounded-xl border border-[var(--admin-border)]"
|
className="flex h-[calc(100dvh-7rem)] min-h-[520px] flex-col overflow-hidden rounded-xl border border-[var(--admin-border)]"
|
||||||
@@ -741,8 +745,9 @@ export function StudioClient({
|
|||||||
<SelectValue placeholder="Status" />
|
<SelectValue placeholder="Status" />
|
||||||
</SelectTrigger>
|
</SelectTrigger>
|
||||||
<SelectContent>
|
<SelectContent>
|
||||||
<SelectItem value="all">All statuses</SelectItem>
|
<SelectItem value="all">
|
||||||
<SelectItem value="new">Not imported</SelectItem>
|
All statuses {notImportedCount > 0 && notImportedCount}
|
||||||
|
</SelectItem>
|
||||||
<SelectItem value="imported">Imported</SelectItem>
|
<SelectItem value="imported">Imported</SelectItem>
|
||||||
<SelectItem value="inCatalog">In catalog</SelectItem>
|
<SelectItem value="inCatalog">In catalog</SelectItem>
|
||||||
<SelectItem value="missingNitro">Missing nitro</SelectItem>
|
<SelectItem value="missingNitro">Missing nitro</SelectItem>
|
||||||
|
|||||||
Reference in new issue
Block a user