diff --git a/i18n/en.pot b/i18n/en.pot index 9fbf4b1d2..8199e6295 100644 --- a/i18n/en.pot +++ b/i18n/en.pot @@ -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: 2020-08-25T05:26:00.043Z\n" -"PO-Revision-Date: 2020-08-25T05:26:00.043Z\n" +"POT-Creation-Date: 2020-08-26T05:58:25.332Z\n" +"PO-Revision-Date: 2020-08-26T05:58:25.332Z\n" msgid "Cancel" msgstr "" @@ -177,6 +177,9 @@ msgstr "" msgid "Dashboard title" msgstr "" +msgid "Untitled dashboard" +msgstr "" + msgid "Dashboard description" msgstr "" diff --git a/src/actions/editDashboard.js b/src/actions/editDashboard.js index cdc6a664a..d138b44c0 100644 --- a/src/actions/editDashboard.js +++ b/src/actions/editDashboard.js @@ -1,4 +1,5 @@ import { generateUid } from 'd2/uid' +import i18n from '@dhis2/d2-i18n' import { RECEIVED_EDIT_DASHBOARD, @@ -125,6 +126,7 @@ export const tSaveDashboard = () => async (dispatch, getState) => { const dashboardToSave = { ...dashboard, dashboardItems: convertUiItemsToBackend(dashboard.dashboardItems), + name: dashboard.name || i18n.t('Untitled dashboard'), } try { diff --git a/src/components/TitleBar/EditTitleBar.js b/src/components/TitleBar/EditTitleBar.js index 5f45f5037..84ed701f7 100644 --- a/src/components/TitleBar/EditTitleBar.js +++ b/src/components/TitleBar/EditTitleBar.js @@ -38,6 +38,7 @@ export const EditTitleBar = ({ type="text" onChange={updateTitle} value={name} + placeholder={i18n.t('Untitled dashboard')} /> 'textfield') -jest.mock('../../ItemSelector/ItemSelector', () => 'itemselector') +jest.mock('@dhis2/d2-ui-core/text-field/TextField', () => 'TextField') +jest.mock('../../ItemSelector/ItemSelector', () => 'ItemSelector') describe('EditTitleBar', () => { const props = { @@ -23,15 +23,14 @@ describe('EditTitleBar', () => { }, } - it('renders correctly when displayName not provided', () => { + it('renders correctly', () => { const tree = shallow() expect(toJson(tree)).toMatchSnapshot() }) - it('renders correctly when displayName is provided', () => { - const tree = shallow( - - ) + it('renders correctly when no name', () => { + props.name = '' + const tree = shallow() expect(toJson(tree)).toMatchSnapshot() }) }) diff --git a/src/components/TitleBar/__tests__/__snapshots__/EditTitleBar.spec.js.snap b/src/components/TitleBar/__tests__/__snapshots__/EditTitleBar.spec.js.snap index 1cc61258c..6fc4ce7b1 100644 --- a/src/components/TitleBar/__tests__/__snapshots__/EditTitleBar.spec.js.snap +++ b/src/components/TitleBar/__tests__/__snapshots__/EditTitleBar.spec.js.snap @@ -1,6 +1,6 @@ // Jest Snapshot v1, https://goo.gl/fbAQLP -exports[`EditTitleBar renders correctly when displayName is provided 1`] = ` +exports[`EditTitleBar renders correctly 1`] = `
@@ -13,6 +13,7 @@ exports[`EditTitleBar renders correctly when displayName is provided 1`] = ` label="Dashboard title" name="Dashboard title input" onChange={[Function]} + placeholder="Untitled dashboard" type="text" value="Rainbow Dash" /> @@ -31,12 +32,12 @@ exports[`EditTitleBar renders correctly when displayName is provided 1`] = `
- +
`; -exports[`EditTitleBar renders correctly when displayName not provided 1`] = ` +exports[`EditTitleBar renders correctly when no name 1`] = `
@@ -49,8 +50,9 @@ exports[`EditTitleBar renders correctly when displayName not provided 1`] = ` label="Dashboard title" name="Dashboard title input" onChange={[Function]} + placeholder="Untitled dashboard" type="text" - value="Rainbow Dash" + value="" /> - +
`;