title.tsx 736 B

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