Skip to content

Commit 63e74a5

Browse files
Update Cross Language CLient Code
1 parent cbb24eb commit 63e74a5

9 files changed

Lines changed: 791 additions & 808 deletions

File tree

src/dotnet/APIView/APIViewWeb/Client/css/shared/bootstraps-overrides.scss

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -67,10 +67,6 @@
6767
box-shadow: var(--box-shadow-link);
6868
}
6969

70-
.breadcrumb-item + .breadcrumb-item::before {
71-
margin-top: 0.25rem;
72-
}
73-
7470
.page-link {
7571
background-color: var(--base-fg-color);
7672
border: 1px solid var(--border-color);

src/dotnet/APIView/APIViewWeb/Client/src/pages/review.module.ts

Lines changed: 145 additions & 145 deletions
Original file line numberDiff line numberDiff line change
@@ -16,22 +16,22 @@ export function splitReviewPageContent() {
1616
const rl = $('#review-left');
1717
const rr = $('#review-right');
1818

19-
if (rl.length && rr.length) {
20-
Split(['#review-left', '#review-right'], {
21-
direction: 'horizontal',
22-
sizes: [17, 83],
23-
elementStyle: (dimension, size, gutterSize) => {
24-
return {
25-
'flex-basis': `calc(${size}% - ${gutterSize}px`
26-
}
27-
},
28-
gutterStyle: (dimension, gutterSize) => {
29-
return {
30-
'flex-basis': `${gutterSize}px`
19+
if (rl.length && rr.length) {
20+
Split(['#review-left', '#review-right'], {
21+
direction: 'horizontal',
22+
sizes: [17, 83],
23+
elementStyle: (dimension, size, gutterSize) => {
24+
return {
25+
'flex-basis': `calc(${size}% - ${gutterSize}px`
26+
}
27+
},
28+
gutterStyle: (dimension, gutterSize) => {
29+
return {
30+
'flex-basis': `${gutterSize}px`
31+
}
3132
}
32-
}
33-
});
34-
}
33+
});
34+
}
3535
}
3636

3737
//-------------------------------------------------------------------------------------------------
@@ -587,160 +587,160 @@ export function addApprover(lowerTextSpan: HTMLElement, approvedByText: string,
587587
addApprovedBorder();
588588
}
589589
addApproverHrefToApprovers(lowerTextSpan, approverHref, approver);
590-
}
590+
}
591591

