pluginDeprecationAlert.tsx 1.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364
  1. import {Component, Fragment} from 'react';
  2. import styled from '@emotion/styled';
  3. import {Alert} from 'sentry/components/alert';
  4. import {LinkButton} from 'sentry/components/button';
  5. import {t} from 'sentry/locale';
  6. import type {PluginWithProjectList} from 'sentry/types/integrations';
  7. import type {Organization} from 'sentry/types/organization';
  8. import {trackIntegrationAnalytics} from 'sentry/utils/integrationUtil';
  9. type Props = {
  10. organization: Organization;
  11. plugin: PluginWithProjectList;
  12. };
  13. type State = {};
  14. class PluginDeprecationAlert extends Component<Props, State> {
  15. render() {
  16. const {organization, plugin} = this.props;
  17. // Short-circuit if not deprecated.
  18. if (!plugin.deprecationDate) {
  19. return <Fragment />;
  20. }
  21. const resource = plugin.altIsSentryApp ? 'sentry-apps' : 'integrations';
  22. const upgradeUrl = `/settings/${organization.slug}/${resource}/${plugin.firstPartyAlternative}/`;
  23. const queryParams = `?${
  24. plugin.altIsSentryApp ? '' : 'tab=configurations&'
  25. }referrer=directory_upgrade_now`;
  26. return (
  27. <div>
  28. <Alert
  29. type="warning"
  30. showIcon
  31. trailingItems={
  32. <UpgradeNowButton
  33. href={`${upgradeUrl}${queryParams}`}
  34. size="xs"
  35. onClick={() =>
  36. trackIntegrationAnalytics('integrations.resolve_now_clicked', {
  37. integration_type: 'plugin',
  38. integration: plugin.slug,
  39. organization,
  40. })
  41. }
  42. >
  43. {t('Upgrade Now')}
  44. </UpgradeNowButton>
  45. }
  46. >
  47. {`This integration is being deprecated on ${plugin.deprecationDate}. Please upgrade to avoid any disruption.`}
  48. </Alert>
  49. </div>
  50. );
  51. }
  52. }
  53. const UpgradeNowButton = styled(LinkButton)`
  54. color: ${p => p.theme.subText};
  55. float: right;
  56. `;
  57. export default PluginDeprecationAlert;