-
Notifications
You must be signed in to change notification settings - Fork 0
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
Conversation
There was a problem hiding this 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
const cursorQP = 'c' | ||
const pageURLBase = '/auditlog' | ||
|
||
export const urlReactiveAuditLogQuery = (fromQueryReactiveWithDefault: (key: string, defaultValue: string) => WritableComputedRef<string>): WritableComputedRef<AuditLogQueryReq> => { |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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
Gets a first draft of the audit log functionality into the frontend to make testing Audit Log testing easier.
Notable outstanding TODOs:
where
queries