Skip to content

Commit c995889

Browse files
lint
I had some weird linting errors and I don't have time to test if the changes introduced bugs. keeping this lint as a separate commit. If there are bugs, you may need to undo these changes best, will
1 parent 6e923bc commit c995889

File tree

2 files changed

+28
-25
lines changed

2 files changed

+28
-25
lines changed

packages/react-components/src/trace-explorer/trace-explorer-views-widget.tsx

+25-22
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import * as React from 'react';
22
import '../../style/output-components-style.css';
33
import { OutputAddedSignalPayload } from 'traceviewer-base/lib/signals/output-added-signal-payload';
4-
import { signalManager, Signals } from 'traceviewer-base/lib/signals/signal-manager';
4+
import { signalManager } from 'traceviewer-base/lib/signals/signal-manager';
55
import { OutputDescriptor, ProviderType } from 'tsp-typescript-client/lib/models/output-descriptor';
66
import { Experiment } from 'tsp-typescript-client/lib/models/experiment';
77
import { ITspClientProvider } from 'traceviewer-base/lib/tsp-client-provider';
@@ -216,7 +216,7 @@ export class ReactAvailableViewsWidget extends React.Component<ReactAvailableVie
216216
}
217217

218218
private entryToTreeNode(entry: OutputDescriptor, idStringToNodeId: { [key: string]: number }): TreeNode {
219-
let id = idStringToNodeId[entry.id] ?? (idStringToNodeId[entry.id] = this._idGenerator++);
219+
const id = idStringToNodeId[entry.id] ?? (idStringToNodeId[entry.id] = this._idGenerator++);
220220

221221
let parentId = -1;
222222
if (entry.parentId) {
@@ -241,6 +241,7 @@ export class ReactAvailableViewsWidget extends React.Component<ReactAvailableVie
241241
const isCustomizable = entry.capabilities?.canCreate === true;
242242
const isDeletable = entry.capabilities?.canDelete === true;
243243

244+
// Return undefined if no relevant capabilities
244245
if (!isCustomizable && !isDeletable) {
245246
return undefined;
246247
}
@@ -253,36 +254,38 @@ export class ReactAvailableViewsWidget extends React.Component<ReactAvailableVie
253254
flexShrink: 1
254255
};
255256

256-
if (isCustomizable) {
257-
return (): JSX.Element => (
258-
<>
259-
<span style={nameSpanStyle}>{entry.name}</span>
260-
<div className="remove-output-button-container" title={`Add custom analysis to ${entry.name}`}>
261-
<button className="remove-output-button" onClick={e => this.handleCustomizeClick(entry, e)}>
262-
<FontAwesomeIcon icon={faPlus} />
263-
</button>
264-
</div>
265-
</>
266-
);
267-
} else {
268-
// Must be deletable based on our conditions
269-
return (): JSX.Element => (
257+
const useCustomizableUI = isCustomizable;
258+
259+
const EnrichedContent = (): JSX.Element => {
260+
const displayName = useCustomizableUI ? entry.name : entry.configuration?.name;
261+
262+
const buttonTitle = useCustomizableUI ? `Add custom analysis to ${displayName}` : `Remove "${displayName}"`;
263+
264+
const icon = useCustomizableUI ? faPlus : faTimes;
265+
266+
const handleClick = useCustomizableUI
267+
? (e: React.MouseEvent) => this.handleCustomizeClick(entry, e)
268+
: (e: React.MouseEvent) => this.handleDeleteClick(entry, e);
269+
270+
return (
270271
<>
271-
<span style={nameSpanStyle}>{entry.configuration?.name}</span>
272-
<div className="remove-output-button-container" title={`Remove "${entry.configuration?.name}"`}>
273-
<button className="remove-output-button" onClick={e => this.handleDeleteClick(entry, e)}>
274-
<FontAwesomeIcon icon={faTimes} />
272+
<span style={nameSpanStyle}>{displayName}</span>
273+
<div className={'enriched-output-button-container'} title={buttonTitle}>
274+
<button className={'enriched-output-button'} onClick={handleClick}>
275+
<FontAwesomeIcon icon={icon} />
275276
</button>
276277
</div>
277278
</>
278279
);
279-
}
280+
};
281+
282+
return EnrichedContent;
280283
}
281284

282285
private handleCustomizeClick = async (entry: OutputDescriptor, e: React.MouseEvent) => {
283286
e.stopPropagation();
284287
if (this.props.onCustomizationClick && this._selectedExperiment) {
285-
await this.props.onCustomizationClick(entry, this._selectedExperiment);
288+
this.props.onCustomizationClick(entry, this._selectedExperiment);
286289
this.updateAvailableViews();
287290
}
288291
};

packages/react-components/style/output-components-style.css

+3-3
Original file line numberDiff line numberDiff line change
@@ -575,15 +575,15 @@ input[type="reset"].input-button {
575575
flex-shrink: 0;
576576
}
577577

578-
.remove-output-button-container {
578+
.enriched-output-button-container {
579579
margin-right: 2px;
580580
display: flex;
581581
justify-content: center;
582582
align-items: flex-start;
583583
margin-left: auto;
584584
}
585585

586-
.remove-output-button {
586+
.enriched-output-button {
587587
background: none;
588588
border: none;
589589
visibility: visible;
@@ -592,6 +592,6 @@ input[type="reset"].input-button {
592592
cursor: pointer;
593593
}
594594

595-
.remove-output-button :hover {
595+
.enriched-output-button :hover {
596596
background: none;
597597
}

0 commit comments

Comments
 (0)