-
Notifications
You must be signed in to change notification settings - Fork 216
Feat baa #2898
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Feat baa #2898
Changes from all commits
bf2166b
b93b07d
fa54499
599ce48
2465da5
12db4e6
23dd014
dd159cf
214ba5c
e50b147
7488e57
f63879a
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -6,9 +6,11 @@ | |
| import { sdk } from '$lib/stores/sdk'; | ||
| import { members, organization } from '$lib/stores/organization'; | ||
| import { projects } from '../store'; | ||
| import { invalidate } from '$app/navigation'; | ||
| import { goto, invalidate } from '$app/navigation'; | ||
| import { resolve } from '$app/paths'; | ||
| import { Dependencies } from '$lib/constants'; | ||
| import { onMount } from 'svelte'; | ||
| import { page } from '$app/state'; | ||
| import Delete from './deleteOrganizationModal.svelte'; | ||
| import DownloadDPA from './downloadDPA.svelte'; | ||
| import { Submit, trackEvent, trackError } from '$lib/actions/analytics'; | ||
|
|
@@ -22,8 +24,66 @@ | |
| let name: string; | ||
| let showDelete = false; | ||
|
|
||
| onMount(() => { | ||
| onMount(async () => { | ||
| name = $organization.name; | ||
|
|
||
| if (page.url.searchParams.get('type') === 'validate-addon') { | ||
| let addonId = page.url.searchParams.get('addonId'); | ||
|
|
||
| // Fall back to listing addons if addonId is missing or invalid | ||
| if (!addonId || addonId === 'undefined') { | ||
| try { | ||
| const addons = await sdk.forConsole.organizations.listAddons({ | ||
| organizationId: $organization.$id | ||
| }); | ||
| const pending = addons.addons.find( | ||
| (a) => a.key === 'baa' && a.status === 'pending' | ||
| ); | ||
| addonId = pending?.$id ?? null; | ||
| } catch { | ||
| addonId = null; | ||
| } | ||
|
Comment on lines
+35
to
+45
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Avoid reporting success when addon lookup fails. If Proposed fix onMount(async () => {
name = $organization.name;
if (page.url.searchParams.get('type') === 'validate-addon') {
let addonId = page.url.searchParams.get('addonId');
+ let lookupFailed = false;
// Fall back to listing addons if addonId is missing or invalid
if (!addonId || addonId === 'undefined') {
try {
const addons = await sdk.forConsole.organizations.listAddons({
organizationId: $organization.$id
});
const pending = addons.addons.find(
(a) => a.key === 'baa' && a.status === 'pending'
);
addonId = pending?.$id ?? null;
- } catch {
- addonId = null;
+ } catch (e) {
+ lookupFailed = true;
+ addNotification({
+ message: e?.message ?? 'Unable to verify BAA addon status. Please retry.',
+ type: 'error'
+ });
}
}
+
+ if (lookupFailed) {
+ const settingsUrl = resolve('/(console)/organization-[organization]/settings', {
+ organization: $organization.$id
+ });
+ await goto(settingsUrl, { replaceState: true });
+ return;
+ }
if (addonId) {
// existing logic...Also applies to: 80-89 🤖 Prompt for AI Agents |
||
| } | ||
|
|
||
| if (addonId) { | ||
| try { | ||
| await sdk.forConsole.organizations.validateAddonPayment({ | ||
| organizationId: $organization.$id, | ||
| addonId | ||
| }); | ||
| await Promise.all([ | ||
| invalidate(Dependencies.ADDONS), | ||
| invalidate(Dependencies.ORGANIZATION) | ||
| ]); | ||
| addNotification({ | ||
| message: 'BAA addon has been enabled', | ||
| type: 'success' | ||
| }); | ||
| } catch (e) { | ||
| // If addon not found, payment webhook may have already activated it | ||
| if (e?.type === 'addon_not_found' || e?.code === 404) { | ||
| await Promise.all([ | ||
| invalidate(Dependencies.ADDONS), | ||
| invalidate(Dependencies.ORGANIZATION) | ||
| ]); | ||
| addNotification({ | ||
| message: 'BAA addon has been enabled', | ||
| type: 'success' | ||
| }); | ||
| } else { | ||
| addNotification({ | ||
| message: e.message, | ||
| type: 'error' | ||
| }); | ||
| } | ||
| } | ||
| } | ||
|
|
||
| const settingsUrl = resolve('/(console)/organization-[organization]/settings', { | ||
| organization: $organization.$id | ||
| }); | ||
| await goto(settingsUrl, { replaceState: true }); | ||
| } | ||
| }); | ||
|
|
||
| async function updateName() { | ||
|
|
@@ -75,7 +135,7 @@ | |
|
|
||
| {#if isCloud} | ||
| <DownloadDPA /> | ||
| <Baa locale={data.locale} countryList={data.countryList} /> | ||
| <Baa addons={data.addons} /> | ||
| <Soc2 locale={data.locale} countryList={data.countryList} /> | ||
| {/if} | ||
|
|
||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🧩 Analysis chain
🏁 Script executed:
Repository: appwrite/console
Length of output: 2125
Appwrite-only enum alias breaks provider-specific SDK method calls
Line 2 aliases
AppwriteMigrationResourceas the sharedResourcestype, which narrowsproviderResourcesto appwrite-only enum values. This causes type incompatibility whengetSupabaseReport(),getFirebaseReport(), andgetNHostReport()are called with mismatched resource types (lines 56, 67, 74 in resource-form.svelte).The
@todocomment on line 54 confirms this was known to be incomplete.Import the provider-specific resource enums from
@appwrite.io/consoleand use a mapped type forproviderResources:Proposed fix
🤖 Prompt for AI Agents