organizationSelectHeader.tsx 1.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  1. import styled from '@emotion/styled';
  2. import SelectControl from 'sentry/components/forms/controls/selectControl';
  3. import {t} from 'sentry/locale';
  4. import {space} from 'sentry/styles/space';
  5. import {Organization} from 'sentry/types';
  6. type OrganizationSelectHeaderProps = {
  7. handleOrgChange: (orgId: string) => void;
  8. organizationId: string | undefined;
  9. organizations: Organization[];
  10. };
  11. export function OrganizationSelectHeader({
  12. handleOrgChange,
  13. organizationId,
  14. organizations,
  15. }: OrganizationSelectHeaderProps) {
  16. return (
  17. <OrgControlWrapper>
  18. {t('Settings for Organization')}
  19. <StyledSelectControl
  20. options={organizations.map(org => {
  21. return {
  22. label: org.name,
  23. value: org.id,
  24. };
  25. })}
  26. onChange={option => handleOrgChange(option.value)}
  27. value={organizationId}
  28. styles={{
  29. container: (provided: Record<string, string>) => ({
  30. ...provided,
  31. minWidth: `200px`,
  32. }),
  33. }}
  34. />
  35. </OrgControlWrapper>
  36. );
  37. }
  38. // Resetting styles because its in a panel header
  39. const StyledSelectControl = styled(SelectControl)`
  40. text-transform: initial;
  41. font-weight: normal;
  42. `;
  43. const OrgControlWrapper = styled('div')`
  44. display: flex;
  45. align-items: center;
  46. gap: ${space(1)};
  47. flex-grow: 1;
  48. `;