import * as React from 'react'; import {RouteComponentProps} from 'react-router'; import {css} from '@emotion/react'; import styled from '@emotion/styled'; import omit from 'lodash/omit'; import {fetchOrganizationDetails} from 'sentry/actionCreators/organizations'; import DemoModeGate from 'sentry/components/acl/demoModeGate'; import OrganizationAvatar from 'sentry/components/avatar/organizationAvatar'; import UserAvatar from 'sentry/components/avatar/userAvatar'; import ExternalLink from 'sentry/components/links/externalLink'; import Link from 'sentry/components/links/link'; import LoadingIndicator from 'sentry/components/loadingIndicator'; import {Panel, PanelBody, PanelHeader} from 'sentry/components/panels'; import SentryDocumentTitle from 'sentry/components/sentryDocumentTitle'; import {IconDocs, IconLock, IconStack, IconSupport} from 'sentry/icons'; import {t} from 'sentry/locale'; import ConfigStore from 'sentry/stores/configStore'; import overflowEllipsis from 'sentry/styles/overflowEllipsis'; import {Organization} from 'sentry/types'; import withLatestContext from 'sentry/utils/withLatestContext'; import SettingsLayout from 'sentry/views/settings/components/settingsLayout'; const LINKS = { DOCUMENTATION: 'https://docs.sentry.io/', DOCUMENTATION_PLATFORMS: 'https://docs.sentry.io/clients/', DOCUMENTATION_QUICKSTART: 'https://docs.sentry.io/platform-redirect/?next=/', DOCUMENTATION_CLI: 'https://docs.sentry.io/product/cli/', DOCUMENTATION_API: 'https://docs.sentry.io/api/', API: '/settings/account/api/', MANAGE: '/manage/', FORUM: 'https://forum.sentry.io/', GITHUB_ISSUES: 'https://github.com/getsentry/sentry/issues', SERVICE_STATUS: 'https://status.sentry.io/', }; const HOME_ICON_SIZE = 56; const flexCenter = css` display: flex; flex-direction: column; align-items: center; `; type Props = { organization: Organization; } & RouteComponentProps<{}, {}>; class SettingsIndex extends React.Component { componentDidUpdate(prevProps: Props) { const {organization} = this.props; if (prevProps.organization === organization) { return; } // if there is no org in context, SidebarDropdown uses an org from `withLatestContext` // (which queries the org index endpoint instead of org details) // and does not have `access` info if (organization && typeof organization.access === 'undefined') { fetchOrganizationDetails(organization.slug, { setActive: true, loadProjects: true, }); } } render() { const {organization} = this.props; const user = ConfigStore.get('user'); const isOnPremise = ConfigStore.get('isOnPremise'); const organizationSettingsUrl = (organization && `/settings/${organization.slug}/`) || ''; const supportLinkProps = { isOnPremise, href: LINKS.FORUM, to: `${organizationSettingsUrl}support`, }; const supportText = isOnPremise ? t('Community Forums') : t('Contact Support'); return ( {t('My Account')}

{t('Quick links')}:

  • {t('Change my password')}
  • {t('Notification Preferences')}
  • {t('Change my avatar')}
{/* if admin */} {!organization && } {organization ? ( ) : ( )} {organization ? organization.slug : t('No Organization')}

{t('Quick links')}:

  • {t('Projects')}
  • {t('Teams')}
  • {t('Members')}
{t('Documentation')}

{t('Quick links')}:

  • {t('Quickstart Guide')}
  • {t('Platforms & Frameworks')}
  • {t('Sentry CLI')}
{t('Support')}

{t('Quick links')}:

  • {supportText}
  • {t('Sentry on GitHub')}
  • {t('Service Status')}
{t('API Keys')}

{t('Quick links')}:

  • {t('Auth Tokens')}
  • {t('Your Integrations')}
  • {t('Documentation')}
); } } export {SettingsIndex}; export default withLatestContext(SettingsIndex); const HomePanelHeader = styled(PanelHeader)` background: ${p => p.theme.background}; flex-direction: column; text-align: center; justify-content: center; font-size: 18px; text-transform: unset; padding: 35px 30px; `; const HomePanelBody = styled(PanelBody)` padding: 30px; h3 { font-size: 14px; } ul { margin: 0; li { line-height: 1.6; /* Bullet color */ color: ${p => p.theme.gray200}; } } `; const HomeIcon = styled('div')<{color?: string}>` background: ${p => p.theme[p.color || 'gray300']}; color: ${p => p.theme.white}; width: ${HOME_ICON_SIZE}px; height: ${HOME_ICON_SIZE}px; border-radius: ${HOME_ICON_SIZE}px; display: flex; justify-content: center; align-items: center; margin-bottom: 20px; `; const HomeLink = styled(Link)` color: ${p => p.theme.purple300}; &:hover { color: ${p => p.theme.purple300}; } `; const HomeLinkIcon = styled(HomeLink)` overflow: hidden; width: 100%; ${flexCenter}; `; type CenterableProps = { isCentered?: boolean; }; const ExternalHomeLink = styled( (props: CenterableProps & React.ComponentPropsWithRef) => ( ) )` color: ${p => p.theme.purple300}; &:hover { color: ${p => p.theme.purple300}; } ${p => p.isCentered && flexCenter}; `; type SupportLinkProps = { isOnPremise: T; href: string; to: string; isCentered?: boolean; } & React.ComponentPropsWithoutRef< T extends true ? typeof ExternalLink : typeof HomeLink >; const SupportLinkComponent = ({ isCentered, isOnPremise, href, to, ...props }: SupportLinkProps) => isOnPremise ? ( ) : ( ); const AvatarContainer = styled('div')` margin-bottom: 20px; `; const OrganizationName = styled('div')` line-height: 1.1em; ${overflowEllipsis}; `; const GridLayout = styled('div')` display: grid; grid-template-columns: 1fr 1fr 1fr; grid-gap: 16px; `; const GridPanel = styled(Panel)` margin-bottom: 0; `;