edit.tsx 925 B

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  1. import {t} from 'sentry/locale';
  2. import type {Relay} from 'sentry/types/relay';
  3. import ModalManager from './modalManager';
  4. type Props = {
  5. relay: Relay;
  6. } & ModalManager['props'];
  7. type State = ModalManager['state'];
  8. class Edit extends ModalManager<Props, State> {
  9. getDefaultState() {
  10. return {
  11. ...super.getDefaultState(),
  12. values: {
  13. name: this.props.relay.name,
  14. publicKey: this.props.relay.publicKey,
  15. description: this.props.relay.description || '',
  16. },
  17. disables: {publicKey: true},
  18. };
  19. }
  20. getTitle() {
  21. return t('Edit Key');
  22. }
  23. getData() {
  24. const {savedRelays} = this.props;
  25. const updatedRelay = this.state.values;
  26. const trustedRelays = savedRelays.map(relay => {
  27. if (relay.publicKey === updatedRelay.publicKey) {
  28. return updatedRelay;
  29. }
  30. return relay;
  31. });
  32. return {trustedRelays};
  33. }
  34. }
  35. export default Edit;