Files
api/web/components/Activation/store/activationCodeModal.ts
Eli Bosley 345e83bfb0 feat: upgrade nuxt-custom-elements (#1461)
<!-- This is an auto-generated comment: release notes by coderabbit.ai
-->
## Summary by CodeRabbit

* **New Features**
* Added new modal dialogs and UI components, including activation steps,
OS update feedback, and expanded notification management.
* Introduced a plugin to configure internationalization, state
management, and Apollo client support in web components.
* Added a new Log Viewer page with a streamlined interface for viewing
logs.

* **Improvements**
* Centralized Pinia state management by consolidating all stores to use
a shared global Pinia instance.
* Simplified component templates by removing redundant
internationalization host wrappers.
* Enhanced ESLint configuration with stricter rules and global variable
declarations.
* Refined custom element build process to prevent jQuery conflicts and
optimize minification.
* Updated component imports and templates for consistent structure and
maintainability.
* Streamlined log viewer dropdowns using simplified select components
with improved formatting.
* Improved notification sidebar with filtering by importance and modular
components.
* Replaced legacy notification popups with new UI components and added
automatic root session creation for localhost requests.
* Updated OS version display and user profile UI with refined styling
and component usage.

* **Bug Fixes**
* Fixed component tag capitalization and improved type annotations
across components.

* **Chores**
* Updated development dependencies including ESLint plugins and build
tools.
* Removed deprecated log viewer patch class and cleaned up related test
fixtures.
  * Removed unused imports and simplified Apollo client setup.
* Cleaned up test mocks and removed obsolete i18n host component tests.
<!-- end of auto-generated comment: release notes by coderabbit.ai -->

---
- To see the specific tasks where the Asana app for GitHub is being
used, see below:
  - https://app.asana.com/0/0/1210730229632804

---------

Co-authored-by: Pujit Mehrotra <pujit@lime-technology.com>
Co-authored-by: Zack Spear <zackspear@users.noreply.github.com>
2025-07-08 10:05:39 -04:00

84 lines
2.3 KiB
TypeScript

import { computed, onMounted, onUnmounted } from 'vue';
import { defineStore, storeToRefs } from 'pinia';
import { useSessionStorage } from '@vueuse/core';
import { ACTIVATION_CODE_MODAL_HIDDEN_STORAGE_KEY } from '~/consts';
import { useActivationCodeDataStore } from '~/components/Activation/store/activationCodeData';
import { useCallbackActionsStore } from '~/store/callbackActions';
// Uses the shared global Pinia instance
import '~/store/globalPinia';
export const useActivationCodeModalStore = defineStore('activationCodeModal', () => {
const isHidden = useSessionStorage<boolean | null>(ACTIVATION_CODE_MODAL_HIDDEN_STORAGE_KEY, null);
const { isFreshInstall } = storeToRefs(useActivationCodeDataStore());
const { callbackData } = storeToRefs(useCallbackActionsStore());
const setIsHidden = (value: boolean | null) => {
isHidden.value = value;
};
/**
* Should only see this if
* 1. It's explicitly set to show (isHidden === false)
* OR
* 2. It's a fresh server install where no keyfile has been present before
* 3. there's not callback data
* 4. it's not been explicitly hidden (isHidden === null)
*/
const isVisible = computed<boolean>(() => {
// Force show if explicitly set to false
if (isHidden.value === false) {
return true;
}
// Default visibility logic (show if not explicitly hidden AND fresh install AND no callback data)
return isHidden.value === null && isFreshInstall.value && !callbackData.value;
});
/**
* Listen for konami code sequence to close the modal
*/
const keySequence = [
'ArrowUp',
'ArrowUp',
'ArrowDown',
'ArrowDown',
'ArrowLeft',
'ArrowRight',
'ArrowLeft',
'ArrowRight',
'b',
'a',
];
let sequenceIndex = 0;
const handleKeydown = (event: KeyboardEvent) => {
if (event.key === keySequence[sequenceIndex]) {
sequenceIndex++;
} else {
sequenceIndex = 0;
}
if (sequenceIndex === keySequence.length) {
setIsHidden(true);
// Redirect only if explicitly hidden via konami code, not just closed normally
window.location.href = '/Tools/Registration';
}
};
onMounted(() => {
window?.addEventListener('keydown', handleKeydown);
});
onUnmounted(() => {
window?.removeEventListener('keydown', handleKeydown);
});
return {
isVisible,
setIsHidden,
};
});