mirror of
https://github.com/appwrite/console.git
synced 2026-11-18 20:47:21 +00:00
Address Greptile review
Replace heading-string matching with an explicit collapsible flag on PermissionGroup, use startsWith instead of full-text search for the organization picker, and reset loadingMore via finally on stale-term early returns. Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
4 files changed
+21
-14
No files matched your search
@@ -287,7 +287,9 @@ export async function searchOrganizations(
|
||||
try {
|
||||
const queries = [Query.offset(offset), Query.limit(limit)];
|
||||
const trimmed = term.trim();
|
||||
if (trimmed !== '') queries.push(Query.search('name', trimmed));
|
||||
// startsWith over search: search is full-text (word-boundary) matching,
|
||||
// which drops partial-fragment matches; this mirrors the project search.
|
||||
if (trimmed !== '') queries.push(Query.startsWith('name', trimmed));
|
||||
|
||||
const orgs = await getTeamOrOrganizationList(queries);
|
||||
return {
|
||||
|
||||
@@ -476,6 +476,8 @@ export interface PermissionGroup {
|
||||
heading: string;
|
||||
/** Contextual note under the heading, e.g. which resources it applies to. */
|
||||
note?: string;
|
||||
/** Whether the consent screen lets the user collapse this group. */
|
||||
collapsible?: boolean;
|
||||
lines: PermissionLine[];
|
||||
}
|
||||
|
||||
@@ -666,6 +668,7 @@ export function buildConsentPermissions(model: ConsentScopeModel): PermissionGro
|
||||
groups.push({
|
||||
heading: 'Projects',
|
||||
note: 'Applies only to the projects you select below.',
|
||||
collapsible: true,
|
||||
lines: projectLines
|
||||
});
|
||||
}
|
||||
@@ -680,6 +683,7 @@ export function buildConsentPermissions(model: ConsentScopeModel): PermissionGro
|
||||
groups.push({
|
||||
heading: 'Organizations',
|
||||
note: 'Applies only to the organizations you select below.',
|
||||
collapsible: true,
|
||||
lines: organizationLines
|
||||
});
|
||||
}
|
||||
|
||||
@@ -686,9 +686,7 @@
|
||||
{#if showPermissions}
|
||||
<div class="panel-body">
|
||||
{#each permissionGroups as group (group.heading)}
|
||||
{@const collapsible =
|
||||
group.heading === 'Projects' ||
|
||||
group.heading === 'Organizations'}
|
||||
{@const collapsible = group.collapsible === true}
|
||||
<div class="perm-group">
|
||||
<div class="perm-group-head">
|
||||
{#if collapsible}
|
||||
|
||||
@@ -112,17 +112,20 @@
|
||||
const currentTerm = term;
|
||||
const offset = results.length;
|
||||
loadingMore = true;
|
||||
const page = await find(currentTerm, offset, PAGE_SIZE);
|
||||
if (currentTerm !== term) return;
|
||||
try {
|
||||
const page = await find(currentTerm, offset, PAGE_SIZE);
|
||||
if (currentTerm !== term) return;
|
||||
|
||||
const seen = new Set(results.map((resource) => resource.id));
|
||||
const next = page.resources.filter((resource) => !seen.has(resource.id));
|
||||
results = [...results, ...next];
|
||||
hasMore = page.hasMore;
|
||||
const merged = { ...names };
|
||||
for (const resource of next) merged[resource.id] = resource;
|
||||
names = merged;
|
||||
loadingMore = false;
|
||||
const seen = new Set(results.map((resource) => resource.id));
|
||||
const next = page.resources.filter((resource) => !seen.has(resource.id));
|
||||
results = [...results, ...next];
|
||||
hasMore = page.hasMore;
|
||||
const merged = { ...names };
|
||||
for (const resource of next) merged[resource.id] = resource;
|
||||
names = merged;
|
||||
} finally {
|
||||
loadingMore = false;
|
||||
}
|
||||
}
|
||||
|
||||
function handleResultsScroll(event: Event) {
|
||||
|
||||
Reference in new issue
Block a user