import {useState} from 'react';
import styled from '@emotion/styled';
import {Button} from 'sentry/components/button';
import PanelItem from 'sentry/components/panels/panelItem';
import {IconChevron} from 'sentry/icons/iconChevron';
import {IconRefresh} from 'sentry/icons/iconRefresh';
import {t} from 'sentry/locale';
import {space} from 'sentry/styles/space';
import {CustomRepo, CustomRepoType} from 'sentry/types/debugFiles';
import CustomRepositoryActions from './actions';
import Details from './details';
import Status from './status';
import {customRepoTypeLabel} from './utils';
type Props = {
hasAccess: boolean;
hasFeature: boolean;
onDelete: (repositoryId: string) => void;
onEdit: (repositoryId: string) => void;
onSyncNow: (repositoryId: string) => void;
repository: CustomRepo;
};
function Repository({
repository,
onSyncNow,
onDelete,
onEdit,
hasFeature,
hasAccess,
}: Props) {
const [isDetailsExpanded, setIsDetailsExpanded] = useState(false);
const {id, name, type} = repository;
if (repository.type === CustomRepoType.APP_STORE_CONNECT) {
const authenticated = repository.details?.credentials.status !== 'invalid';
const detailsAvailable = repository.details !== undefined;
return (
detailsAvailable ? setIsDetailsExpanded(!isDetailsExpanded) : undefined
}
direction={isDetailsExpanded ? 'down' : 'up'}
/>
{name}
{customRepoTypeLabel[type]}
onEdit(id)} />
onDelete(id)}
onEdit={() => onEdit(id)}
disabled={repository.details === undefined}
syncNowButton={
}
/>
{isDetailsExpanded && }
);
}
return (
{name}
{customRepoTypeLabel[type]}
onDelete(id)}
onEdit={() => onEdit(id)}
/>
);
}
export default Repository;
const StyledPanelItem = styled(PanelItem)`
display: grid;
align-items: flex-start;
gap: ${space(1)};
grid-template-columns: max-content 1fr;
@media (min-width: ${p => p.theme.breakpoints.small}) {
grid-template-columns: max-content 1fr max-content;
}
`;
const Name = styled('div')`
grid-column: 2/2;
@media (min-width: ${p => p.theme.breakpoints.small}) {
grid-column: 2/3;
grid-row: 1/2;
}
`;
const TypeAndStatus = styled('div')`
color: ${p => p.theme.gray300};
font-size: ${p => p.theme.fontSizeMedium};
display: flex;
flex-wrap: wrap;
align-items: center;
grid-column: 2/2;
gap: ${space(1.5)};
@media (min-width: ${p => p.theme.breakpoints.small}) {
grid-column: 2/3;
grid-row: 2/2;
gap: ${space(1)};
}
`;
const ToggleDetails = styled(IconChevron)`
cursor: pointer;
`;