fix: show run button only for schedule or manual (#17327)

This commit is contained in:
Karan Hotchandani 2024-08-07 19:57:50 +05:30 committed by GitHub
parent c6e7fe9423
commit 5ea7f8cc55
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with 27 additions and 10 deletions

View File

@ -25,6 +25,7 @@ import { useLimitStore } from '../../../../context/LimitsProvider/useLimitsStore
import {
AppScheduleClass,
AppType,
ScheduleType,
} from '../../../../generated/entity/applications/app';
import { getIngestionPipelineByFqn } from '../../../../rest/ingestionPipelineAPI';
import { getScheduleOptionsFromSchedules } from '../../../../utils/ScheduleUtils';
@ -51,6 +52,14 @@ const AppSchedule = ({
const [isSaveLoading, setIsSaveLoading] = useState(false);
const { config } = useLimitStore();
const showRunNowButton = useMemo(() => {
if (appData && appData.scheduleType === ScheduleType.ScheduledOrManual) {
return true;
}
return false;
}, [appData]);
const { pipelineSchedules } =
config?.limits?.config.featureLimits.find(
(feature) => feature.name === 'app'
@ -213,14 +222,16 @@ const AppSchedule = ({
</Button>
)}
<Button
data-testid="run-now-button"
disabled={appData.deleted}
loading={isRunLoading}
type="primary"
onClick={onAppTrigger}>
{t('label.run-now')}
</Button>
{showRunNowButton && (
<Button
data-testid="run-now-button"
disabled={appData.deleted}
loading={isRunLoading}
type="primary"
onClick={onAppTrigger}>
{t('label.run-now')}
</Button>
)}
</Space>
</Col>
)}

View File

@ -17,7 +17,10 @@ import {
} from '@testing-library/react';
import userEvent from '@testing-library/user-event';
import React from 'react';
import { AppType } from '../../../../generated/entity/applications/app';
import {
AppType,
ScheduleType,
} from '../../../../generated/entity/applications/app';
import { EntityReference } from '../../../../generated/tests/testSuite';
import { mockApplicationData } from '../../../../mocks/rests/applicationAPI.mock';
import { getScheduleOptionsFromSchedules } from '../../../../utils/ScheduleUtils';
@ -87,6 +90,7 @@ const mockProps2 = {
appType: AppType.External,
pipelines: [{}] as EntityReference[],
appSchedule: null,
scheduleType: ScheduleType.Scheduled,
name: 'DataInsightsReportApplication',
},
};
@ -140,6 +144,8 @@ describe('AppSchedule component', () => {
await waitForElementToBeRemoved(() => screen.getByText('Loader'));
expect(screen.queryByText('label.run-now')).not.toBeInTheDocument();
expect(screen.queryByText('label.schedule-type')).not.toBeInTheDocument();
expect(
screen.queryByText('label.schedule-interval')

View File

@ -42,7 +42,7 @@ export const mockApplicationData = {
supportEmail: 'support@getcollate.io',
className: 'org.openmetadata.service.apps.bundles.searchIndex.SearchIndexApp',
appType: AppType.Internal,
scheduleType: ScheduleType.Scheduled,
scheduleType: ScheduleType.ScheduledOrManual,
permission: Permissions.All,
bot: {
id: '7afdf172-ba26-44b5-b2bd-4dfd6768f44c',