forked from grafana/grafana
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Alerting: Reorder new alert and export buttons (grafana#68418)
* Add component for rule creation and dropdown * Make each route type have a different path * Remove unneeded import * Fix tests * Rename CreateRuleButton to MoreActionRuleButtons * Remove Recording Rule option from new rule form * Use alerting and recording for path params on new rules * Fix tests * Only show new button if permissions are granted * Fix tests
- Loading branch information
Showing
13 changed files
with
135 additions
and
64 deletions.
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
59 changes: 59 additions & 0 deletions
59
public/app/features/alerting/unified/MoreActionsRuleButtons.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,59 @@ | ||
import React from 'react'; | ||
import { useLocation } from 'react-router-dom'; | ||
|
||
import { urlUtil } from '@grafana/data'; | ||
import { Button, Dropdown, Icon, LinkButton, Menu, MenuItem } from '@grafana/ui'; | ||
|
||
import { logInfo, LogMessages } from './Analytics'; | ||
import { useRulesAccess } from './utils/accessControlHooks'; | ||
import { createUrl } from './utils/url'; | ||
|
||
interface Props {} | ||
|
||
export function MoreActionsRuleButtons({}: Props) { | ||
const { canCreateGrafanaRules, canCreateCloudRules, canReadProvisioning } = useRulesAccess(); | ||
const location = useLocation(); | ||
const newMenu = ( | ||
<Menu> | ||
{(canCreateGrafanaRules || canCreateCloudRules) && ( | ||
<MenuItem | ||
url={urlUtil.renderUrl(`alerting/new/recording`, { | ||
returnTo: location.pathname + location.search, | ||
})} | ||
label="New recording rule" | ||
/> | ||
)} | ||
{canReadProvisioning && ( | ||
<MenuItem | ||
url={createUrl('/api/v1/provisioning/alert-rules/export', { | ||
download: 'true', | ||
format: 'yaml', | ||
})} | ||
label="Export all" | ||
target="_blank" | ||
/> | ||
)} | ||
</Menu> | ||
); | ||
|
||
return ( | ||
<> | ||
{(canCreateGrafanaRules || canCreateCloudRules) && ( | ||
<LinkButton | ||
href={urlUtil.renderUrl('alerting/new/alerting', { returnTo: location.pathname + location.search })} | ||
icon="plus" | ||
onClick={() => logInfo(LogMessages.alertRuleFromScratch)} | ||
> | ||
New alert rule | ||
</LinkButton> | ||
)} | ||
|
||
<Dropdown overlay={newMenu}> | ||
<Button variant="secondary"> | ||
More | ||
<Icon name="angle-down" /> | ||
</Button> | ||
</Dropdown> | ||
</> | ||
); | ||
} |
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
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
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
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
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.