fix(ui): move schedule option logic to class base (#17503)

* fix(ui): move schedule option logic to class base

* skip datainsight run test covered in playwright
This commit is contained in:
Chirag Madlani 2024-08-20 22:13:11 +05:30 committed by GitHub
parent a868596db7
commit bee4bda501
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
5 changed files with 39 additions and 21 deletions

View File

@ -122,7 +122,8 @@ describe(
}); });
if (Cypress.env('isOss')) { if (Cypress.env('isOss')) {
it('Run application', () => { // We are running it for DataInsight page tests
it.skip('Run application', () => {
interceptURL( interceptURL(
'GET', 'GET',
'/api/v1/apps/name/DataInsightsApplication?fields=*', '/api/v1/apps/name/DataInsightsApplication?fields=*',

View File

@ -76,6 +76,7 @@ const AppContainer = () => {
<Layout <Layout
className={classNames('app-container', { className={classNames('app-container', {
['extra-banner']: Boolean(bannerDetails), ['extra-banner']: Boolean(bannerDetails),
['reserve-right-sidebar']: Boolean(ApplicationExtras),
})}> })}>
<Sider <Sider
className={classNames('left-sidebar-col', { className={classNames('left-sidebar-col', {

View File

@ -12,6 +12,8 @@
*/ */
import { FC } from 'react'; import { FC } from 'react';
import { AppType } from '../../../../generated/entity/applications/app';
import { getScheduleOptionsFromSchedules } from '../../../../utils/ScheduleUtils';
class ApplicationsClassBase { class ApplicationsClassBase {
public importSchema(fqn: string) { public importSchema(fqn: string) {
@ -35,6 +37,22 @@ class ApplicationsClassBase {
public importAppScreenshot(screenshotName: string) { public importAppScreenshot(screenshotName: string) {
return import(`../../../../assets/img/appScreenshots/${screenshotName}`); return import(`../../../../assets/img/appScreenshots/${screenshotName}`);
} }
public getScheduleOptionsForApp(
app: string,
appType: AppType,
pipelineSchedules?: string[]
) {
if (app === 'DataInsightsReportApplication') {
return ['week'];
} else if (appType === AppType.External) {
return ['day'];
}
return pipelineSchedules
? getScheduleOptionsFromSchedules(pipelineSchedules)
: undefined;
}
} }
const applicationsClassBase = new ApplicationsClassBase(); const applicationsClassBase = new ApplicationsClassBase();

View File

@ -28,11 +28,11 @@ import {
ScheduleType, ScheduleType,
} from '../../../../generated/entity/applications/app'; } from '../../../../generated/entity/applications/app';
import { getIngestionPipelineByFqn } from '../../../../rest/ingestionPipelineAPI'; import { getIngestionPipelineByFqn } from '../../../../rest/ingestionPipelineAPI';
import { getScheduleOptionsFromSchedules } from '../../../../utils/ScheduleUtils';
import { getWeekCron } from '../../../common/CronEditor/CronEditor.constant'; import { getWeekCron } from '../../../common/CronEditor/CronEditor.constant';
import Loader from '../../../common/Loader/Loader'; import Loader from '../../../common/Loader/Loader';
import { TestSuiteIngestionDataType } from '../../../DataQuality/AddDataQualityTest/AddDataQualityTest.interface'; import { TestSuiteIngestionDataType } from '../../../DataQuality/AddDataQualityTest/AddDataQualityTest.interface';
import TestSuiteScheduler from '../../../DataQuality/AddDataQualityTest/components/TestSuiteScheduler'; import TestSuiteScheduler from '../../../DataQuality/AddDataQualityTest/components/TestSuiteScheduler';
import applicationsClassBase from '../AppDetails/ApplicationsClassBase';
import AppRunsHistory from '../AppRunsHistory/AppRunsHistory.component'; import AppRunsHistory from '../AppRunsHistory/AppRunsHistory.component';
import { AppRunsHistoryRef } from '../AppRunsHistory/AppRunsHistory.interface'; import { AppRunsHistoryRef } from '../AppRunsHistory/AppRunsHistory.interface';
import { AppScheduleProps } from './AppScheduleProps.interface'; import { AppScheduleProps } from './AppScheduleProps.interface';
@ -146,15 +146,11 @@ const AppSchedule = ({
}, [appData, isPipelineDeployed, appRunsHistoryRef]); }, [appData, isPipelineDeployed, appRunsHistoryRef]);
const initialOptions = useMemo(() => { const initialOptions = useMemo(() => {
if (appData.name === 'DataInsightsReportApplication') { return applicationsClassBase.getScheduleOptionsForApp(
return ['week']; appData.name,
} else if (appData.appType === AppType.External) { appData.appType,
return ['day']; pipelineSchedules
} );
return pipelineSchedules
? getScheduleOptionsFromSchedules(pipelineSchedules)
: undefined;
}, [appData.name, appData.appType, pipelineSchedules]); }, [appData.name, appData.appType, pipelineSchedules]);
useEffect(() => { useEffect(() => {

View File

@ -26,7 +26,10 @@ import Loader from '../../components/common/Loader/Loader';
import { TestSuiteIngestionDataType } from '../../components/DataQuality/AddDataQualityTest/AddDataQualityTest.interface'; import { TestSuiteIngestionDataType } from '../../components/DataQuality/AddDataQualityTest/AddDataQualityTest.interface';
import TestSuiteScheduler from '../../components/DataQuality/AddDataQualityTest/components/TestSuiteScheduler'; import TestSuiteScheduler from '../../components/DataQuality/AddDataQualityTest/components/TestSuiteScheduler';
import PageLayoutV1 from '../../components/PageLayoutV1/PageLayoutV1'; import PageLayoutV1 from '../../components/PageLayoutV1/PageLayoutV1';
import applicationSchemaClassBase from '../../components/Settings/Applications/AppDetails/ApplicationsClassBase'; import {
default as applicationSchemaClassBase,
default as applicationsClassBase,
} from '../../components/Settings/Applications/AppDetails/ApplicationsClassBase';
import AppInstallVerifyCard from '../../components/Settings/Applications/AppInstallVerifyCard/AppInstallVerifyCard.component'; import AppInstallVerifyCard from '../../components/Settings/Applications/AppInstallVerifyCard/AppInstallVerifyCard.component';
import IngestionStepper from '../../components/Settings/Services/Ingestion/IngestionStepper/IngestionStepper.component'; import IngestionStepper from '../../components/Settings/Services/Ingestion/IngestionStepper/IngestionStepper.component';
import { STEPS_FOR_APP_INSTALL } from '../../constants/Applications.constant'; import { STEPS_FOR_APP_INSTALL } from '../../constants/Applications.constant';
@ -50,7 +53,6 @@ import {
getMarketPlaceAppDetailsPath, getMarketPlaceAppDetailsPath,
getSettingPath, getSettingPath,
} from '../../utils/RouterUtils'; } from '../../utils/RouterUtils';
import { getScheduleOptionsFromSchedules } from '../../utils/ScheduleUtils';
import { showErrorToast, showSuccessToast } from '../../utils/ToastUtils'; import { showErrorToast, showSuccessToast } from '../../utils/ToastUtils';
import './app-install.less'; import './app-install.less';
@ -81,16 +83,16 @@ const AppInstall = () => {
); );
const { initialOptions, initialValue } = useMemo(() => { const { initialOptions, initialValue } = useMemo(() => {
let initialOptions; if (!appData) {
return {};
if (appData?.name === 'DataInsightsReportApplication') {
initialOptions = ['week'];
} else if (appData?.appType === AppType.External) {
initialOptions = ['day'];
} else if (pipelineSchedules && !isEmpty(pipelineSchedules)) {
initialOptions = getScheduleOptionsFromSchedules(pipelineSchedules);
} }
const initialOptions = applicationsClassBase.getScheduleOptionsForApp(
appData?.name,
appData?.appType,
pipelineSchedules
);
return { return {
initialOptions, initialOptions,
initialValue: { initialValue: {