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

Refactor File Details page #177

Merged
merged 4 commits into from
Mar 12, 2024
Merged

Refactor File Details page #177

merged 4 commits into from
Mar 12, 2024

Conversation

TimCsaky
Copy link
Contributor

@TimCsaky TimCsaky commented Feb 24, 2024

Description

  • reduce coupling with prop/watch pattern
  • use models to pass current and latest versionId's
  • convert some store 'find' actions into getters
  • extend action to fetchMetadata/tags for all versions in one shot
  • consolidate async action calls for COMS data

Types of changes

Bug fix (non-breaking change which fixes an issue)

Checklist

  • I have read the CONTRIBUTING doc
  • I have checked that unit tests pass locally with my changes
  • I have added tests that prove my fix is effective or that my feature works
  • I have added necessary documentation (if appropriate)

Further comments

Copy link

Coverage Report (Application)

Totals Coverage
Statements: 70.67% ( 53 / 75 )
Methods: 62.5% ( 5 / 8 )
Lines: 81.63% ( 40 / 49 )
Branches: 44.44% ( 8 / 18 )

@TimCsaky TimCsaky force-pushed the computed branch 5 times, most recently from d0759b8 to 40e6dbe Compare February 27, 2024 18:23
@TimCsaky TimCsaky force-pushed the object-table branch 3 times, most recently from 82359bc to edb6909 Compare February 27, 2024 23:53
Base automatically changed from object-table to master February 27, 2024 23:58
@TimCsaky TimCsaky force-pushed the computed branch 2 times, most recently from 2456a7f to f165231 Compare February 28, 2024 01:05
Copy link

github-actions bot commented Feb 28, 2024

Coverage Report (Frontend)

Totals Coverage
Statements: 18.27% ( 623 / 3410 )
Methods: 17.77% ( 123 / 692 )
Lines: 21.86% ( 433 / 1981 )
Branches: 9.09% ( 67 / 737 )

move and conolidate async action calls for data
convert some store 'find' actions into getters
reduce watch pattern
use models to to pass current and latest versionId's
extend action to fetchMetadata/tags for all versions in one shot
@TimCsaky TimCsaky changed the title Computed Refactor File Details page Feb 29, 2024
Copy link
Member

@jujaga jujaga left a comment

Choose a reason for hiding this comment

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

Some minor flow comments and potential optimizations regarding async/await. Looks reasonably good otherwise - good work! Being able to finally use computeds over the action workaround will definitely simply things in the long run.

version.value = versionStore.findVersionById(props.versionId);
onMounted(async () => {
const head = await objectStore.headObject(props.objectId);
const isPublic = head?.status === 204;
Copy link
Member

Choose a reason for hiding this comment

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

As this HTTP 204 check is only being used in one place, it might be better to just inline this on line 88.

// Actions
const router = useRouter();
const versionId = defineModel<string>('versionId');
const versions: Ref<Array<Version>> = computed((): any => getVersionsByObjectId.value(props.objectId));
Copy link
Member

Choose a reason for hiding this comment

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

Should that any be Array<Version>? Looks like the any is describing the return structure type if I'm reading this right.

const router = useRouter();
const versionId = defineModel<string>('versionId');
const versions: Ref<Array<Version>> = computed((): any => getVersionsByObjectId.value(props.objectId));
const tableData: Ref<Array<VersionDataSource>> = computed(() => {
Copy link
Member

Choose a reason for hiding this comment

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

Might be this for more strict ts typing?

Ref<Array<VersionDataSource>> = computed((): Array<VersionDataSource> => {

Comment on lines 61 to 62
watch(props, async () => {
await userStore.fetchUsers({ userId: versions.value.map((x: Version) => x.createdBy) });
Copy link
Member

Choose a reason for hiding this comment

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

Not completely certain if we really need the async and await here as this callback just fires and finishes when it finishes. There doesn't appear to be any dependent functions that need to be blocking on this specific thread.

Comment on lines 36 to 39
() => (userId: string | undefined) => state.userSearch.value.find((x: User) => userId === x.userId)
),
// returns an array of Users corresponding to provided user IDs
getUsers: computed(() => (userIds: Array<string> | undefined) => {
Copy link
Member

Choose a reason for hiding this comment

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

Not absolutely certain, but assuming no typescript snafus, it might be better to have the blah | undefined be marked as blah? instead to signal optionality?

Copy link
Member

Choose a reason for hiding this comment

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

I'm presuming this is an intentional change to the file details page where no matter what, we want routing to always reroute a url to go from /details?objectId=blah to /details?objectId=blah&versionId=foo in every case? We want to make sure this url isn't too hard-coerced and can still forward-hydrate as this will be the main entrypoint for numerous user flows.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

visiting the file details page with a url that includes the versionId is is still supported, the page does load with that version.

@jujaga
Copy link
Member

jujaga commented Mar 12, 2024

Temporarily closing and reopening due to pipeline issues

@jujaga jujaga closed this Mar 12, 2024
@jujaga jujaga reopened this Mar 12, 2024
@jujaga jujaga merged commit b7749a4 into master Mar 12, 2024
28 of 31 checks passed
@jujaga jujaga deleted the computed branch March 12, 2024 19:04
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