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

First Draft of Audit Log FE #137

Merged
merged 6 commits into from
Jan 16, 2024
Merged

First Draft of Audit Log FE #137

merged 6 commits into from
Jan 16, 2024

Conversation

gbdubs
Copy link
Contributor

@gbdubs gbdubs commented Jan 11, 2024

Gets a first draft of the audit log functionality into the frontend to make testing Audit Log testing easier.

Notable outstanding TODOs:

  • support for where queries
  • refresh on sort change
  • hiding column selection in a sub menu or something

@gbdubs gbdubs requested a review from bcspragu January 11, 2024 21:50
Copy link
Collaborator

@bcspragu bcspragu left a comment

Choose a reason for hiding this comment

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

LGTM! And sorry, this one slipped past, only just noticed it

frontend/lib/auditlogquery/index.ts Outdated Show resolved Hide resolved
const cursorQP = 'c'
const pageURLBase = '/auditlog'

export const urlReactiveAuditLogQuery = (fromQueryReactiveWithDefault: (key: string, defaultValue: string) => WritableComputedRef<string>): WritableComputedRef<AuditLogQueryReq> => {
Copy link
Collaborator

Choose a reason for hiding this comment

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

You're playing a dangerous game, making library functions that depend on access to things that use setup-only constructs like computed. It's already two levels of indirection (urlReactiveAuditLogQuery -> fromQueryReactiveWithDefault -> computed), it just makes it too easy to forget you should only be calling it in a setup function.

It looks like this will only ever be used once, you could just inline it into /audit-logs or into a component used by /audit-logs where it's unambiguously only ever called from setup

And more generally, I think this pattern of taking in functions that should only ever be called in setup is dicey, for the above mentioned reason that it obfuscates where things are being called.

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 this isn't quite correct: I'm pretty sure (from experience around how we do editors, ex) that computed can be created and used outside of setup. One of the vue authors seems to hold this position too. Could you provide documentation for exactly what can and can't be called outside of setup? A 5 minute google left me without a clear north star.

By taking fromQueryReactiveWithDefault as an argument rather than invoking the composable to pull it out, we avoid invoking a composable (which I agree is a riskier game).

My main goal was just keeping the logic for constructing + decoding URLs that point to audit log queries in one place, to avoid exporting the ~10 helper methods and constants that would be needed to replicate this interface outside of this package. I agree that we shouldn't overly obfuscate where/when core functionality is being used, but I think this approach actually does a good job of balancing between the competing goals as I understand them.

Copy link
Collaborator

Choose a reason for hiding this comment

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

Oh that's interesting, I thought computed fell into that bucket too. Looking at the Nuxt docs, it's basically all of the use* helpers (some of which are just compiler macros that get expanded at build time) that need to be invoked in setup, but computed isn't documented as such

@gbdubs gbdubs enabled auto-merge (squash) January 16, 2024 19:02
@gbdubs gbdubs merged commit a712132 into main Jan 16, 2024
2 checks passed
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.

2 participants