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

feat: introduce database content layout #713

Merged
merged 8 commits into from
Oct 11, 2024
Merged

Conversation

dcshzj
Copy link
Contributor

@dcshzj dcshzj commented Sep 30, 2024

Problem

Closes ISOM-1592.

Solution

Breaking Changes

  • Yes - this PR contains breaking changes
  • No - this PR is backwards compatible

Features:

  • Introduce a new SearchableTable component that creates a table that comes with a search filter and pagination controls.
  • Introduce a new database layout which locks the SearchableTable component at the bottom of the page.

Screenshots

image

@dcshzj dcshzj requested a review from a team as a code owner September 30, 2024 09:57
Copy link

vercel bot commented Sep 30, 2024

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
isomer-studio ✅ Ready (Inspect) Visit Preview 💬 Add feedback Oct 11, 2024 3:15am

Copy link

linear bot commented Sep 30, 2024

Copy link
Contributor

@karrui karrui left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

initial review.

should the searchtable also be useable on other layouts (i.e. is database layout necessary)?

// This is the maximum number of columns that the table can have
// 10 was decided because at 1240px, each column will only have 124px which is
// the minimum width for a column to be readable
export const MAX_NUMBER_OF_COLUMNS = 10
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

in mobile will still look weird right haha. Might as well set min-width on each cell. Can always enhance it (and our other tables?) with something like https://www.npmjs.com/package/react-table-column-resizer (or write our own/vendorize) to allow users to resize columns.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hmm this one to discuss with @sehyunidaaa. I think letting users resize the columns will not happen, but whether to use min-width I need to check.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If we set min-width (e.g., 124px) on the cols, will a table with 10 cols overflow and hori scroll on w=1025px (desktop)?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think with the borders likely will overflow, so maybe we can use a smaller number such that the min-width of all columns + borders is <= 1024px?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hmm I don't think overflow is necessarily bad when you have 10 (!!) columns, because at that point your data table is so big, that it's more important for us to guarantee that the column texts are readable than trying to avoid overflow. I'd rather the table be scrollable than we try to squeeze 10 columns into {1024px - margins} which might break words at awkward places.

I guess no issue in setting a min-width on columns, but should we be setting a max-width on the entire table instead? So we let the columns resize depending on content but prevent the scroll being ridiculously long, like 2* of the screen width

@datadog-opengovsg
Copy link

datadog-opengovsg bot commented Oct 3, 2024

Datadog Report

Branch report: feat/introduce-database-layout
Commit report: c5070a9
Test service: isomer-studio

✅ 0 Failed, 8 Passed, 1 Skipped, 7.98s Total Time

@sehyunidaaa
Copy link
Contributor

@dcshzj sorry to bother you again! just fyi got some small items pending on chromatic, after you push again please let me know i'll approve chromatic

@dcshzj dcshzj force-pushed the feat/introduce-database-layout branch from 019344a to fe5cb0a Compare October 8, 2024 05:38
Copy link
Contributor

@seaerchin seaerchin left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

first pass review! some questoins on my end but overall seems ok. what's the point of the sentinel =HYPERLINK(? are we going to use it internally for github stored pages?

also, do we need an equivalent on studio for the layotu here?


const maxNoOfColumns = Math.min(
headers.length,
...items.map((row) => row.row.length),
Copy link
Contributor

@seaerchin seaerchin Oct 9, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

what happens if we have a case where the header length is shorter than the max row length? do we have to handle overflow? (i never check on local)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This checks every row and finds the minimum number of columns. So if we have header row with 6 columns, 1st row with 6 columns and 2nd row with 3 columns, the max we should display is 3.

Overflow is handled automatically via scroll.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ah ok, so to double check what happens here - we only display 3 and there's a scrollbar allowing us to horizontally scroll and see the other 6? ok with this, i wanted to double check that we're not just removing the content

searchValue,
}: GetFilteredItemsParams) =>
items
.filter((item) => item.key.includes(searchValue.toLowerCase()))
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

if we want a case insensitive search, might as well lowercase the key!

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hmm the key is lowercased in the server component so the client does lesser stuff: https://github.com/opengovsg/isomer/pull/713/files#diff-5c209342b9152356c25bfdfc004d41eeb44c795172426b1bc17569d3b0e31bdb

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

not very good to assume here, we should just lowercase if it's cheap to do so. i think the runtime here won't be anyting significant

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hmm this is done as part of a performance improvement suggested here: #713 (comment)

I'm more inclined to reduce the work that the client does, especially since our users may have devices that are extremely slow.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ok! can add a comment on the studio side then, so people are aware of this!

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Eh hmm there's no studio equivalent here, so the input is fine but on build time the key is generated with the lowercase.

@dcshzj
Copy link
Contributor Author

dcshzj commented Oct 10, 2024

first pass review! some questoins on my end but overall seems ok. what's the point of the sentinel =HYPERLINK(? are we going to use it internally for github stored pages?

This is to support links. The intent is for people to create their table in Excel, export as CSV then upload to Studio in the future.

also, do we need an equivalent on studio for the layotu here?

Nope, editing on Studio for this layout is deprioritised for now, cos quite complicated to implement.

@seaerchin
Copy link
Contributor

the logic here doesn't quite work! this is because we parse the text after we cache it. because of this, a false search of hyperlink will cause the result involving the link to show up!

image

in order to circumvent this, we should probably parse first prior to doing the cache construction so that we get a repsentation of the textual content.

@dcshzj
Copy link
Contributor Author

dcshzj commented Oct 11, 2024

the logic here doesn't quite work! this is because we parse the text after we cache it. because of this, a false search of hyperlink will cause the result involving the link to show up!

Updated in 79a1f81.

@dcshzj dcshzj merged commit e0fd6bb into main Oct 11, 2024
18 of 19 checks passed
@dcshzj dcshzj deleted the feat/introduce-database-layout branch October 11, 2024 08:07
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants