columnEditor.stories.js 1.9 KB

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