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 = () => (
);
const renderTeamSelect = () => (
{({model}) => {
const owner = model.getValue('owner');
const ownerId = owner && owner.split(':')[1];
return (
model.setValue('owner', value && `team:${value}`)}
teamFilter={(team: Team) =>
team.isMember || team.id === ownerId || team.access.includes('team:admin')
}
useId
includeUnassigned
disabled={disabled}
/>
);
}}
);
return (
{t('Establish ownership')}
{renderRuleName()}
{renderTeamSelect()}
);
}
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)}`};
`;