Skip to content

Conversation

@emoral435
Copy link
Contributor

☑️ Resolves #42508

🚧 Summary

Changes the language for the Files Breadcrumb component TS - there may be more that needs to be added for better typing functionality, but this is just to get the ball rolling!

const fileId = this.getFileIdFromPath(path)
const node = this.getNodeFromId(fileId)
const fileId: number | undefined = this.getFileIdFromPath(path)
Copy link
Contributor

Choose a reason for hiding this comment

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

You assert in the next line that the fileid is not undefined so you are sure this returns a valid number.
So I would say you should then assert on this line or be defensive on the next line.

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 decided to be defensive on the next line. The changes in the updated commit is

const fileId: number | undefined = this.getFileIdFromPath(path)

const node: Node | undefined = (fileId) ? this.getNodeFromId(fileId) : undefined

Using getNodeFromId() will just access an array from the filestore, so accessing array[undefined] will throw undefined anyways, but its good to be declarative with the ternary operator. If you believe there is a better, more intuitive way to display this LMK!! :)

@emoral435 emoral435 force-pushed the enh/files/42508/enhance-breadcrumb-component branch 2 times, most recently from 63dabe1 to 461f208 Compare January 2, 2024 16:37
@emoral435
Copy link
Contributor Author

Cherry-picked the wrong commit (sorry Julia) by accident! Should be all good now

@emoral435 emoral435 requested a review from susnux January 2, 2024 16:38
@emoral435 emoral435 force-pushed the enh/files/42508/enhance-breadcrumb-component branch from 461f208 to e7129bb Compare January 4, 2024 16:18
@emoral435 emoral435 enabled auto-merge January 4, 2024 16:18
@emoral435 emoral435 added 4. to release Ready to be released and/or waiting for tests to finish and removed 3. to review Waiting for reviews labels Jan 4, 2024
@emoral435 emoral435 merged commit 7c3936b into master Jan 4, 2024
@emoral435 emoral435 deleted the enh/files/42508/enhance-breadcrumb-component branch January 4, 2024 16:31
@blizzz blizzz mentioned this pull request Mar 5, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

4. to release Ready to be released and/or waiting for tests to finish enhancement feature: files

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Enh(files): make Breacrumbs.vue's script TS and add copyright header

5 participants