Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Dataset Quality] Change logic to identify integrations #198692

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
58 commits
Select commit Hold shift + click to select a range
b34b9f1
Fix refresh table breaking for summary
achyutjhunjhunwala Jun 21, 2024
d1fdaeb
Add timeout to find
achyutjhunjhunwala Jun 21, 2024
ac496c4
Merge branch 'elastic:main' into main
achyutjhunjhunwala Jun 21, 2024
12cad21
Merge branch 'elastic:main' into main
achyutjhunjhunwala Jun 21, 2024
db7d63b
Revert "Add timeout to find"
achyutjhunjhunwala Jun 21, 2024
c3a2774
Revert "Fix refresh table breaking for summary"
achyutjhunjhunwala Jun 21, 2024
9ba8128
Merge branch 'elastic:main' into main
achyutjhunjhunwala Jun 24, 2024
425cdb4
Merge branch 'elastic:main' into main
achyutjhunjhunwala Jun 25, 2024
a5ccc32
Merge branch 'elastic:main' into main
achyutjhunjhunwala Jun 26, 2024
1ab7806
Merge branch 'elastic:main' into main
achyutjhunjhunwala Jul 1, 2024
abad280
Merge branch 'elastic:main' into main
achyutjhunjhunwala Jul 3, 2024
14a3620
Merge branch 'elastic:main' into main
achyutjhunjhunwala Jul 5, 2024
0dd0eb1
Merge branch 'elastic:main' into main
achyutjhunjhunwala Jul 9, 2024
2dd64cc
Merge branch 'elastic:main' into main
achyutjhunjhunwala Jul 22, 2024
3833283
Merge branch 'elastic:main' into main
achyutjhunjhunwala Jul 23, 2024
a1a1ce1
Merge branch 'elastic:main' into main
achyutjhunjhunwala Jul 25, 2024
6278a51
Merge branch 'elastic:main' into main
achyutjhunjhunwala Aug 9, 2024
14161a3
Merge branch 'elastic:main' into main
achyutjhunjhunwala Aug 13, 2024
2df6d10
Merge branch 'elastic:main' into main
achyutjhunjhunwala Aug 13, 2024
99d8084
Merge branch 'elastic:main' into main
achyutjhunjhunwala Aug 13, 2024
28e789c
Merge branch 'elastic:main' into main
achyutjhunjhunwala Aug 14, 2024
59fc802
Merge branch 'elastic:main' into main
achyutjhunjhunwala Aug 27, 2024
dec1cae
Merge branch 'elastic:main' into main
achyutjhunjhunwala Aug 27, 2024
33c0c60
Merge branch 'elastic:main' into main
achyutjhunjhunwala Sep 4, 2024
6f5c1c6
Merge branch 'elastic:main' into main
achyutjhunjhunwala Sep 5, 2024
fbf7d08
Merge branch 'elastic:main' into main
achyutjhunjhunwala Sep 6, 2024
55d1cff
Merge branch 'elastic:main' into main
achyutjhunjhunwala Sep 17, 2024
73ae28d
Merge branch 'elastic:main' into main
achyutjhunjhunwala Sep 26, 2024
b475502
Merge branch 'elastic:main' into main
achyutjhunjhunwala Oct 3, 2024
53e9a19
Merge branch 'elastic:main' into main
achyutjhunjhunwala Oct 7, 2024
ddb587a
Merge branch 'elastic:main' into main
achyutjhunjhunwala Oct 9, 2024
a3cb5cc
Merge branch 'elastic:main' into main
achyutjhunjhunwala Oct 14, 2024
5a26974
Merge branch 'elastic:main' into main
achyutjhunjhunwala Oct 25, 2024
5f18e66
Merge branch 'elastic:main' into main
achyutjhunjhunwala Oct 28, 2024
9330c8f
Merge branch 'elastic:main' into main
achyutjhunjhunwala Oct 30, 2024
35a407b
Change logic to identify and load integrations
achyutjhunjhunwala Nov 1, 2024
474f9b7
Merge branch 'main' into change-logic-to-identify-integrations
achyutjhunjhunwala Nov 1, 2024
de2ba6f
[CI] Auto-commit changed files from 'node scripts/lint_ts_projects --…
kibanamachine Nov 1, 2024
3159330
Merge branch 'main' into change-logic-to-identify-integrations
achyutjhunjhunwala Nov 4, 2024
2d8c5ea
Fix logic to handle loading integrations from meta as well
achyutjhunjhunwala Nov 4, 2024
7b12709
Changed logic to also return assets available instead of only integra…
achyutjhunjhunwala Nov 7, 2024
d422d9b
Merge branch 'main' into change-logic-to-identify-integrations
achyutjhunjhunwala Nov 7, 2024
4643609
Fix checktype issues and bugs
achyutjhunjhunwala Nov 7, 2024
d4b31f2
Add FTR tests for stateful and serverless
achyutjhunjhunwala Nov 7, 2024
24ef5b4
Fix one more CT issue
achyutjhunjhunwala Nov 7, 2024
aabca91
Fix some more unknown unexpected merge related changes
achyutjhunjhunwala Nov 7, 2024
03b70e4
Merge branch 'main' into change-logic-to-identify-integrations
elasticmachine Nov 12, 2024
9121f97
Remove unnecessary useMemo
weltenwort Nov 12, 2024
f717fb8
Remove left-over debug logging
weltenwort Nov 12, 2024
da85e71
Fix translation tooling errors
weltenwort Nov 13, 2024
cc93662
Merge remote-tracking branch 'upstream/main' into change-logic-to-ide…
weltenwort Nov 13, 2024
591235c
Improve array access
weltenwort Nov 14, 2024
6c0fd87
Make common code path more efficient
weltenwort Nov 19, 2024
38e3655
Merge remote-tracking branch 'upstream/main' into change-logic-to-ide…
weltenwort Nov 19, 2024
3ea6f9a
Update mock and tests
weltenwort Nov 19, 2024
4467d7f
Merge branch 'main' into change-logic-to-identify-integrations
elasticmachine Nov 19, 2024
3e515f5
Merge branch 'main' into change-logic-to-identify-integrations
elasticmachine Nov 22, 2024
cd42ce6
Merge branch 'main' into change-logic-to-identify-integrations
elasticmachine Dec 2, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,10 @@ export function DatasetQualityDetailsContextProvider({
urlStateStorageContainer,
datasetQualityDetailsState: state,
});
const breadcrumbValue = getBreadcrumbValue(state.dataStream, state.integration);
const breadcrumbValue = getBreadcrumbValue(
state.dataStream,
state.integration?.integration
);
setBreadcrumbs([{ text: breadcrumbValue }]);
}
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ const createClientMock = (): jest.Mocked<PackageClient> => ({
fetchFindLatestPackage: jest.fn(),
readBundledPackage: jest.fn(),
getAgentPolicyConfigYAML: jest.fn(),
getLatestPackageInfo: jest.fn(),
getPackage: jest.fn(),
getPackageFieldsMetadata: jest.fn(),
getPackages: jest.fn(),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ const testKeys = [
'getInstallation',
'ensureInstalledPackage',
'fetchFindLatestPackage',
'getLatestPackageInfo',
'getPackage',
'getPackageFieldsMetadata',
'reinstallEsAssets',
Expand Down Expand Up @@ -112,6 +113,23 @@ function getTest(
};
break;
case testKeys[3]:
test = {
method: mocks.packageClient.getLatestPackageInfo.bind(mocks.packageClient),
args: ['package name'],
spy: jest.spyOn(epmPackagesGet, 'getPackageInfo'),
spyArgs: [
{
pkgName: 'package name',
pkgVersion: '',
savedObjectsClient: mocks.soClient,
prerelease: undefined,
},
],
spyResponse: { name: 'getLatestPackageInfo test' },
expectedReturnValue: { name: 'getLatestPackageInfo test' },
};
break;
case testKeys[4]:
test = {
method: mocks.packageClient.getPackage.bind(mocks.packageClient),
args: ['package name', '8.0.0'],
Expand All @@ -127,7 +145,7 @@ function getTest(
},
};
break;
case testKeys[4]:
case testKeys[5]:
test = {
method: mocks.packageClient.getPackageFieldsMetadata.bind(mocks.packageClient),
args: [{ packageName: 'package_name', datasetName: 'dataset_name' }],
Expand All @@ -141,7 +159,7 @@ function getTest(
},
};
break;
case testKeys[5]:
case testKeys[6]:
const pkg: InstallablePackage = {
format_version: '1.0.0',
name: 'package name',
Expand Down Expand Up @@ -187,7 +205,7 @@ function getTest(
],
};
break;
case testKeys[6]:
case testKeys[7]:
const bundledPackage = {
name: 'package name',
version: '8.0.0',
Expand Down
16 changes: 16 additions & 0 deletions x-pack/plugins/fleet/server/services/epm/package_service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@ import {
getPackages,
installPackage,
getTemplateInputs,
getPackageInfo,
} from './packages';
import { generatePackageInfoFromArchiveBuffer } from './archive';
import { getEsPackage } from './archive/storage';
Expand Down Expand Up @@ -113,6 +114,11 @@ export interface PackageClient {
options?: Parameters<typeof getPackageFieldsMetadata>['1']
): ReturnType<typeof getPackageFieldsMetadata>;

getLatestPackageInfo(
packageName: string,
prerelease?: boolean
): ReturnType<typeof getPackageInfo>;

getPackages(params?: {
excludeInstallStatus?: false;
category?: CategoryId;
Expand Down Expand Up @@ -328,6 +334,16 @@ class PackageClientImpl implements PackageClient {
return getPackageFieldsMetadata(params, options);
}

public async getLatestPackageInfo(packageName: string, prerelease?: boolean) {
weltenwort marked this conversation as resolved.
Show resolved Hide resolved
await this.#runPreflight(READ_PACKAGE_INFO_AUTHZ);
return getPackageInfo({
savedObjectsClient: this.internalSoClient,
pkgName: packageName,
pkgVersion: '',
prerelease,
});
}

public async getPackages(params?: {
excludeInstallStatus?: false;
category?: CategoryId;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -95,13 +95,24 @@ export const integrationRt = rt.intersection([

export type IntegrationType = rt.TypeOf<typeof integrationRt>;

export const checkAndLoadIntegrationResponseRt = rt.union([
rt.type({ isIntegration: rt.literal(false), areAssetsAvailable: rt.boolean }),
rt.type({
isIntegration: rt.literal(true),
areAssetsAvailable: rt.literal(true),
integration: integrationRt,
}),
]);

export type CheckAndLoadIntegrationResponse = rt.TypeOf<typeof checkAndLoadIntegrationResponseRt>;

export const getIntegrationsResponseRt = rt.exact(
rt.type({
integrations: rt.array(integrationRt),
})
);

export type IntegrationResponse = rt.TypeOf<typeof getIntegrationsResponseRt>;
export type IntegrationsResponse = rt.TypeOf<typeof getIntegrationsResponseRt>;

export const degradedFieldRt = rt.type({
name: rt.string,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,7 @@
* 2.0.
*/

export interface GetDataStreamIntegrationParams {
integrationName: string;
}
import { Integration } from '../data_streams_stats/integration';

export interface AnalyzeDegradedFieldsParams {
dataStream: string;
Expand All @@ -19,3 +17,13 @@ export interface UpdateFieldLimitParams {
dataStream: string;
newFieldLimit: number;
}

export interface CheckAndLoadIntegrationParams {
dataStream: string;
}

export interface IntegrationType {
isIntegration: boolean;
areAssetsAvailable: boolean;
integration?: Integration;
}
tonyghiani marked this conversation as resolved.
Show resolved Hide resolved
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,11 @@ import { IncreaseFieldMappingLimit } from './increase_field_mapping_limit';
import { FieldLimitDocLink } from './field_limit_documentation_link';
import { MessageCallout } from './message_callout';

export function FieldMappingLimit({ isIntegration }: { isIntegration: boolean }) {
export function FieldMappingLimit({
areIntegrationAssetsAvailable,
}: {
areIntegrationAssetsAvailable: boolean;
}) {
const accordionId = useGeneratedHtmlId({
prefix: increaseFieldMappingLimitTitle,
});
Expand Down Expand Up @@ -66,7 +70,7 @@ export function FieldMappingLimit({ isIntegration }: { isIntegration: boolean })
</ul>
</EuiText>
<EuiHorizontalRule margin="s" />
{isIntegration && (
{areIntegrationAssetsAvailable && (
<>
<IncreaseFieldMappingLimit
totalFieldLimit={degradedFieldAnalysis?.totalFieldLimit ?? 0}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ export function IncreaseFieldMappingLimit({ totalFieldLimit }: { totalFieldLimit
<EuiFlexItem grow={false}>
<EuiFormRow hasEmptyLabelSpace>
<EuiButton
data-test-subj="datasetQualityIncreaseFieldMappingLimitButtonButton"
data-test-subj="datasetQualityIncreaseFieldMappingLimitButton"
disabled={isInvalid}
onClick={() => updateNewFieldLimit(newFieldLimit)}
isLoading={isMitigationInProgress}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ import { PossibleMitigationTitle } from './title';
export function PossibleMitigations() {
const { degradedFieldAnalysis, isAnalysisInProgress } = useDegradedFields();
const { integrationDetails } = useDatasetQualityDetailsState();
const isIntegration = Boolean(integrationDetails?.integration);
const areIntegrationAssetsAvailable = !!integrationDetails?.integration?.areAssetsAvailable;

return (
!isAnalysisInProgress && (
Expand All @@ -24,7 +24,7 @@ export function PossibleMitigations() {
<EuiSpacer size="m" />
{degradedFieldAnalysis?.isFieldLimitIssue && (
<>
<FieldMappingLimit isIntegration={isIntegration} />
<FieldMappingLimit areIntegrationAssetsAvailable={areIntegrationAssetsAvailable} />
<EuiSpacer size="m" />
</>
)}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,11 @@ import { useDatasetQualityDetailsState } from '../../../../../hooks';
import { getComponentTemplatePrefixFromIndexTemplate } from '../../../../../../common/utils/component_template_name';
import { otherMitigationsCustomComponentTemplate } from '../../../../../../common/translations';

export function CreateEditComponentTemplateLink({ isIntegration }: { isIntegration: boolean }) {
export function CreateEditComponentTemplateLink({
areIntegrationAssetsAvailable,
}: {
areIntegrationAssetsAvailable: boolean;
}) {
const {
services: {
application,
Expand Down Expand Up @@ -54,7 +58,7 @@ export function CreateEditComponentTemplateLink({ isIntegration }: { isIntegrati
name,
]);

const templateUrl = isIntegration ? componentTemplatePath : indexTemplatePath;
const templateUrl = areIntegrationAssetsAvailable ? componentTemplatePath : indexTemplatePath;

const onClickHandler = useCallback(async () => {
const options = {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,27 +13,27 @@ import { CreateEditPipelineLink } from './pipeline_link';
import { otherMitigationsLoadingAriaText } from '../../../../../../common/translations';

export function ManualMitigations() {
const { integrationDetails, loadingState, dataStreamSettings } = useDatasetQualityDetailsState();
const isIntegrationPresentInSettings = dataStreamSettings?.integration;
const isIntegration = !!integrationDetails?.integration;
const { dataStreamSettingsLoading, integrationDetailsLoadings } = loadingState;

const hasIntegrationCheckCompleted =
!dataStreamSettingsLoading &&
((isIntegrationPresentInSettings && !integrationDetailsLoadings) ||
!isIntegrationPresentInSettings);
const {
integrationDetails,
loadingState: { integrationDetailsLoaded },
} = useDatasetQualityDetailsState();
const areIntegrationAssetsAvailable = !!integrationDetails?.integration?.areAssetsAvailable;

return (
<EuiSkeletonRectangle
isLoading={!hasIntegrationCheckCompleted}
isLoading={!integrationDetailsLoaded}
contentAriaLabel={otherMitigationsLoadingAriaText}
width="100%"
height={300}
borderRadius="none"
data-test-subj="datasetQualityDetailsFlyoutManualMitigationsLoading"
className="datasetQualityDetailsFlyoutManualMitigationsLoading"
>
<CreateEditComponentTemplateLink isIntegration={isIntegration} />
<CreateEditComponentTemplateLink
areIntegrationAssetsAvailable={areIntegrationAssetsAvailable}
/>
<EuiSpacer size="s" />
<CreateEditPipelineLink isIntegration={isIntegration} />
<CreateEditPipelineLink areIntegrationAssetsAvailable={areIntegrationAssetsAvailable} />
</EuiSkeletonRectangle>
);
}
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
* 2.0.
*/

import React, { useCallback, useMemo } from 'react';
import React, { useCallback } from 'react';
import { FormattedMessage } from '@kbn/i18n-react';
import { i18n } from '@kbn/i18n';
import {
Expand Down Expand Up @@ -34,7 +34,11 @@ const AccordionTitle = () => (
</EuiTitle>
);

export function CreateEditPipelineLink({ isIntegration }: { isIntegration: boolean }) {
export function CreateEditPipelineLink({
areIntegrationAssetsAvailable,
}: {
areIntegrationAssetsAvailable: boolean;
}) {
const {
services: {
share: {
Expand All @@ -50,10 +54,7 @@ export function CreateEditPipelineLink({ isIntegration }: { isIntegration: boole
const { datasetDetails } = useDatasetQualityDetailsState();
const { type, name } = datasetDetails;

const pipelineName = useMemo(
() => (isIntegration ? `${type}-${name}@custom` : `${type}@custom`),
[isIntegration, type, name]
);
const pipelineName = areIntegrationAssetsAvailable ? `${type}-${name}@custom` : `${type}@custom`;

const ingestPipelineLocator = locators.get('INGEST_PIPELINES_APP_LOCATOR');

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

import React, { Fragment } from 'react';
import { ES_FIELD_TYPES, KBN_FIELD_TYPES } from '@kbn/field-types';
import { EuiBadge, EuiFlexGroup, EuiPanel, EuiText } from '@elastic/eui';
import { EuiBadge, EuiFlexGroup, EuiPanel, EuiSkeletonRectangle, EuiText } from '@elastic/eui';
import { css } from '@emotion/react';
import { IntegrationActionsMenu } from './integration_actions_menu';
import {
Expand All @@ -29,7 +29,8 @@ export function DatasetSummary() {
const {
dataStreamDetailsLoading,
dataStreamSettingsLoading,
integrationDetailsLoadings,
integrationDetailsLoading,
integrationDetailsLoaded,
integrationDashboardsLoading,
} = loadingState;
const formattedLastActivity = dataStreamDetails?.lastActivity
Expand All @@ -39,12 +40,19 @@ export function DatasetSummary() {
? dataFormatter.convert(dataStreamSettings.createdOn)
: '-';

return (
return !integrationDetailsLoaded ? (
<EuiSkeletonRectangle
width="100%"
height="200px"
data-test-subj="datasetQualityDetailsDetailsSectionLoading"
className="datasetQualityDetailsDetailsSectionLoading"
/>
) : (
<EuiPanel hasBorder={false} hasShadow={false} paddingSize="none">
<Fragment>
<FieldsList
fields={[
...(integrationDetails?.integration
...(integrationDetails?.integration?.integration
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not sure what integrationDetails.integration.integration represents but I guess is an object, although it's not clear what the first 2 accesses are, some renaming might help for future debugging and code maintenance.

Copy link
Contributor Author

@achyutjhunjhunwala achyutjhunjhunwala Nov 12, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I too thought the same but due to lack of time was not 100% convinced to do the change.

IntegrationDetails define 2 items - response from Integration API and response from integration dashboard API.

So integrationDetails.integration here means response from Integration API.

Now as part of this PR, this API response changed and it returns isIntegration, areAssetsAvailable and the actual integration object. Hence this long name

? [
{
fieldTitle: integrationNameText,
Expand All @@ -56,24 +64,28 @@ export function DatasetSummary() {
`}
>
<EuiFlexGroup gutterSize="xs" alignItems="center">
<IntegrationIcon integration={integrationDetails.integration} />
<EuiText size="s">{integrationDetails.integration?.name}</EuiText>
<IntegrationIcon
integration={integrationDetails.integration.integration}
/>
<EuiText size="s">
{integrationDetails.integration.integration?.name}
</EuiText>
</EuiFlexGroup>
</EuiBadge>
),
actionsMenu: (
<IntegrationActionsMenu
integration={integrationDetails.integration}
integration={integrationDetails.integration.integration}
dashboards={integrationDetails.dashboard}
dashboardsLoading={integrationDashboardsLoading}
/>
),
isLoading: integrationDetailsLoadings,
isLoading: integrationDetailsLoading,
},
{
fieldTitle: integrationVersionText,
fieldValue: integrationDetails.integration?.version,
isLoading: integrationDetailsLoadings,
fieldValue: integrationDetails.integration.integration?.version,
isLoading: integrationDetailsLoading,
},
]
: []),
Expand Down
Loading
Loading