-
Notifications
You must be signed in to change notification settings - Fork 8.3k
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
Status filter #128343
Closed
Closed
Status filter #128343
Changes from all commits
Commits
Show all changes
18 commits
Select commit
Hold shift + click to select a range
3a07e12
users with read permissions can not edit/delete/create rules
mgiota 32ff27d
users with read permissions can not change the status
mgiota 22d99c8
Merge branch 'main' of github.com:elastic/kibana into 123585_rules_pa…
mgiota dbeef85
Merge branch 'main' into 123585_rules_page_read_permissions
kibanamachine 882de2e
clean up unused code
mgiota 20607d6
localization for change status aria label
mgiota 237cb23
remove console log
mgiota 2d51427
add muted status
mgiota ca868ba
rename to snoozed
mgiota d87bd1c
remove unused imports
mgiota ab76864
rename snoozed to snoozed permanently
mgiota 316a086
localize statuses
mgiota 1699116
implement no data and no permission screen
mgiota f71fca7
fix prompt filenames
mgiota 4685334
fix i18n error
mgiota f249324
Merge branch 'main' into 123585_rules_page_read_permissions
kibanamachine 4b9937e
change permanently to indefinitely
mgiota 652504e
status filter
mgiota File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
77 changes: 77 additions & 0 deletions
77
x-pack/plugins/observability/public/pages/rules/components/filters/status_filter.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,77 @@ | ||
/* | ||
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one | ||
* or more contributor license agreements. Licensed under the Elastic License | ||
* 2.0; you may not use this file except in compliance with the Elastic License | ||
* 2.0. | ||
*/ | ||
|
||
import React, { useState, useEffect, useMemo } from 'react'; | ||
import { EuiFilterGroup, EuiPopover, EuiFilterButton, EuiFilterSelectItem } from '@elastic/eui'; | ||
import { FormattedMessage } from '@kbn/i18n-react'; | ||
import { RuleStatus } from '../../types'; | ||
import { statusMap } from '../../config'; | ||
|
||
export function StatusFilter({ selectedStatuses, onChange }) { | ||
const [isPopoverOpen, setIsPopoverOpen] = useState<boolean>(false); | ||
const [selectedValues, setSelectedValues] = useState<string[]>(selectedStatuses); | ||
|
||
useEffect(() => { | ||
if (onChange) { | ||
onChange(selectedValues); | ||
} | ||
}, [selectedValues, onChange]); | ||
|
||
useEffect(() => { | ||
setSelectedValues(selectedStatuses); | ||
}, [selectedStatuses]); | ||
|
||
const panelItems = useMemo( | ||
() => | ||
Object.values(RuleStatus).map((status: RuleStatus) => ( | ||
<EuiFilterSelectItem | ||
key={status} | ||
onClick={() => { | ||
const isPreviouslyChecked = selectedValues.includes(status); | ||
if (isPreviouslyChecked) { | ||
setSelectedValues(selectedValues.filter((val) => val !== status)); | ||
} else { | ||
setSelectedValues(selectedValues.concat(status)); | ||
} | ||
}} | ||
checked={selectedValues.includes(status) ? 'on' : undefined} | ||
data-test-subj={`ruleStatus${status}FilterOption`} | ||
> | ||
{statusMap[status].label} | ||
</EuiFilterSelectItem> | ||
)), | ||
[selectedValues] | ||
); | ||
|
||
return ( | ||
<EuiFilterGroup> | ||
<EuiPopover | ||
button={ | ||
<EuiFilterButton | ||
iconType="arrowDown" | ||
hasActiveFilters={selectedValues.length > 0} | ||
numActiveFilters={selectedValues.length} | ||
numFilters={selectedValues.length} | ||
onClick={() => setIsPopoverOpen(!isPopoverOpen)} | ||
data-test-subj="ruleStatusFilterButton" | ||
> | ||
<FormattedMessage | ||
id="xpack.observability.rules.ruleStatusFilterLabel" | ||
defaultMessage="Status" | ||
/> | ||
</EuiFilterButton> | ||
} | ||
closePopover={() => setIsPopoverOpen(false)} | ||
anchorPosition="downLeft" | ||
isOpen={isPopoverOpen} | ||
panelPaddingSize="none" | ||
> | ||
{panelItems} | ||
</EuiPopover> | ||
</EuiFilterGroup> | ||
); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
69 changes: 69 additions & 0 deletions
69
x-pack/plugins/observability/public/pages/rules/components/prompts/no_data_prompt.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,69 @@ | ||
/* | ||
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one | ||
* or more contributor license agreements. Licensed under the Elastic License | ||
* 2.0; you may not use this file except in compliance with the Elastic License | ||
* 2.0. | ||
*/ | ||
|
||
import { FormattedMessage } from '@kbn/i18n-react'; | ||
import React from 'react'; | ||
import { EuiButton, EuiEmptyPrompt, EuiLink, EuiButtonEmpty, EuiPageTemplate } from '@elastic/eui'; | ||
|
||
export function NoDataPrompt({ | ||
onCTAClicked, | ||
documentationLink, | ||
}: { | ||
onCTAClicked: () => void; | ||
documentationLink: string; | ||
}) { | ||
return ( | ||
<EuiPageTemplate | ||
template="centeredContent" | ||
pageContentProps={{ | ||
paddingSize: 'none', | ||
role: null, // For passing a11y tests in EUI docs only | ||
}} | ||
> | ||
<EuiEmptyPrompt | ||
color="plain" | ||
hasBorder={true} | ||
data-test-subj="createFirstRuleEmptyPrompt" | ||
title={ | ||
<h2> | ||
<FormattedMessage | ||
id="xpack.observability.rules.emptyPrompt.emptyTitle" | ||
defaultMessage="Create your first Rule" | ||
/> | ||
</h2> | ||
} | ||
body={ | ||
<p> | ||
<FormattedMessage | ||
id="xpack.observability.rules.noDataPrompt.noDataDesc" | ||
defaultMessage="Rules allow you to receive alerts and automate custom actions when specific conditions are met." | ||
/> | ||
</p> | ||
} | ||
actions={[ | ||
<EuiButton | ||
iconType="plusInCircle" | ||
data-test-subj="createFirstRuleButton" | ||
key="create-action" | ||
fill | ||
onClick={onCTAClicked} | ||
> | ||
<FormattedMessage | ||
id="xpack.observability.rules.emptyPrompt.emptyButton" | ||
defaultMessage="Create Rule" | ||
/> | ||
</EuiButton>, | ||
<EuiButtonEmpty color="primary"> | ||
<EuiLink href={documentationLink} target="_blank"> | ||
Documentation | ||
</EuiLink> | ||
</EuiButtonEmpty>, | ||
]} | ||
/> | ||
</EuiPageTemplate> | ||
); | ||
} |
44 changes: 44 additions & 0 deletions
44
x-pack/plugins/observability/public/pages/rules/components/prompts/no_permission_prompt.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
/* | ||
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one | ||
* or more contributor license agreements. Licensed under the Elastic License | ||
* 2.0; you may not use this file except in compliance with the Elastic License | ||
* 2.0. | ||
*/ | ||
|
||
import { FormattedMessage } from '@kbn/i18n-react'; | ||
import React from 'react'; | ||
import { EuiEmptyPrompt, EuiPageTemplate } from '@elastic/eui'; | ||
|
||
export function NoPermissionPrompt() { | ||
return ( | ||
<EuiPageTemplate | ||
template="centeredContent" | ||
pageContentProps={{ | ||
paddingSize: 'none', | ||
role: null, // For passing a11y tests in EUI docs only | ||
}} | ||
> | ||
<EuiEmptyPrompt | ||
color="plain" | ||
hasBorder={true} | ||
iconType="securityApp" | ||
title={ | ||
<h1> | ||
<FormattedMessage | ||
id="xpack.observability.rules.noPermissionToCreateTitle" | ||
defaultMessage="No permissions to create rules" | ||
/> | ||
</h1> | ||
} | ||
body={ | ||
<p data-test-subj="permissionDeniedMessage"> | ||
<FormattedMessage | ||
id="xpack.observability.rules.noPermissionToCreateDescription" | ||
defaultMessage="Contact your system administrator." | ||
/> | ||
</p> | ||
} | ||
/> | ||
</EuiPageTemplate> | ||
); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I hardcoded here just for testing. ruleStatusFilter at the moment is an array of strings for example ['enabled', 'disabled'], but
alert.attributes.enabled
is a boolean, so these values need to be converted to booleans.With the newly added snoozed status, the logic needs to be changed, that's why I didn't proceed further and hardcoded some boolean value to see it working just for enabled and disabled. This implementation will definitely change.