Skip to content

fix quickfixes and annotations, modal sizes #76

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

Merged
merged 1 commit into from
Jun 3, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 2 additions & 23 deletions rubberduckvba.Server/Services/CacheService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@ public void Invalidate(InspectionsFeatureViewModel newContent)
public void Invalidate(QuickFixesFeatureViewModel newContent)
{
GetCurrentJobState();
if (XmldocJobState?.StateName == JobStateSucceeded)
if (!TryReadXmldocCache<QuickFixesFeatureViewModel>("quickfixes", out _) || XmldocJobState?.StateName == JobStateSucceeded)
{
Write("quickfixes", newContent);
foreach (var item in newContent.QuickFixes)
Expand All @@ -136,7 +136,7 @@ public void Invalidate(QuickFixesFeatureViewModel newContent)
public void Invalidate(AnnotationsFeatureViewModel newContent)
{
GetCurrentJobState();
if (XmldocJobState?.StateName == JobStateSucceeded)
if (!TryReadXmldocCache<AnnotationsFeatureViewModel>("annotations", out _) || XmldocJobState?.StateName == JobStateSucceeded)
{
Write("annotations", newContent);
foreach (var item in newContent.Annotations)
Expand All @@ -156,27 +156,6 @@ public void Clear()
_logger.LogInformation("Cache was cleared.");
}

private bool IsTagsCacheValid() => IsCacheValid(TagsJobState, () => TagsJobState);

private bool IsXmldocCacheValid() => IsCacheValid(XmldocJobState, () => XmldocJobState);

/// <summary>
/// Side-effecting:
/// </summary>
/// <param name="initial">The initial state before the check</param>
/// <param name="getCurrent">The current state after the check</param>
/// <returns></returns>
private bool IsCacheValid(HangfireJobState? initial, Func<HangfireJobState?> getCurrent)
{
GetCurrentJobState();
var current = getCurrent.Invoke();

return current is null
|| (current.StateName == JobStateSucceeded // last executed job must have succeeded
&& current.LastJobId == initial?.LastJobId // last executed job must be the same job ID we know about
&& current.StateTimestamp == initial?.StateTimestamp); // same execution -> cache was not invalidated
}

private void Write<T>(string key, T value)
{
_cache.Set(key, value, _options);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ <h5>Parameters</h5>
<div class="small text-muted text-center">
<a href="{{annotationInfo.getGitHubViewLink()}}">View</a> | <a href="{{annotationInfo.getGitHubEditLink()}}">Edit</a> this content on <fa-icon [icon]="['fab', 'github']"></fa-icon>&nbsp;GitHub
</div>
<a href="/annotations/{{annotationInfo.name}}" class="btn btn-expand" title="Expand to page"><fa-icon [icon]="['fas', 'expand']"></fa-icon></a>
<a href="/annotations/{{annotationInfo.name}}" class="btn btn-expand" title="Expand to page"><fa-icon [icon]="['fas', 'expand']"></fa-icon>&nbsp;View page</a>
</div>
</div>
</div>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ export class AnnotationItemBoxComponent implements OnInit, OnChanges {

public showDetailsModal(): void {
console.log(`Showing details for annotation: ${this.annotationInfo.name}`);
this.modal.open(this.annotationDetails);
this.modal.open(this.annotationDetails, { modalDialogClass: this.annotationInfo.parameters.length > 0 || this.annotationInfo.examples.length > 0 ? 'modal-xl' : 'modal-l' });
}

public get annotationInfo(): AnnotationViewModel {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,35 +28,35 @@ <h6 class="d-inline text-wrap">&nbsp;{{inspectionInfo.title}}</h6>
</div>
</div>

<ng-template #inspectionDetails let-modal class="modal-xl">
<ng-template #inspectionDetails let-modal>
<div class="modal-header align-content-center">
<h4><img src="../../assets/vector-ducky-540.png" height="32">&nbsp;{{inspectionInfo.title}}</h4>
<button type="button" class="btn-close" aria-label="close" (click)="modal.dismiss('x')"></button>
</div>
<div class="modal-body">
<div class="row">
<div class="text-start">
<div class="row">
<div class="modal-body my-2 mx-4">
<div class="row text-start">
<div class="col-6">
<div class="">
<strong class="fw-medium" [innerHtml]="inspectionInfo.summary"></strong>
<h6>Reasoning</h6>
<p [innerHtml]="inspectionInfo.reasoning"></p>
</div>
</div>
<div class="col-6">
<div>
<h6>
<h6>Inspection Type</h6>
<strong>
<fa-icon [icon]="'lightbulb'"></fa-icon>&nbsp;{{inspectionInfo.inspectionType}}
</h6>
</strong>
<p class="small text-black-50">{{inspectionTypeTitle}}</p>
</div>
</div>
<div class="row">
<hr />
<div>
Default Severity: <strong>{{inspectionInfo.defaultSeverity}}</strong>&nbsp;<span ngClass="{{severityIconClass}}"></span>
<h6>Default Severity</h6>
<span ngClass="{{severityIconClass}}"></span>&nbsp;<strong>{{inspectionInfo.defaultSeverity}}</strong>
<p class="small text-black-50">{{severityTitle}}</p>
</div>
</div>
<div class="row">
<div class="col-11 ms-2">
<div class="bg-light rounded-4 px-3 pt-2 pb-1">
<p class="fw-medium" [innerHtml]="inspectionInfo.summary"></p>
</div>
<p [innerHtml]="inspectionInfo.reasoning"></p>
</div>
<hr />
</div>
<div *ngIf="(inspectionInfo.hostApp?.length ?? 0) > 0" class="row">
<div>
Expand Down Expand Up @@ -101,7 +101,6 @@ <h6><fa-icon [icon]="'circle-check'"></fa-icon>&nbsp;{{fix.name}}</h6>
</ul>
</div>
</div>
</div>
</div>

<div *ngIf="inspectionInfo.examples && inspectionInfo.examples.length > 0"
Expand Down Expand Up @@ -134,6 +133,6 @@ <h6><fa-icon [icon]="'circle-check'"></fa-icon>&nbsp;{{fix.name}}</h6>
<div class="small text-muted text-center">
<a href="{{inspectionInfo.getGitHubViewLink()}}">View</a> | <a href="{{inspectionInfo.getGitHubEditLink()}}">Edit</a> this content on <fa-icon [icon]="['fab', 'github']"></fa-icon>&nbsp;GitHub
</div>
<a href="/inspections/{{inspectionInfo.name}}" class="btn btn-expand" title="Expand to page"><fa-icon [icon]="['fas', 'expand']"></fa-icon></a>
<a href="/inspections/{{inspectionInfo.name}}" class="btn btn-expand" title="Expand to page"><fa-icon [icon]="['fas', 'expand']"></fa-icon>&nbsp;View page</a>
</div>
</ng-template>
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ export class InspectionItemBoxComponent implements OnInit, OnChanges {
public showDetailsModal(): void {
this.api.getInspection(this.inspectionInfo.name).subscribe((inspection: InspectionViewModel) => {
this._inspectionInfo.next(inspection);
this.modal.open(this.inspectionDetails);
this.modal.open(this.inspectionDetails, { modalDialogClass: 'modal-xl'});
});
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,7 @@ <h6><span [ngClass]="inspection.getSeverityIconClass"></span>&nbsp;{{inspection.
<div class="small text-muted text-center">
<a href="{{quickFixInfo.getGitHubViewLink()}}">View</a> | <a href="{{quickFixInfo.getGitHubEditLink()}}">Edit</a> this content on <fa-icon [icon]="['fab', 'github']"></fa-icon>&nbsp;GitHub
</div>
<a href="/quickfixes/{{quickFixInfo.name}}" class="btn btn-expand" title="Expand to page"><fa-icon [icon]="['fas', 'expand']"></fa-icon></a>
<a href="/quickfixes/{{quickFixInfo.name}}" class="btn btn-expand" title="Expand to page"><fa-icon [icon]="['fas', 'expand']"></fa-icon>&nbsp;View page</a>
</div>
</div>
</div>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ export class QuickFixItemBoxComponent implements OnInit, OnChanges {

public showDetailsModal(): void {
console.log(`Showing details for QuickFix: ${this.quickFixInfo.name}`);
this.modal.open(this.QuickFixDetails);
this.modal.open(this.QuickFixDetails, { modalDialogClass: 'modal-xl' });
}

public get quickFixInfo(): QuickFixViewModelClass {
Expand Down