Skip to content

Commit

Permalink
fix(constants): prevent circular dependency
Browse files Browse the repository at this point in the history
  • Loading branch information
Mohammer5 committed Sep 26, 2023
1 parent a88586e commit 5a19ffb
Show file tree
Hide file tree
Showing 25 changed files with 50 additions and 36 deletions.
19 changes: 14 additions & 5 deletions i18n/en.pot
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@ msgstr ""
"Content-Type: text/plain; charset=utf-8\n"
"Content-Transfer-Encoding: 8bit\n"
"Plural-Forms: nplurals=2; plural=(n != 1)\n"
"POT-Creation-Date: 2023-09-12T11:17:52.981Z\n"
"PO-Revision-Date: 2023-09-12T11:17:52.981Z\n"
"POT-Creation-Date: 2023-09-26T12:37:14.624Z\n"
"PO-Revision-Date: 2023-09-26T12:37:14.624Z\n"

msgid "schemas"
msgstr "schemas"
Expand Down Expand Up @@ -93,9 +93,6 @@ msgstr "Type to filter options"
msgid "No matches"
msgstr "No matches"

msgid "Data set"
msgstr "Data set"

msgid "Clear all filters"
msgstr "Clear all filters"

Expand Down Expand Up @@ -129,6 +126,15 @@ msgstr "Public can view"
msgid "Public cannot access"
msgstr "Public cannot access"

msgid "Public access"
msgstr "Public access"

msgid "Domain"
msgstr "Domain"

msgid "Value"
msgstr "Value"

msgid "Category"
msgstr "Category"

Expand Down Expand Up @@ -183,6 +189,9 @@ msgstr "Data element group set"
msgid "Data element group sets"
msgstr "Data element group sets"

msgid "Data set"
msgstr "Data set"

msgid "Data sets"
msgstr "Data sets"

Expand Down
2 changes: 1 addition & 1 deletion src/app/layout/Breadcrumb.spec.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import '@testing-library/jest-dom'
import { configure, render } from '@testing-library/react'
import React from 'react'
import { useMatches, HashRouter } from 'react-router-dom'
import { OVERVIEW_SECTIONS, SECTIONS_MAP } from '../../constants/sections'
import { OVERVIEW_SECTIONS, SECTIONS_MAP } from '../../lib'
import { MatchRouteHandle, RouteHandle } from '../routes/types'
import { Breadcrumbs, BreadcrumbItem } from './Breadcrumb'

Expand Down
2 changes: 1 addition & 1 deletion src/app/layout/Breadcrumb.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import React from 'react'
import { Link, useMatches } from 'react-router-dom'
import { Section, isOverviewSection } from '../../constants'
import { Section, isOverviewSection } from '../../lib'
import { getSectionPath, getOverviewPath } from '../routes/routePaths'
import { MatchRouteHandle } from '../routes/types'
import css from './Breadcrumb.module.css'
Expand Down
2 changes: 1 addition & 1 deletion src/app/routes/LegacyAppRedirect.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import i18n from '@dhis2/d2-i18n'
import { NoticeBox, Button } from '@dhis2/ui'
import React from 'react'
import { useParams, Params } from 'react-router-dom'
import { isOverviewSection, Section, SECTIONS_MAP } from '../../constants'
import { isOverviewSection, Section, SECTIONS_MAP } from '../../lib'

const legacyPath = '/dhis-web-maintenance/index.html#/'

Expand Down
5 changes: 3 additions & 2 deletions src/app/routes/Router.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,9 @@ import {
Section,
SchemaSection,
OVERVIEW_SECTIONS,
} from '../../constants'
import { isValidUid, isModuleNotFoundError } from '../../lib'
isValidUid,
isModuleNotFoundError,
} from '../../lib'
import { OverviewSection } from '../../types'
import { Layout, Breadcrumbs, BreadcrumbItem } from '../layout'
import { CheckAuthorityForSection } from './CheckAuthorityForSection'
Expand Down
2 changes: 1 addition & 1 deletion src/app/routes/routePaths.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import type { Section } from '../../constants/sections'
import type { Section } from '../../lib'