592-
/**
593-
* Removes the @approver from @lowerTextSpan of review page
594-
* @param lowerTextSpan HTMLElement of the span that contains who approved the review or pending approval
595-
* @param approver GitHub username of the review approver
596-
* @param approvalPendingText string of approval pending text to use when removing the last approver
597-
*/
598-
export function removeApprover(lowerTextSpan: HTMLElement, approver: string, approvalPendingText: string) {
599-
let children = lowerTextSpan.children;
600-
let numApprovers = children.length;
592+
/**
593+
* Removes the @approver from @lowerTextSpan of review page
594+
* @param lowerTextSpan HTMLElement of the span that contains who approved the review or pending approval
595+
* @param approver GitHub username of the review approver
596+
* @param approvalPendingText string of approval pending text to use when removing the last approver
597+
*/
598+
export function removeApprover(lowerTextSpan: HTMLElement, approver: string, approvalPendingText: string) {
599+
let children = lowerTextSpan.children;
600+
let numApprovers = children.length;
601601

602-
if (numApprovers > 1) {
603-
removeApproverFromApproversList(children, approver);
604-
} else {
605-
lowerTextSpan.textContent = approvalPendingText;
606-
removeApprovalBorder();
602+
if (numApprovers > 1) {
603+
removeApproverFromApproversList(children, approver);
604+
} else {
605+
lowerTextSpan.textContent = approvalPendingText;
606+
removeApprovalBorder();
607+
}
607608
}
608-
}
609609

610-
/**
611-
* adds the @approver with a hyperlink to their apiview profile to @lowerTextSpan
612-
*/
613-
export function addApproverHrefToApprovers(lowerTextSpan: HTMLElement, approverHref: string, approver: any) {
614-
$(lowerTextSpan).append('<a href="' + approverHref + '">' + approver + '</a>');
615-
}
610+
/**
611+
* adds the @approver with a hyperlink to their apiview profile to @lowerTextSpan
612+
*/
613+
export function addApproverHrefToApprovers(lowerTextSpan: HTMLElement, approverHref: string, approver: any) {
614+
$(lowerTextSpan).append('<a href="' + approverHref + '">' + approver + '</a>');
615+
}
616616

617-
/**
618-
* adds the text above the approve button to indicate whether the current user approved the review
619-
*/
620-
export function addUpperTextSpan(approvesCurrentRevisionText: string) {
621-
let $upperTextSpan = $("<span>").text(approvesCurrentRevisionText).addClass("small text-muted");
622-
let $upperTextForm = $("ul#approveCollapse form.form-inline");
623-
$upperTextForm.prepend($upperTextSpan);
624-
}
617+
/**
618+
* adds the text above the approve button to indicate whether the current user approved the review
619+
*/
620+
export function addUpperTextSpan(approvesCurrentRevisionText: string) {
621+
let $upperTextSpan = $("<span>").text(approvesCurrentRevisionText).addClass("small text-muted");
622+
let $upperTextForm = $("ul#approveCollapse form.form-inline");
623+
$upperTextForm.prepend($upperTextSpan);
624+
}
625625

626-
/**
627-
* change the button state from a green "not approved" to grey "approved"
628-
*/
629-
export function addButtonApproval() {
630-
let $approveBtn = $("form.form-inline button.btn.btn-success");
631-
$approveBtn.removeClass("btn-success");
632-
$approveBtn.addClass("btn-outline-secondary");
633-
$approveBtn.text("Revert API Approval");
634-
}
626+
/**
627+
* change the button state from a green "not approved" to grey "approved"
628+
*/
629+
export function addButtonApproval() {
630+
let $approveBtn = $("form.form-inline button.btn.btn-success");
631+
$approveBtn.removeClass("btn-success");
632+
$approveBtn.addClass("btn-outline-secondary");
633+
$approveBtn.text("Revert API Approval");
634+
}
635635

636-
/**
637-
* change the button state from a grey "approved" to green "not approved"
638-
*/
639-
export function removeButtonApproval() {
640-
let $approveBtn = $("form.form-inline button.btn.btn-outline-secondary");
641-
$approveBtn.removeClass("btn-outline-secondary");
642-
$approveBtn.addClass("btn-success");
643-
$approveBtn.text("Approve");
644-
}
636+
/**
637+
* change the button state from a grey "approved" to green "not approved"
638+
*/
639+
export function removeButtonApproval() {
640+
let $approveBtn = $("form.form-inline button.btn.btn-outline-secondary");
641+
$approveBtn.removeClass("btn-outline-secondary");
642+
$approveBtn.addClass("btn-success");
643+
$approveBtn.text("Approve");
644+
}
645645

646-
/**
647-
* change the review panel border state from grey "not approved" to green "approved"
648-
*/
649-
export function addApprovedBorder() {
650-
let reviewLeft = $("#review-left");
651-
reviewLeft.addClass("review-approved");
652-
reviewLeft.removeClass("border");
653-
reviewLeft.removeClass("rounded-1");
646+
/**
647+
* change the review panel border state from grey "not approved" to green "approved"
648+
*/
649+
export function addApprovedBorder() {
650+
let reviewLeft = $("#review-left");
651+
reviewLeft.addClass("review-approved");
652+
reviewLeft.removeClass("border");
653+
reviewLeft.removeClass("rounded-1");
654654

655-
let reviewRight = $("#review-right");
656-
reviewRight.addClass("review-approved");
657-
reviewRight.removeClass("border");
658-
reviewRight.removeClass("rounded-1");
659-
}
655+
let reviewRight = $("#review-right");
656+
reviewRight.addClass("review-approved");
657+
reviewRight.removeClass("border");
658+
reviewRight.removeClass("rounded-1");
659+
}
660660

661-
/**
662-
* change the review panel border state from green "approved" to grey "not approved"
663-
*/
664-
export function removeApprovalBorder() {
665-
let $reviewLeft = $("#review-left");
666-
$reviewLeft.removeClass("review-approved");
667-
$reviewLeft.addClass("border");
668-
$reviewLeft.addClass("rounded-1");
661+
/**
662+
* change the review panel border state from green "approved" to grey "not approved"
663+
*/
664+
export function removeApprovalBorder() {
665+
let $reviewLeft = $("#review-left");
666+
$reviewLeft.removeClass("review-approved");
667+
$reviewLeft.addClass("border");
668+
$reviewLeft.addClass("rounded-1");
669669

670-
let $reviewRight = $("#review-right");
671-
$reviewRight.removeClass("review-approved");
672-
$reviewRight.addClass("border");
673-
$reviewRight.addClass("rounded-1");
674-
}
670+
let $reviewRight = $("#review-right");
671+
$reviewRight.removeClass("review-approved");
672+
$reviewRight.addClass("border");
673+
$reviewRight.addClass("rounded-1");
674+
}
675675

676-
/**
677-
* parse the approval spans for its existence and order
678-
* @param $approvalSpans may contain <upper text>, <approve button>, and/or <lower text>
679-
* @param approvedByText string for <lower text> that indicates preexisting approvers
680-
* @param approvalPendingText string for <lower text> that indicates no current approvers
681-
* @param approvesCurrentRevisionText string for <upper text> that indicates the current user did not approve
682-
* @returns a dictionary with the index of the upper and lower text elements. Value is -1 if an element does not exist.
683-
*/
684-
export function parseApprovalSpanIndex($approvalSpans: JQuery<HTMLElement>, approvedByText: string, approvalPendingText: string, approvesCurrentRevisionText: string) {
685-
let indexResult = {
686-
"approvers": -1,
687-
"upperText": -1,
688-
};
676+
/**
677+
* parse the approval spans for its existence and order
678+
* @param $approvalSpans may contain <upper text>, <approve button>, and/or <lower text>
679+
* @param approvedByText string for <lower text> that indicates preexisting approvers
680+
* @param approvalPendingText string for <lower text> that indicates no current approvers
681+
* @param approvesCurrentRevisionText string for <upper text> that indicates the current user did not approve
682+
* @returns a dictionary with the index of the upper and lower text elements. Value is -1 if an element does not exist.
683+
*/
684+
export function parseApprovalSpanIndex($approvalSpans: JQuery<HTMLElement>, approvedByText: string, approvalPendingText: string, approvesCurrentRevisionText: string) {
685+
let indexResult = {
686+
"approvers": -1,
687+
"upperText": -1,
688+
};
689689

690-
for (var i = 0; i < $approvalSpans.length; i++) {
691-
let content = $approvalSpans[i].textContent;
690+
for (var i = 0; i < $approvalSpans.length; i++) {
691+
let content = $approvalSpans[i].textContent;
692692

693-
if (!content) {
694-
return indexResult;
693+
if (!content) {
694+
return indexResult;
695+
}
696+
697+
if (content.includes(approvedByText) || content.includes(approvalPendingText)) {
698+
indexResult["approvers"] = i;
699+
}
700+
if (content.includes(approvesCurrentRevisionText)) {
701+
indexResult["upperText"] = i;
702+
}
695703
}
696704

697-
if (content.includes(approvedByText) || content.includes(approvalPendingText)) {
698-
indexResult["approvers"] = i;
699-
}
700-
if (content.includes(approvesCurrentRevisionText)) {
701-
indexResult["upperText"] = i;
702-
}
705+
return indexResult;
703706
}
704707

705-
return indexResult;
706-
}
707-
708-
/**
709-
* call when the current user approves the current review. removes the upper text
710-
* @param upperTextIndex index of the upper text in @$approvalSpans
711-
* @param $approvalSpans span that includes revision approval block
712-
*/
713-
export function removeUpperTextSpan(upperTextIndex: number, $approvalSpans: JQuery<HTMLElement>) {
714-
if (upperTextIndex !== -1) {
715-
let upperTextSpan: HTMLElement = $approvalSpans[upperTextIndex];
716-
upperTextSpan.remove();
708+
/**
709+
* call when the current user approves the current review. removes the upper text
710+
* @param upperTextIndex index of the upper text in @$approvalSpans
711+
* @param $approvalSpans span that includes revision approval block
712+
*/
713+
export function removeUpperTextSpan(upperTextIndex: number, $approvalSpans: JQuery<HTMLElement>) {
714+
if (upperTextIndex !== -1) {
715+
let upperTextSpan: HTMLElement = $approvalSpans[upperTextIndex];
716+
upperTextSpan.remove();
717+
}
717718
}
718-
}
719719

720-
/**
721-
* remove the @approver from list of @approvers
722-
* @param approvers list of preexisting approvers
723-
* @param approver GitHub username of user to remove from the list
724-
*/
725-
export function removeApproverFromApproversList(approvers, approver) {
726-
for (var i = 0; i < approvers.length; i++) {
727-
if (approvers[i].innerHTML === approver) {
728-
if (i === 0) {
729-
approvers[i].nextSibling?.remove();
730-
} else {
731-
approvers[i].previousSibling?.remove();
720+
/**
721+
* remove the @approver from list of @approvers
722+
* @param approvers list of preexisting approvers
723+
* @param approver GitHub username of user to remove from the list
724+
*/
725+
export function removeApproverFromApproversList(approvers, approver) {
726+
for (var i = 0; i < approvers.length; i++) {
727+
if (approvers[i].innerHTML === approver) {
728+
if (i === 0) {
729+
approvers[i].nextSibling?.remove();
730+
} else {
731+
approvers[i].previousSibling?.remove();
732+
}
733+
approvers[i].remove();
734+
break;
732735
}
733-
approvers[i].remove();
734-
break;
735736
}
736737
}
737-
}
738738

739-
/**
739+
/**
740740
* Add event handler for cross language panel button
741741
*/
742742
export function addCrossLaguageCloseBtnHandler() {
743-
$(".cross-language-panel .btn-close").on("click", function (e: JQuery.ClickEvent) {
744-
$(this).closest(".cross-language-panel").addClass("d-none");
745-
});
746-
}
743+
$(".cross-language-panel .btn-close").on("click", function (e: JQuery.ClickEvent) {
744+
$(this).closest(".cross-language-panel").addClass("d-none");
745+
});
746+
}

0 commit comments

Comments
 (0)