chore: remove unused ShareBar and dead hook returns

ShareBar, its export and its CSS have no user. useRoutingTrace no longer
returns available and useArrange no longer returns byGroup, which nothing
reads. recorderPatchValue was an identity function, so the settings form
assigns the choice directly.
This commit is contained in:
Zakk committed 2026-10-01 00:38:23 +10:00
1 parent 6a3efe1043
commit dbbca3c756
8 files changed
+2 -90

No files matched your search

@@ -94,7 +94,6 @@ export function useArrange(source: Pick<MainSourceEdit, 'main' | 'writable' | 'b
return {
groups: view.groups,
unknown: view.unknown,
byGroup,
subscriptions: traySubs,
nodes: trayNodes,
search,
-1
View File
@@ -184,7 +184,6 @@ export function useRoutingTrace({form, setForm, advanced, setAdvanced}: ReturnTy
canSubmit: !busy && canSubmit,
reason: traceReason({loaded: !!capabilities.data, busy: busy !== null, available, invalid: invalid?.key ?? null, modeOffered: modes.includes(resolve)}, t),
submit,
available,
modes: modes.map(id => ({id, label: t(resolveLabels[id])})),
// An untouched form is not wrong yet; submit stays disabled until it is complete.
errors: {
@@ -10,7 +10,6 @@ import {
numericFieldView,
recorderFields,
recorderAccess,
recorderPatchValue,
recorderView,
recordingNote,
runtimeApplyReason,
@@ -76,7 +75,7 @@ export function useRuntimeSettingsForm() {
}));
const patch: RuntimeSettingsPatch = {};
if (baseline) {
for (const recorder of recorders) if (recorder.value !== modeOf(recorder.id)) patch[recorder.id] = recorderPatchValue(recorder.value);
for (const recorder of recorders) if (recorder.value !== modeOf(recorder.id)) patch[recorder.id] = recorder.value;
if (hasLevel && level !== baseline.log?.level) patch.log = {level: level as NonNullable<RuntimeSettings['log']>['level']};
for (const field of numeric)
if (!field.invalid && Number(field.value) !== numericAccess[field.id].read(baseline)) numericAccess[field.id].write(patch, Number(field.value));
-4
View File
@@ -17,7 +17,6 @@ import {
profileView,
recorderAccess,
recorderFields,
recorderPatchValue,
recorderView,
flowRecordingNote,
recordingNote,
@@ -73,9 +72,6 @@ it('recorder controls follow the reported state and the wire form', () => {
expect(forbidden.disabled).toBe(true);
expect(forbidden.status).toBe('settings.recordingForbidden');
expect(recorderView('record_dns_log', 'off', undefined, t).tone).toBe('neutral');
expect(recorderPatchValue('auto')).toBe('auto');
expect(recorderPatchValue('on')).toBe('on');
expect(recorderPatchValue('off')).toBe('off');
const recording = {flows: active, logs: active, dns_log: active, events: {active: false}, grace_remaining_seconds: 0} as never;
expect(recordingNote(recording, t)).toBe('settings.recordingDetached');
expect(recordingNote({...(recording as object), grace_remaining_seconds: 42} as never, t)).toBe('settings.recordingGrace:{"n":42}');
+1 -3
View File
@@ -1,5 +1,5 @@
import {formatBytes} from '../../i18n/format';
import type {Capabilities, RecorderMode, RecorderState, RuntimeSettingField, RuntimeSettings, RuntimeSettingsPatch, GeoData, Version} from '../../api/model';
import type {Capabilities, RecorderState, RuntimeSettingField, RuntimeSettings, RuntimeSettingsPatch, GeoData, Version} from '../../api/model';
import {engineOf} from '../../api/engines';
import {formatList, formatNumber, type Lang, type Params, type Translator} from '../../i18n';
import {href} from '../../shell/route';
@@ -18,8 +18,6 @@ export const recorderAccess: Record<Recorder, {state: 'flows' | 'logs' | 'dns_lo
};
export const recorderFields = Object.keys(recorderAccess) as Recorder[];
const recorderChoiceLabel: Record<RecorderChoice, Key> = {auto: 'settings.record.auto', on: 'settings.record.on', off: 'settings.record.off'};
// The wire form is the choice itself.
export const recorderPatchValue = (choice: RecorderChoice): RecorderMode => choice;
export function recorderView(id: Recorder, choice: RecorderChoice, state: RecorderState | undefined, t: Translator) {
const forbidden = state ? !state.allowed : false;
return {
-39
View File
@@ -1,39 +0,0 @@
import {useT} from '../../i18n';
import {shareDescription, useChartDescription} from './description';
import {ChartTip, useChartTip} from './tip';
export type ShareSegment = {id: string; label: string; count: number; color: string; text: string};
// One bar split by share, left to right from the largest, with the counts in the legend under it.
export function ShareBar({label, segments}: {label: string; segments: ShareSegment[]}) {
const t = useT();
const describedBy = useChartDescription();
const {ref: tipRef, tip: tipState, show: showTip, hide: hideTip} = useChartTip();
const total = segments.reduce((sum, segment) => sum + segment.count, 0);
return (
<div className="rp-sharebar rp-chart-hover" ref={tipRef} onPointerLeave={hideTip}>
<div className="bar" role="img" aria-label={shareDescription(label, segments, t)} aria-describedby={describedBy}>
{/* An empty share has no part of the bar; the legend still lists it with its zero. */}
{segments
.filter(segment => segment.count > 0 || !total)
.map(segment => (
<i
key={segment.id}
style={{flexGrow: total ? segment.count : 1, background: segment.color}}
onPointerMove={event => showTip(event, [segment.label, segment.text])}
/>
))}
</div>
<ul className="legend">
{segments.map(segment => (
<li key={segment.id}>
<i className="sw" style={{background: segment.color}} />
<span>{segment.label}</span>
<b>{segment.text}</b>
</li>
))}
</ul>
<ChartTip tip={tipState} />
</div>
);
}
-1
View File
@@ -9,4 +9,3 @@ export {Waffle, type WaffleShare} from './Waffle';
export {MarkerPlot, type MarkerGroup, type MarkerRow, type MarkerKind} from './MarkerPlot';
export {Heatmap, type HeatRow} from './Heatmap';
export {Scatter, ScatterLegend, type ScatterPoint, type ScatterSeries} from './Scatter';
export {ShareBar, type ShareSegment} from './ShareBar';
-39
View File
@@ -443,45 +443,6 @@
padding-block: 4px;
}
/* ---- Share bar ---- */
.rp-sharebar {
display: flex;
flex-direction: column;
gap: 10px;
}
.rp-sharebar .bar {
display: flex;
gap: 2px;
height: 16px;
border-radius: var(--rp-r-md);
overflow: hidden;
}
.rp-sharebar .bar > i {
flex-basis: 0;
min-width: 4px;
}
.rp-sharebar .legend {
display: flex;
flex-wrap: wrap;
gap: 6px 16px;
margin: 0;
padding: 0;
list-style: none;
font-size: var(--rp-text-sm);
}
.rp-sharebar .legend li {
display: inline-flex;
align-items: center;
gap: 6px;
}
.rp-sharebar .legend .sw {
width: 10px;
height: 10px;
border-radius: 3px;
}
.rp-sharebar .legend b {
font-variant-numeric: tabular-nums;
}
/* On a phone a lead tile takes the first row alone and the rest pair up below it, so the odd last tile no longer fills
its row. */
@media (max-width: 599.98px) {