Files
api/web/components/Activation/store/activationCodeData.ts
Eli Bosley 39e83b2aa1 feat: move activation code logic into the API (#1369)
<!-- This is an auto-generated comment: release notes by coderabbit.ai
-->
## Summary by CodeRabbit

- **New Features**
- Added comprehensive activation code customization service with dynamic
theming, partner branding, and UI updates.
- Introduced new GraphQL types and public queries for activation code,
partner info, and theme data.
- Implemented new web UI stores and components for activation modal,
partner logos, and theme management.
- **Improvements**
- Removed legacy activation code scripts, PHP components, and plugin
references, streamlining activation logic.
- Enhanced configuration and environment support for activation and
theming features.
- Improved error handling, validation, and type safety in activation and
customization modules.
- **Bug Fixes**
- Fixed color code validation and path handling in customization
service.
- **Chores**
  - Added pre-commit linting hooks and related configuration.
  - Cleaned up test and development environment files.
- **Tests**
- Added extensive tests covering activation customization service
initialization, data handling, and file modifications.
  - Removed obsolete tests related to legacy activation code store.
- **Refactor**
- Migrated activation and partner branding logic from legacy scripts and
PHP to TypeScript services and GraphQL resolvers.
- Reorganized store and component architecture for activation-related
features.
- **Style**
- Updated UI components for improved branding, theming, accessibility,
and layout consistency.
<!-- end of auto-generated comment: release notes by coderabbit.ai -->

---------

Co-authored-by: Zack Spear <hi@zackspear.com>
2025-05-01 17:40:36 -04:00

45 lines
1.4 KiB
TypeScript

import { computed } from 'vue';
import { createPinia, defineStore, setActivePinia } from 'pinia';
import { useQuery } from '@vue/apollo-composable';
import {
ACTIVATION_CODE_QUERY,
PARTNER_INFO_QUERY,
} from '~/components/Activation/graphql/activationCode.query';
import { RegistrationState } from '~/composables/gql/graphql';
setActivePinia(createPinia()); /** required in web component context */
export const useActivationCodeDataStore = defineStore('activationCodeData', () => {
const { result: activationCodeResult, loading: activationCodeLoading } = useQuery(
ACTIVATION_CODE_QUERY,
{},
{ errorPolicy: 'all' }
);
const { result: partnerInfoResult, loading: partnerInfoLoading } = useQuery(
PARTNER_INFO_QUERY,
{},
{ errorPolicy: 'all' }
);
const activationCode = computed(() => activationCodeResult.value?.customization?.activationCode);
const isFreshInstall = computed(
() => activationCodeResult.value?.vars?.regState === RegistrationState.ENOKEYFILE
);
/**
* Public Partner Info becomes null when the user has set a password, so we fall back to the partnerInfo from the activation code
*/
const partnerInfo = computed(
() =>
partnerInfoResult.value?.publicPartnerInfo ??
activationCodeResult.value?.customization?.partnerInfo
);
return {
loading: computed(() => activationCodeLoading.value || partnerInfoLoading.value),
activationCode,
isFreshInstall,
partnerInfo,
};
});