|
@@ -4,7 +4,7 @@ import {
|
|
addSuccessMessage,
|
|
addSuccessMessage,
|
|
} from 'sentry/actionCreators/indicator';
|
|
} from 'sentry/actionCreators/indicator';
|
|
import {navigateTo} from 'sentry/actionCreators/navigation';
|
|
import {navigateTo} from 'sentry/actionCreators/navigation';
|
|
-import Access from 'sentry/components/acl/access';
|
|
|
|
|
|
+import {hasEveryAccess} from 'sentry/components/acl/access';
|
|
import GuideAnchor from 'sentry/components/assistant/guideAnchor';
|
|
import GuideAnchor from 'sentry/components/assistant/guideAnchor';
|
|
import {Button, ButtonProps} from 'sentry/components/button';
|
|
import {Button, ButtonProps} from 'sentry/components/button';
|
|
import Link from 'sentry/components/links/link';
|
|
import Link from 'sentry/components/links/link';
|
|
@@ -15,6 +15,7 @@ import type {Organization, Project} from 'sentry/types';
|
|
import type EventView from 'sentry/utils/discover/eventView';
|
|
import type EventView from 'sentry/utils/discover/eventView';
|
|
import useApi from 'sentry/utils/useApi';
|
|
import useApi from 'sentry/utils/useApi';
|
|
import useRouter from 'sentry/utils/useRouter';
|
|
import useRouter from 'sentry/utils/useRouter';
|
|
|
|
+import withProjects from 'sentry/utils/withProjects';
|
|
import {
|
|
import {
|
|
AlertType,
|
|
AlertType,
|
|
AlertWizardAlertNames,
|
|
AlertWizardAlertNames,
|
|
@@ -91,6 +92,7 @@ function CreateAlertFromViewButton({
|
|
return (
|
|
return (
|
|
<CreateAlertButton
|
|
<CreateAlertButton
|
|
organization={organization}
|
|
organization={organization}
|
|
|
|
+ projects={projects}
|
|
onClick={handleClick}
|
|
onClick={handleClick}
|
|
to={to}
|
|
to={to}
|
|
aria-label={t('Create Alert')}
|
|
aria-label={t('Create Alert')}
|
|
@@ -101,6 +103,7 @@ function CreateAlertFromViewButton({
|
|
|
|
|
|
type CreateAlertButtonProps = {
|
|
type CreateAlertButtonProps = {
|
|
organization: Organization;
|
|
organization: Organization;
|
|
|
|
+ projects: Project[];
|
|
alertOption?: keyof typeof AlertWizardAlertNames;
|
|
alertOption?: keyof typeof AlertWizardAlertNames;
|
|
hideIcon?: boolean;
|
|
hideIcon?: boolean;
|
|
iconProps?: SVGIconProps;
|
|
iconProps?: SVGIconProps;
|
|
@@ -117,6 +120,7 @@ type CreateAlertButtonProps = {
|
|
|
|
|
|
function CreateAlertButton({
|
|
function CreateAlertButton({
|
|
organization,
|
|
organization,
|
|
|
|
+ projects,
|
|
projectSlug,
|
|
projectSlug,
|
|
iconProps,
|
|
iconProps,
|
|
referrer,
|
|
referrer,
|
|
@@ -191,28 +195,22 @@ function CreateAlertButton({
|
|
);
|
|
);
|
|
|
|
|
|
const showGuide = !organization.alertsMemberWrite && !!showPermissionGuide;
|
|
const showGuide = !organization.alertsMemberWrite && !!showPermissionGuide;
|
|
-
|
|
|
|
- return (
|
|
|
|
- <Access access={['alerts:write']}>
|
|
|
|
- {({hasAccess}) =>
|
|
|
|
- showGuide ? (
|
|
|
|
- <Access access={['org:write']}>
|
|
|
|
- {({hasAccess: isOrgAdmin}) => (
|
|
|
|
- <GuideAnchor
|
|
|
|
- target={isOrgAdmin ? 'alerts_write_owner' : 'alerts_write_member'}
|
|
|
|
- onFinish={isOrgAdmin ? enableAlertsMemberWrite : undefined}
|
|
|
|
- >
|
|
|
|
- {renderButton(hasAccess)}
|
|
|
|
- </GuideAnchor>
|
|
|
|
- )}
|
|
|
|
- </Access>
|
|
|
|
- ) : (
|
|
|
|
- renderButton(hasAccess)
|
|
|
|
- )
|
|
|
|
- }
|
|
|
|
- </Access>
|
|
|
|
|
|
+ const canCreateAlert =
|
|
|
|
+ hasEveryAccess(['alerts:write'], {organization}) ||
|
|
|
|
+ projects.some(p => hasEveryAccess(['alerts:write'], {project: p}));
|
|
|
|
+ const hasOrgWrite = hasEveryAccess(['org:write'], {organization});
|
|
|
|
+
|
|
|
|
+ return showGuide ? (
|
|
|
|
+ <GuideAnchor
|
|
|
|
+ target={hasOrgWrite ? 'alerts_write_owner' : 'alerts_write_member'}
|
|
|
|
+ onFinish={hasOrgWrite ? enableAlertsMemberWrite : undefined}
|
|
|
|
+ >
|
|
|
|
+ {renderButton(canCreateAlert)}
|
|
|
|
+ </GuideAnchor>
|
|
|
|
+ ) : (
|
|
|
|
+ renderButton(canCreateAlert)
|
|
);
|
|
);
|
|
}
|
|
}
|
|
|
|
|
|
export {CreateAlertFromViewButton};
|
|
export {CreateAlertFromViewButton};
|
|
-export default CreateAlertButton;
|
|
|
|
|
|
+export default withProjects(CreateAlertButton);
|