Skip to content

Display health and maintenance issues separately. #1644

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 2 commits into from
Sep 26, 2018
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
48 changes: 33 additions & 15 deletions app/lib/frontend/templates.dart
Original file line number Diff line number Diff line change
Expand Up @@ -238,18 +238,6 @@ class TemplateService {
break;
}

final List suggestions = analysis.suggestions?.map((suggestion) {
return {
'icon_class': _suggestionIconClass(suggestion.level),
'title_html':
_renderSuggestionTitle(suggestion.title, suggestion.score),
'description_html': markdownToHtml(suggestion.description, null),
'suggestion_help_html': getSuggestionHelpMessage(suggestion.code),
};
})?.toList();
final hasIssues =
analysis.suggestions?.any((s) => s.isError || s.isWarning) ?? false;

List<Map> prepareDependencies(List<PkgDependency> list) {
if (list == null || list.isEmpty) return const [];
return list.map((pd) => {'row_html': _renderAnalysisDepRow(pd)}).toList();
Expand Down Expand Up @@ -285,9 +273,12 @@ class TemplateService {
?.join(', ') ??
'<i>unsure</i>',
'platforms_reason_html': markdownToHtml(analysis.platformsReason, null),
'hasSuggestions': suggestions != null && suggestions.isNotEmpty,
'suggestions_label': hasIssues ? 'Issues and suggestions' : 'Suggestions',
'suggestions': suggestions,
'analysis_suggestions_html':
_renderSuggestionBlockHtml('Analysis', analysis.panaSuggestions),
'health_suggestions_html':
_renderSuggestionBlockHtml('Health', analysis.healthSuggestions),
'maintenance_suggestions_html': _renderSuggestionBlockHtml(
'Maintenance', analysis.maintenanceSuggestions),
'has_dependency': hasDependency,
'dependencies': {
'has_sdk': hasSdkConstraint,
Expand All @@ -305,6 +296,33 @@ class TemplateService {
return _renderTemplate('pkg/analysis_tab', data);
}

String _renderSuggestionBlockHtml(
String header, List<Suggestion> suggestions) {
if (suggestions == null || suggestions.isEmpty) {
return null;
}

final hasIssues = suggestions.any((s) => s.isError || s.isWarning);
final label =
hasIssues ? '$header issues and suggestions' : '$header suggestions';

final mappedValues = suggestions.map((suggestion) {
return {
'icon_class': _suggestionIconClass(suggestion.level),
'title_html':
_renderSuggestionTitle(suggestion.title, suggestion.score),
'description_html': markdownToHtml(suggestion.description, null),
'suggestion_help_html': getSuggestionHelpMessage(suggestion.code),
};
}).toList();

final data = <String, dynamic>{
'label': label,
'suggestions': mappedValues,
};
return _renderTemplate('pkg/analysis_suggestion_block', data);
}

Map<String, Object> _pkgShowPageValues(
Package package,
List<PackageVersion> versions,
Expand Down
5 changes: 5 additions & 0 deletions app/lib/shared/analyzer_client.dart
Original file line number Diff line number Diff line change
Expand Up @@ -245,6 +245,11 @@ class AnalysisView {

List<Suggestion> get suggestions => getAllSuggestions(_summary);

List<Suggestion> get panaSuggestions => _summary?.suggestions;
List<Suggestion> get healthSuggestions => _summary?.health?.suggestions;
List<Suggestion> get maintenanceSuggestions =>
_summary?.maintenance?.suggestions;

double get maintenanceScore => _data?.maintenanceScore ?? 0.0;
}

Expand Down
3 changes: 3 additions & 0 deletions app/test/frontend/golden/analysis_tab_aborted.html
Original file line number Diff line number Diff line change
Expand Up @@ -112,3 +112,6 @@ <h4>Platforms</h4>
<blockquote></blockquote>





5 changes: 4 additions & 1 deletion app/test/frontend/golden/analysis_tab_http.html
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,9 @@ <h4>Platforms</h4>
<blockquote><p>No platform restriction found in primary library <code>package:http/http.dart</code>.</p>
</blockquote>

<h4>Suggestions</h4>


<h4>Maintenance suggestions</h4>
<div class="suggestion-row">
<div class="suggestion-title">
<span class="suggestion-icon-info"></span>
Expand All @@ -138,6 +140,7 @@ <h4>Suggestions</h4>
</div>
</div>


<h4>Dependencies</h4>
<div class="overflow-x">
<table class="dependency-table">
Expand Down
5 changes: 4 additions & 1 deletion app/test/frontend/golden/analysis_tab_mock.html
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,8 @@ <h4>Platforms</h4>
<blockquote><p>All libraries agree.</p>
</blockquote>

<h4>Issues and suggestions</h4>

<h4>Health issues and suggestions</h4>
<div class="suggestion-row">
<div class="suggestion-title">
<span class="suggestion-icon-danger"></span>
Expand All @@ -126,6 +127,8 @@ <h4>Issues and suggestions</h4>
</div>
</div>



<h4>Dependencies</h4>
<div class="overflow-x">
<table class="dependency-table">
Expand Down
3 changes: 3 additions & 0 deletions app/test/frontend/golden/analysis_tab_outdated.html
Original file line number Diff line number Diff line change
Expand Up @@ -101,3 +101,6 @@
</p>





3 changes: 3 additions & 0 deletions app/test/frontend/golden/pkg_show_page.html
Original file line number Diff line number Diff line change
Expand Up @@ -292,6 +292,9 @@ <h4>Platforms</h4>
<blockquote></blockquote>





<h4>Dependencies</h4>
<div class="overflow-x">
<table class="dependency-table">
Expand Down
3 changes: 3 additions & 0 deletions app/test/frontend/golden/pkg_show_page_discontinued.html
Original file line number Diff line number Diff line change
Expand Up @@ -276,6 +276,9 @@ <h3>3. Import it</h3>






</section>
</div>

Expand Down
3 changes: 3 additions & 0 deletions app/test/frontend/golden/pkg_show_page_flutter_plugin.html
Original file line number Diff line number Diff line change
Expand Up @@ -280,6 +280,9 @@ <h4>Platforms</h4>






</section>
</div>

Expand Down
5 changes: 4 additions & 1 deletion app/test/frontend/golden/pkg_show_page_legacy.html
Original file line number Diff line number Diff line change
Expand Up @@ -278,7 +278,7 @@ <h3>3. Import it</h3>
Until this is resolved, the package will receive a health and maintenance score of 0.
</p>

<h4>Issues and suggestions</h4>
<h4>Analysis issues and suggestions</h4>
<div class="suggestion-row">
<div class="suggestion-title">
<span class="suggestion-icon-danger"></span>
Expand All @@ -293,6 +293,9 @@ <h4>Issues and suggestions</h4>
</div>





</section>
</div>

Expand Down
3 changes: 3 additions & 0 deletions app/test/frontend/golden/pkg_show_page_outdated.html
Original file line number Diff line number Diff line change
Expand Up @@ -280,6 +280,9 @@ <h3>3. Import it</h3>






</section>
</div>

Expand Down
3 changes: 3 additions & 0 deletions app/test/frontend/golden/pkg_show_version_page.html
Original file line number Diff line number Diff line change
Expand Up @@ -294,6 +294,9 @@ <h4>Platforms</h4>
<blockquote></blockquote>





<h4>Dependencies</h4>
<div class="overflow-x">
<table class="dependency-table">
Expand Down
14 changes: 13 additions & 1 deletion app/test/frontend/templates_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -299,7 +299,7 @@ void main() {
platforms: ['web'],
platformsReason: 'All libraries agree.',
health: 0.95,
suggestions: [
healthSuggestions: [
new Suggestion.error(SuggestionCode.dartfmtAborted,
'Fix `dartfmt`.', 'Running `dartfmt -n .` failed.'),
],
Expand Down Expand Up @@ -650,6 +650,15 @@ class MockAnalysisView implements AnalysisView {
@override
List<Suggestion> suggestions;

@override
List<Suggestion> panaSuggestions;

@override
List<Suggestion> healthSuggestions;

@override
List<Suggestion> maintenanceSuggestions;

@override
double maintenanceScore;

Expand All @@ -663,5 +672,8 @@ class MockAnalysisView implements AnalysisView {
this.devDependencies,
this.health,
this.suggestions,
this.panaSuggestions,
this.healthSuggestions,
this.maintenanceSuggestions,
});
}
16 changes: 16 additions & 0 deletions app/views/pkg/analysis_suggestion_block.mustache
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
{{! Copyright (c) 2018, the Dart project authors. Please see the AUTHORS file
for details. All rights reserved. Use of this source code is governed by a
BSD-style license that can be found in the LICENSE file. }}
<h4>{{label}}</h4>
{{#suggestions}}
<div class="suggestion-row">
<div class="suggestion-title">
<span class="{{icon_class}}"></span>
{{& title_html}}
</div>
<div class="suggestion-description">
{{& description_html}}
{{& suggestion_help_html}}
</div>
</div>
{{/suggestions}}
18 changes: 3 additions & 15 deletions app/views/pkg/analysis_tab.mustache
Original file line number Diff line number Diff line change
Expand Up @@ -91,21 +91,9 @@
<blockquote>{{& platforms_reason_html}}</blockquote>
{{/show_analysis}}

{{#hasSuggestions}}
<h4>{{suggestions_label}}</h4>
{{#suggestions}}
<div class="suggestion-row">
<div class="suggestion-title">
<span class="{{icon_class}}"></span>
{{& title_html}}
</div>
<div class="suggestion-description">
{{& description_html}}
{{& suggestion_help_html}}
</div>
</div>
{{/suggestions}}
{{/hasSuggestions}}
{{& analysis_suggestions_html}}
{{& health_suggestions_html}}
{{& maintenance_suggestions_html}}

{{#has_dependency}}
<h4>Dependencies</h4>
Expand Down