columnEditor.stories.js 1.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107
  1. import {openModal} from 'sentry/actionCreators/modal';
  2. import Button from 'sentry/components/button';
  3. import GlobalModal from 'sentry/components/globalModal';
  4. import ColumnEditModal, {modalCss} from 'sentry/views/eventsV2/table/columnEditModal';
  5. const columns = [
  6. {
  7. kind: 'field',
  8. field: 'event.type',
  9. },
  10. {
  11. kind: 'field',
  12. field: 'browser.name',
  13. },
  14. {
  15. kind: 'function',
  16. function: ['count', 'id'],
  17. },
  18. {
  19. kind: 'function',
  20. function: ['count_unique', 'title'],
  21. },
  22. {
  23. kind: 'function',
  24. function: ['p95'],
  25. },
  26. {
  27. kind: 'field',
  28. field: 'issue.id',
  29. },
  30. {
  31. kind: 'function',
  32. function: ['count_unique', 'issue.id'],
  33. },
  34. {
  35. kind: 'function',
  36. function: ['percentile', 'transaction.duration', '0.81'],
  37. },
  38. {
  39. kind: 'field',
  40. field: 'tags[project]',
  41. },
  42. ];
  43. export default {
  44. title: 'Components/Tables/ColumnEditor',
  45. component: ColumnEditModal,
  46. args: {
  47. tags: ['browser.name', 'custom-field', 'project'],
  48. columns,
  49. },
  50. argTypes: {
  51. organization: {
  52. table: {
  53. disable: true,
  54. },
  55. },
  56. header: {
  57. table: {
  58. disable: true,
  59. },
  60. },
  61. body: {
  62. table: {
  63. disable: true,
  64. },
  65. },
  66. footer: {
  67. table: {
  68. disable: true,
  69. },
  70. },
  71. onApply: {action: 'onApply'},
  72. },
  73. };
  74. export const Default = ({...args}) => {
  75. const organization = {
  76. slug: 'test-org',
  77. features: ['discover-query', 'performance-view'],
  78. };
  79. const showModal = () => {
  80. openModal(
  81. modalProps => (
  82. <ColumnEditModal {...modalProps} organization={organization} {...args} />
  83. ),
  84. {modalCss}
  85. );
  86. };
  87. return (
  88. <div>
  89. <Button onClick={showModal}>Edit columns</Button>
  90. <GlobalModal />
  91. </div>
  92. );
  93. };
  94. Default.storyName = 'ColumnEditor';
  95. Default.parameters = {
  96. docs: {
  97. description: {
  98. story: 'Playground for building out column editor v2 for discover',
  99. },
  100. },
  101. };