Skip to content

Commit

Permalink
[Observability] [Cases] Cases in the observability app (elastic#101487)
Browse files Browse the repository at this point in the history
  • Loading branch information
stephmilovic committed Jun 10, 2021
1 parent d0188d6 commit 9d7af06
Show file tree
Hide file tree
Showing 82 changed files with 2,949 additions and 206 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -148,6 +148,7 @@ export const applicationUsageSchema = {
maps: commonSchema,
ml: commonSchema,
monitoring: commonSchema,
observabilityCases: commonSchema,
'observability-overview': commonSchema,
osquery: commonSchema,
security_account: commonSchema,
Expand Down
131 changes: 131 additions & 0 deletions src/plugins/telemetry/schema/oss_plugins.json
Original file line number Diff line number Diff line change
Expand Up @@ -3970,6 +3970,137 @@
}
}
},
"observabilityCases": {
"properties": {
"appId": {
"type": "keyword",
"_meta": {
"description": "The application being tracked"
}
},
"viewId": {
"type": "keyword",
"_meta": {
"description": "Always `main`"
}
},
"clicks_total": {
"type": "long",
"_meta": {
"description": "General number of clicks in the application since we started counting them"
}
},
"clicks_7_days": {
"type": "long",
"_meta": {
"description": "General number of clicks in the application over the last 7 days"
}
},
"clicks_30_days": {
"type": "long",
"_meta": {
"description": "General number of clicks in the application over the last 30 days"
}
},
"clicks_90_days": {
"type": "long",
"_meta": {
"description": "General number of clicks in the application over the last 90 days"
}
},
"minutes_on_screen_total": {
"type": "float",
"_meta": {
"description": "Minutes the application is active and on-screen since we started counting them."
}
},
"minutes_on_screen_7_days": {
"type": "float",
"_meta": {
"description": "Minutes the application is active and on-screen over the last 7 days"
}
},
"minutes_on_screen_30_days": {
"type": "float",
"_meta": {
"description": "Minutes the application is active and on-screen over the last 30 days"
}
},
"minutes_on_screen_90_days": {
"type": "float",
"_meta": {
"description": "Minutes the application is active and on-screen over the last 90 days"
}
},
"views": {
"type": "array",
"items": {
"properties": {
"appId": {
"type": "keyword",
"_meta": {
"description": "The application being tracked"
}
},
"viewId": {
"type": "keyword",
"_meta": {
"description": "The application view being tracked"
}
},
"clicks_total": {
"type": "long",
"_meta": {
"description": "General number of clicks in the application sub view since we started counting them"
}
},
"clicks_7_days": {
"type": "long",
"_meta": {
"description": "General number of clicks in the active application sub view over the last 7 days"
}
},
"clicks_30_days": {
"type": "long",
"_meta": {
"description": "General number of clicks in the active application sub view over the last 30 days"
}
},
"clicks_90_days": {
"type": "long",
"_meta": {
"description": "General number of clicks in the active application sub view over the last 90 days"
}
},
"minutes_on_screen_total": {
"type": "float",
"_meta": {
"description": "Minutes the application sub view is active and on-screen since we started counting them."
}
},
"minutes_on_screen_7_days": {
"type": "float",
"_meta": {
"description": "Minutes the application is active and on-screen active application sub view over the last 7 days"
}
},
"minutes_on_screen_30_days": {
"type": "float",
"_meta": {
"description": "Minutes the application is active and on-screen active application sub view over the last 30 days"
}
},
"minutes_on_screen_90_days": {
"type": "float",
"_meta": {
"description": "Minutes the application is active and on-screen active application sub view over the last 90 days"
}
}
}
}
}
}
},
"observability-overview": {
"properties": {
"appId": {
Expand Down
3 changes: 3 additions & 0 deletions test/functional/config.js
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,9 @@ export default async function ({ readConfigFile }) {
pathname: '/app/home',
hash: '/',
},
observabilityCases: {
pathname: '/app/observability/cases',
},
},
junit: {
reportName: 'Chrome UI Functional Tests',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -62,9 +62,11 @@ interface AllCasesGenericProps {
caseDetailsNavigation?: CasesNavigation<CaseDetailsHrefSchema, 'configurable'>; // if not passed, case name is not displayed as a link (Formerly dependant on isSelectorView)
configureCasesNavigation?: CasesNavigation; // if not passed, header with nav is not displayed (Formerly dependant on isSelectorView)
createCaseNavigation: CasesNavigation;
disableAlerts?: boolean;
hiddenStatuses?: CaseStatusWithAllStatus[];
isSelectorView?: boolean;
onRowClick?: (theCase?: Case | SubCase) => void;
showTitle?: boolean;
updateCase?: (newCase: Case) => void;
userCanCrud: boolean;
}
Expand All @@ -75,9 +77,11 @@ export const AllCasesGeneric = React.memo<AllCasesGenericProps>(
caseDetailsNavigation,
configureCasesNavigation,
createCaseNavigation,
disableAlerts,
hiddenStatuses = [],
isSelectorView,
onRowClick,
showTitle,
updateCase,
userCanCrud,
}) => {
Expand Down Expand Up @@ -190,6 +194,7 @@ export const AllCasesGeneric = React.memo<AllCasesGenericProps>(

const columns = useCasesColumns({
caseDetailsNavigation,
disableAlerts,
dispatchUpdateCaseProperty,
filterStatus: filterOptions.status,
handleIsLoading,
Expand Down Expand Up @@ -271,6 +276,7 @@ export const AllCasesGeneric = React.memo<AllCasesGenericProps>(
createCaseNavigation={createCaseNavigation}
configureCasesNavigation={configureCasesNavigation}
refresh={refresh}
showTitle={showTitle}
userCanCrud={userCanCrud}
/>
)}
Expand Down
24 changes: 15 additions & 9 deletions x-pack/plugins/cases/public/components/all_cases/columns.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ const renderStringField = (field: string, dataTestSubj: string) =>

export interface GetCasesColumn {
caseDetailsNavigation?: CasesNavigation<CaseDetailsHrefSchema, 'configurable'>;
disableAlerts?: boolean;
dispatchUpdateCaseProperty: (u: UpdateCase) => void;
filterStatus: string;
handleIsLoading: (a: boolean) => void;
Expand All @@ -64,6 +65,7 @@ export interface GetCasesColumn {
}
export const useCasesColumns = ({
caseDetailsNavigation,
disableAlerts = false,
dispatchUpdateCaseProperty,
filterStatus,
handleIsLoading,
Expand Down Expand Up @@ -203,15 +205,19 @@ export const useCasesColumns = ({
},
truncateText: true,
},
{
align: RIGHT_ALIGNMENT,
field: 'totalAlerts',
name: ALERTS,
render: (totalAlerts: Case['totalAlerts']) =>
totalAlerts != null
? renderStringField(`${totalAlerts}`, `case-table-column-alertsCount`)
: getEmptyTagValue(),
},
...(!disableAlerts
? [
{
align: RIGHT_ALIGNMENT,
field: 'totalAlerts',
name: ALERTS,
render: (totalAlerts: Case['totalAlerts']) =>
totalAlerts != null
? renderStringField(`${totalAlerts}`, `case-table-column-alertsCount`)
: getEmptyTagValue(),
},
]
: []),
{
align: RIGHT_ALIGNMENT,
field: 'totalComment',
Expand Down
4 changes: 3 additions & 1 deletion x-pack/plugins/cases/public/components/all_cases/header.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ interface OwnProps {
configureCasesNavigation: CasesNavigation;
createCaseNavigation: CasesNavigation;
refresh: number;
showTitle?: boolean;
userCanCrud: boolean;
}

Expand All @@ -40,9 +41,10 @@ export const CasesTableHeader: FunctionComponent<Props> = ({
configureCasesNavigation,
createCaseNavigation,
refresh,
showTitle = true,
userCanCrud,
}) => (
<CaseHeaderPage title={i18n.PAGE_TITLE}>
<CaseHeaderPage title={showTitle ? i18n.PAGE_TITLE : ''}>
<EuiFlexGroup
alignItems="center"
gutterSize="m"
Expand Down
2 changes: 2 additions & 0 deletions x-pack/plugins/cases/public/components/all_cases/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@ export interface AllCasesProps extends Owner {
caseDetailsNavigation: CasesNavigation<CaseDetailsHrefSchema, 'configurable'>; // if not passed, case name is not displayed as a link (Formerly dependant on isSelector)
configureCasesNavigation: CasesNavigation; // if not passed, header with nav is not displayed (Formerly dependant on isSelector)
createCaseNavigation: CasesNavigation;
disableAlerts?: boolean;
showTitle?: boolean;
userCanCrud: boolean;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ describe('Callout', () => {
});

it('dismiss the callout correctly', () => {
const wrapper = mount(<CallOut {...defaultProps} messages={[]} />);
const wrapper = mount(<CallOut {...defaultProps} />);
expect(wrapper.find(`[data-test-subj="callout-dismiss-md5-hex"]`).exists()).toBeTruthy();
wrapper.find(`button[data-test-subj="callout-dismiss-md5-hex"]`).simulate('click');
wrapper.update();
Expand Down
6 changes: 2 additions & 4 deletions x-pack/plugins/cases/public/components/callout/callout.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -35,11 +35,9 @@ const CallOutComponent = ({
type,
]);

return showCallOut ? (
return showCallOut && !isEmpty(messages) ? (
<EuiCallOut title={title} color={type} iconType="gear" data-test-subj={`case-callout-${id}`}>
{!isEmpty(messages) && (
<EuiDescriptionList data-test-subj={`callout-messages-${id}`} listItems={messages} />
)}
<EuiDescriptionList data-test-subj={`callout-messages-${id}`} listItems={messages} />
<EuiButton
data-test-subj={`callout-dismiss-${id}`}
color={type === 'success' ? 'secondary' : type}
Expand Down
2 changes: 1 addition & 1 deletion x-pack/plugins/cases/public/components/callout/helpers.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import md5 from 'md5';
import * as i18n from './translations';
import { ErrorMessage } from './types';

export const savedObjectReadOnlyErrorMessage: ErrorMessage = {
export const permissionsReadOnlyErrorMessage: ErrorMessage = {
id: 'read-only-privileges-error',
title: i18n.READ_ONLY_FEATURE_TITLE,
description: <>{i18n.READ_ONLY_FEATURE_MSG}</>,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,14 @@ jest.mock('react-router-dom', () => {
}),
};
});

const defaultProps = {
allCasesNavigation: {
href: 'all-cases-href',
onClick: () => {},
},
caseData: basicCase,
currentExternalIncident: null,
};
describe('CaseView actions', () => {
const handleOnDeleteConfirm = jest.fn();
const handleToggleModal = jest.fn();
Expand All @@ -49,7 +56,7 @@ describe('CaseView actions', () => {
it('clicking trash toggles modal', () => {
const wrapper = mount(
<TestProviders>
<Actions caseData={basicCase} currentExternalIncident={null} />
<Actions {...defaultProps} />
</TestProviders>
);

Expand All @@ -67,7 +74,7 @@ describe('CaseView actions', () => {
}));
const wrapper = mount(
<TestProviders>
<Actions caseData={basicCase} currentExternalIncident={null} />
<Actions {...defaultProps} />
</TestProviders>
);

Expand All @@ -82,7 +89,7 @@ describe('CaseView actions', () => {
const wrapper = mount(
<TestProviders>
<Actions
caseData={basicCase}
{...defaultProps}
currentExternalIncident={{
...basicPush,
firstPushIndex: 5,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,26 +7,27 @@

import { isEmpty } from 'lodash/fp';
import React, { useMemo } from 'react';
import { useHistory } from 'react-router-dom';
import * as i18n from '../case_view/translations';
import { useDeleteCases } from '../../containers/use_delete_cases';
import { ConfirmDeleteCaseModal } from '../confirm_delete_case';
import { PropertyActions } from '../property_actions';
import { Case } from '../../containers/types';
import { Case } from '../../../common';
import { CaseService } from '../../containers/use_get_case_user_actions';
import { CasesNavigation } from '../links';

interface CaseViewActions {
allCasesNavigation: CasesNavigation;
caseData: Case;
currentExternalIncident: CaseService | null;
disabled?: boolean;
}

const ActionsComponent: React.FC<CaseViewActions> = ({
allCasesNavigation,
caseData,
currentExternalIncident,
disabled = false,
}) => {
const history = useHistory();
// Delete case
const {
handleToggleModal,
Expand Down Expand Up @@ -57,7 +58,7 @@ const ActionsComponent: React.FC<CaseViewActions> = ({
);

if (isDeleted) {
history.push('/');
allCasesNavigation.onClick(null);
return null;
}
return (
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,12 @@ describe('CaseActionBar', () => {
const onRefresh = jest.fn();
const onUpdateField = jest.fn();
const defaultProps = {
allCasesNavigation: {
href: 'all-cases-href',
onClick: () => {},
},
caseData: basicCase,
disableAlerting: false,
isLoading: false,
onRefresh,
onUpdateField,
Expand Down
Loading

0 comments on commit 9d7af06

Please sign in to comment.