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

isom-1659 internal links for folders #865

Open
wants to merge 17 commits into
base: main
Choose a base branch
from

Conversation

adriangohjw
Copy link
Contributor

@adriangohjw adriangohjw commented Nov 7, 2024

Problem

Closes https://linear.app/ogp/issue/ISOM-1659/internal-links-for-folders

Solution

Breaking Changes

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

Features:

Improvements:

  • refactor such that all components use this to reduce to keep it DRY
Screen.Recording.2024-11-07.at.6.29.36.PM.mov

@adriangohjw adriangohjw added the enhancement New feature or request label Nov 7, 2024
@adriangohjw adriangohjw self-assigned this Nov 7, 2024
Copy link

linear bot commented Nov 7, 2024

Copy link

vercel bot commented Nov 7, 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 Nov 15, 2024 6:27am

@datadog-opengovsg
Copy link

datadog-opengovsg bot commented Nov 7, 2024

Datadog Report

Branch report: adriangohjw/isom-1659-internal-links-for-folders
Commit report: 24d4628
Test service: isomer-studio

✅ 0 Failed, 184 Passed, 34 Skipped, 43.04s Total Time
➡️ Test Sessions change in coverage: 1 no change

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.

i like the chagne to standardise on using resource selector but i think tying the trpc.procedure's type directly to the selector itself might be abit sussy. i think we can be abit more verbose and just specify types + functions etc so we avoid this lock in

)}
</>
<ResourceSelector
queryFn={trpc.resource.getChildrenOf.useInfiniteQuery}
Copy link
Contributor

Choose a reason for hiding this comment

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

nit: to be honest, this feels like a code-smell. this works for now because they have relatively similar interfaces but we tie it very closely to the actual function too (the type of queryFn is specified as those 2 queries). i worry that if change is needed to either of the 2 functions, this component might not be as easily reusable down the line.

something we could consider is shifting the subcomponents out and favouring composition so that, for example, 1 component purely displays another and another triggers the refetch. another alternative we could do is specify the type ourselves + specify the refetch etc as extra props so we don't depend so strictly on teh trpc type!

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 thought about it for some time and decided to update it to pass in a prop onlyShowFolders which will be used to decide which query to used

  const queryFn = onlyShowFolders
    ? trpc.resource.getFolderChildrenOf.useInfiniteQuery
    : trpc.resource.getChildrenOf.useInfiniteQuery

Why this is an improvement:

  • Centralized Updates: If there are changes to the getFolderChildrenOf or getChildrenOf props, we only need to update them in a single location (this file). Most of the changes will be confined to updating the props, which simplifies maintenance and enhances extensibility without over-engineering the solution.
  • Flexibility in Handling Query Changes: If the interfaces of the queries change significantly, we can simply create a copy and preserve the original query. This approach avoids forcing them to reuse the same query, providing more flexibility as the system evolves.
  • Simplified Parent Component Props: The parent component no longer needs to be aware of which specific query to pass in. This reduces complexity and decouples the parent from needing to handle the specifics of the query logic.

Comment on lines +73 to +77
useEffect(() => {
if (curResourceId) {
onChange(curResourceId)
}
}, [curResourceId])
Copy link
Contributor

Choose a reason for hiding this comment

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

clarification needed - i don't quite understand this section here, i'd expect to see teh onChange on a button as that's the trigger for the change rather than on useEffect, as that implies we're syncing state somewhere

Copy link
Contributor Author

Choose a reason for hiding this comment

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

in some cases, the parent component that uses ResourceSelector will need onChange (props passed in) to trigger state change

apps/studio/src/server/modules/resource/resource.router.ts Outdated Show resolved Hide resolved
@adriangohjw
Copy link
Contributor Author

converting to draft first - need to update it to show full permalink of the resource instead of the permalink only

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants