mirror of
https://github.com/elastic/kibana.git
synced 2025-04-24 01:38:56 -04:00
# Conflicts: # x-pack/plugins/osquery/public/components/app.tsx
This commit is contained in:
parent
f356797bb7
commit
281aa198e9
2 changed files with 74 additions and 45 deletions
|
@ -9,7 +9,17 @@
|
|||
|
||||
import React, { useMemo } from 'react';
|
||||
import { FormattedMessage } from '@kbn/i18n/react';
|
||||
import { EuiButtonEmpty, EuiFlexGroup, EuiFlexItem, EuiTabs, EuiTab } from '@elastic/eui';
|
||||
import {
|
||||
EuiButtonEmpty,
|
||||
EuiFlexGroup,
|
||||
EuiFlexItem,
|
||||
EuiTabs,
|
||||
EuiTab,
|
||||
EuiLoadingElastic,
|
||||
EuiPage,
|
||||
EuiPageBody,
|
||||
EuiPageContent,
|
||||
} from '@elastic/eui';
|
||||
import { useLocation } from 'react-router-dom';
|
||||
|
||||
import { Container, Nav, Wrapper } from './layouts';
|
||||
|
@ -24,7 +34,25 @@ const OsqueryAppComponent = () => {
|
|||
const section = useMemo(() => location.pathname.split('/')[1] ?? 'overview', [location.pathname]);
|
||||
const { data: osqueryIntegration, isFetched } = useOsqueryIntegrationStatus();
|
||||
|
||||
if (isFetched && osqueryIntegration.install_status !== 'installed') {
|
||||
if (!isFetched) {
|
||||
return (
|
||||
<EuiPage paddingSize="none">
|
||||
<EuiPageBody>
|
||||
<EuiPageContent
|
||||
verticalPosition="center"
|
||||
horizontalPosition="center"
|
||||
paddingSize="none"
|
||||
color="subdued"
|
||||
hasShadow={false}
|
||||
>
|
||||
<EuiLoadingElastic size="xxl" />
|
||||
</EuiPageContent>
|
||||
</EuiPageBody>
|
||||
</EuiPage>
|
||||
);
|
||||
}
|
||||
|
||||
if (isFetched && osqueryIntegration?.install_status !== 'installed') {
|
||||
return <OsqueryAppEmptyState />;
|
||||
}
|
||||
|
||||
|
|
|
@ -107,6 +107,50 @@ export const createStatusRoute = (router: IRouter, osqueryContext: OsqueryAppCon
|
|||
pkgName: OSQUERY_INTEGRATION_NAME,
|
||||
});
|
||||
|
||||
const agentPolicyIds = uniq(map(policyPackages?.items, 'policy_id'));
|
||||
const agentPolicies = mapKeys(
|
||||
await agentPolicyService?.getByIds(internalSavedObjectsClient, agentPolicyIds),
|
||||
'id'
|
||||
);
|
||||
|
||||
await Promise.all(
|
||||
map(migrationObject.packs, async (packObject) => {
|
||||
await internalSavedObjectsClient.create(
|
||||
packSavedObjectType,
|
||||
{
|
||||
// @ts-expect-error update types
|
||||
name: packObject.name,
|
||||
// @ts-expect-error update types
|
||||
description: packObject.description,
|
||||
// @ts-expect-error update types
|
||||
queries: convertPackQueriesToSO(packObject.queries),
|
||||
// @ts-expect-error update types
|
||||
enabled: packObject.enabled,
|
||||
created_at: new Date().toISOString(),
|
||||
created_by: 'system',
|
||||
updated_at: new Date().toISOString(),
|
||||
updated_by: 'system',
|
||||
},
|
||||
{
|
||||
// @ts-expect-error update types
|
||||
references: packObject.policy_ids.map((policyId: string) => ({
|
||||
id: policyId,
|
||||
name: agentPolicies[policyId].name,
|
||||
type: AGENT_POLICY_SAVED_OBJECT_TYPE,
|
||||
})),
|
||||
refresh: 'wait_for',
|
||||
}
|
||||
);
|
||||
})
|
||||
);
|
||||
|
||||
// delete unnecessary package policies
|
||||
await packagePolicyService?.delete(
|
||||
internalSavedObjectsClient,
|
||||
esClient,
|
||||
migrationObject.packagePoliciesToDelete
|
||||
);
|
||||
|
||||
// updatePackagePolicies
|
||||
await Promise.all(
|
||||
map(migrationObject.agentPolicyToPackage, async (value, key) => {
|
||||
|
@ -151,49 +195,6 @@ export const createStatusRoute = (router: IRouter, osqueryContext: OsqueryAppCon
|
|||
}
|
||||
})
|
||||
);
|
||||
|
||||
const agentPolicyIds = uniq(map(policyPackages?.items, 'policy_id'));
|
||||
const agentPolicies = mapKeys(
|
||||
await agentPolicyService?.getByIds(internalSavedObjectsClient, agentPolicyIds),
|
||||
'id'
|
||||
);
|
||||
|
||||
await Promise.all(
|
||||
map(migrationObject.packs, async (packObject) => {
|
||||
await internalSavedObjectsClient.create(
|
||||
packSavedObjectType,
|
||||
{
|
||||
// @ts-expect-error update types
|
||||
name: packObject.name,
|
||||
// @ts-expect-error update types
|
||||
description: packObject.description,
|
||||
// @ts-expect-error update types
|
||||
queries: convertPackQueriesToSO(packObject.queries),
|
||||
// @ts-expect-error update types
|
||||
enabled: packObject.enabled,
|
||||
created_at: new Date().toISOString(),
|
||||
created_by: 'system',
|
||||
updated_at: new Date().toISOString(),
|
||||
updated_by: 'system',
|
||||
},
|
||||
{
|
||||
// @ts-expect-error update types
|
||||
references: packObject.policy_ids.map((policyId: string) => ({
|
||||
id: policyId,
|
||||
name: agentPolicies[policyId].name,
|
||||
type: AGENT_POLICY_SAVED_OBJECT_TYPE,
|
||||
})),
|
||||
refresh: 'wait_for',
|
||||
}
|
||||
);
|
||||
})
|
||||
);
|
||||
|
||||
await packagePolicyService?.delete(
|
||||
internalSavedObjectsClient,
|
||||
esClient,
|
||||
migrationObject.packagePoliciesToDelete
|
||||
);
|
||||
// eslint-disable-next-line no-empty
|
||||
} catch (e) {}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue