mirror of
https://github.com/unraid/api.git
synced 2026-05-05 06:33:03 -05:00
fix: enhance activation code modal visibility logic (#1733)
Updated the visibility logic in the activation code modal store to include a check for the presence of an activation code. The modal will now be shown if it is not explicitly hidden, the installation is fresh, there is no callback data, and an activation code is present. <!-- This is an auto-generated comment: release notes by coderabbit.ai --> ## Summary by CodeRabbit * **Bug Fixes** * Activation modal visibility refined: it now appears only when an activation code is available, it’s a fresh install, the modal isn’t hidden, and there’s no callback data. Prevents unnecessary prompts. * **Tests** * Expanded coverage to include activation code presence/absence and combined scenarios with fresh install and hidden states, ensuring accurate visibility logic. <!-- end of auto-generated comment: release notes by coderabbit.ai -->
This commit is contained in:
@@ -10,7 +10,7 @@ import { useCallbackActionsStore } from '~/store/callbackActions';
|
||||
export const useActivationCodeModalStore = defineStore('activationCodeModal', () => {
|
||||
const isHidden = useSessionStorage<boolean | null>(ACTIVATION_CODE_MODAL_HIDDEN_STORAGE_KEY, null);
|
||||
|
||||
const { isFreshInstall } = storeToRefs(useActivationCodeDataStore());
|
||||
const { isFreshInstall, activationCode } = storeToRefs(useActivationCodeDataStore());
|
||||
const { callbackData } = storeToRefs(useCallbackActionsStore());
|
||||
|
||||
const setIsHidden = (value: boolean | null) => {
|
||||
@@ -30,8 +30,13 @@ export const useActivationCodeModalStore = defineStore('activationCodeModal', ()
|
||||
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;
|
||||
// Default visibility logic (show if not explicitly hidden AND fresh install AND no callback data AND activation code is present)
|
||||
return (
|
||||
isHidden.value === null &&
|
||||
isFreshInstall.value &&
|
||||
!callbackData.value &&
|
||||
Boolean(activationCode.value?.code)
|
||||
);
|
||||
});
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user