Skip to content

Commit

Permalink
fix: more links
Browse files Browse the repository at this point in the history
  • Loading branch information
TorstenDittmann committed Jan 28, 2025
1 parent f7aca88 commit 03bd2b4
Show file tree
Hide file tree
Showing 28 changed files with 122 additions and 98 deletions.
9 changes: 5 additions & 4 deletions src/lib/commandCenter/searchers/buckets.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,11 @@ import { FilesPanel } from '../panels';
import { base } from '$app/paths';
import { page } from '$app/stores';

const getBucketCommand = (bucket: Models.Bucket, projectId: string) => {
const getBucketCommand = (bucket: Models.Bucket, region: string, projectId: string) => {
return {
label: `${bucket.name}`,
callback() {
goto(`${base}/project-${projectId}/storage/bucket-${bucket.$id}`);
goto(`${base}/project-${region}-${projectId}/storage/bucket-${bucket.$id}`);
},
group: 'buckets',
icon: 'folder'
Expand All @@ -23,6 +23,7 @@ const getBucketCommand = (bucket: Models.Bucket, projectId: string) => {
export const bucketSearcher = (async (query: string) => {
const $page = get(page);
const $project = get(project);
const region = $page.params.region;
const { buckets } = await sdk
.forProject($page.params.region, $page.params.project)
.storage.listBuckets([Query.orderDesc('$createdAt')]);
Expand All @@ -32,7 +33,7 @@ export const bucketSearcher = (async (query: string) => {
if (filtered.length === 1) {
const bucket = filtered[0];
return [
getBucketCommand(bucket, $project.$id),
getBucketCommand(bucket, region, $project.$id),
{
label: 'Find files',
async callback() {
Expand Down Expand Up @@ -84,5 +85,5 @@ export const bucketSearcher = (async (query: string) => {
];
}

return filtered.map((bucket) => getBucketCommand(bucket, $project.$id));
return filtered.map((bucket) => getBucketCommand(bucket, $project.region, $project.$id));
}) satisfies Searcher;
4 changes: 1 addition & 3 deletions src/lib/commandCenter/searchers/collections.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import { goto } from '$app/navigation';
import { database } from '$routes/(console)/project-[region]-[project]/databases/database-[database]/store';
import { project } from '$routes/(console)/project-[region]-[project]/store';
import { get } from 'svelte/store';
import type { Searcher } from '../commands';
import { sdk } from '$lib/stores/sdk';
Expand All @@ -14,7 +13,6 @@ export const collectionsSearcher = (async (query: string) => {
.forProject($page.params.region, $page.params.project)
.databases.listCollections(databaseId);

const projectId = get(project).$id;
return collections
.filter((col) => col.name.toLowerCase().includes(query.toLowerCase()))
.map(
Expand All @@ -24,7 +22,7 @@ export const collectionsSearcher = (async (query: string) => {
label: col.name,
callback: () => {
goto(
`${base}/project-${projectId}/databases/database-${databaseId}/collection-${col.$id}`
`${base}/project-${$page.params.region}-${$page.params.project}/databases/database-${databaseId}/collection-${col.$id}`
);
}
}) as const
Expand Down
5 changes: 3 additions & 2 deletions src/lib/commandCenter/searchers/databases.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import { goto } from '$app/navigation';
import { project } from '$routes/(console)/project-[region]-[project]/store';
import { get } from 'svelte/store';
import type { Searcher } from '../commands';
import { sdk } from '$lib/stores/sdk';
Expand All @@ -20,7 +19,9 @@ export const dbSearcher = (async (query: string) => {
group: 'databases',
label: db.name,
callback: () => {
goto(`${base}/project-${get(project).$id}/databases/database-${db.$id}`);
goto(
`${base}/project-${$page.params.region}-${$page.params.project}/databases/database-${db.$id}`
);
},
icon: 'database'
}) as const
Expand Down
28 changes: 19 additions & 9 deletions src/lib/commandCenter/searchers/functions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,11 @@ import { page } from '$app/stores';
import { showCreateDeployment } from '$routes/(console)/project-[region]-[project]/functions/function-[function]/store';
import { base } from '$app/paths';

const getFunctionCommand = (fn: Models.Function, projectId: string) => {
const getFunctionCommand = (fn: Models.Function, region: string, projectId: string) => {
return {
label: fn.name,
callback: () => {
goto(`${base}/project-${projectId}/functions/function-${fn.$id}`);
goto(`${base}/project-${region}-${projectId}/functions/function-${fn.$id}`);
},
group: 'functions',
icon: 'lightning-bolt'
Expand All @@ -31,14 +31,16 @@ export const functionsSearcher = (async (query: string) => {
if (filtered.length === 1) {
const func = filtered[0];
return [
getFunctionCommand(func, projectId),
getFunctionCommand(func, $page.params.region, projectId),
{
label: 'Create deployment',
nested: true,
async callback() {
const $page = get(page);
if (!$page.url.pathname.endsWith(func.$id)) {
await goto(`${base}/project-${projectId}/functions/function-${func.$id}`);
await goto(
`${base}/project-${$page.params.region}-${projectId}/functions/function-${func.$id}`
);
}
showCreateDeployment.set(true);
},
Expand All @@ -49,36 +51,44 @@ export const functionsSearcher = (async (query: string) => {
label: 'Go to deployments',
nested: true,
callback() {
goto(`${base}/project-${projectId}/functions/function-${func.$id}`);
goto(
`${base}/project-${$page.params.region}-${projectId}/functions/function-${func.$id}`
);
},
group: 'functions'
},
{
label: 'Go to usage',
nested: true,
callback() {
goto(`${base}/project-${projectId}/functions/function-${func.$id}/usage`);
goto(
`${base}/project-${$page.params.region}-${projectId}/functions/function-${func.$id}/usage`
);
},
group: 'functions'
},
{
label: 'Go to executions',
nested: true,
callback() {
goto(`${base}/project-${projectId}/functions/function-${func.$id}/executions`);
goto(
`${base}/project-${$page.params.region}-${projectId}/functions/function-${func.$id}/executions`
);
},
group: 'functions'
},
{
label: 'Go to settings',
nested: true,
callback() {
goto(`${base}/project-${projectId}/functions/function-${func.$id}/settings`);
goto(
`${base}/project-${$page.params.region}-${projectId}/functions/function-${func.$id}/settings`
);
},
group: 'functions'
}
];
}

return filtered.map((fn) => getFunctionCommand(fn, projectId));
return filtered.map((fn) => getFunctionCommand(fn, $page.params.region, projectId));
}) satisfies Searcher;
10 changes: 5 additions & 5 deletions src/lib/commandCenter/searchers/messages.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
import { goto } from '$app/navigation';
import { project } from '$routes/(console)/project-[region]-[project]/store';
import { get } from 'svelte/store';
import { type Searcher } from '../commands';
import { sdk } from '$lib/stores/sdk';
import { MessagingProviderType } from '@appwrite.io/console';
import { MessagingProviderType, type Models } from '@appwrite.io/console';
import { base } from '$app/paths';
import { page } from '$app/stores';

Expand All @@ -20,7 +19,7 @@ const getLabel = (message) => {
}
};

const getIcon = (message) => {
const getIcon = (message: Models.Message) => {
switch (message.providerType) {
case MessagingProviderType.Push:
return 'device-mobile';
Expand All @@ -35,7 +34,6 @@ const getIcon = (message) => {

export const messagesSearcher = (async (query: string) => {
const $page = get(page);
const projectId = get(project).$id;
const { messages } = await sdk
.forProject($page.params.region, $page.params.project)
.messaging.listMessages([], query || undefined);
Expand All @@ -48,7 +46,9 @@ export const messagesSearcher = (async (query: string) => {
group: 'messages',
label: getLabel(message),
callback: () => {
goto(`${base}/project-${projectId}/messaging/message-${message.$id}`);
goto(
`${base}/project-${$page.params.region}-${$page.params.project}/messaging/message-${message.$id}`
);
},
icon: getIcon(message)
}) as const
Expand Down
4 changes: 1 addition & 3 deletions src/lib/commandCenter/searchers/providers.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import { goto } from '$app/navigation';
import { project } from '$routes/(console)/project-[region]-[project]/store';
import { get } from 'svelte/store';
import type { Searcher } from '../commands';
import { sdk } from '$lib/stores/sdk';
Expand All @@ -14,7 +13,6 @@ const getIcon = (provider: string) => {

export const providersSearcher = (async (query: string) => {
const $page = get(page);
const projectId = get(project).$id;
const { providers } = await sdk
.forProject($page.params.region, $page.params.project)
.messaging.listProviders([], query || undefined);
Expand All @@ -28,7 +26,7 @@ export const providersSearcher = (async (query: string) => {
label: provider.name,
callback: () => {
goto(
`${base}/project-${projectId}/messaging/providers/provider-${provider.$id}`
`${base}/project-${$page.params.region}-${$page.params.project}/messaging/providers/provider-${provider.$id}`
);
},
image: getIcon(provider.provider)
Expand Down
18 changes: 10 additions & 8 deletions src/lib/commandCenter/searchers/teams.ts
Original file line number Diff line number Diff line change
@@ -1,36 +1,36 @@
import { goto } from '$app/navigation';
import { sdk } from '$lib/stores/sdk';
import { project } from '$routes/(console)/project-[region]-[project]/store';
import { get } from 'svelte/store';
import type { Command, Searcher } from '../commands';
import type { Models } from '@appwrite.io/console';
import { base } from '$app/paths';
import { page } from '$app/stores';

const getTeamCommand = (team: Models.Team<Models.Preferences>, projectId: string) =>
const getTeamCommand = (team: Models.Team<Models.Preferences>, region: string, projectId: string) =>
({
label: team.name,
callback: () => {
goto(`${base}/project-${projectId}/auth/teams/team-${team.$id}`);
goto(`${base}/project-${region}-${projectId}/auth/teams/team-${team.$id}`);
},
group: 'teams',
icon: 'user-circle'
}) satisfies Command;

export const teamSearcher = (async (query: string) => {
const $page = get(page);
const projectId = get(project).$id;
const { teams } = await sdk
.forProject($page.params.region, $page.params.project)
.teams.list([], query);

if (teams.length === 1) {
return [
getTeamCommand(teams[0], projectId),
getTeamCommand(teams[0], $page.params.region, $page.params.project),
{
label: 'Go to members',
callback: () => {
goto(`${base}/project-${projectId}/auth/teams/team-${teams[0].$id}/members`);
goto(
`${base}/project-${$page.params.region}-${$page.params.project}/auth/teams/team-${teams[0].$id}/members`
);
},
group: 'teams',
nested: true
Expand All @@ -39,12 +39,14 @@ export const teamSearcher = (async (query: string) => {
{
label: 'Go to activity',
callback: () => {
goto(`${base}/project-${projectId}/auth/teams/team-${teams[0].$id}/activity`);
goto(
`${base}/project-${$page.params.region}-${$page.params.project}/auth/teams/team-${teams[0].$id}/activity`
);
},
group: 'teams',
nested: true
}
];
}
return teams.map((team) => getTeamCommand(team, projectId));
return teams.map((team) => getTeamCommand(team, $page.params.region, $page.params.project));
}) satisfies Searcher;
6 changes: 3 additions & 3 deletions src/lib/commandCenter/searchers/topics.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import { goto } from '$app/navigation';
import { project } from '$routes/(console)/project-[region]-[project]/store';
import { get } from 'svelte/store';
import type { Searcher } from '../commands';
import { sdk } from '$lib/stores/sdk';
Expand All @@ -8,7 +7,6 @@ import { page } from '$app/stores';

export const topicsSearcher = (async (query: string) => {
const $page = get(page);
const projectId = get(project).$id;
const { topics } = await sdk
.forProject($page.params.region, $page.params.project)
.messaging.listTopics([], query || undefined);
Expand All @@ -21,7 +19,9 @@ export const topicsSearcher = (async (query: string) => {
group: 'topics',
label: topic.name,
callback: () => {
goto(`${base}/project-${projectId}/messaging/topics/topic-${topic.$id}`);
goto(
`${base}/project-${$page.params.region}-${$page.params.project}/messaging/topics/topic-${topic.$id}`
);
},
icon: 'send'
}) as const
Expand Down
22 changes: 13 additions & 9 deletions src/lib/commandCenter/searchers/users.ts
Original file line number Diff line number Diff line change
@@ -1,33 +1,31 @@
import { goto } from '$app/navigation';
import { sdk } from '$lib/stores/sdk';
import { project } from '$routes/(console)/project-[region]-[project]/store';
import { get } from 'svelte/store';
import type { Command, Searcher } from '../commands';
import type { Models } from '@appwrite.io/console';
import { promptDeleteUser } from '$routes/(console)/project-[region]-[project]/auth/user-[user]/dangerZone.svelte';
import { base } from '$app/paths';
import { page } from '$app/stores';

const getUserCommand = (user: Models.User<Models.Preferences>, projectId: string) =>
const getUserCommand = (user: Models.User<Models.Preferences>, region: string, projectId: string) =>
({
label: user.name,
callback: () => {
goto(`${base}/project-${projectId}/auth/user-${user.$id}`);
goto(`${base}/project-${region}-${projectId}/auth/user-${user.$id}`);
},
group: 'users',
icon: 'user-circle'
}) satisfies Command;

export const userSearcher = (async (query: string) => {
const $page = get(page);
const projectId = get(project).$id;
const { users } = await sdk
.forProject($page.params.region, $page.params.project)
.users.list([], query || undefined);

if (users.length === 1) {
return [
getUserCommand(users[0], projectId),
getUserCommand(users[0], $page.params.region, $page.params.project),
{
label: 'Delete user',
callback: () => {
Expand All @@ -40,28 +38,34 @@ export const userSearcher = (async (query: string) => {
{
label: 'Go to activity',
callback: () => {
goto(`${base}/project-${projectId}/auth/user-${users[0].$id}/activity`);
goto(
`${base}/project-${$page.params.region}-${$page.params.project}/auth/user-${users[0].$id}/activity`
);
},
group: 'users',
nested: true
},
{
label: 'Go to sessions',
callback: () => {
goto(`${base}/project-${projectId}/auth/user-${users[0].$id}/sessions`);
goto(
`${base}/project-${$page.params.region}-${$page.params.project}/auth/user-${users[0].$id}/sessions`
);
},
group: 'users',
nested: true
},
{
label: 'Go to memberships',
callback: () => {
goto(`${base}/project-${projectId}/auth/user-${users[0].$id}/memberships`);
goto(
`${base}/project-${$page.params.region}-${$page.params.project}/auth/user-${users[0].$id}/memberships`
);
},
group: 'users',
nested: true
}
];
}
return users.map((user) => getUserCommand(user, projectId));
return users.map((user) => getUserCommand(user, $page.params.region, $page.params.project));
}) satisfies Searcher;
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,11 @@
title: $organization?.name
},
{
href: `${base}/project-${$project?.$id}`,
href: `${base}/project-${$project.region}-${$project?.$id}`,
title: $project?.name
},
{
href: `${base}/project-${$project?.$id}/auth`,
href: `${base}/project-${$project.region}-${$project?.$id}/auth`,
title: 'Auth'
}
];
Expand Down
Loading

0 comments on commit 03bd2b4

Please sign in to comment.