[Asset management] Fix UI capabilities validation (#97663)
This commit is contained in:
parent
a555338bdc
commit
f0a05e8c81
6 changed files with 21 additions and 47 deletions
|
@ -16,13 +16,7 @@ import { useOsqueryIntegration } from '../common/hooks';
|
|||
|
||||
const ManageIntegrationLinkComponent = () => {
|
||||
const {
|
||||
application: {
|
||||
getUrlForApp,
|
||||
navigateToApp,
|
||||
capabilities: {
|
||||
osquery: { save: hasSaveUICapabilities },
|
||||
},
|
||||
},
|
||||
application: { getUrlForApp, navigateToApp },
|
||||
} = useKibana().services;
|
||||
const { data: osqueryIntegration } = useOsqueryIntegration();
|
||||
|
||||
|
@ -56,7 +50,7 @@ const ManageIntegrationLinkComponent = () => {
|
|||
[navigateToApp, osqueryIntegration]
|
||||
);
|
||||
|
||||
return hasSaveUICapabilities && integrationHref ? (
|
||||
return integrationHref ? (
|
||||
<EuiFlexItem>
|
||||
{
|
||||
// eslint-disable-next-line @elastic/eui/href-or-on-click
|
||||
|
|
|
@ -9,14 +9,13 @@ import { EuiButton, EuiFlexGroup, EuiFlexItem } from '@elastic/eui';
|
|||
import { FormattedMessage } from '@kbn/i18n/react';
|
||||
import React, { useMemo } from 'react';
|
||||
|
||||
import { useKibana, useRouterNavigate } from '../../../common/lib/kibana';
|
||||
import { useRouterNavigate } from '../../../common/lib/kibana';
|
||||
import { ActionsTable } from '../../../actions/actions_table';
|
||||
import { WithHeaderLayout } from '../../../components/layouts';
|
||||
import { useBreadcrumbs } from '../../../common/hooks/use_breadcrumbs';
|
||||
import { BetaBadge, BetaBadgeRowWrapper } from '../../../components/beta_badge';
|
||||
|
||||
const LiveQueriesPageComponent = () => {
|
||||
const hasSaveUICapabilities = useKibana().services.application.capabilities.osquery.save;
|
||||
useBreadcrumbs('live_queries');
|
||||
const newQueryLinkProps = useRouterNavigate('live_queries/new');
|
||||
|
||||
|
@ -52,11 +51,7 @@ const LiveQueriesPageComponent = () => {
|
|||
);
|
||||
|
||||
return (
|
||||
<WithHeaderLayout
|
||||
leftColumn={LeftColumn}
|
||||
rightColumn={hasSaveUICapabilities ? RightColumn : undefined}
|
||||
rightColumnGrow={false}
|
||||
>
|
||||
<WithHeaderLayout leftColumn={LeftColumn} rightColumn={RightColumn} rightColumnGrow={false}>
|
||||
<ActionsTable />
|
||||
</WithHeaderLayout>
|
||||
);
|
||||
|
|
|
@ -19,7 +19,7 @@ import React, { useMemo } from 'react';
|
|||
import { useParams } from 'react-router-dom';
|
||||
import styled from 'styled-components';
|
||||
|
||||
import { useKibana, useRouterNavigate } from '../../../common/lib/kibana';
|
||||
import { useRouterNavigate } from '../../../common/lib/kibana';
|
||||
import { WithHeaderLayout } from '../../../components/layouts';
|
||||
import { useScheduledQueryGroup } from '../../../scheduled_query_groups/use_scheduled_query_group';
|
||||
import { ScheduledQueryGroupQueriesTable } from '../../../scheduled_query_groups/scheduled_query_group_queries_table';
|
||||
|
@ -34,7 +34,6 @@ const Divider = styled.div`
|
|||
`;
|
||||
|
||||
const ScheduledQueryGroupDetailsPageComponent = () => {
|
||||
const hasSaveUICapabilities = useKibana().services.application.capabilities.osquery.save;
|
||||
const { scheduledQueryGroupId } = useParams<{ scheduledQueryGroupId: string }>();
|
||||
const scheduledQueryGroupsListProps = useRouterNavigate('scheduled_query_groups');
|
||||
const editQueryLinkProps = useRouterNavigate(
|
||||
|
@ -98,24 +97,20 @@ const ScheduledQueryGroupDetailsPageComponent = () => {
|
|||
</EuiDescriptionListDescription>
|
||||
</EuiDescriptionList>
|
||||
</EuiFlexItem>
|
||||
{hasSaveUICapabilities ? (
|
||||
<>
|
||||
<EuiFlexItem grow={false} key="agents_failed_count_divider">
|
||||
<Divider />
|
||||
</EuiFlexItem>
|
||||
<EuiFlexItem grow={false} key="edit_button">
|
||||
<EuiButton fill {...editQueryLinkProps} iconType="pencil">
|
||||
<FormattedMessage
|
||||
id="xpack.osquery.scheduledQueryDetailsPage.editQueryButtonLabel"
|
||||
defaultMessage="Edit"
|
||||
/>
|
||||
</EuiButton>
|
||||
</EuiFlexItem>
|
||||
</>
|
||||
) : undefined}
|
||||
<EuiFlexItem grow={false} key="agents_failed_count_divider">
|
||||
<Divider />
|
||||
</EuiFlexItem>
|
||||
<EuiFlexItem grow={false} key="edit_button">
|
||||
<EuiButton fill {...editQueryLinkProps} iconType="pencil">
|
||||
<FormattedMessage
|
||||
id="xpack.osquery.scheduledQueryDetailsPage.editQueryButtonLabel"
|
||||
defaultMessage="Edit"
|
||||
/>
|
||||
</EuiButton>
|
||||
</EuiFlexItem>
|
||||
</EuiFlexGroup>
|
||||
),
|
||||
[data?.policy_id, editQueryLinkProps, hasSaveUICapabilities]
|
||||
[data?.policy_id, editQueryLinkProps]
|
||||
);
|
||||
|
||||
return (
|
||||
|
|
|
@ -9,13 +9,12 @@ import { EuiButton, EuiFlexGroup, EuiFlexItem } from '@elastic/eui';
|
|||
import { FormattedMessage } from '@kbn/i18n/react';
|
||||
import React, { useMemo } from 'react';
|
||||
|
||||
import { useKibana, useRouterNavigate } from '../../../common/lib/kibana';
|
||||
import { useRouterNavigate } from '../../../common/lib/kibana';
|
||||
import { WithHeaderLayout } from '../../../components/layouts';
|
||||
import { ScheduledQueryGroupsTable } from '../../../scheduled_query_groups/scheduled_query_groups_table';
|
||||
import { BetaBadge, BetaBadgeRowWrapper } from '../../../components/beta_badge';
|
||||
|
||||
const ScheduledQueryGroupsPageComponent = () => {
|
||||
const hasSaveUICapabilities = useKibana().services.application.capabilities.osquery.save;
|
||||
const newQueryLinkProps = useRouterNavigate('scheduled_query_groups/add');
|
||||
|
||||
const LeftColumn = useMemo(
|
||||
|
@ -50,11 +49,7 @@ const ScheduledQueryGroupsPageComponent = () => {
|
|||
);
|
||||
|
||||
return (
|
||||
<WithHeaderLayout
|
||||
leftColumn={LeftColumn}
|
||||
rightColumn={hasSaveUICapabilities ? RightColumn : undefined}
|
||||
rightColumnGrow={false}
|
||||
>
|
||||
<WithHeaderLayout leftColumn={LeftColumn} rightColumn={RightColumn} rightColumnGrow={false}>
|
||||
<ScheduledQueryGroupsTable />
|
||||
</WithHeaderLayout>
|
||||
);
|
||||
|
|
|
@ -35,11 +35,6 @@ const ActiveStateSwitchComponent: React.FC<ActiveStateSwitchProps> = ({ item })
|
|||
const {
|
||||
http,
|
||||
notifications: { toasts },
|
||||
application: {
|
||||
capabilities: {
|
||||
osquery: { save: hasSaveUICapabilities },
|
||||
},
|
||||
},
|
||||
} = useKibana().services;
|
||||
const [confirmationModal, setConfirmationModal] = useState(false);
|
||||
|
||||
|
@ -124,7 +119,7 @@ const ActiveStateSwitchComponent: React.FC<ActiveStateSwitchProps> = ({ item })
|
|||
{isLoading && <StyledEuiLoadingSpinner />}
|
||||
<EuiSwitch
|
||||
checked={item.enabled}
|
||||
disabled={!hasSaveUICapabilities || isLoading}
|
||||
disabled={isLoading}
|
||||
showLabel={false}
|
||||
label=""
|
||||
onChange={handleToggleActiveClick}
|
||||
|
|
|
@ -88,7 +88,7 @@ const OsqueryPackUploaderComponent: React.FC<OsqueryPackUploaderProps> = ({ onCh
|
|||
|
||||
if (
|
||||
inputFiles.length &&
|
||||
((!!inputFiles[0].type.length && !SUPPORTED_PACK_EXTENSIONS.includes(inputFiles[0].type)) ||
|
||||
((!!inputFiles[0].type.length && !SUPPORTED_PACK_EXTENSIONS.includes(inputFiles[0].type)) ??
|
||||
!inputFiles[0].name.endsWith('.conf'))
|
||||
) {
|
||||
packName.current = '';
|
||||
|
|
Loading…
Reference in a new issue