Skip to content

Commit

Permalink
feat: Add file extension type column to shared data card for files (#…
Browse files Browse the repository at this point in the history
…1660)

* feat: Add the file type to shared files info as a column in a nested grid.

* feat: remove nested grid and just shrink the space used for the title in order to accomodate the file type column

* docs: remove comments that were just notes to self

* fix: move uppercasing text to the view layer. This also fixes failing tests.

* test: add expectation of a file name and its extension type
  • Loading branch information
knipec authored Mar 22, 2024
1 parent 8c3b52c commit 8d661ac
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 9 deletions.
4 changes: 4 additions & 0 deletions src/landscape/components/LandscapeView.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,7 @@ const baseViewTest = async (
description: `Description ${index}`,
size: 3456,
entryType: 'FILE',
resourceType: 'txt',
visualizations: { edges: [] },
},
},
Expand Down Expand Up @@ -233,6 +234,9 @@ test('LandscapeView: Display data', async () => {
const entriesList = within(sharedDataRegion.getByRole('list'));
const items = entriesList.getAllByRole('listitem');
expect(items.length).toBe(6);
const firstEntry = within(items[0]);
expect(firstEntry.getByText('Data Entry 0')).toBeInTheDocument();
expect(firstEntry.getByText('txt')).toBeInTheDocument();

// Boundary
expect(
Expand Down
29 changes: 21 additions & 8 deletions src/sharedData/components/SharedDataEntryBase.js
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,8 @@ const SharedDataEntryBase = props => {
EntryTypeIcon,
DownloadComponent,
ShareComponent,
info,
fileSize,
resourceType,
deleteTooltip,
} = props;
const [isEditingName, setIsEditingName] = useState(false);
Expand Down Expand Up @@ -173,7 +174,7 @@ const SharedDataEntryBase = props => {
<Grid
item
xs={isEditingName ? 12 : 8}
md={6}
md={5}
order={{ xs: 2, md: 2 }}
component={StackRow}
>
Expand Down Expand Up @@ -203,26 +204,38 @@ const SharedDataEntryBase = props => {
/>
</Restricted>
</Grid>
<Grid item xs={1} order={{ xs: 5 }} display={{ md: 'none' }} />

<Grid item xs={1} order={{ xs: 4 }} display={{ md: 'none' }} />
<Grid
item
xs={11}
xs={2}
md={1}
order={{ xs: 6, md: 4 }}
order={{ xs: 5, md: 4 }}
sx={{ wordWrap: 'break-word', textTransform: 'uppercase' }}
>
{resourceType}
</Grid>
<Grid
item
xs={2}
md={1}
order={{ xs: 6, md: 5 }}
sx={{ wordWrap: 'break-word' }}
>
{info}
{fileSize}
</Grid>
<Grid item xs={7} order={{ xs: 7 }} display={{ md: 'none' }} />
<Grid item xs={1} order={{ xs: 7 }} display={{ md: 'none' }} />
<Grid item xs={11} md={3} order={{ xs: 8, md: 4 }}>
<Grid item xs={11} md={3} order={{ xs: 8, md: 6 }}>
{formatDate(i18n.resolvedLanguage, dataEntry.createdAt)}, by{' '}
{t('user.full_name', { user: dataEntry.createdBy })}
</Grid>

<Grid
item
xs={4}
md={2}
order={{ xs: 3, md: 4 }}
order={{ xs: 3, md: 6 }}
component={StackRow}
justifyContent="flex-end"
display={isEditingName ? 'none' : 'inherit'}
Expand Down
3 changes: 2 additions & 1 deletion src/sharedData/components/SharedDataEntryFile.js
Original file line number Diff line number Diff line change
Expand Up @@ -362,7 +362,8 @@ const SharedDataEntryFile = props => {
EntryTypeIcon={SharedFileIcon}
DownloadComponent={DownloadComponent}
ShareComponent={ShareComponent}
info={filesize(sharedResource.dataEntry.size, { round: 0 })}
fileSize={filesize(sharedResource.dataEntry.size, { round: 0 })}
resourceType={sharedResource.dataEntry.resourceType}
>
<Visualizations file={sharedResource.dataEntry} />
</SharedDataEntryBase>
Expand Down

0 comments on commit 8d661ac

Please sign in to comment.