-
Notifications
You must be signed in to change notification settings - Fork 191
feat: org projects pagination and add archived pagination #2312
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
base: main
Are you sure you want to change the base?
Changes from 6 commits
2a058be
82cc38d
11e460c
cc9a62c
86048c1
655b053
4f4c679
7287571
6ad7ee1
c8bbb97
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
HarshMN2345 marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
@@ -0,0 +1,44 @@ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
<script lang="ts"> | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
import { goto } from '$app/navigation'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
import { page as pageStore } from '$app/state'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
import { InputSelect } from '$lib/elements/forms'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
import { preferences } from '$lib/stores/preferences'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
import { Layout } from '@appwrite.io/pink-svelte'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
let { sum, limit, name }: { sum: number; limit: number; name: string } = $props(); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
const options = [ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
{ label: '6', value: 6 }, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
{ label: '12', value: 12 }, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
{ label: '24', value: 24 }, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
{ label: '48', value: 48 }, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
{ label: '96', value: 96 } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
]; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
async function limitChange() { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
const url = new URL(pageStore.url); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
const previousLimit = Number(url.searchParams.get('limit')); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
url.searchParams.set('limit', limit.toString()); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
preferences.setLimit(limit); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
// Handle archived page pagination | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
if (url.searchParams.has('archivedPage')) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
const page = Number(url.searchParams.get('archivedPage')); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
const newPage = Math.floor(((page - 1) * previousLimit) / limit); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
if (newPage === 1) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
url.searchParams.delete('archivedPage'); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
} else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
url.searchParams.set('archivedPage', newPage.toString()); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
} | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
} | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
await goto(url.toString()); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
} | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
async function limitChange() { | |
const url = new URL(pageStore.url); | |
const previousLimit = Number(url.searchParams.get('limit')); | |
url.searchParams.set('limit', limit.toString()); | |
preferences.setLimit(limit); | |
// Handle archived page pagination | |
if (url.searchParams.has('archivedPage')) { | |
const page = Number(url.searchParams.get('archivedPage')); | |
const newPage = Math.floor(((page - 1) * previousLimit) / limit); | |
if (newPage === 1) { | |
url.searchParams.delete('archivedPage'); | |
} else { | |
url.searchParams.set('archivedPage', newPage.toString()); | |
} | |
} | |
await goto(url.toString()); | |
} | |
async function limitChange() { | |
const url = new URL(pageStore.url); | |
const previousLimit = Number(url.searchParams.get('limit') ?? limit) || limit; | |
url.searchParams.set('limit', limit.toString()); | |
preferences.setLimit(limit); | |
// Handle archived page pagination | |
if (url.searchParams.has('archivedPage')) { | |
const page = Math.max(1, Number(url.searchParams.get('archivedPage')) || 1); | |
const startIndex = (page - 1) * Math.max(1, previousLimit); | |
const newPage = Math.max(1, Math.floor(startIndex / Math.max(1, limit)) + 1); | |
if (newPage <= 1) { | |
url.searchParams.delete('archivedPage'); | |
} else { | |
url.searchParams.set('archivedPage', String(newPage)); | |
} | |
} | |
await goto(url.toString()); | |
} |
HarshMN2345 marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
<script lang="ts"> | ||
import { page as pageStore } from '$app/state'; | ||
import { Pagination } from '@appwrite.io/pink-svelte'; | ||
|
||
let { sum, limit, offset }: { sum: number; limit: number; offset: number } = $props(); | ||
|
||
const currentPage = $derived(Math.floor(offset / limit + 1)); | ||
|
||
function getLink(page: number): string { | ||
const url = new URL(pageStore.url); | ||
if (page === 1) { | ||
url.searchParams.delete('archivedPage'); | ||
} else { | ||
url.searchParams.set('archivedPage', page.toString()); | ||
} | ||
|
||
return url.toString(); | ||
} | ||
|
||
const paginationProps = $derived({ type: 'link', createLink: getLink } as const); | ||
</script> | ||
|
||
<Pagination on:page {limit} total={sum} page={currentPage} {...paginationProps} /> |
HarshMN2345 marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
<script lang="ts"> | ||
import ArchivedLimit from './archivedLimit.svelte'; | ||
import ArchivedPagination from './archivedPagination.svelte'; | ||
import { Layout } from '@appwrite.io/pink-svelte'; | ||
|
||
let { | ||
limit, | ||
offset, | ||
total, | ||
name, | ||
useCreateLink = true | ||
}: { | ||
limit: number; | ||
offset: number; | ||
total: number; | ||
name: string; | ||
useCreateLink?: boolean; | ||
} = $props(); | ||
|
||
const showLimit = $derived(!!useCreateLink); | ||
const direction = $derived(showLimit ? 'row' : 'column'); | ||
const alignItems = $derived(showLimit ? 'center' : 'flex-end'); | ||
</script> | ||
|
||
<Layout.Stack wrap="wrap" {direction} {alignItems} justifyContent="space-between"> | ||
{#if showLimit} | ||
<ArchivedLimit {limit} sum={total} {name} /> | ||
{/if} | ||
|
||
<ArchivedPagination on:page {limit} {offset} sum={total} /> | ||
</Layout.Stack> |
Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
@@ -109,11 +109,19 @@ | |||||||||||||||||||||||||||||||
return project.status === 'archived'; | ||||||||||||||||||||||||||||||||
} | ||||||||||||||||||||||||||||||||
$: projectsToArchive = isCloud | ||||||||||||||||||||||||||||||||
? data.projects.projects.filter((project) => project.status === 'archived') | ||||||||||||||||||||||||||||||||
: []; | ||||||||||||||||||||||||||||||||
$: projectsToArchive = (data.archivedProjectsPage ?? data.projects.projects).filter( | ||||||||||||||||||||||||||||||||
(project) => (isCloud ? project.status === 'archived' : project.status !== 'active') // fallback for non-cloud | ||||||||||||||||||||||||||||||||
HarshMN2345 marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||||||||||||||||||||||||||||||||
); | ||||||||||||||||||||||||||||||||
$: activeProjects = data.projects.projects.filter((project) => project.status !== 'archived'); | ||||||||||||||||||||||||||||||||
$: activeProjects = (data.activeProjectsPage ?? data.projects.projects).filter( | ||||||||||||||||||||||||||||||||
(project) => project.status === 'active' | ||||||||||||||||||||||||||||||||
); | ||||||||||||||||||||||||||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Correct archived/active filters for non-cloud (null means active) Per prior guidance, only - $: projectsToArchive = (data.archivedProjectsPage ?? data.projects.projects).filter(
- (project) => (isCloud ? project.status === 'archived' : project.status !== 'active') // fallback for non-cloud
- );
+ $: projectsToArchive = (data.archivedProjectsPage ?? data.projects.projects).filter(
+ (project) => project.status === 'archived'
+ );
@@
- $: activeProjects = (data.activeProjectsPage ?? data.projects.projects).filter(
- (project) => project.status === 'active'
- );
+ $: activeProjects = (data.activeProjectsPage ?? data.projects.projects).filter(
+ (project) => project.status !== 'archived'
+ ); 📝 Committable suggestion
Suggested change
🤖 Prompt for AI Agents
|
||||||||||||||||||||||||||||||||
$: activeTotalOverall = | ||||||||||||||||||||||||||||||||
data?.activeTotalOverall ?? | ||||||||||||||||||||||||||||||||
data?.organization?.projects?.length ?? | ||||||||||||||||||||||||||||||||
data?.projects?.total ?? | ||||||||||||||||||||||||||||||||
0; | ||||||||||||||||||||||||||||||||
function clearSearch() { | ||||||||||||||||||||||||||||||||
searchQuery?.clearInput(); | ||||||||||||||||||||||||||||||||
} | ||||||||||||||||||||||||||||||||
|
@@ -165,7 +173,7 @@ | |||||||||||||||||||||||||||||||
{#if activeProjects.length > 0} | ||||||||||||||||||||||||||||||||
<CardContainer | ||||||||||||||||||||||||||||||||
disableEmpty={!$canWriteProjects} | ||||||||||||||||||||||||||||||||
total={data.projects.total} | ||||||||||||||||||||||||||||||||
total={activeTotalOverall} | ||||||||||||||||||||||||||||||||
offset={data.offset} | ||||||||||||||||||||||||||||||||
on:click={handleCreateProject}> | ||||||||||||||||||||||||||||||||
{#each activeProjects as project} | ||||||||||||||||||||||||||||||||
|
@@ -250,13 +258,16 @@ | |||||||||||||||||||||||||||||||
name="Projects" | ||||||||||||||||||||||||||||||||
limit={data.limit} | ||||||||||||||||||||||||||||||||
offset={data.offset} | ||||||||||||||||||||||||||||||||
total={data.projects.total} /> | ||||||||||||||||||||||||||||||||
total={activeTotalOverall} /> | ||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||
<!-- Archived Projects Section --> | ||||||||||||||||||||||||||||||||
<ArchiveProject | ||||||||||||||||||||||||||||||||
{projectsToArchive} | ||||||||||||||||||||||||||||||||
organization={data.organization} | ||||||||||||||||||||||||||||||||
currentPlan={$currentPlan} /> | ||||||||||||||||||||||||||||||||
currentPlan={$currentPlan} | ||||||||||||||||||||||||||||||||
archivedTotalOverall={data.archivedTotalOverall} | ||||||||||||||||||||||||||||||||
archivedOffset={data.archivedOffset} | ||||||||||||||||||||||||||||||||
limit={data.limit} /> | ||||||||||||||||||||||||||||||||
</Container> | ||||||||||||||||||||||||||||||||
<CreateOrganization bind:show={addOrganization} /> | ||||||||||||||||||||||||||||||||
<CreateProject bind:show={showCreate} teamId={page.params.organization} /> | ||||||||||||||||||||||||||||||||
|
HarshMN2345 marked this conversation as resolved.
Show resolved
Hide resolved
|
Uh oh!
There was an error while loading. Please reload this page.