Skip to content

Commit

Permalink
refactor(organisationunittree): colocate code and stories
Browse files Browse the repository at this point in the history
  • Loading branch information
varl committed Mar 9, 2020
1 parent fc63d99 commit 1c50f51
Show file tree
Hide file tree
Showing 28 changed files with 41 additions and 35 deletions.
2 changes: 1 addition & 1 deletion packages/core/src/AlertStack/AlertStack.stories.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { storiesOf } from '@storybook/react'
import { AlertStack } from './AlertStack.js'
import { AlertBar } from '../index.js'

storiesOf('Component/Widget/AlertStack', module).add('Default', () => (
storiesOf('Component/Core/AlertStack', module).add('Default', () => (
<AlertStack>
<AlertBar permanent>First notification - I am at the bottom</AlertBar>
<AlertBar permanent critical>
Expand Down
2 changes: 1 addition & 1 deletion packages/core/src/Menu/Menu.stories.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import { Menu } from './Menu.js'

const Wrapper = fn => <div style={{}}>{fn()}</div>

storiesOf('Component/Widget/Menu', module)
storiesOf('Component/Core/Menu', module)
.addDecorator(Wrapper)

.add('Default', () => (
Expand Down
2 changes: 1 addition & 1 deletion packages/core/src/Modal/Modal.stories.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ window.onClose = (payload, event) => {

const onClose = (...args) => window.onClose(...args)

storiesOf('Component/Widget/Modal', module)
storiesOf('Component/Core/Modal', module)
.add('Default: Content', () => (
<Modal onClose={onClose}>
<ModalContent>
Expand Down
2 changes: 1 addition & 1 deletion packages/core/src/StackedTable/StackedTable.stories.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ const CustomCell = props => (
</td>
)

storiesOf('Component/Widget/StackedTable', module)
storiesOf('Component/Core/StackedTable', module)
.add('Default', () => (
<StackedTable>
<StackedTableHead>
Expand Down
4 changes: 2 additions & 2 deletions packages/core/src/Table/Table.stories.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ const TableFooterButton = () => (

const TableButton = () => <Button primary>Table button</Button>

storiesOf('Component/Widget/Table', module).add('Static layout', () => (
storiesOf('Component/Core/Table', module).add('Static layout', () => (
<Table>
<TableHead>
<TableRowHead>
Expand Down Expand Up @@ -154,7 +154,7 @@ storiesOf('Component/Widget/Table', module).add('Static layout', () => (
</Table>
))

storiesOf('Component/Widget/Table', module).add(
storiesOf('Component/Core/Table', module).add(
'Static layout with buttons in dense cells',
() => (
<Table>
Expand Down
2 changes: 1 addition & 1 deletion packages/widgets/src/HeaderBar/HeaderBar.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@ import { Logo } from './Logo.js'
import { Title } from './Title.js'
import { Notifications } from './Notifications.js'

import './locales'
import i18n from '@dhis2/d2-i18n'
import '../locales'

const query = {
systemInfo: {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
import React, { useEffect } from 'react'
import propTypes from 'prop-types'

import { OrganisationUnitNode } from './OrganisationUnitTree/OrganisationUnitNode'
import { RootError } from './OrganisationUnitTree/RootError'
import { RootLoading } from './OrganisationUnitTree/RootLoading'
import { orgUnitPathPropType } from './OrganisationUnitTree/propTypes'
import { useExpanded } from './OrganisationUnitTree/useExpanded'
import { useForceReload } from './OrganisationUnitTree/useForceReload'
import { useOrgData } from './OrganisationUnitTree/useOrgData'
import { OrganisationUnitNode } from './OrganisationUnitNode.js'
import { RootError } from './RootError.js'
import { RootLoading } from './RootLoading.js'
import { orgUnitPathPropType } from './propTypes.js'
import { useExpanded } from './useExpanded.js'
import { useForceReload } from './useForceReload.js'
import { useOrgData } from './useOrgData.js'

/**
* @module
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
/* eslint-disable react/no-unescaped-entities,react/prop-types */
import React, { useEffect, useState } from 'react'
import { storiesOf } from '@storybook/react'
import { OrganisationUnitTree } from '../index'
import { CustomDataProvider, DataProvider } from '@dhis2/app-runtime'

import { OrganisationUnitTree } from './OrganisationUnitTree.js'

const log = true
const onChange = (...args) => log && console.log('onChange', ...args)
const onExpand = (...args) => log && console.log('onExpand', ...args)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
import React from 'react'
import { storiesOf } from '@storybook/react'
import { OrganisationUnitTree } from '../../index'
import { CustomDataProvider } from '@dhis2/app-runtime'

import { OrganisationUnitTree } from '../OrganisationUnitTree.js'

import {
StatefulMultiSelectionWrapper,
dataProviderData,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import React from 'react'
import { storiesOf } from '@storybook/react'
import { OrganisationUnitTree } from '../../index'
import { CustomDataProvider } from '@dhis2/app-runtime'
import { OrganisationUnitTree } from '../OrganisationUnitTree.js'
import {
StatefulMultiSelectionWrapper,
dataProviderData,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import { Button } from '@dhis2/ui-core'
import React, { useState } from 'react'
import { storiesOf } from '@storybook/react'
import { OrganisationUnitTree } from '../../index'
import { CustomDataProvider } from '@dhis2/app-runtime'
import { OrganisationUnitTree } from '../OrganisationUnitTree.js'
import {
StatefulMultiSelectionWrapper,
dataProviderData,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import React from 'react'
import { storiesOf } from '@storybook/react'
import { OrganisationUnitTree } from '../../index'
import { CustomDataProvider } from '@dhis2/app-runtime'
import { OrganisationUnitTree } from '../OrganisationUnitTree.js'
import {
StatefulMultiSelectionWrapper,
dataProviderData,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import React from 'react'
import { storiesOf } from '@storybook/react'
import { OrganisationUnitTree } from '../../index'
import { CustomDataProvider } from '@dhis2/app-runtime'
import { OrganisationUnitTree } from '../OrganisationUnitTree.js'
import {
StatefulMultiSelectionWrapper,
dataProviderData,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import React from 'react'
import { storiesOf } from '@storybook/react'
import { OrganisationUnitTree } from '../../index'
import { CustomDataProvider } from '@dhis2/app-runtime'
import { OrganisationUnitTree } from '../OrganisationUnitTree.js'
import {
StatefulMultiSelectionWrapper,
dataProviderData,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import React from 'react'
import { storiesOf } from '@storybook/react'
import { OrganisationUnitTree } from '../../index'
import { CustomDataProvider } from '@dhis2/app-runtime'
import { OrganisationUnitTree } from '../OrganisationUnitTree.js'
import {
StatefulMultiSelectionWrapper,
dataProviderData,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import React from 'react'
import { storiesOf } from '@storybook/react'
import { OrganisationUnitTree } from '../../index'
import { CustomDataProvider } from '@dhis2/app-runtime'
import { OrganisationUnitTree } from '../OrganisationUnitTree.js'
import {
StatefulMultiSelectionWrapper,
dataProviderData,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import React from 'react'
import { storiesOf } from '@storybook/react'
import { OrganisationUnitTree } from '../../index'
import { CustomDataProvider } from '@dhis2/app-runtime'
import { OrganisationUnitTree } from '../OrganisationUnitTree.js'
import {
StatefulMultiSelectionWrapper,
dataProviderData,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import React from 'react'
import { storiesOf } from '@storybook/react'
import { OrganisationUnitTree } from '../../index'
import { CustomDataProvider } from '@dhis2/app-runtime'
import { OrganisationUnitTree } from '../OrganisationUnitTree.js'
import {
StatefulMultiSelectionWrapper,
dataProviderData,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import React from 'react'
import { storiesOf } from '@storybook/react'
import { OrganisationUnitTree } from '../../index'
import { CustomDataProvider } from '@dhis2/app-runtime'
import { OrganisationUnitTree } from '../OrganisationUnitTree.js'
import {
StatefulMultiSelectionWrapper,
dataProviderData,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { computeChildNodes } from '../computeChildNodes'
import { computeChildNodes } from '../computeChildNodes.js'

describe('computeChildNodes', () => {
let node = { path: 'foo/bar' }
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { fromEntries } from '../fromEntries'
import { fromEntries } from '../fromEntries.js'

describe('fromEntries', () => {
it('should transform an array of entries to an object', () => {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { hasDescendantSelectedPaths } from '../hasDescendantSelectedPaths'
import { hasDescendantSelectedPaths } from '../hasDescendantSelectedPaths.js'

describe('hasDescendantSelectedPaths', () => {
it('should return true when the path is a parent path of one of the selected paths', () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import {
createExpandHandlers,
getInitiallyExpandedPaths,
} from '../useExpanded/helpers'
import { useExpanded } from '../useExpanded'
import { useExpanded } from '../useExpanded.js'

jest.mock('react', () => ({
useState: jest.fn(initialValue => [initialValue, () => null]),
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { useEffect, useState } from 'react'
import { useForceReload } from '../useForceReload'
import { useForceReload } from '../useForceReload.js'

jest.mock('react', () => ({
useEffect: jest.fn(callback => callback()),
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { useEffect, useState } from 'react'
import { useOpenState } from '../useOpenState'
import { useOpenState } from '../useOpenState.js'

jest.mock('react', () => ({
useState: jest.fn(),
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,10 @@
import { useDataQuery } from '@dhis2/app-runtime'

import { addMissingDisplayNameProps, createQuery } from '../useOrgData/helpers'
import { useOrgData } from '../useOrgData'
import {
addMissingDisplayNameProps,
createQuery,
} from '../useOrgData/helpers.js'
import { useOrgData } from '../useOrgData.js'

jest.mock('@dhis2/app-runtime', () => ({
useDataQuery: jest.fn(() => ({ loading: false, error: null, data: {} })),
Expand Down
2 changes: 1 addition & 1 deletion packages/widgets/src/index.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
export { HeaderBar } from './HeaderBar/HeaderBar.js'
export { OrganisationUnitTree } from './OrganisationUnitTree'
export { OrganisationUnitTree } from './OrganisationUnitTree/OrganisationUnitTree.js'

export { CheckboxField } from './CheckboxField/CheckboxField.js'
export { FileInputField } from './FileInputField/FileInputField.js'
Expand Down

0 comments on commit 1c50f51

Please sign in to comment.