import {Fragment} from 'react';
import styled from '@emotion/styled';
import type {Location} from 'history';
import {archiveRelease, restoreRelease} from 'sentry/actionCreators/release';
import {Client} from 'sentry/api';
import {LinkButton} from 'sentry/components/button';
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 TextOverflow from 'sentry/components/textOverflow';
import {Tooltip} from 'sentry/components/tooltip';
import {IconEllipsis, IconNext, IconPrevious} from 'sentry/icons';
import {t, tct, tn} from 'sentry/locale';
import {space} from 'sentry/styles/space';
import type {Organization} from 'sentry/types/organization';
import type {Release, ReleaseMeta} from 'sentry/types/release';
import {trackAnalytics} from 'sentry/utils/analytics';
import {browserHistory} from 'sentry/utils/browserHistory';
import normalizeUrl from 'sentry/utils/url/normalizeUrl';
import {formatVersion} from 'sentry/utils/versions/formatVersion';
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 (