Skip to content

Commit

Permalink
fix: update instance endpoint, use ConfigProvider
Browse files Browse the repository at this point in the history
  • Loading branch information
edoardo committed Nov 7, 2024
1 parent e494464 commit 8a91b2b
Show file tree
Hide file tree
Showing 3 changed files with 70 additions and 61 deletions.
113 changes: 54 additions & 59 deletions src/__demo__/OpenFileDialog.stories.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Provider } from '@dhis2/app-runtime'
import { DataProvider } from '@dhis2/app-runtime'
import React from 'react'
import { OpenFileDialog } from '../components/OpenFileDialog/OpenFileDialog.js'
import {
Expand All @@ -10,10 +10,14 @@ import {
VIS_TYPE_LINE_LIST,
} from '../modules/visTypes.js'

const configMock = {
baseUrl: 'https://debug.dhis2.org/dev',
apiVersion: 37,
}
const Wrapper = (story) => (
<DataProvider
baseUrl="https://test.e2e.dhis2.org/analytics-41dev/"
apiVersion="41"
>
{story()}
</DataProvider>
)

const user = {
displayName: 'John Traore',
Expand All @@ -33,38 +37,35 @@ const filterVisTypesWithGroupsAndDivider = [

export default {
title: 'OpenFileDialog',
decorators: [Wrapper],
}

export const ListOfVisualizationsWithVisTypeFilterAndDividerNoDefaultVisType =
() => (
<Provider config={configMock}>
<OpenFileDialog
type="visualization"
filterVisTypes={filterVisTypesWithGroupsAndDivider}
onClose={Function.prototype}
onFileSelect={onFileSelect}
onNew={Function.prototype}
open={true}
currentUser={user}
/>
</Provider>
)

ListOfVisualizationsWithVisTypeFilterAndDividerNoDefaultVisType.story = {
name: 'List of visualizations with vis type filter and divider (no default vis type)',
}

export const ListOfMapsNoVisTypeFilter = () => (
<Provider config={configMock}>
<OpenFileDialog
type="map"
type="visualization"
filterVisTypes={filterVisTypesWithGroupsAndDivider}
onClose={Function.prototype}
onFileSelect={onFileSelect}
onNew={Function.prototype}
open={true}
currentUser={user}
/>
</Provider>
)

ListOfVisualizationsWithVisTypeFilterAndDividerNoDefaultVisType.story = {
name: 'List of visualizations with vis type filter and divider (no default vis type)',
}

export const ListOfMapsNoVisTypeFilter = () => (
<OpenFileDialog
type="map"
onClose={Function.prototype}
onFileSelect={onFileSelect}
onNew={Function.prototype}
open={true}
currentUser={user}
/>
)

ListOfMapsNoVisTypeFilter.story = {
Expand All @@ -78,18 +79,16 @@ const filterVisTypesWithDisabled = [

export const ListOfEventVisualizationsWithVisTypeFilterDisabledTypeAndDefaultVisType =
() => (
<Provider config={configMock}>
<OpenFileDialog
type="eventVisualization"
filterVisTypes={filterVisTypesWithDisabled}
defaultFilterVisType={VIS_TYPE_LINE_LIST}
onClose={Function.prototype}
onFileSelect={onFileSelect}
onNew={Function.prototype}
open={true}
currentUser={user}
/>
</Provider>
<OpenFileDialog
type="eventVisualization"
filterVisTypes={filterVisTypesWithDisabled}
defaultFilterVisType={VIS_TYPE_LINE_LIST}
onClose={Function.prototype}
onFileSelect={onFileSelect}
onNew={Function.prototype}
open={true}
currentUser={user}
/>
)

ListOfEventVisualizationsWithVisTypeFilterDisabledTypeAndDefaultVisType.story =
Expand All @@ -105,17 +104,15 @@ const filterVisTypesWithGroupDividerAndDisabled = [

export const ListOfVisualizationsWithVisTypeFilterWithGroupTypeDividerAndDisabledOptionNoDefaultVisType =
() => (
<Provider config={configMock}>
<OpenFileDialog
type="visualization"
filterVisTypes={filterVisTypesWithGroupDividerAndDisabled}
onClose={Function.prototype}
onFileSelect={onFileSelect}
onNew={Function.prototype}
open={true}
currentUser={user}
/>
</Provider>
<OpenFileDialog
type="visualization"
filterVisTypes={filterVisTypesWithGroupDividerAndDisabled}
onClose={Function.prototype}
onFileSelect={onFileSelect}
onNew={Function.prototype}
open={true}
currentUser={user}
/>
)

ListOfVisualizationsWithVisTypeFilterWithGroupTypeDividerAndDisabledOptionNoDefaultVisType.story =
Expand All @@ -124,16 +121,14 @@ ListOfVisualizationsWithVisTypeFilterWithGroupTypeDividerAndDisabledOptionNoDefa
}

export const NoConnection = () => (
<Provider config={configMock}>
<OpenFileDialog
type="map"
onClose={Function.prototype}
onFileSelect={onFileSelect}
onNew={Function.prototype}
open={true}
currentUser={user}
/>
</Provider>
<OpenFileDialog
type="map"
onClose={Function.prototype}
onFileSelect={onFileSelect}
onNew={Function.prototype}
open={true}
currentUser={user}
/>
)

NoConnection.story = {
Expand Down
4 changes: 2 additions & 2 deletions src/__demo__/OrgUnitDimension.stories.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ import OrgUnitDimension from '../components/OrgUnitDimension/OrgUnitDimension.js

const Wrapper = (story) => (
<DataProvider
baseUrl="https://debug.dhis2.org/analytics-dev/"
apiVersion=""
baseUrl="https://test.e2e.dhis2.org/analytics-41dev/"
apiVersion="41"
>
{story()}
</DataProvider>
Expand Down
14 changes: 14 additions & 0 deletions src/__demo__/PeriodDimension.stories.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import { DataProvider } from '@dhis2/app-runtime'
import { ConfigProvider } from '@dhis2/app-service-config'
import React from 'react'
import PeriodDimension from '../components/PeriodDimension/PeriodDimension.js'
import {
Expand All @@ -12,10 +14,22 @@ import {
BIMONTHLY,
} from '../components/PeriodDimension/utils/index.js'

const Wrapper = (story) => (
<ConfigProvider config={{ systemInfo: {} }}>
<DataProvider
baseUrl="https://test.e2e.dhis2.org/analytics-41dev/"
apiVersion="41"
>
{story()}
</DataProvider>
</ConfigProvider>
)

const selectedPeriods = [{ id: 'LAST_12_MONTHS', name: 'Last 12 months' }]

export default {
title: 'PeriodDimension',
decorators: [Wrapper],
}

export const NoneSelected = () => {
Expand Down

0 comments on commit 8a91b2b

Please sign in to comment.