-
-
Notifications
You must be signed in to change notification settings - Fork 4.8k
feat(ui): Add basic templates for Incident Rules in settings #14112
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
Merged
billyvg
merged 3 commits into
master
from
feat/ui/incident-rules/add-basic-views-and-routes
Jul 23, 2019
Merged
Changes from all commits
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
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 hidden or 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
10 changes: 10 additions & 0 deletions
10
src/sentry/static/sentry/app/components/charts/components/graphic.jsx
This file contains hidden or 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,10 @@ | ||
| import 'echarts/lib/component/graphic'; | ||
|
|
||
| /** | ||
| * eCharts graphic | ||
| * | ||
| * See https://echarts.apache.org/en/option.html#graphic | ||
| */ | ||
| export default function Graphic(props) { | ||
| return props; | ||
| } |
This file contains hidden or 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 hidden or 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
97 changes: 97 additions & 0 deletions
97
src/sentry/static/sentry/app/views/settings/organizationIncidentRules/create.jsx
This file contains hidden or 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,97 @@ | ||
| import PropTypes from 'prop-types'; | ||
| import React from 'react'; | ||
|
|
||
| import {t} from 'app/locale'; | ||
| import Form from 'app/views/settings/components/forms/form'; | ||
| import Graphic from 'app/components/charts/components/graphic'; | ||
| import JsonForm from 'app/views/settings/components/forms/jsonForm'; | ||
| import LineChart from 'app/components/charts/lineChart'; | ||
| import SettingsPageHeader from 'app/views/settings/components/settingsPageHeader'; | ||
|
|
||
| class IncidentRulesCreate extends React.Component { | ||
| static propTypes = { | ||
| data: PropTypes.array, | ||
| }; | ||
|
|
||
| static defaultProps = { | ||
| data: [], | ||
| }; | ||
|
|
||
| state = { | ||
| width: null, | ||
| }; | ||
|
|
||
| render() { | ||
| const {orgId} = this.props.params; | ||
|
|
||
| return ( | ||
| <div> | ||
| <SettingsPageHeader title={t('New Incident Rule')} /> | ||
| <LineChart | ||
| isGroupedByDate | ||
| forwardedRef={e => { | ||
| if (e && typeof e.getEchartsInstance === 'function') { | ||
| const width = e.getEchartsInstance().getWidth(); | ||
| if (width !== this.state.width) { | ||
| this.setState({width}); | ||
| } | ||
| } | ||
| }} | ||
| graphic={Graphic({ | ||
| elements: [ | ||
| { | ||
| type: 'line', | ||
| draggable: true, | ||
| shape: {y1: 1, y2: 1, x1: 0, x2: this.state.width}, | ||
| ondrag: () => {}, | ||
| }, | ||
| ], | ||
| })} | ||
| series={this.props.data} | ||
| /> | ||
| <Form | ||
| apiMethod="POST" | ||
| apiEndpoint={`/organizations/${orgId}/incident-rules/`} | ||
| initialData={{}} | ||
| saveOnBlur={false} | ||
| > | ||
| <JsonForm | ||
| forms={[ | ||
| { | ||
| title: t('Metric'), | ||
| fields: [ | ||
| { | ||
| label: t('Metric'), | ||
| name: 'metric', | ||
| type: 'select', | ||
| help: t('Choose which metric to display on the Y-axis'), | ||
| choices: [['users', 'Users Affected']], | ||
| }, | ||
| { | ||
| label: t('Upper Bound'), | ||
| name: 'upper', | ||
| type: 'range', | ||
| help: t( | ||
| 'Anything trending above this limit will trigger an incident' | ||
| ), | ||
| }, | ||
| { | ||
| label: t('Lower Bound'), | ||
| name: 'lower', | ||
| type: 'range', | ||
| help: t( | ||
| 'Anything trending below this limit will trigger an incident' | ||
| ), | ||
| }, | ||
| ], | ||
| required: true, | ||
| }, | ||
| ]} | ||
| /> | ||
| </Form> | ||
| </div> | ||
| ); | ||
| } | ||
| } | ||
|
|
||
| export default IncidentRulesCreate; | ||
34 changes: 34 additions & 0 deletions
34
src/sentry/static/sentry/app/views/settings/organizationIncidentRules/details.jsx
This file contains hidden or 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,34 @@ | ||
| import React from 'react'; | ||
|
|
||
| import AsyncView from 'app/views/asyncView'; | ||
| import {Panel, PanelBody, PanelHeader} from 'app/components/panels'; | ||
| import SentryTypes from 'app/sentryTypes'; | ||
| import SettingsPageHeader from 'app/views/settings/components/settingsPageHeader'; | ||
| import {t} from 'app/locale'; | ||
|
|
||
| class IncidentRulesDetails extends AsyncView { | ||
| static propTypes = { | ||
| organization: SentryTypes.Organization.isRequired, | ||
| }; | ||
|
|
||
| getEndpoints() { | ||
| return []; | ||
| // const {orgId, incidentRuleId} = this.props.params; | ||
|
|
||
| // return [['rule', `/organizations/${orgId}/incident-rules/${ incidentRuleId }/`]]; | ||
| } | ||
|
|
||
| renderBody() { | ||
| return ( | ||
| <div> | ||
| <SettingsPageHeader title={t('Incident Rule')} /> | ||
| <Panel> | ||
| <PanelHeader>{t('Rule')}</PanelHeader> | ||
| <PanelBody>TODO</PanelBody> | ||
| </Panel> | ||
| </div> | ||
| ); | ||
| } | ||
| } | ||
|
|
||
| export default IncidentRulesDetails; |
11 changes: 11 additions & 0 deletions
11
src/sentry/static/sentry/app/views/settings/organizationIncidentRules/index.jsx
This file contains hidden or 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,11 @@ | ||
| import React from 'react'; | ||
|
|
||
| import Feature from 'app/components/acl/feature'; | ||
|
|
||
| export default function OrganizationIncidentRules({children}) { | ||
| return ( | ||
| <Feature features={['incidents']} renderDisabled> | ||
| {children} | ||
| </Feature> | ||
| ); | ||
| } |
54 changes: 54 additions & 0 deletions
54
src/sentry/static/sentry/app/views/settings/organizationIncidentRules/list.jsx
This file contains hidden or 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,54 @@ | ||
| import React from 'react'; | ||
|
|
||
| import AsyncView from 'app/views/asyncView'; | ||
| import Button from 'app/components/button'; | ||
| import EmptyMessage from 'app/views/settings/components/emptyMessage'; | ||
| import {Panel, PanelBody, PanelHeader} from 'app/components/panels'; | ||
| import SentryTypes from 'app/sentryTypes'; | ||
| import SettingsPageHeader from 'app/views/settings/components/settingsPageHeader'; | ||
| import {t} from 'app/locale'; | ||
|
|
||
| class IncidentRulesList extends AsyncView { | ||
| static propTypes = { | ||
| organization: SentryTypes.Organization.isRequired, | ||
| }; | ||
|
|
||
| getEndpoints() { | ||
| return []; | ||
| // const {orgId} = this.props.params; | ||
|
|
||
| // return [['rules', `/organizations/${orgId}/incident-rules/`]]; | ||
| } | ||
|
|
||
| renderBody() { | ||
| const {orgId} = this.props.params; | ||
| const action = ( | ||
| <Button | ||
| priority="primary" | ||
| size="small" | ||
| to={`/settings/${orgId}/incident-rules/new/`} | ||
| icon="icon-circle-add" | ||
| > | ||
| {t('Create New Rule')} | ||
| </Button> | ||
| ); | ||
|
|
||
| const isEmpty = true; | ||
|
|
||
| return ( | ||
| <div> | ||
| <SettingsPageHeader title={t('Incident Rules')} action={action} /> | ||
| <Panel> | ||
| <PanelHeader>{t('Rules')}</PanelHeader> | ||
| <PanelBody> | ||
| {!isEmpty ? null : ( | ||
| <EmptyMessage>{t('No Incident rules have been created yet.')}</EmptyMessage> | ||
| )} | ||
| </PanelBody> | ||
| </Panel> | ||
| </div> | ||
| ); | ||
| } | ||
| } | ||
|
|
||
| export default IncidentRulesList; |
18 changes: 18 additions & 0 deletions
18
tests/js/spec/views/settings/organizationIncidentRules/create.spec.jsx
This file contains hidden or 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,18 @@ | ||
| import {mount} from 'enzyme'; | ||
| import React from 'react'; | ||
|
|
||
| import {initializeOrg} from 'app-test/helpers/initializeOrg'; | ||
| import IncidentRulesCreate from 'app/views/settings/organizationIncidentRules/create'; | ||
|
|
||
| describe('Incident Rules Create', function() { | ||
| it('renders', function() { | ||
| const {organization, routerContext} = initializeOrg(); | ||
| mount( | ||
| <IncidentRulesCreate | ||
| params={{orgId: organization.slug}} | ||
| organization={organization} | ||
| />, | ||
| routerContext | ||
| ); | ||
| }); | ||
| }); |
18 changes: 18 additions & 0 deletions
18
tests/js/spec/views/settings/organizationIncidentRules/details.spec.jsx
This file contains hidden or 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,18 @@ | ||
| import {mount} from 'enzyme'; | ||
| import React from 'react'; | ||
|
|
||
| import {initializeOrg} from 'app-test/helpers/initializeOrg'; | ||
| import IncidentRulesDetails from 'app/views/settings/organizationIncidentRules/details'; | ||
|
|
||
| describe('Incident Rules Details', function() { | ||
| it('renders', function() { | ||
| const {organization, routerContext} = initializeOrg(); | ||
| mount( | ||
| <IncidentRulesDetails | ||
| params={{orgId: organization.slug}} | ||
| organization={organization} | ||
| />, | ||
| routerContext | ||
| ); | ||
| }); | ||
| }); |
18 changes: 18 additions & 0 deletions
18
tests/js/spec/views/settings/organizationIncidentRules/list.spec.jsx
This file contains hidden or 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,18 @@ | ||
| import {mount} from 'enzyme'; | ||
| import React from 'react'; | ||
|
|
||
| import {initializeOrg} from 'app-test/helpers/initializeOrg'; | ||
| import IncidentRulesList from 'app/views/settings/organizationIncidentRules/list'; | ||
|
|
||
| describe('Incident Rules List', function() { | ||
| it('renders', function() { | ||
| const {organization, routerContext} = initializeOrg(); | ||
| mount( | ||
| <IncidentRulesList | ||
| params={{orgId: organization.slug}} | ||
| organization={organization} | ||
| />, | ||
| routerContext | ||
| ); | ||
| }); | ||
| }); |
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.
What happens if you never get an echarts object?
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.
It should only happen in tests