Files
console/src/lib/stores/git.ts
T
Darshan b1df97a4c3 svelte5: cleanups, improvements (#1966)
* update: cleanups, improvements.

* fix: protocol usage.

* update: load failed invoice as non-blocking.

* address comments, make stuff faster!

* fix: missing type on org loads.

* fix: connect button shown on org. page.

* fix: error check.

* update: comment, just ocd things.

* update: flip `localStorage` check after `browser` check.

* update: comment.

* perf: parallelize fetch for faster loads [↓49%]

* update: compute things later.

* update: don't rely on dependency or reload if scope doesn't allow.

* update: simplify.

* update: do not load credits if the organization plan does not support it.

* update: just some cleaning.

* address comments for promise handling.

* address comments; remove: unused api calls!!!

* address comments;

* address comment.

* misc.

* cleaner endpoint creation.

* fix: required to optional.

* update: url to quick load.

* address comments.

* update: load payments on ui.

* update: load non-urgent calls on UI.

* fix: unnecessary runs of root layout.

* reduce: calls to countries, locale api.

* reduce: calls to countries, locale api in org settings.

* update: simplify api calls and data passing.

* address comments.

* remove: id from `UsageProjectInfo`.

* update: make api call only when needed.

* fix: text.

* fix: endpoint flag design <> verified by design.

* fix: `inline` inner stack so project name has enough space.

* fix: tests.

* update: improve orgs loading?

* update: misc.

* remove: todo.

* updates: more billing cleanups.

* misc.

* misc.

* fix: tests and a warning.

* address comment.

* fix: merge leftover issues.

* fix: tab selection on overview.

* fix: issues with user store on main project layout.

* remove: `selectedTab` store.

* fix: account menu regression.

* fix: reactive logic. use `svelte5` syntax.

* Remove trailing comma in invalidate array

* remove: unused method.

* updates: misc optimizations.

* fix: lint.

* update: changes after merge.

* update: modal size for credits and show loader.

* update: misc and PR freeze!

* update: use a default credit card icon if one isn't supported by the API.

* fix: project loading state as per updated org ID. LAST FIX.

* address comments.

---------

Co-authored-by: Torsten Dittmann <torsten.dittmann@googlemail.com>
2025-06-20 15:17:23 +02:00

40 lines
1.3 KiB
TypeScript

import { page } from '$app/state';
import { getApiEndpoint } from './sdk';
export function connectGitHub(callbackState: Record<string, string> = null) {
const redirect = new URL(page.url);
if (callbackState) {
Object.keys(callbackState).forEach((key) => {
redirect.searchParams.append(key, callbackState[key]);
});
}
const target = new URL(`${getApiEndpoint(page.params.region)}/vcs/github/authorize`);
target.searchParams.set('project', page.params.project);
target.searchParams.set('success', redirect.toString());
target.searchParams.set('failure', redirect.toString());
target.searchParams.set('mode', 'admin');
return target;
}
export function deploymentStatusConverter(status: string) {
// Status component possible values - status: 'waiting' | 'ready' | 'processing' | 'pending' | 'failed' | 'complete';
switch (status) {
case 'ready':
return 'ready';
case 'processing':
return 'processing';
case 'building':
return 'pending';
case 'waiting':
return 'waiting';
case 'queued':
return 'waiting';
case 'cancelled':
return 'processing';
case 'failed':
return 'failed';
default:
return 'processing';
}
}