mirror of
https://github.com/react/react-native-devtools-frontend.git
synced 2026-10-06 20:11:38 +08:00
R=szuend@chromium.org Bug: 1222126 Change-Id: I80190d4d6257a9620f099e1d1711e50a7d206387 Reviewed-on: https://chromium-review.googlesource.com/c/devtools/devtools-frontend/+/3342108 Auto-Submit: Tim Van der Lippe <tvanderlippe@chromium.org> Reviewed-by: Simon Zünd <szuend@chromium.org> Commit-Queue: Simon Zünd <szuend@chromium.org>
69 lines
2.2 KiB
TypeScript
69 lines
2.2 KiB
TypeScript
// Copyright 2021 The Chromium Authors. All rights reserved.
|
|
// Use of this source code is governed by a BSD-style license that can be
|
|
// found in the LICENSE file.
|
|
|
|
import * as i18n from '../../core/i18n/i18n.js';
|
|
import type * as Platform from '../../core/platform/platform.js';
|
|
import type * as IssuesManager from '../../models/issues_manager/issues_manager.js';
|
|
|
|
import {AffectedResourcesView} from './AffectedResourcesView.js';
|
|
|
|
const UIStrings = {
|
|
/**
|
|
*@description Label for number of affected resources indication in issue view
|
|
*/
|
|
nResources: '{n, plural, =1 {# resource} other {# resources}}',
|
|
/**
|
|
*@description Title for the 'Frame' column.
|
|
*/
|
|
frameId: 'Frame',
|
|
};
|
|
|
|
const str_ = i18n.i18n.registerUIStrings('panels/issues/GenericIssueDetailsView.ts', UIStrings);
|
|
const i18nString = i18n.i18n.getLocalizedString.bind(undefined, str_);
|
|
|
|
export class GenericIssueDetailsView extends AffectedResourcesView {
|
|
protected getResourceNameWithCount(count: number): Platform.UIString.LocalizedString {
|
|
return i18nString(UIStrings.nResources, {n: count});
|
|
}
|
|
|
|
#appendDetails(genericIssues: ReadonlySet<IssuesManager.GenericIssue.GenericIssue>): void {
|
|
const header = document.createElement('tr');
|
|
|
|
const sampleIssueDetails = genericIssues.values().next().value.details();
|
|
if (sampleIssueDetails.frameId) {
|
|
this.appendColumnTitle(header, i18nString(UIStrings.frameId));
|
|
}
|
|
|
|
this.affectedResources.appendChild(header);
|
|
let count = 0;
|
|
for (const genericIssue of genericIssues) {
|
|
count++;
|
|
this.#appendDetail(genericIssue);
|
|
}
|
|
this.updateAffectedResourceCount(count);
|
|
}
|
|
|
|
#appendDetail(genericIssue: IssuesManager.GenericIssue.GenericIssue): void {
|
|
const element = document.createElement('tr');
|
|
element.classList.add('affected-resource-directive');
|
|
|
|
const details = genericIssue.details();
|
|
if (details.frameId) {
|
|
element.appendChild(this.createFrameCell(details.frameId, genericIssue.getCategory()));
|
|
}
|
|
|
|
this.affectedResources.appendChild(element);
|
|
}
|
|
|
|
update(): void {
|
|
this.clear();
|
|
const issues = this.issue.getGenericIssues();
|
|
if (issues.size > 0) {
|
|
this.#appendDetails(issues);
|
|
} else {
|
|
this.updateAffectedResourceCount(0);
|
|
}
|
|
}
|
|
}
|