Skip to content

Commit

Permalink
fix: proper error message for TET without dimensions
Browse files Browse the repository at this point in the history
  • Loading branch information
martinkrulltott committed Nov 27, 2023
1 parent d4cccf6 commit 3081676
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 6 deletions.
7 changes: 5 additions & 2 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-11-21T13:23:15.736Z\n"
"PO-Revision-Date: 2023-11-21T13:23:15.737Z\n"
"POT-Creation-Date: 2023-11-27T12:33:11.369Z\n"
"PO-Revision-Date: 2023-11-27T12:33:11.369Z\n"

msgid "Add to {{axisName}}"
msgstr "Add to {{axisName}}"
Expand Down Expand Up @@ -201,6 +201,9 @@ msgstr "No dimensions found for '{{- searchTerm}}'"
msgid "No dimensions found in the {{- programName}} program"
msgstr "No dimensions found in the {{- programName}} program"

msgid " {{- trackedEntityType}} has no dimensions"
msgstr " {{- trackedEntityType}} has no dimensions"

msgid "No dimensions found"
msgstr "No dimensions found"

Expand Down
21 changes: 17 additions & 4 deletions src/components/MainSidebar/DimensionsList/DimensionsList.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,16 +6,23 @@ import { DimensionItem } from '../DimensionItem/index.js'
import { useSelectedDimensions } from '../SelectedDimensionsContext.js'
import styles from './DimensionsList.module.css'

const getNoResultsMessage = (searchTerm, programName) => {
const getNoResultsMessage = ({
searchTerm,
programName,
trackedEntityType,
}) => {
if (searchTerm) {
return i18n.t("No dimensions found for '{{- searchTerm}}'", {
searchTerm,
})
}
if (programName) {
} else if (programName) {
return i18n.t('No dimensions found in the {{- programName}} program', {
programName,
})
} else if (trackedEntityType) {
return i18n.t(' {{- trackedEntityType}} has no dimensions', {
trackedEntityType,
})
}
return i18n.t('No dimensions found')
}
Expand All @@ -32,6 +39,7 @@ const DimensionsList = ({
searchTerm,
setIsListEndVisible,
dataTest,
trackedEntityType,
}) => {
const scrollBoxRef = useRef()
const { getIsDimensionSelected } = useSelectedDimensions()
Expand Down Expand Up @@ -66,7 +74,11 @@ const DimensionsList = ({
if (!dimensions?.length) {
return (
<div className={styles.noResults}>
{getNoResultsMessage(searchTerm, programName)}
{getNoResultsMessage({
searchTerm,
programName,
trackedEntityType,
})}
</div>
)
}
Expand Down Expand Up @@ -111,6 +123,7 @@ DimensionsList.propTypes = {
loading: PropTypes.bool,
programName: PropTypes.string,
searchTerm: PropTypes.string,
trackedEntityType: PropTypes.string,
}

export { DimensionsList }
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import React, { useState } from 'react'
import { useSelector } from 'react-redux'
import { DERIVED_USER_SETTINGS_DISPLAY_NAME_PROPERTY } from '../../../modules/userSettings.js'
import { useDebounce } from '../../../modules/utils.js'
import { sGetMetadataById } from '../../../reducers/metadata.js'
import { sGetUiEntityTypeId } from '../../../reducers/ui.js'
import { DimensionsList } from '../DimensionsList/index.js'
import { ProgramFilter } from './ProgramFilter.js'
Expand All @@ -16,6 +17,9 @@ const TrackedEntityDimensionsPanel = ({ visible }) => {
const [searchTerm, setSearchTerm] = useState('')
const [selectedProgramId, setSelectedProgramId] = useState(null)
const selectedEntityTypeId = useSelector(sGetUiEntityTypeId)
const entityType = useSelector((state) =>
sGetMetadataById(state, selectedEntityTypeId)
)
const debouncedSearchTerm = useDebounce(searchTerm)
const { currentUser } = useCachedDataQuery()
const { loading, fetching, error, dimensions, setIsListEndVisible } =
Expand Down Expand Up @@ -65,6 +69,7 @@ const TrackedEntityDimensionsPanel = ({ visible }) => {
loading={loading}
searchTerm={debouncedSearchTerm}
dataTest="tracked-entity-dimensions"
trackedEntityType={entityType?.name}
/>
</>
)
Expand Down

0 comments on commit 3081676

Please sign in to comment.