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
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
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;
}
getColor = (key: string) => getRgbColorByKey(key, this.props.theme);
getColor = (key: string) => getRgbColorByKey(key);
componentDidMount() {
this._draw();

View File

@ -392,7 +392,6 @@ export class UnthemedVirtualizedTraceView extends React.Component<VirtualizedTra
hoverIndentGuideIds,
addHoverIndentGuideId,
removeHoverIndentGuideId,
theme,
createSpanLink,
focusedSpanId,
focusedSpanIdForSearch,
@ -401,7 +400,7 @@ export class UnthemedVirtualizedTraceView extends React.Component<VirtualizedTra
if (!trace) {
return null;
}
const color = getColorByKey(serviceName, theme);
const color = getColorByKey(serviceName);
const isCollapsed = childrenHiddenIDs.has(spanID);
const isDetailExpanded = detailStates.has(spanID);
const isMatchingFilter = findMatchesIDs ? findMatchesIDs.has(spanID) : false;
@ -415,7 +414,7 @@ export class UnthemedVirtualizedTraceView extends React.Component<VirtualizedTra
if (rpcSpan) {
const rpcViewBounds = this.getViewedBounds()(rpcSpan.startTime, rpcSpan.startTime + rpcSpan.duration);
rpc = {
color: getColorByKey(rpcSpan.process.serviceName, theme),
color: getColorByKey(rpcSpan.process.serviceName),
operationName: rpcSpan.operationName,
serviceName: rpcSpan.process.serviceName,
viewEnd: rpcViewBounds.end,
@ -431,7 +430,7 @@ export class UnthemedVirtualizedTraceView extends React.Component<VirtualizedTra
if (!span.hasChildren && peerServiceKV && isKindClient(span)) {
noInstrumentedServer = {
serviceName: peerServiceKV.value,
color: getColorByKey(peerServiceKV.value, theme),
color: getColorByKey(peerServiceKV.value),
};
}
@ -487,7 +486,6 @@ export class UnthemedVirtualizedTraceView extends React.Component<VirtualizedTra
addHoverIndentGuideId,
removeHoverIndentGuideId,
linksGetter,
theme,
createSpanLink,
focusedSpanId,
createFocusSpanLink,
@ -497,7 +495,7 @@ export class UnthemedVirtualizedTraceView extends React.Component<VirtualizedTra
if (!trace || !detailState) {
return null;
}
const color = getColorByKey(serviceName, theme);
const color = getColorByKey(serviceName);
const styles = getStyles(this.props);
return (
<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
// limitations under the License.
import { createTheme } from '@grafana/data';
import { getColorByKey, clear } from './color-generator';
it('gives the same color for the same key', () => {
clear();
const colorOne = getColorByKey('serviceA', createTheme());
const colorTwo = getColorByKey('serviceA', createTheme());
const colorOne = getColorByKey('serviceA');
const colorTwo = getColorByKey('serviceA');
expect(colorOne).toBe(colorTwo);
});
it('gives different colors for each for each key', () => {
clear();
const colorOne = getColorByKey('serviceA', createTheme());
const colorTwo = getColorByKey('serviceB', createTheme());
const colorOne = getColorByKey('serviceA');
const colorTwo = getColorByKey('serviceB');
expect(colorOne).not.toBe(colorTwo);
});
@ -34,6 +32,6 @@ it('should not allow red', () => {
clear();
// when aPAKNMeFcF is hashed it's index is 4
// 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');
});

View File

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