Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add sorting header for mobile file browser #1786

Merged
merged 15 commits into from
Dec 6, 2021
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,8 @@ import {
GridIcon,
TableIcon,
UploadSvg,
PlusCircleSvg
PlusCircleSvg,
MoreIcon,
Tbaut marked this conversation as resolved.
Show resolved Hide resolved
} from "@chainsafe/common-components"
import { useState } from "react"
import { useMemo } from "react"
Expand Down Expand Up @@ -415,6 +416,14 @@ const FilesList = ({ isShared = false }: Props) => {
}
}

const toggleSortDirection = () => {
if (direction === "ascend") {
setDirection("descend")
} else {
setDirection("ascend")
}
}

// Previews
const setNextPreview = () => {
if (
Expand Down Expand Up @@ -882,7 +891,7 @@ const FilesList = ({ isShared = false }: Props) => {
className={clsx(loadingCurrentPath && classes.fadeOutLoading)}
testId="home"
>
{desktop && (
{desktop ? (
<TableHead>
<TableRow type="grid"
className={classes.tableRow}>
Expand Down Expand Up @@ -928,6 +937,58 @@ const FilesList = ({ isShared = false }: Props) => {
<TableHeadCell>{/* Menu */}</TableHeadCell>
</TableRow>
</TableHead>
) : (
<TableHead>
<TableRow type="grid"
className={classes.tableRow}>
<TableHeadCell>
{/* Checkbox */}
</TableHeadCell>
<TableHeadCell
sortButtons
align='left'
onSortChange={toggleSortDirection}
sortDirection={direction}
>
{column === "name" ? "Name" : column === "date_uploaded" ? "Date uploaded" : "Size"}
FSM1 marked this conversation as resolved.
Show resolved Hide resolved
</TableHeadCell>
<TableHeadCell align='right'>
<Menu
testId='fileDropdown'
icon={<MoreIcon className={classes.dropdownIcon} />}
options={[{
contents: (
<>
<span data-cy="sort-menu-name">
<Trans>Name</Trans>
</span>
</>
),
onClick: () => setColumn("name")
}, {
contents: (
<>
<span data-cy="sort-menu-date-uploaded">
<Trans>Date Uploaded</Trans>
</span>
</>
),
onClick: () => setColumn("date_uploaded")
}, {
contents: (
<>
<span data-cy="sort-menu-size">
<Trans>Size</Trans>
</span>
</>
),
onClick: () => setColumn("size")
}]}
style={{ focusVisible: classes.focusVisible }}
/>
</TableHeadCell>
</TableRow>
</TableHead>
)}
<TableBody>
{items.map((file, index) => (
Expand Down
3 changes: 3 additions & 0 deletions packages/files-ui/src/locales/de/messages.po
Original file line number Diff line number Diff line change
Expand Up @@ -193,6 +193,9 @@ msgstr ""
msgid "Data restored successfully"
msgstr ""

msgid "Date Uploaded"
msgstr ""

msgid "Date uploaded"
msgstr "Hochgeladen am"

Expand Down
3 changes: 3 additions & 0 deletions packages/files-ui/src/locales/en/messages.po
Original file line number Diff line number Diff line change
Expand Up @@ -193,6 +193,9 @@ msgstr "Data moved to bin successfully"
msgid "Data restored successfully"
msgstr "Data restored successfully"

msgid "Date Uploaded"
msgstr "Date Uploaded"

msgid "Date uploaded"
msgstr "Date uploaded"

Expand Down
3 changes: 3 additions & 0 deletions packages/files-ui/src/locales/es/messages.po
Original file line number Diff line number Diff line change
Expand Up @@ -194,6 +194,9 @@ msgstr ""
msgid "Data restored successfully"
msgstr ""

msgid "Date Uploaded"
msgstr ""

msgid "Date uploaded"
msgstr "Fecha de subida"

Expand Down
3 changes: 3 additions & 0 deletions packages/files-ui/src/locales/fr/messages.po
Original file line number Diff line number Diff line change
Expand Up @@ -194,6 +194,9 @@ msgstr "Les données ont été déplacées vers la poubelle avec succès"
msgid "Data restored successfully"
msgstr "Données restaurées avec succès"

msgid "Date Uploaded"
msgstr ""

msgid "Date uploaded"
msgstr "Téléversé le"

Expand Down
3 changes: 3 additions & 0 deletions packages/files-ui/src/locales/no/messages.po
Original file line number Diff line number Diff line change
Expand Up @@ -193,6 +193,9 @@ msgstr ""
msgid "Data restored successfully"
msgstr ""

msgid "Date Uploaded"
msgstr ""

msgid "Date uploaded"
msgstr "Dato opplastet"

Expand Down