mirror of
https://github.com/appwrite/console.git
synced 2026-06-06 19:27:48 +00:00
Merge pull request #1811 from appwrite/fix-undefined-url-region
Fix: region based url being undefined in the URL
This commit is contained in:
@@ -13,28 +13,30 @@
|
||||
: '';
|
||||
</script>
|
||||
|
||||
<Copy value={getProjectEndpoint()} appendTo="parent" copyText="Copy endpoint">
|
||||
<div
|
||||
class="flex u-gap-8 u-cross-center interactive-text-output is-buttons-on-top u-text-center"
|
||||
style:min-inline-size="0"
|
||||
style:display="inline-flex">
|
||||
<span
|
||||
style:white-space="nowrap"
|
||||
class="text u-line-height-1-5"
|
||||
style:overflow="hidden"
|
||||
style:word-break="break-all"
|
||||
use:truncateText
|
||||
style:font-family="unset">
|
||||
{$projectRegion?.name}
|
||||
</span>
|
||||
{#if $projectRegion}
|
||||
<Copy value={getProjectEndpoint()} appendTo="parent" copyText="Copy endpoint">
|
||||
<div
|
||||
class="flex u-gap-8 u-cross-center interactive-text-output is-buttons-on-top u-text-center"
|
||||
style:min-inline-size="0"
|
||||
style:display="inline-flex">
|
||||
<span
|
||||
style:white-space="nowrap"
|
||||
class="text u-line-height-1-5"
|
||||
style:overflow="hidden"
|
||||
style:word-break="break-all"
|
||||
use:truncateText
|
||||
style:font-family="unset">
|
||||
{$projectRegion?.name}
|
||||
</span>
|
||||
|
||||
{#if flagSrc}
|
||||
<img
|
||||
style="border-radius: 2.5px"
|
||||
src={flagSrc}
|
||||
alt={$projectRegion?.name}
|
||||
width={16}
|
||||
height={12} />
|
||||
{/if}
|
||||
</div>
|
||||
</Copy>
|
||||
{#if flagSrc}
|
||||
<img
|
||||
style="border-radius: 2.5px"
|
||||
src={flagSrc}
|
||||
alt={$projectRegion?.name}
|
||||
width={16}
|
||||
height={12} />
|
||||
{/if}
|
||||
</div>
|
||||
</Copy>
|
||||
{/if}
|
||||
|
||||
@@ -15,14 +15,22 @@ export const load: PageLoad = async ({ params, url, route, depends, parent }) =>
|
||||
return redirect(301, `/console/organization-${params.organization}/billing`);
|
||||
}
|
||||
|
||||
const projects = await sdk.forConsole.projects.list([
|
||||
Query.offset(offset),
|
||||
Query.equal('teamId', params.organization),
|
||||
Query.limit(limit),
|
||||
Query.orderDesc('')
|
||||
]);
|
||||
|
||||
// set `default` or something else,
|
||||
// `undefined` in the url looks really off!
|
||||
for (const project of projects.projects) {
|
||||
project.region ??= 'default';
|
||||
}
|
||||
|
||||
return {
|
||||
offset,
|
||||
limit,
|
||||
projects: await sdk.forConsole.projects.list([
|
||||
Query.offset(offset),
|
||||
Query.equal('teamId', params.organization),
|
||||
Query.limit(limit),
|
||||
Query.orderDesc('')
|
||||
])
|
||||
projects
|
||||
};
|
||||
};
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
import { get } from 'svelte/store';
|
||||
import { sdk } from '$lib/stores/sdk';
|
||||
import { isCloud } from '$lib/system';
|
||||
import { regions } from '$lib/stores/organization';
|
||||
|
||||
let lastLoadedOrganization = null;
|
||||
@@ -10,10 +11,11 @@ let lastLoadedOrganization = null;
|
||||
* Prevents unnecessary API calls if the regions are already loaded for the same organization.
|
||||
*/
|
||||
export async function loadAvailableRegions(orgId: string): Promise<void> {
|
||||
if (!isCloud) return;
|
||||
|
||||
try {
|
||||
const storedRegions = get(regions);
|
||||
|
||||
// note that regions can vary based on an organization's plan!
|
||||
if (storedRegions?.regions && lastLoadedOrganization === orgId) {
|
||||
// already loaded for this organization, fast path return.
|
||||
return;
|
||||
|
||||
Reference in New Issue
Block a user