shareIssue.stories.js 1.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566
  1. import {Component} from 'react';
  2. import {action} from '@storybook/addon-actions';
  3. import ShareIssue from 'sentry/views/organizationGroupDetails/actions/shareIssue';
  4. export default {
  5. title: 'Features/Issues/Share Issue',
  6. component: ShareIssue,
  7. args: {
  8. shareUrl: 'https://sentry.io/share/issue/thisisanexampleshareurl/',
  9. },
  10. argTypes: {
  11. onReshare: {action: 'onReshare'},
  12. loading: {
  13. table: {
  14. disable: true,
  15. },
  16. },
  17. onToggle: {
  18. table: {
  19. disable: true,
  20. },
  21. },
  22. isShared: {
  23. table: {
  24. disable: true,
  25. },
  26. },
  27. },
  28. };
  29. class ShareSimulator extends Component {
  30. state = {isShared: false, loading: false};
  31. toggleAction = action('Toggle');
  32. toggleShare() {
  33. this.toggleAction();
  34. this.setState({loading: true});
  35. // Simulate loading
  36. setTimeout(() => {
  37. this.setState(state => ({loading: false, isShared: !state.isShared}));
  38. }, 1000);
  39. }
  40. render() {
  41. return this.props.children({...this.state, toggleShare: () => this.toggleShare()});
  42. }
  43. }
  44. export const Default = ({...args}) => {
  45. return (
  46. <ShareSimulator>
  47. {({isShared, loading, toggleShare}) => (
  48. <ShareIssue
  49. loading={loading}
  50. isShared={isShared}
  51. onToggle={toggleShare}
  52. {...args}
  53. />
  54. )}
  55. </ShareSimulator>
  56. );
  57. };
  58. Default.storyName = 'Share Issue';