123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293 |
- import {Fragment} from 'react';
- import styled from '@emotion/styled';
- import TextField from 'sentry/components/forms/fields/textField';
- import FormField from 'sentry/components/forms/formField';
- import ListItem from 'sentry/components/list/listItem';
- import TeamSelector from 'sentry/components/teamSelector';
- import {t} from 'sentry/locale';
- import space from 'sentry/styles/space';
- import {Project, Team} from 'sentry/types';
- type Props = {
- disabled: boolean;
- project: Project;
- };
- export default function RuleNameOwnerForm({disabled, project}: Props) {
- const renderRuleName = () => (
- <StyledTextField
- data-test-id="alert-name"
- disabled={disabled}
- name="name"
- label={null}
- help={null}
- placeholder={t('Enter Alert Name')}
- required
- flexibleControlStateSize
- />
- );
- const renderTeamSelect = () => (
- <StyledFormField
- extraMargin
- name="owner"
- label={null}
- help={null}
- disabled={disabled}
- flexibleControlStateSize
- >
- {({model}) => {
- const owner = model.getValue('owner');
- const ownerId = owner && owner.split(':')[1];
- return (
- <TeamSelector
- value={ownerId}
- project={project}
- onChange={({value}) => model.setValue('owner', value && `team:${value}`)}
- teamFilter={(team: Team) => team.isMember || team.id === ownerId}
- useId
- includeUnassigned
- disabled={disabled}
- />
- );
- }}
- </StyledFormField>
- );
- return (
- <Fragment>
- <StyledListItem>{t('Establish ownership')}</StyledListItem>
- {renderRuleName()}
- {renderTeamSelect()}
- </Fragment>
- );
- }
- const StyledListItem = styled(ListItem)`
- margin: ${space(2)} 0 ${space(1)} 0;
- font-size: ${p => p.theme.fontSizeExtraLarge};
- `;
- const StyledTextField = styled(TextField)`
- border-bottom: none;
- padding: 0;
- & > div {
- padding: 0;
- width: 100%;
- }
- margin-bottom: ${space(1)};
- `;
- const StyledFormField = styled(FormField)<{extraMargin?: boolean}>`
- padding: 0;
- & > div {
- padding: 0;
- width: 100%;
- }
- margin-bottom: ${p => `${p.extraMargin ? '60px' : space(1)}`};
- `;
|