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

feature/deseng751: Added ability to use an external link as if it is an internal file. #126

Merged
merged 3 commits into from
Jan 15, 2025

Conversation

jareth-whitney
Copy link
Contributor

  • Added the ability to add an external link as if it is an internal file. DESENG-751
  • Functionality works in all file views, including file list, file details, file add/edit, comment period view, comment period edit.
  • All file list functionality works, including open/download, publish, unpublish, edit, and delete.
  • All upper-right context menu items are working from file list, file details, etc.
  • No multi-edit for external link files yet.

Copy link
Contributor

@Baelx Baelx left a comment

Choose a reason for hiding this comment

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

Thanks for this! Lots of work involved to make this feature a reality - appreciate your efforts :)

Please have a look at my comments. In particular, could you:

  • Remove any console.log calls
  • Ensure links open in the same tab unless they're subject to exception from WCAG Guideline G200
  • Remove any transformations of URLs that may alter the casing. URLs paths should mostly be treated as case sensitive

@@ -0,0 +1,29 @@
import * as _ from 'lodash';
Copy link
Contributor

Choose a reason for hiding this comment

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

Why is lodash needed here?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Removed

dateUpdated: Date;
description: string;
projectPhase: string;
checkbox: boolean;
Copy link
Contributor

Choose a reason for hiding this comment

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

Just curious what this property is

@@ -25,7 +26,8 @@ import { encode } from 'punycode';
export class AddDocumentComponent implements OnInit, OnDestroy {
public terms = new SearchTerms();
private ngUnsubscribe: Subject<boolean> = new Subject<boolean>();
public documents: Document[] = null;
public documents = null;
Copy link
Contributor

Choose a reason for hiding this comment

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

Just curious why you removed the type for this one. Maybe I can help restore it?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

As discussed, this is to prevent errors that arise from combining types in an array and then referencing properties. It could be handled more strictly with more verbosity, but that would not be in line with the degree of typing that is present in the existing codebase.

@@ -50,6 +51,7 @@ export class AddEditCommentPeriodComponent implements OnInit, OnDestroy {
private commentPeriodService: CommentPeriodService,
private config: ConfigService,
private surveyService: SurveyService,
private externalLinkService: LinkService,
Copy link
Contributor

Choose a reason for hiding this comment

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

the indentation got a little squirrelly here

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Will replace tab characters with spaces

.takeUntil(this.ngUnsubscribe)
.subscribe(
data => {
console.log('made it here');
Copy link
Contributor

Choose a reason for hiding this comment

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

Console.log left in

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Ah yes I caught that just after I submitted my PR. It was removed.

* @return {void}
*/
public validateLink() {
const link = this.myForm.value.externalLink.toLowerCase();
Copy link
Contributor

Choose a reason for hiding this comment

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

URLs have case-sensitive parts. This may break some URLs

https://webmasters.stackexchange.com/a/90378

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Removed

this.tableParams.totalListItems = 0;
this.documents = [];
}
const documents = res.documents?.documents[0] || [];
Copy link
Contributor

Choose a reason for hiding this comment

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

Okay this looks to be just a bug in the diff presentation on Github. Please disregard my previous comments about indentation

const safeName = item.documentFileName.replace(/ /g, '_');
selBox.value = `${this.pathAPI}/document/${item._id}/fetch/${safeName}`;
} else {
selBox.value = item.documentFileName;
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
selBox.value = item.documentFileName;
selBox.value = item.externalLink;

IMO, it would be more readable to do this instead of assigning documentFileName to externalLink

Copy link
Contributor Author

@jareth-whitney jareth-whitney Jan 14, 2025

Choose a reason for hiding this comment

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

Ah I see what you're saying. So in the case of the data tables, I mapped all the data before feeding it into the data table component, so that I gave it uniform values regardless of the source: external link or document. So in this case, I had already mapped the external link to another property because the property externalLink doesn't exist in the format that I feed the table component.

}

onDownload() {
if (this.document.externalLink) {
window.open(this.document.externalLink, "_blank");
Copy link
Contributor

Choose a reason for hiding this comment

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

WCAG guidelines state that even external links must open in the same tab whenever possible. One of the exceptions is if you're in the middle of filling out a form. Is that the case here? Otherwise, it should open in the same tab.

https://www.w3.org/WAI/WCAG21/Techniques/general/G200

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 removed some instances of "_blank". I believe a document open happens in a new tab by default though.

break;
case 'delete':
this.onDeleteDocument();
break;
case 'download':
this.documentTableData.data.map((item) => {
if (item.checkbox === true) {
promises.push(this.api.downloadDocument(this.documents.filter(d => d._id === item._id)[0]));
if ('external' === item.internalExt) {
window.open(item.documentFileName, "_blank");
Copy link
Contributor

Choose a reason for hiding this comment

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

Links should open only in the same tab unless a form is being filled out or other exceptions: https://www.w3.org/WAI/WCAG21/Techniques/general/G200

@@ -274,6 +274,7 @@ export class CommentPeriodDetailsTabComponent implements OnInit, OnChanges, OnDe
* @returns {Promise<void>}
*/
public downloadDocument(document) {
console.log('ran download document code');
Copy link
Contributor

Choose a reason for hiding this comment

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

console.log to remove

Copy link
Contributor

@Baelx Baelx left a comment

Choose a reason for hiding this comment

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

Thanks! approved

@jareth-whitney jareth-whitney merged commit 4893e37 into dev Jan 15, 2025
2 of 3 checks passed
@jareth-whitney jareth-whitney deleted the feature/deseng751 branch January 15, 2025 01:05
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