-
Notifications
You must be signed in to change notification settings - Fork 124
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
42a2e56
commit b5c93d0
Showing
5 changed files
with
58 additions
and
41 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
34 changes: 0 additions & 34 deletions
34
web-admin/src/routes/[organization]/-/project-breakdown/+page.ts
This file was deleted.
Oops, something went wrong.
File renamed without changes.
41 changes: 41 additions & 0 deletions
41
web-admin/src/routes/[organization]/-/projects-breakdown/+page.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
import { | ||
adminServiceGetBillingProjectCredentials, | ||
getAdminServiceGetBillingProjectCredentialsQueryKey, | ||
} from "@rilldata/web-admin/client"; | ||
import { queryClient } from "@rilldata/web-common/lib/svelte-query/globalQueryClient"; | ||
import { fixLocalhostRuntimePort } from "@rilldata/web-common/runtime-client/fix-localhost-runtime-port"; | ||
import type { Runtime } from "@rilldata/web-common/runtime-client/runtime-store"; | ||
import { error } from "@sveltejs/kit"; | ||
|
||
export const load = async ({ params, parent }) => { | ||
const { organizationPermissions } = await parent(); | ||
if (!organizationPermissions.manageProjects) { | ||
throw error(404, "Page not found"); | ||
} | ||
|
||
try { | ||
const { organization } = params; | ||
const billingProjectCredsResp = await queryClient.fetchQuery({ | ||
queryKey: getAdminServiceGetBillingProjectCredentialsQueryKey({ | ||
organization, | ||
}), | ||
queryFn: () => adminServiceGetBillingProjectCredentials({ organization }), | ||
}); | ||
const runtime: Runtime = { | ||
host: fixLocalhostRuntimePort(billingProjectCredsResp.runtimeHost), | ||
instanceId: billingProjectCredsResp.instanceId, | ||
jwt: { | ||
token: billingProjectCredsResp.accessToken, | ||
authContext: "embed", | ||
receivedAt: Date.now(), | ||
}, | ||
}; | ||
|
||
return { | ||
runtime, | ||
}; | ||
} catch (err) { | ||
const statusCode = err?.response?.status || 500; | ||
throw error(statusCode, "Failed to fetch project breakdown"); | ||
} | ||
}; |