Chore: Remove unused theme (#54175)

This commit is contained in:
Hamas Shafiq
2022-08-26 10:15:21 +01:00
committed by GitHub
parent 74158ed66b
commit cd26cade68
4 changed files with 12 additions and 17 deletions

View File

@ -50,7 +50,7 @@ export class UnthemedCanvasSpanGraph extends React.PureComponent<CanvasSpanGraph
this._canvasElm = undefined; this._canvasElm = undefined;
} }
getColor = (key: string) => getRgbColorByKey(key, this.props.theme); getColor = (key: string) => getRgbColorByKey(key);
componentDidMount() { componentDidMount() {
this._draw(); this._draw();

View File

@ -392,7 +392,6 @@ export class UnthemedVirtualizedTraceView extends React.Component<VirtualizedTra
hoverIndentGuideIds, hoverIndentGuideIds,
addHoverIndentGuideId, addHoverIndentGuideId,
removeHoverIndentGuideId, removeHoverIndentGuideId,
theme,
createSpanLink, createSpanLink,
focusedSpanId, focusedSpanId,
focusedSpanIdForSearch, focusedSpanIdForSearch,
@ -401,7 +400,7 @@ export class UnthemedVirtualizedTraceView extends React.Component<VirtualizedTra
if (!trace) { if (!trace) {
return null; return null;
} }
const color = getColorByKey(serviceName, theme); const color = getColorByKey(serviceName);
const isCollapsed = childrenHiddenIDs.has(spanID); const isCollapsed = childrenHiddenIDs.has(spanID);
const isDetailExpanded = detailStates.has(spanID); const isDetailExpanded = detailStates.has(spanID);
const isMatchingFilter = findMatchesIDs ? findMatchesIDs.has(spanID) : false; const isMatchingFilter = findMatchesIDs ? findMatchesIDs.has(spanID) : false;
@ -415,7 +414,7 @@ export class UnthemedVirtualizedTraceView extends React.Component<VirtualizedTra
if (rpcSpan) { if (rpcSpan) {
const rpcViewBounds = this.getViewedBounds()(rpcSpan.startTime, rpcSpan.startTime + rpcSpan.duration); const rpcViewBounds = this.getViewedBounds()(rpcSpan.startTime, rpcSpan.startTime + rpcSpan.duration);
rpc = { rpc = {
color: getColorByKey(rpcSpan.process.serviceName, theme), color: getColorByKey(rpcSpan.process.serviceName),
operationName: rpcSpan.operationName, operationName: rpcSpan.operationName,
serviceName: rpcSpan.process.serviceName, serviceName: rpcSpan.process.serviceName,
viewEnd: rpcViewBounds.end, viewEnd: rpcViewBounds.end,
@ -431,7 +430,7 @@ export class UnthemedVirtualizedTraceView extends React.Component<VirtualizedTra
if (!span.hasChildren && peerServiceKV && isKindClient(span)) { if (!span.hasChildren && peerServiceKV && isKindClient(span)) {
noInstrumentedServer = { noInstrumentedServer = {
serviceName: peerServiceKV.value, serviceName: peerServiceKV.value,
color: getColorByKey(peerServiceKV.value, theme), color: getColorByKey(peerServiceKV.value),
}; };
} }
@ -487,7 +486,6 @@ export class UnthemedVirtualizedTraceView extends React.Component<VirtualizedTra
addHoverIndentGuideId, addHoverIndentGuideId,
removeHoverIndentGuideId, removeHoverIndentGuideId,
linksGetter, linksGetter,
theme,
createSpanLink, createSpanLink,
focusedSpanId, focusedSpanId,
createFocusSpanLink, createFocusSpanLink,
@ -497,7 +495,7 @@ export class UnthemedVirtualizedTraceView extends React.Component<VirtualizedTra
if (!trace || !detailState) { if (!trace || !detailState) {
return null; return null;
} }
const color = getColorByKey(serviceName, theme); const color = getColorByKey(serviceName);
const styles = getStyles(this.props); const styles = getStyles(this.props);
return ( return (
<div className={styles.row} key={key} style={{ ...style, zIndex: 1 }} {...attrs}> <div className={styles.row} key={key} style={{ ...style, zIndex: 1 }} {...attrs}>

View File

@ -12,21 +12,19 @@
// See the License for the specific language governing permissions and // See the License for the specific language governing permissions and
// limitations under the License. // limitations under the License.
import { createTheme } from '@grafana/data';
import { getColorByKey, clear } from './color-generator'; import { getColorByKey, clear } from './color-generator';
it('gives the same color for the same key', () => { it('gives the same color for the same key', () => {
clear(); clear();
const colorOne = getColorByKey('serviceA', createTheme()); const colorOne = getColorByKey('serviceA');
const colorTwo = getColorByKey('serviceA', createTheme()); const colorTwo = getColorByKey('serviceA');
expect(colorOne).toBe(colorTwo); expect(colorOne).toBe(colorTwo);
}); });
it('gives different colors for each for each key', () => { it('gives different colors for each for each key', () => {
clear(); clear();
const colorOne = getColorByKey('serviceA', createTheme()); const colorOne = getColorByKey('serviceA');
const colorTwo = getColorByKey('serviceB', createTheme()); const colorTwo = getColorByKey('serviceB');
expect(colorOne).not.toBe(colorTwo); expect(colorOne).not.toBe(colorTwo);
}); });
@ -34,6 +32,6 @@ it('should not allow red', () => {
clear(); clear();
// when aPAKNMeFcF is hashed it's index is 4 // when aPAKNMeFcF is hashed it's index is 4
// which is red, which we disallow because it looks like an error // which is red, which we disallow because it looks like an error
const colorOne = getColorByKey('aPAKNMeFcF', createTheme()); const colorOne = getColorByKey('aPAKNMeFcF');
expect(colorOne).not.toBe('#E24D42'); expect(colorOne).not.toBe('#E24D42');
}); });

View File

@ -14,7 +14,6 @@
import memoizeOne from 'memoize-one'; import memoizeOne from 'memoize-one';
import { GrafanaTheme2 } from '@grafana/data';
import { colors } from '@grafana/ui'; import { colors } from '@grafana/ui';
// TS needs the precise return type // TS needs the precise return type
@ -95,10 +94,10 @@ export function clear() {
getGenerator([]); getGenerator([]);
} }
export function getColorByKey(key: string, theme: GrafanaTheme2) { export function getColorByKey(key: string) {
return getGenerator(colors).getColorByKey(key); return getGenerator(colors).getColorByKey(key);
} }
export function getRgbColorByKey(key: string, theme: GrafanaTheme2): [number, number, number] { export function getRgbColorByKey(key: string): [number, number, number] {
return getGenerator(colors).getRgbColorByKey(key); return getGenerator(colors).getRgbColorByKey(key);
} }