export const routePaths = {
overviewRoot: 'overview',
Expand Down
4 changes: 2 additions & 2 deletions src/app/sidebar/SidebarLinks.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ import {
OVERVIEW_SECTIONS,
SECTIONS_MAP,
Section,
} from '../../constants/sections'
import { useIsSectionAuthorizedPredicate } from '../../lib'
useIsSectionAuthorizedPredicate,
} from '../../lib'
import { getOverviewPath, getSectionPath } from '../routes/routePaths'

export interface LinkItem {
Expand Down
5 changes: 1 addition & 4 deletions src/components/sectionList/filters/ConstantFilters.tsx
Original file line number Diff line number Diff line change
@@ -1,8 +1,5 @@
import React from 'react'
import {
DOMAIN_TYPE,
VALUE_TYPE,
} from '../../../constants/translatedModelConstants'
import { DOMAIN_TYPE, VALUE_TYPE } from '../../../lib'
import { ConstantSelectionFilter } from './ConstantSelectionFilter'

export const DomainTypeSelectionFilter = () => {
Expand Down
6 changes: 4 additions & 2 deletions src/components/sectionList/listView/ManageListView.tsx
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
import i18n from '@dhis2/d2-i18n'
import { Button, Transfer } from '@dhis2/ui'
import React, { useEffect, useMemo, useRef, useState } from 'react'
import { getColumnsForSection } from '../../../constants'
import { useModelSectionHandleOrThrow } from '../../../lib'
import {
getColumnsForSection,
useModelSectionHandleOrThrow,
} from '../../../lib'
import css from './ManageListView.module.css'
import { useModelListView, useMutateModelListViews } from './useModelListView'

Expand Down
4 changes: 2 additions & 2 deletions src/components/sectionList/listView/types.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { SectionName } from '../../../constants'
import type { ModelPropertyDescriptor } from '../../../constants'
import { SectionName } from '../../../lib'
import type { ModelPropertyDescriptor } from '../../../lib'

export interface ModelListView {
name: string
Expand Down
7 changes: 5 additions & 2 deletions src/components/sectionList/listView/useModelListView.tsx
Original file line number Diff line number Diff line change
@@ -1,8 +1,11 @@
import { useMemo, useCallback } from 'react'
import { useQueryClient } from 'react-query'
import { z } from 'zod'
import { getViewConfigForSection, sectionNames } from '../../../constants'
import { useModelSectionHandleOrThrow } from '../../../lib'
import {
getViewConfigForSection,
sectionNames,
useModelSectionHandleOrThrow,
} from '../../../lib'
import { useDataStoreValues } from '../../../lib/dataStore'
import {
queryCreators,
Expand Down
2 changes: 1 addition & 1 deletion src/components/sectionList/modelValue/ConstantValue.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import React from 'react'
import { getConstantTranslation } from '../../../constants/translatedModelConstants'
import { getConstantTranslation } from '../../../lib'

export const ConstantValue = ({ value }: { value?: string }) => (
<span>{getConstantTranslation(value || '')}</span>
Expand Down
3 changes: 2 additions & 1 deletion src/constants/index.ts → src/lib/constants/index.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
export * from './sectionListViews'
export * from './sections'
export * from './translatedModelConstants'
export * from './translatedModelProperties'
export * from './sectionListViews'
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import i18n from '@dhis2/d2-i18n'
import { PublicAccessValue } from '../components/sectionList/modelValue/PublicAccess'
import { uniqueBy } from '../lib'
import { PublicAccessValue } from '../../components/sectionList/modelValue/PublicAccess'
import { uniqueBy } from '../utils'
import { SectionName } from './sections'
import { getTranslatedProperty } from './translatedModelProperties'

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import {
OverviewSectionMap,
OverviewSection,
NonSchemaSection,
} from '../types'
} from '../../types'

// for convenience so types can be imported with the map below
export type { SectionMap, Section, SchemaSection, SchemaSectionMap }
Expand Down
File renamed without changes.
File renamed without changes.
1 change: 1 addition & 0 deletions src/lib/index.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
export * from './constants'
export * from './models'
export * from './schemas'
export { useLoadApp } from './useLoadApp'
Expand Down
2 changes: 1 addition & 1 deletion src/lib/routeUtils/useSectionHandle.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { useMatches } from 'react-router-dom'
import { MatchRouteHandle } from '../../app/routes/types'
import { isOverviewSection, isSchemaSection } from '../../constants'
import { ModelSection, SchemaSection, Section } from '../../types'
import { isOverviewSection, isSchemaSection } from '../constants'

export const useSectionHandle = (): Section | undefined => {
const matches = useMatches() as MatchRouteHandle[]
Expand Down
2 changes: 1 addition & 1 deletion src/lib/sections/sectionAuthorities.spec.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { renderHook } from '@testing-library/react-hooks'
import { OVERVIEW_SECTIONS, SECTIONS_MAP } from '../../constants'
import { SystemSettings } from '../../types'
import { OVERVIEW_SECTIONS, SECTIONS_MAP } from '../constants'
import { useSchemaStore } from '../schemas/schemaStore'
import { useSystemSettingsStore } from '../systemSettings/systemSettingsStore'
import { ModelSchemas, CurrentUser } from '../useLoadApp'
Expand Down
4 changes: 2 additions & 2 deletions src/lib/sections/sectionAuthorities.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
import { useCallback } from 'react'
import { ModelSection } from '../../types'
import {
SECTIONS_MAP,
isSchemaSection,
Section,
SchemaSection,
isOverviewSection,
} from '../../constants'
import { ModelSection } from '../../types'
} from '../constants'
import { useSchemas } from '../schemas'
import { useSystemSetting } from '../systemSettings'
import { ModelSchemas } from '../useLoadApp'
Expand Down
2 changes: 1 addition & 1 deletion src/pages/dataElements/List.spec.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import React from 'react'
import dataElementsMock from '../../__mocks__/gists/dataElementsMock.json'
import filteredDataElementsMock from '../../__mocks__/gists/filteredDataElementsMock.json'
import dataElementSchemaMock from '../../__mocks__/schema/dataElementsSchema.json'
import { SECTIONS_MAP } from '../../constants'
import { SECTIONS_MAP } from '../../lib'
import { useSchemaStore } from '../../lib/schemas/schemaStore'
import { ModelSchemas } from '../../lib/useLoadApp'
import TestComponentWithRouter, {
Expand Down
2 changes: 1 addition & 1 deletion src/pages/overview/Categories.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import i18n from '@dhis2/d2-i18n'
import React from 'react'
import { OVERVIEW_SECTIONS, SECTIONS_MAP } from '../../constants'
import { OVERVIEW_SECTIONS, SECTIONS_MAP } from '../../lib'
import { FilterAuthorizedSections, SummaryCard, SummaryCardGroup } from './card'
import { OverviewGroup, OverviewGroupSummary } from './group'

Expand Down
2 changes: 1 addition & 1 deletion src/pages/overview/DataElements.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import i18n from '@dhis2/d2-i18n'
import React from 'react'
import { OVERVIEW_SECTIONS, SECTIONS_MAP } from '../../constants'
import { OVERVIEW_SECTIONS, SECTIONS_MAP } from '../../lib'
import { FilterAuthorizedSections, SummaryCard, SummaryCardGroup } from './card'
import { OverviewGroup, OverviewGroupSummary } from './group'

Expand Down
2 changes: 1 addition & 1 deletion src/types/section.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import type { OverviewSectionName, SectionName } from '../constants'
import type { OverviewSectionName, SectionName } from '../lib'
import { SchemaAuthorities, SchemaName } from './schemaBase'

export interface SectionBase {
Expand Down

0 comments on commit 5a19ffb

Please sign in to comment.