Skip to content

Commit

Permalink
fix(photos): Improve wording for empty state
Browse files Browse the repository at this point in the history
  • Loading branch information
cballevre committed Sep 7, 2023
1 parent b857399 commit a6cffd9
Show file tree
Hide file tree
Showing 8 changed files with 26 additions and 13 deletions.
7 changes: 6 additions & 1 deletion src/components/Error/Empty.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import DriveIcon from 'cozy-ui/transpiled/react/Icons/FileTypeFolder'
import TrashIcon from 'cozy-ui/transpiled/react/Icons/Trash'
import PhotosIcon from 'cozy-ui/transpiled/react/Icons/FileTypeImage'
import EncryptedFolderIcon from 'drive/web/modules/views/Folder/EncryptedFolderIcon'
import useBreakpoints from 'cozy-ui/transpiled/react/hooks/useBreakpoints'

import styles from './empty.styl'

Expand All @@ -17,14 +18,18 @@ const EmptyIcon = {
trash: TrashIcon
}

const EmptyCanvas = ({ type, canUpload, localeKey }) => {
const EmptyCanvas = ({ type, canUpload, localeKey, hasTextMobileVersion }) => {
const { t } = useI18n()
const { isMobile } = useBreakpoints()
return (
<Empty
data-testid="empty-folder"
icon={EmptyIcon[type]}
title={localeKey ? t(`empty.${localeKey}_title`) : t('empty.title')}
text={
(hasTextMobileVersion &&
isMobile &&
t(`empty.${localeKey}_mobile_text`)) ||
(localeKey && t(`empty.${localeKey}_text`)) ||
(canUpload && t('empty.text'))
}
Expand Down
4 changes: 3 additions & 1 deletion src/photos/components/PhotoBoard.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,9 @@ const PhotoBoard = ({
return <Loading loadingType="photos_fetching" />
}
if (!isFetching && (lists.length === 0 || lists[0].photos.length === 0)) {
return <EmptyPhotos localeKey={`${photosContext}_photos`} />
return (
<EmptyPhotos localeKey={`${photosContext}_photos`} hasTextMobileVersion />
)
}

return (
Expand Down
2 changes: 1 addition & 1 deletion src/photos/ducks/albums/components/AlbumPhotos.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -184,7 +184,7 @@ class AlbumPhotos extends Component {
<PhotoBoard
lists={[{ photos }]}
selected={selected}
photosContext="timeline"
photosContext="album_with"
showSelection={active}
onPhotoToggle={selection.toggle}
onPhotosSelect={selection.select}
Expand Down
2 changes: 1 addition & 1 deletion src/photos/ducks/albums/components/AlbumsList.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ const sortByCreationDate = (a, b) => {

const AlbumsList = ({ data, hasMore, fetchMore, t }) =>
data.length === 0 ? (
<EmptyPhotos localeKey="albums" />
<EmptyPhotos localeKey="albums" hasTextMobileVersion />
) : (
<Content>
<div className={styles['pho-album-list']}>
Expand Down
4 changes: 3 additions & 1 deletion src/photos/ducks/albums/index.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,9 @@ describe('Album view', () => {
setup()

// Then
const label = await screen.findByText("You don't have any photos yet.")
const label = await screen.findByText(
'There is no photo in this album yet.'
)
expect(label).toBeInTheDocument()
})

Expand Down
14 changes: 9 additions & 5 deletions src/photos/locales/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,13 +18,17 @@
},
"empty": {
"timeline_photos_title": "You don't have any photos yet.",
"timeline_photos_text": "Click the \"Upload\" button to add photos.",
"timeline_photos_text": "Click on \"Upload\" button to add photos.",
"timeline_photos_mobile_text": "Click on \"...\" in the top right-hand corner and then on \"Upload photos\" to add photos.",
"albums_title": "You don't have any album yet.",
"albums_text": "Start by clicking \"New album\" to create your first album.",
"album_photos_title": "There is no photo in this album yet.",
"album_photos_text": "Start by clicking \"Add photos to album\" to add some.",
"albums_text": "Click on \"New album\" to create your first album.",
"albums_mobile_text": "Click on \"...\" in the top right-hand corner and then on \"New album\" to create your first album.",
"album_with_photos_title": "There is no photo in this album yet.",
"album_with_photos_text": "Click on \"...\" in the top right-hand corner and then on \"Add photos to album\" to add some.",
"album_with_photos_mobile_text": "Click on \"...\" in the top right-hand corner and then on \"Add photos to album\" to add some.",
"shared_album_photos_title": "There is no photo in this album yet.",
"shared_album_photos_text": "Come back later"
"shared_album_photos_text": "Come back later",
"shared_album_photos_mobile_text": "Come back later"
},
"Error": {
"albums_title": "An error occurred while retrieving the albums list. Please try again later.",
Expand Down
2 changes: 1 addition & 1 deletion src/photos/targets/public/App.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ export class App extends Component {
<PhotoBoard
lists={[{ photos }]}
selected={selected}
photosContext="timeline"
photosContext="shared_album"
showSelection={active}
onPhotoToggle={selection.toggle}
onPhotosSelect={selection.select}
Expand Down
4 changes: 2 additions & 2 deletions src/photos/targets/public/__snapshots__/App.spec.jsx.snap
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ exports[`Public view should render children when they are present 1`] = `
onPhotoToggle={[Function]}
onPhotosSelect={[Function]}
onPhotosUnselect={[Function]}
photosContext="timeline"
photosContext="shared_album"
selected={Array []}
showSelection={false}
/>
Expand Down Expand Up @@ -110,7 +110,7 @@ exports[`Public view should render the album 1`] = `
onPhotoToggle={[Function]}
onPhotosSelect={[Function]}
onPhotosUnselect={[Function]}
photosContext="timeline"
photosContext="shared_album"
selected={Array []}
showSelection={false}
/>
Expand Down

0 comments on commit a6cffd9

Please sign in to comment.