title.tsx 806 B

1234567891011121314151617181920212223242526272829303132
  1. import {Fragment} from 'react';
  2. import EditableText from 'sentry/components/editableText';
  3. import {t} from 'sentry/locale';
  4. import {DashboardDetails} from './types';
  5. type Props = {
  6. dashboard: DashboardDetails | null;
  7. isEditingDashboard: boolean;
  8. onUpdate: (dashboard: DashboardDetails) => void;
  9. };
  10. function DashboardTitle({dashboard, isEditingDashboard, onUpdate}: Props) {
  11. return (
  12. <Fragment>
  13. {!dashboard ? (
  14. t('Dashboards')
  15. ) : (
  16. <EditableText
  17. isDisabled={!isEditingDashboard}
  18. value={dashboard.title}
  19. onChange={newTitle => onUpdate({...dashboard, title: newTitle})}
  20. errorMessage={t('Please set a title for this dashboard')}
  21. autoSelect
  22. />
  23. )}
  24. </Fragment>
  25. );
  26. }
  27. export default DashboardTitle;