mirror of
https://github.com/prowler-cloud/prowler.git
synced 2026-07-04 19:21:51 +00:00
fix(ui): improve scan scheduling flows (#11684)
This commit is contained in:
@@ -93,17 +93,19 @@ export function LaunchStep({
|
||||
const capability = capabilityProp ?? getScanScheduleCapability(isCloud());
|
||||
const isManualOnly = capability === SCAN_SCHEDULE_CAPABILITY.MANUAL_ONLY;
|
||||
const isAdvanced = capability === SCAN_SCHEDULE_CAPABILITY.ADVANCED;
|
||||
const isDailyLegacy = capability === SCAN_SCHEDULE_CAPABILITY.DAILY_LEGACY;
|
||||
const isBlocked = capability === SCAN_SCHEDULE_CAPABILITY.BLOCKED;
|
||||
const canUseScheduleMode = isAdvanced || isDailyLegacy;
|
||||
const [isLaunching, setIsLaunching] = useState(false);
|
||||
const [mode, setMode] = useState<LaunchMode>(
|
||||
isAdvanced ? LAUNCH_MODE.SCHEDULE : LAUNCH_MODE.NOW,
|
||||
canUseScheduleMode ? LAUNCH_MODE.SCHEDULE : LAUNCH_MODE.NOW,
|
||||
);
|
||||
const form = useForm<ScheduleFormValues>({
|
||||
resolver: zodResolver(scheduleFormSchema),
|
||||
defaultValues: getScheduleFormDefaults(),
|
||||
});
|
||||
|
||||
const isScheduleMode = isAdvanced && mode === LAUNCH_MODE.SCHEDULE;
|
||||
const isScheduleMode = canUseScheduleMode && mode === LAUNCH_MODE.SCHEDULE;
|
||||
const isLimitBlocked = mode === LAUNCH_MODE.NOW && isScanLimitReached;
|
||||
const isActionBlocked =
|
||||
isLaunching ||
|
||||
@@ -129,10 +131,10 @@ export function LaunchStep({
|
||||
})();
|
||||
|
||||
useEffect(() => {
|
||||
if (!isAdvanced && mode !== LAUNCH_MODE.NOW) {
|
||||
if (!canUseScheduleMode && mode !== LAUNCH_MODE.NOW) {
|
||||
setMode(LAUNCH_MODE.NOW);
|
||||
}
|
||||
}, [isAdvanced, mode]);
|
||||
}, [canUseScheduleMode, mode]);
|
||||
|
||||
const launchOnDemandScan = async (): Promise<ActionErrorResult | null> => {
|
||||
if (!providerId || isBlocked) return null;
|
||||
@@ -327,10 +329,10 @@ export function LaunchStep({
|
||||
<RadioGroupItem
|
||||
value={LAUNCH_MODE.SCHEDULE}
|
||||
aria-label="On a schedule"
|
||||
disabled={!isAdvanced}
|
||||
disabled={!canUseScheduleMode}
|
||||
/>
|
||||
On a schedule
|
||||
{!isAdvanced &&
|
||||
{!canUseScheduleMode &&
|
||||
!isBlocked &&
|
||||
(isManualOnly ? (
|
||||
<CloudFeatureBadge label="Requires subscription" size="sm" />
|
||||
@@ -341,7 +343,7 @@ export function LaunchStep({
|
||||
</RadioGroup>
|
||||
</Field>
|
||||
|
||||
{!isAdvanced && !isBlocked && (
|
||||
{isManualOnly && !isBlocked && (
|
||||
<p className="text-text-neutral-secondary text-sm">
|
||||
Scheduled scans are not available for this account. Run now to get
|
||||
immediate findings.
|
||||
@@ -361,6 +363,8 @@ export function LaunchStep({
|
||||
disabled={isLaunching || !providerId}
|
||||
showLaunchInitialScan
|
||||
showNextScheduledCopy
|
||||
canUseAdvancedSchedule={isAdvanced}
|
||||
showCloudUpgradeBadge={isDailyLegacy}
|
||||
/>
|
||||
)}
|
||||
</div>
|
||||
|
||||
Reference in New Issue
Block a user