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

[WIP] Mantine datatables #5218

Merged
merged 460 commits into from
Jul 27, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
460 commits
Select commit Hold shift + click to select a range
b0f6274
Merge pull request #52 from invenhost/deps
matmair Nov 30, 2022
810f824
Create dependency-review.yml
matmair Dec 1, 2022
271ac5c
Create scan.yml
matmair Dec 2, 2022
1389329
Create sonar-project.properties
matmair Dec 2, 2022
410fc66
Merge pull request #57 from invenhost/matmair-sonar
matmair Dec 2, 2022
43255dd
add option to use sections and refactro
matmair Dec 2, 2022
b339d86
translate error messages
matmair Dec 2, 2022
ecc6abb
remove unneeded vars
matmair Dec 2, 2022
a7c5e89
move function code
matmair Dec 2, 2022
864362a
move data inside
matmair Dec 2, 2022
7af2664
add global section
matmair Dec 3, 2022
41f4bd3
add plugin section
matmair Dec 3, 2022
d94552d
use translated section titles
matmair Dec 3, 2022
7e2138d
add translation strings
matmair Dec 3, 2022
338ff94
Merge pull request #58 from invenhost/settings-sections
matmair Dec 3, 2022
5342a66
rename scan action
matmair Dec 4, 2022
04fa760
Merge pull request #59 from invenhost/matmair-scan
matmair Dec 4, 2022
4862bda
add user settings
matmair Dec 4, 2022
eacf087
use ordered data
matmair Dec 4, 2022
fdca9a9
fix settings url
matmair Dec 4, 2022
9b39c32
use debounced value for strings (not choices!)
matmair Dec 4, 2022
1d56a69
Merge pull request #60 from invenhost/settings-sections
matmair Dec 4, 2022
1ba55a3
rename contex to context
matmair Dec 4, 2022
308c2d7
move i18n provider up
matmair Dec 4, 2022
acf5714
move theme options into seperate context/ component
matmair Dec 4, 2022
f07a7cd
renmae statrtup vars
matmair Dec 4, 2022
9352da8
move translations out
matmair Dec 4, 2022
a63b770
reactivate sentry
matmair Dec 4, 2022
6f1908d
move i18n provider to seperate context
matmair Dec 5, 2022
ce3dc4f
move langauge state completly out of App
matmair Dec 5, 2022
e78ba5f
use theme out
matmair Dec 5, 2022
7581ca2
move theme context
matmair Dec 5, 2022
099da09
move LanguageContext
matmair Dec 5, 2022
5f3678e
move function into state
matmair Dec 5, 2022
844d31e
make sentry optional for now
matmair Dec 5, 2022
08013c9
add key to accordion
matmair Dec 5, 2022
ae599b7
init langauge context on top
matmair Dec 5, 2022
06e5b3a
remove unneeded css files
matmair Dec 5, 2022
3b2308e
move errorpage to tsx
matmair Dec 5, 2022
0494121
add translation for error page
matmair Dec 5, 2022
435d2fa
Add error to title
matmair Dec 5, 2022
f472a5d
add typecast for error
matmair Dec 5, 2022
71dc3cc
move type definition out
matmair Dec 5, 2022
9887642
remove todo -> type was already added
matmair Dec 5, 2022
afa1bf0
Merge pull request #61 from invenhost/refactor-2
matmair Dec 5, 2022
f4b2809
Merge pull request #63 from invenhost/matmair-patch-2
matmair Dec 11, 2022
7f7292b
upgrade deps
matmair Dec 31, 2022
b7978f1
Merge pull request #65 from invenhost/deps
matmair Dec 31, 2022
368f0ea
add bootstrap
matmair Dec 31, 2022
333943e
remove @mantine/core
matmair Dec 31, 2022
90d6a3f
readd core
matmair Dec 31, 2022
5b11f2a
switch to bootstrap
matmair Dec 31, 2022
80839bf
simplify import
matmair Dec 31, 2022
616dd0c
Merge pull request #66 from invenhost/bootstrap
matmair Dec 31, 2022
eb793b7
Add SPA views for react #2789
matmair Jun 9, 2023
b5c0b26
split up frontend urls
matmair Jun 9, 2023
d7c4baa
Add settings for frontend url loading
matmair Jun 9, 2023
4c507dc
add new UI scaffold
matmair Jun 9, 2023
abf7309
remove tracking insert
matmair Jun 9, 2023
0f2f51f
add platform app
matmair Jun 9, 2023
61ff33a
ensure static indexes work too
matmair Jun 9, 2023
bcc28b0
add lingui
matmair Jun 9, 2023
205399f
add lingui config
matmair Jun 9, 2023
623d23e
add mgmt tasks
matmair Jun 9, 2023
eb0f392
add base locales
matmair Jun 9, 2023
d778b59
Merge branch 'beta' of https://github.com/invenhost/InvenTree into pl…
matmair Jun 9, 2023
f2799ef
Merge branch 'master' of https://github.com/inventree/InvenTree into …
matmair Jun 10, 2023
f98a5d4
settings for frontend dev
matmair Jun 11, 2023
aea6d8f
fix typo
matmair Jun 11, 2023
c2b8954
update deps
matmair Jun 11, 2023
aab7759
add pre-commit
matmair Jun 11, 2023
ccbe3d4
add eslint
matmair Jun 12, 2023
8bcb4f8
add testing scaffold
matmair Jun 12, 2023
de4f024
fix paths
matmair Jun 12, 2023
f7d9a93
remove error - tests trip correctly
matmair Jun 12, 2023
188c4c3
Merge branch 'inventree:master' into plattform
matmair Jun 14, 2023
0aea007
Merge branch 'inventree:master' into plattform
matmair Jun 16, 2023
4353fac
Merge branch 'master' of https://github.com/inventree/InvenTree into …
matmair Jun 26, 2023
9816ec0
merge workflow
matmair Jun 26, 2023
e379320
cleanup samples
matmair Jun 26, 2023
eab41a4
use name inline with other tests
matmair Jun 26, 2023
3030496
Add real worl frontend tests
matmair Jun 26, 2023
36c117c
setup env
matmair Jun 26, 2023
c0ea1db
tun migrations first
matmair Jun 26, 2023
c249717
optimize setup time
matmair Jun 26, 2023
204cc55
setup demo dataset
matmair Jun 26, 2023
515c1bc
optimize run setup
matmair Jun 26, 2023
cd54f59
add test for class ui
matmair Jun 26, 2023
f3ee654
rename
matmair Jun 26, 2023
7a258b2
fix typo
matmair Jun 26, 2023
b7aba13
and another typo
matmair Jun 26, 2023
5eb035f
do install
matmair Jun 26, 2023
29772d9
run migrations first
matmair Jun 26, 2023
ef2d6ed
fix name
matmair Jun 26, 2023
dceeea9
cleanup
matmair Jun 26, 2023
f1f8051
use other credentials
matmair Jun 26, 2023
7ef6878
use other credentials
matmair Jun 26, 2023
4aec179
fix qc
matmair Jun 26, 2023
a454258
move envs to qc
matmair Jun 26, 2023
8638d8f
remove create_site
matmair Jun 26, 2023
7aa040a
reduce testing env
matmair Jun 26, 2023
eb69869
fix test
matmair Jun 26, 2023
9bfe7db
fix test call
matmair Jun 26, 2023
36e271a
allaccess user
matmair Jun 26, 2023
ae9467a
add ui plattform check
matmair Jun 26, 2023
2f0f622
add better check
matmair Jun 26, 2023
441719c
remove unneeded env
matmair Jun 26, 2023
ce0880a
enable debug
matmair Jun 26, 2023
fb49dfe
reduce wait time
matmair Jun 26, 2023
a520e57
also build frontend on static
matmair Jun 26, 2023
8f95b9e
Merge branch 'plattform' of https://github.com/matmair/InvenTree into…
matmair Jun 27, 2023
76bd078
add sekeleton
matmair Jun 27, 2023
0b3cda9
fix various issues
matmair Jun 27, 2023
8cf53b7
add locales
matmair Jun 27, 2023
04c6c20
clean output before building
matmair Jun 27, 2023
e1a0c37
cleanup dir
matmair Jun 27, 2023
cb390c9
remove bootstrap
matmair Jun 27, 2023
455ef12
clean up deps
matmair Jun 27, 2023
16dd975
fix settings panel
matmair Jun 27, 2023
a915226
remove assets
matmair Jun 27, 2023
7a16f37
move logo
matmair Jun 27, 2023
b36f656
split out router
matmair Jun 27, 2023
ab643b1
split up chunks
matmair Jun 27, 2023
9334624
fix zustand import syntax
matmair Jun 27, 2023
077b71a
bundl
matmair Jun 28, 2023
b843307
update pre-render
matmair Jun 28, 2023
d3dab6c
use vendor splitting
matmair Jun 28, 2023
02da78a
maximes space usage
matmair Jun 28, 2023
1e7e0ff
enlarge breakpoints
matmair Jun 28, 2023
d7be6c1
remove wired color changes
matmair Jun 28, 2023
d76dc20
cleanup tabs
matmair Jun 28, 2023
f1a3431
fix error
matmair Jun 28, 2023
037e32f
update auth functions
matmair Jun 29, 2023
96e4159
default to mail login
matmair Jun 29, 2023
cc4dc56
add placeholder marking
matmair Jun 30, 2023
553dcef
Add text to placeholder
matmair Jun 30, 2023
4fb12e4
readd codespell
matmair Jun 30, 2023
687775b
Merge branch 'master' of https://github.com/inventree/InvenTree into …
matmair Jun 30, 2023
310681e
add another test
matmair Jul 2, 2023
0078e7d
add sort plugin
matmair Jul 2, 2023
9efa4f4
add sort plugin
matmair Jul 2, 2023
d8202f7
sort imports
matmair Jul 2, 2023
f3ca199
fix order
matmair Jul 2, 2023
1a5f772
Add mega menu
matmair Jul 6, 2023
f5019ef
run pre-commit fixes
matmair Jul 6, 2023
ec539f0
Merge branch 'master' of https://github.com/inventree/InvenTree into …
matmair Jul 6, 2023
c3c998b
Merge branch 'master' of https://github.com/inventree/InvenTree into …
matmair Jul 6, 2023
42bdf70
add node min version
matmair Jul 7, 2023
24d7460
Docker container (#129)
SchrodingersGat Jul 8, 2023
79b1b6b
Merge branch 'inventree:master' into plattform
matmair Jul 8, 2023
6d1fd97
add import order settings
matmair Jul 8, 2023
4c0a723
Merge branch 'plattform' of https://github.com/matmair/InvenTree into…
matmair Jul 8, 2023
fe4a1b2
cleanout built ui
matmair Jul 9, 2023
c15e994
Add "parttable" component
SchrodingersGat Jul 9, 2023
1bb8b58
Add task to serve front-end code dev
SchrodingersGat Jul 9, 2023
719e321
remove default arg from build
matmair Jul 9, 2023
d10e764
remove eslint
matmair Jul 9, 2023
c1b7af0
optimize svg
matmair Jul 9, 2023
18d2664
Adds generic function for rendering a table with server-side data
SchrodingersGat Jul 9, 2023
1de6602
Implement pagination and sorting
SchrodingersGat Jul 9, 2023
0b99852
Add more example columns
SchrodingersGat Jul 9, 2023
6188510
Enable selection of table data rows
SchrodingersGat Jul 9, 2023
84a24a0
add build step for plattform UI
matmair Jul 9, 2023
a0308fe
fix install command
matmair Jul 9, 2023
e7f84bc
optional parameters
SchrodingersGat Jul 10, 2023
698e012
Add simple stock table
SchrodingersGat Jul 10, 2023
f37e5c2
Add optional parameter for default sort
SchrodingersGat Jul 10, 2023
872f71b
Change "no records" text based on query result
SchrodingersGat Jul 10, 2023
d38f5f0
Translate
SchrodingersGat Jul 10, 2023
904485e
Start writing some helper functions
SchrodingersGat Jul 10, 2023
5d835ef
Add thumbnail component
SchrodingersGat Jul 10, 2023
2d1b19d
Fill out more columns for stock table
SchrodingersGat Jul 10, 2023
affba63
Add simple skeleton for table search input
SchrodingersGat Jul 10, 2023
35542d2
Adjust default table properties
SchrodingersGat Jul 10, 2023
d724834
Change loader variant
SchrodingersGat Jul 10, 2023
953298f
Drop-down for selecting table columns
SchrodingersGat Jul 10, 2023
685a42f
Add search text callback
SchrodingersGat Jul 10, 2023
efc0251
Merge branch 'master' of https://github.com/inventree/InvenTree into …
matmair Jul 10, 2023
4be39a6
use alpine commands
matmair Jul 10, 2023
29c22fb
do not use cache when creating image
matmair Jul 11, 2023
44d96d4
More updates for inventree table
SchrodingersGat Jul 11, 2023
ea8f80a
Search input improvements
SchrodingersGat Jul 11, 2023
6ff4060
Enable mantine notification system
SchrodingersGat Jul 11, 2023
1f1f748
Add "not yet implemented" notification message
SchrodingersGat Jul 11, 2023
a42ae6b
Add download action button
SchrodingersGat Jul 11, 2023
b3b632c
Adds ButtonMenu component
SchrodingersGat Jul 11, 2023
6d4cd45
Add basic build order list table
SchrodingersGat Jul 11, 2023
381779c
Add custom filters button for table
SchrodingersGat Jul 12, 2023
d2f22bd
Allow columns to be toggled
SchrodingersGat Jul 12, 2023
bdd7f27
Column visibility saved across table loads
SchrodingersGat Jul 12, 2023
e06dc9e
Adds display for table filters
SchrodingersGat Jul 12, 2023
f01f605
Cleanup
SchrodingersGat Jul 12, 2023
e0dc0a0
Define type for controlling column data
SchrodingersGat Jul 12, 2023
f8bf76b
Allow custom ordering term for table column
SchrodingersGat Jul 12, 2023
52282cb
Improve build order table
SchrodingersGat Jul 12, 2023
0e276e1
Merge branch 'plattform' into mantine-datatables
SchrodingersGat Jul 13, 2023
4ece47d
Reimplement invoke task to serve frontend files via yarn
SchrodingersGat Jul 13, 2023
f65329c
Update package files with mantine
SchrodingersGat Jul 13, 2023
4a1d322
Implement callback when record selection is changed
SchrodingersGat Jul 13, 2023
86a8520
Adds generic "actionbutton" component
SchrodingersGat Jul 13, 2023
3f09b3f
Merge commit 'f70294b24762d96e6fde8ad1a44bafc272c5efb2' into mantine-…
SchrodingersGat Jul 21, 2023
e1ad06e
Remove duplicate form components
SchrodingersGat Jul 21, 2023
b7cfd67
Remove tracked files in web/static
SchrodingersGat Jul 21, 2023
fb734f2
Remove a bunch of files
SchrodingersGat Jul 21, 2023
8810721
More page fixes
SchrodingersGat Jul 21, 2023
b9c2640
Revert changes to reqiurements-dev.txt
SchrodingersGat Jul 21, 2023
fe0d3c9
Spelling fix
SchrodingersGat Jul 21, 2023
be42910
Component updates
SchrodingersGat Jul 21, 2023
b13e7b2
Cleanup components
SchrodingersGat Jul 21, 2023
5b8217b
Merge commit 'f227315ad140510b7118c54e2ce93896f04b2871' into mantine-…
SchrodingersGat Jul 22, 2023
e48b8f4
Cleanup
SchrodingersGat Jul 22, 2023
8283d66
Use spread operator
SchrodingersGat Jul 22, 2023
c0248d5
Add some new dummy pages for testing
SchrodingersGat Jul 22, 2023
f986534
Cleanup / simplify stockitem table
SchrodingersGat Jul 22, 2023
e9c9f02
Cleanup for part table
SchrodingersGat Jul 22, 2023
44e5a00
Cleanup build order table
SchrodingersGat Jul 22, 2023
446e321
Cleanup column toggle function
SchrodingersGat Jul 22, 2023
84cde07
Remove hard-coded URL
SchrodingersGat Jul 22, 2023
3aca792
Merge commit '507205ca78f0349f1cfeaefb14e6bd76d974acca' into mantine-…
SchrodingersGat Jul 22, 2023
78f79f4
Format updates
SchrodingersGat Jul 22, 2023
001df92
Update deps
SchrodingersGat Jul 23, 2023
d594aa5
npm required for inventree-python checks
SchrodingersGat Jul 23, 2023
c289de1
Fix search input
SchrodingersGat Jul 23, 2023
26a096a
Merge branch 'platform-assets' into mantine-datatables
SchrodingersGat Jul 25, 2023
f3a2be9
Update package files
SchrodingersGat Jul 25, 2023
ec021c1
vite polling fixes
SchrodingersGat Jul 25, 2023
665091a
Implementation for download button
SchrodingersGat Jul 25, 2023
14eac94
Implement callback for download of table data
SchrodingersGat Jul 25, 2023
c48fc71
Better state management for hidden columns
SchrodingersGat Jul 25, 2023
23bb0de
Implement state framework for active custom filters
SchrodingersGat Jul 25, 2023
f27e20b
Silence some errors
SchrodingersGat Jul 25, 2023
884146a
Revert change to vite config
SchrodingersGat Jul 25, 2023
5a306ff
Implement collapsible filter list group
SchrodingersGat Jul 25, 2023
2a0ec20
Fix page names
SchrodingersGat Jul 25, 2023
95d6f05
Simplify search input
SchrodingersGat Jul 25, 2023
feea588
linting
SchrodingersGat Jul 25, 2023
34f6563
Refactor
SchrodingersGat Jul 25, 2023
667c65b
Remove debug msg
SchrodingersGat Jul 25, 2023
c42483c
Simplify search state
SchrodingersGat Jul 25, 2023
5c6533c
Refactor function for constructing API query
SchrodingersGat Jul 25, 2023
9c53838
Add tooltip
SchrodingersGat Jul 25, 2023
0c685ff
Update icons
SchrodingersGat Jul 25, 2023
af116db
Merge remote-tracking branch 'inventree/master' into mantine-datatables
SchrodingersGat Jul 26, 2023
52f8a06
Add modal for selecting filter options
SchrodingersGat Jul 26, 2023
9e5282c
Add more table filters for part table
SchrodingersGat Jul 26, 2023
90f3f72
render custom item for filter select
SchrodingersGat Jul 26, 2023
13d5bc3
Complete implementation for selectable filters
SchrodingersGat Jul 26, 2023
a685f08
Tweak badge
SchrodingersGat Jul 26, 2023
1c6dea2
Cleanup top-level yarn and npm files
SchrodingersGat Jul 26, 2023
05b73ae
Less roundy
SchrodingersGat Jul 26, 2023
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
1 change: 1 addition & 0 deletions .github/workflows/qc_checks.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -152,6 +152,7 @@ jobs:
apt-dependency: gettext poppler-utils
dev-install: true
update: true
npm: true
- name: Download Python Code For `${{ env.wrapper_name }}`
run: git clone --depth 1 https://github.com/inventree/${{ env.wrapper_name }}
./${{ env.wrapper_name }}
Expand Down
2,534 changes: 3 additions & 2,531 deletions package-lock.json

Large diffs are not rendered by default.

8 changes: 1 addition & 7 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,12 +1,6 @@
{
"dependencies": {
"@emotion/react": "^11.11.1",
"@mantine/core": "^6.0.17",
"@mantine/dropzone": "^6.0.17",
"@mantine/hooks": "^6.0.17",
"@mantine/notifications": "^6.0.17",
"eslint": "^8.41.0",
"eslint-config-google": "^0.14.0",
"mantine-datatable": "^2.8.5"
"eslint-config-google": "^0.14.0"
}
}
1 change: 1 addition & 0 deletions src/frontend/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@
"axios": "^1.4.0",
"dayjs": "^1.11.9",
"html5-qrcode": "^2.3.8",
"mantine-datatable": "^2.9.0",
"react": "^18.2.0",
"react-dom": "^18.2.0",
"react-router-dom": "^6.14.2",
Expand Down
35 changes: 35 additions & 0 deletions src/frontend/src/components/items/ActionButton.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
import { ActionIcon, Tooltip } from '@mantine/core';

/**
* Construct a simple action button with consistent styling
*/
export function ActionButton({
icon,
color = 'black',
tooltip = '',
disabled = false,
size = 18,
onClick
}: {
icon: any;
color?: string;
tooltip?: string;
variant?: string;
size?: number;
disabled?: boolean;
onClick?: any;
}) {
return (
<ActionIcon
disabled={disabled}
radius="xs"
color={color}
size={size}
onClick={onClick}
>
<Tooltip disabled={!tooltip} label={tooltip} position="left">
{icon}
</Tooltip>
</ActionIcon>
);
}
36 changes: 36 additions & 0 deletions src/frontend/src/components/items/ButtonMenu.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
import { ActionIcon, Menu, Tooltip } from '@mantine/core';
import { Component } from 'react';

/**
* A ButtonMenu is a button that opens a menu when clicked.
* It features a number of actions, which can be selected by the user.
*/
export function ButtonMenu({
icon,
actions,
tooltip = '',
label = ''
}: {
icon: any;
actions: any[];
label?: string;
tooltip?: string;
}) {
let idx = 0;

return (
<Menu shadow="xs">
<Menu.Target>
<ActionIcon>
<Tooltip label={tooltip}>{icon}</Tooltip>
</ActionIcon>
</Menu.Target>
<Menu.Dropdown>
{label && <Menu.Label>{label}</Menu.Label>}
{actions.map((action) => (
<Menu.Item key={idx++}>{action}</Menu.Item>
))}
</Menu.Dropdown>
</Menu>
);
}
57 changes: 57 additions & 0 deletions src/frontend/src/components/items/Thumbnail.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
import { t } from '@lingui/macro';
import { Image } from '@mantine/core';
import { Group } from '@mantine/core';
import { Text } from '@mantine/core';

export function Thumbnail({
src,
alt = t`Thumbnail`,
size = 24
}: {
src: string;
alt?: string;
size?: number;
}) {
// TODO: Use api to determine the correct URL
let url = 'http://localhost:8000' + src;

// TODO: Use HoverCard to display a larger version of the image

return (
<Image
src={url}
alt={alt}
width={size}
fit="contain"
radius="xs"
withPlaceholder
imageProps={{
style: {
maxHeight: size
}
}}
/>
);
}

export function ThumbnailHoverCard({
src,
text,
link = '',
alt = t`Thumbnail`,
size = 24
}: {
src: string;
text: string;
link?: string;
alt?: string;
size?: number;
}) {
// TODO: Handle link
return (
<Group position="left" spacing={10}>
<Thumbnail src={src} alt={alt} size={size} />
<Text>{text}</Text>
</Group>
);
}
15 changes: 15 additions & 0 deletions src/frontend/src/components/tables/Column.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
/**
* Interface for the table column definition
*/
export type TableColumn = {
accessor: string; // The key in the record to access
ordering?: string; // The key in the record to sort by (defaults to accessor)
title: string; // The title of the column
sortable?: boolean; // Whether the column is sortable
switchable?: boolean; // Whether the column is switchable
hidden?: boolean; // Whether the column is hidden
render?: (record: any) => any; // A custom render function
filter?: any; // A custom filter function
filtering?: boolean; // Whether the column is filterable
width?: number; // The width of the column
};
40 changes: 40 additions & 0 deletions src/frontend/src/components/tables/ColumnSelect.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
import { t } from '@lingui/macro';
import { Checkbox, Menu, Tooltip } from '@mantine/core';
import { ActionIcon } from '@mantine/core';
import { IconAdjustments } from '@tabler/icons-react';

export function TableColumnSelect({
columns,
onToggleColumn
}: {
columns: any[];
onToggleColumn: (columnName: string) => void;
}) {
return (
<Menu shadow="xs">
<Menu.Target>
<ActionIcon>
<Tooltip label={t`Select Columns`}>
<IconAdjustments />
</Tooltip>
</ActionIcon>
</Menu.Target>

<Menu.Dropdown>
<Menu.Label>{t`Select Columns`}</Menu.Label>
{columns
.filter((col) => col.switchable)
.map((col) => (
<Menu.Item key={col.accessor}>
<Checkbox
checked={!col.hidden}
label={col.title || col.accessor}
onChange={(event) => onToggleColumn(col.accessor)}
radius="sm"
/>
</Menu.Item>
))}
</Menu.Dropdown>
</Menu>
);
}
45 changes: 45 additions & 0 deletions src/frontend/src/components/tables/DownloadAction.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
import { Trans, t } from '@lingui/macro';
import { ActionIcon, Divider, Group, Menu, Select } from '@mantine/core';
import { Tooltip } from '@mantine/core';
import { Button, Modal, Stack } from '@mantine/core';
import { useDisclosure } from '@mantine/hooks';
import { IconDownload } from '@tabler/icons-react';
import { useState } from 'react';

export function DownloadAction({
downloadCallback
}: {
downloadCallback: (fileFormat: string) => void;
}) {
const formatOptions = [
{ value: 'csv', label: t`CSV` },
{ value: 'tsv', label: t`TSV` },
{ value: 'xlsx', label: t`Excel` }
];

return (
<>
<Menu>
<Menu.Target>
<ActionIcon>
<Tooltip label={t`Download selected data`}>
<IconDownload />
</Tooltip>
</ActionIcon>
</Menu.Target>
<Menu.Dropdown>
{formatOptions.map((format) => (
<Menu.Item
key={format.value}
onClick={() => {
downloadCallback(format.value);
}}
>
{format.label}
</Menu.Item>
))}
</Menu.Dropdown>
</Menu>
</>
);
}
21 changes: 21 additions & 0 deletions src/frontend/src/components/tables/Filter.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
/**
* Interface for the table filter choice
*/
export type TableFilterChoice = {
value: string;
label: string;
};

/**
* Interface for the table filter,
*/
export type TableFilter = {
name: string;
label: string;
description?: string;
type: string;
choices?: TableFilterChoice[];
choiceFunction?: () => TableFilterChoice[];
defaultValue?: any;
value?: any;
};
50 changes: 50 additions & 0 deletions src/frontend/src/components/tables/FilterBadge.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
import { t } from '@lingui/macro';
import { Badge, CloseButton } from '@mantine/core';
import { Text, Tooltip } from '@mantine/core';
import { Group } from '@mantine/core';

import { TableFilter } from './Filter';

export function FilterBadge({
filter,
onFilterRemove
}: {
filter: TableFilter;
onFilterRemove: () => void;
}) {
/**
* Construct text to display for the given badge ID
*/
function filterDescription() {
let text = filter.label || filter.name;

text += ' = ';
text += filter.value;

return text;
}

return (
<Badge
size="lg"
radius="lg"
variant="outline"
color="gray"
styles={(theme) => ({
root: {
paddingRight: '4px'
},
inner: {
textTransform: 'none'
}
})}
>
<Group spacing={1}>
<Text>{filterDescription()}</Text>
<Tooltip label={t`Remove filter`}>
<CloseButton color="red" onClick={() => onFilterRemove()} />
</Tooltip>
</Group>
</Badge>
);
}
58 changes: 58 additions & 0 deletions src/frontend/src/components/tables/FilterGroup.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
import { t } from '@lingui/macro';
import { ActionIcon, Group, Text, Tooltip } from '@mantine/core';
import { IconFilterMinus } from '@tabler/icons-react';
import { IconFilterPlus } from '@tabler/icons-react';

import { TableFilter } from './Filter';
import { FilterBadge } from './FilterBadge';

/**
* Return a table filter group component:
* - Displays a list of active filters for the table
* - Allows the user to add/remove filters
* - Allows the user to clear all filters
*/
export function FilterGroup({
activeFilters,
onFilterAdd,
onFilterRemove,
onFilterClearAll
}: {
activeFilters: TableFilter[];
onFilterAdd: () => void;
onFilterRemove: (filterName: string) => void;
onFilterClearAll: () => void;
}) {
return (
<Group position="right" spacing={5}>
{activeFilters.length == 0 && (
<Text italic={true} size="sm">{t`Add table filter`}</Text>
)}
{activeFilters.map((f) => (
<FilterBadge
key={f.name}
filter={f}
onFilterRemove={() => onFilterRemove(f.name)}
/>
))}
{activeFilters.length && (
<ActionIcon
radius="sm"
variant="outline"
onClick={() => onFilterClearAll()}
>
<Tooltip label={t`Clear all filters`}>
<IconFilterMinus color="red" />
</Tooltip>
</ActionIcon>
)}
{
<ActionIcon radius="sm" variant="outline" onClick={() => onFilterAdd()}>
<Tooltip label={t`Add filter`}>
<IconFilterPlus color="green" />
</Tooltip>
</ActionIcon>
}
</Group>
);
}
Loading
Loading