import {Fragment} from 'react';
import {browserHistory} from 'react-router';
import styled from '@emotion/styled';
import type {Location} from 'history';
import {archiveRelease, restoreRelease} from 'sentry/actionCreators/release';
import {Client} from 'sentry/api';
import ButtonBar from 'sentry/components/buttonBar';
import {openConfirmModal} from 'sentry/components/confirm';
import {DropdownMenu} from 'sentry/components/dropdownMenu';
import ProjectBadge from 'sentry/components/idBadge/projectBadge';
import NavigationButtonGroup from 'sentry/components/navigationButtonGroup';
import TextOverflow from 'sentry/components/textOverflow';
import {Tooltip} from 'sentry/components/tooltip';
import {IconEllipsis} from 'sentry/icons';
import {t, tct, tn} from 'sentry/locale';
import {space} from 'sentry/styles/space';
import type {Organization, Release, ReleaseMeta} from 'sentry/types';
import {trackAnalytics} from 'sentry/utils/analytics';
import {formatVersion} from 'sentry/utils/formatters';
import {normalizeUrl} from 'sentry/utils/withDomainRequired';
import {isReleaseArchived} from '../../utils';
type Props = {
location: Location;
organization: Organization;
projectSlug: string;
refetchData: () => void;
release: Release;
releaseMeta: ReleaseMeta;
};
function ReleaseActions({
location,
organization,
projectSlug,
release,
releaseMeta,
refetchData,
}: Props) {
async function handleArchive() {
try {
await archiveRelease(new Client(), {
orgSlug: organization.slug,
projectSlug,
releaseVersion: release.version,
});
browserHistory.push(normalizeUrl(`/organizations/${organization.slug}/releases/`));
} catch {
// do nothing, action creator is already displaying error message
}
}
async function handleRestore() {
try {
await restoreRelease(new Client(), {
orgSlug: organization.slug,
projectSlug,
releaseVersion: release.version,
});
refetchData();
} catch {
// do nothing, action creator is already displaying error message
}
}
function getProjectList() {
const maxVisibleProjects = 5;
const visibleProjects = releaseMeta.projects.slice(0, maxVisibleProjects);
const numberOfCollapsedProjects =
releaseMeta.projects.length - visibleProjects.length;
return (