Files
inbuxa-admin/src/stores/accountStore.ts
T
jcoffey-dev 3a33f3d514 Mark the files this fork changed (AGPL section 5(a))
Publishing the source is what asks for it: a modified version has to carry
prominent notices saying it was modified, with a date. These files already
added a Coffey Labs copyright line beside upstream's, which implies as much
without saying it; now they say it.

38 files, found by diffing against the merge base with upstream rather than
by guessing. Upstream's own notices are untouched. The build is unchanged.
2026-09-19 23:48:44 -07:00

44 lines
1.3 KiB
TypeScript

/*
* SPDX-FileCopyrightText: 2020 Stalwart Labs LLC <[email protected]>
* SPDX-FileCopyrightText: 2026 Coffey Labs
*
* SPDX-License-Identifier: AGPL-3.0-only OR LicenseRef-SEL
*
* Modified by Coffey Labs in 2026 for INBUXA.
*/
import { create } from 'zustand';
type Edition = 'enterprise' | 'community' | 'oss';
interface AccountState {
permissions: string[];
edition: Edition;
locale: string;
setAccountInfo: (permissions: string[], edition: Edition, locale: string) => void;
hasPermission: (perm: string) => boolean;
hasObjectPermission: (prefix: string, action: 'Get' | 'Query' | 'Create' | 'Update' | 'Destroy') => boolean;
}
export const useAccountStore = create<AccountState>()((set, get) => ({
permissions: [],
edition: 'community',
locale: 'en',
setAccountInfo: (permissions, _edition, locale) => {
// INBUXA has one edition, with every feature. Whatever the server reports,
// nothing is hidden or disabled as Enterprise-only. Features the server
// hasn't rebuilt yet answer that for themselves.
set({ permissions, edition: 'enterprise', locale });
},
hasPermission: (perm) => {
return get().permissions.includes(perm);
},
hasObjectPermission: (prefix, action) => {
return get().permissions.includes(`${prefix}${action}`);
},
}));