mirror of
https://github.com/appwrite/console.git
synced 2026-06-06 19:27:48 +00:00
checking billing role
This commit is contained in:
@@ -358,7 +358,7 @@ export class Billing {
|
||||
);
|
||||
}
|
||||
|
||||
async getScopes(organizationId: string): Promise<Roles> {
|
||||
async getRoles(organizationId: string): Promise<Roles> {
|
||||
const path = `/organizations/${organizationId}/roles`;
|
||||
const uri = new URL(this.client.config.endpoint + path);
|
||||
return await this.client.call(
|
||||
|
||||
+10
-2
@@ -1,8 +1,16 @@
|
||||
import { page } from "$app/stores";
|
||||
import { derived } from "svelte/store";
|
||||
|
||||
export const roles = derived(page, ($page) => $page.data.roles);
|
||||
export const roles = derived(page, function ($page) {
|
||||
console.log("roles", $page.data.roles);
|
||||
return $page.data.roles;
|
||||
});
|
||||
export const scopes = derived(page, ($page) => $page.data.scopes);
|
||||
export const isDeveloper = derived(roles, ($roles) => $roles.includes("developer"));
|
||||
|
||||
export const isBilling = derived(roles, function ($roles) {
|
||||
let isBilling= $roles.includes("billing");
|
||||
console.log("isBilling", isBilling);
|
||||
return isBilling;
|
||||
});
|
||||
export const isOwner = derived(roles, ($roles) => $roles.includes("owner"));
|
||||
export const canSeeDatabases = derived(scopes, ($scopes) => $scopes.includes("databases.read"));
|
||||
@@ -16,7 +16,10 @@ export const load: LayoutLoad = async ({ params, depends }) => {
|
||||
depends(Dependencies.ORGANIZATION);
|
||||
depends(Dependencies.MEMBERS);
|
||||
depends(Dependencies.PAYMENT_METHODS);
|
||||
|
||||
let data: {roles: string[], scopes: string[]} = {
|
||||
roles: [],
|
||||
scopes: []
|
||||
};
|
||||
if (isCloud) {
|
||||
await failedInvoice.load(params.organization);
|
||||
|
||||
@@ -28,6 +31,10 @@ export const load: LayoutLoad = async ({ params, depends }) => {
|
||||
importance: 1
|
||||
});
|
||||
}
|
||||
|
||||
const res = await sdk.forConsole.billing.getRoles(params.organization);
|
||||
data.roles = res.roles;
|
||||
data.scopes = res.scopes;
|
||||
}
|
||||
|
||||
try {
|
||||
@@ -41,6 +48,8 @@ export const load: LayoutLoad = async ({ params, depends }) => {
|
||||
organization: await (sdk.forConsole.teams.get(
|
||||
params.organization
|
||||
) as Promise<Organization>),
|
||||
roles: data.roles,
|
||||
scopes: data.scopes,
|
||||
members: await sdk.forConsole.teams.listMemberships(params.organization)
|
||||
};
|
||||
} catch (e) {
|
||||
@@ -49,4 +58,5 @@ export const load: LayoutLoad = async ({ params, depends }) => {
|
||||
sdk.forConsole.account.updatePrefs(newPrefs);
|
||||
error(e.code, e.message);
|
||||
}
|
||||
return data;
|
||||
};
|
||||
|
||||
@@ -32,6 +32,7 @@
|
||||
organization,
|
||||
organizationList
|
||||
} from '$lib/stores/organization';
|
||||
import { isBilling, isDeveloper } from '$lib/stores/roles';
|
||||
import { GRACE_PERIOD_OVERRIDE, isCloud } from '$lib/system';
|
||||
|
||||
let areMembersLimited: boolean;
|
||||
@@ -46,6 +47,8 @@
|
||||
|
||||
function createOrg() {
|
||||
showDropdown = false;
|
||||
console.log('billing:', isBilling);
|
||||
console.log('developer:', isDeveloper);
|
||||
if (isCloud) {
|
||||
goto(`${base}/console/create-organization`);
|
||||
} else newOrgModal.set(true);
|
||||
@@ -76,23 +79,38 @@
|
||||
}
|
||||
];
|
||||
|
||||
$: tabs = isCloud
|
||||
? [
|
||||
...permanentTabs,
|
||||
{
|
||||
href: `${path}/usage`,
|
||||
event: 'usage',
|
||||
title: 'Usage',
|
||||
hasChildren: true
|
||||
},
|
||||
{
|
||||
href: `${path}/billing`,
|
||||
event: 'billing',
|
||||
title: 'Billing'
|
||||
},
|
||||
...permanentTabSettings
|
||||
]
|
||||
: [...permanentTabs, ...permanentTabSettings];
|
||||
$: billingTabs = [
|
||||
{
|
||||
href: `${path}/billing`,
|
||||
event: 'billing',
|
||||
title: 'Billing'
|
||||
}
|
||||
];
|
||||
$: tabs =
|
||||
isCloud && isBilling
|
||||
? [
|
||||
...permanentTabs,
|
||||
{
|
||||
href: `${path}/usage`,
|
||||
event: 'usage',
|
||||
title: 'Usage',
|
||||
hasChildren: true
|
||||
},
|
||||
...billingTabs,
|
||||
...permanentTabSettings
|
||||
]
|
||||
: isCloud && !isBilling
|
||||
? [
|
||||
...permanentTabs,
|
||||
{
|
||||
href: `${path}/usage`,
|
||||
event: 'usage',
|
||||
title: 'Usage',
|
||||
hasChildren: true
|
||||
},
|
||||
...permanentTabSettings
|
||||
]
|
||||
: [...permanentTabs, ...permanentTabSettings];
|
||||
</script>
|
||||
|
||||
{#if $organization?.$id}
|
||||
|
||||
Reference in New Issue
Block a user