Skip to content

Commit

Permalink
Merge pull request elastic#15 from Elastic-AWP-Platform/fix-use-style…
Browse files Browse the repository at this point in the history
…-type-error

Fix type issue with useStyles
  • Loading branch information
JiaweiWu authored Nov 25, 2021
2 parents e0cd5bf + 4dbacba commit 9b6aed6
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 18 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ import React, { useMemo, useRef, useLayoutEffect, useState, useEffect, MouseEven
import { EuiButton, EuiIcon } from '@elastic/eui';
import { FormattedMessage } from '@kbn/i18n/react';
import { Process } from '../../hooks/use_process_tree';
import { useStyles } from './styles';
import { useStyles, ButtonType } from './styles';
import { ProcessTreeAlerts } from '../ProcessTreeAlerts';

interface ProcessDeps {
Expand Down Expand Up @@ -119,7 +119,7 @@ export function ProcessTreeNode({
if (!isSessionLeader && process.children.length > 0) {
buttons.push(
<EuiButton
css={styles.getButtonStyle(styles.ButtonType.children)}
css={styles.getButtonStyle(ButtonType.children)}
onClick={() => setChildrenExpanded(!childrenExpanded)}
>
<FormattedMessage
Expand All @@ -134,7 +134,7 @@ export function ProcessTreeNode({
if (alerts.length) {
buttons.push(
<EuiButton
css={styles.getButtonStyle(styles.ButtonType.alerts)}
css={styles.getButtonStyle(ButtonType.alerts)}
onClick={() => setAlertsExpanded(!alertsExpanded)}
>
<FormattedMessage id="xpack.sessionView.alerts" defaultMessage="Alerts" />
Expand Down Expand Up @@ -202,7 +202,7 @@ export function ProcessTreeNode({

if (user.name === 'root' && user.id !== parent.user.id) {
return (
<EuiButton css={styles.getButtonStyle(styles.ButtonType.userChanged)}>
<EuiButton css={styles.getButtonStyle(ButtonType.userChanged)}>
<FormattedMessage
id="xpack.sessionView.execUserChange"
defaultMessage="Root escalation"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,28 +16,28 @@ interface StylesDeps {
hasAlerts: boolean;
}

export enum ButtonType {
children = 'children',
alerts = 'alerts',
output = 'output',
userChanged = 'user',
}

export const useStyles = ({ depth, hasAlerts }: StylesDeps) => {
const { euiTheme } = useEuiTheme();

const cached = useMemo(() => {
const { colors, border, font, size } = euiTheme;

enum ButtonType {
children = 'children',
alerts = 'alerts',
output = 'output',
userChanged = 'user',
}

const darkText: CSSObject = {
color: colors.text,
};

const searchHighlight = `
background-color: ${colors.highlight};
color: ${colors.text};
border-radius: ${border.radius.medium};
`;
const searchHighlight: CSSObject = {
backgroundColor: colors.highlight,
color: colors.text,
borderRadius: border.radius.medium,
};

const children: CSSObject = {
position: 'relative',
Expand Down Expand Up @@ -73,7 +73,7 @@ export const useStyles = ({ depth, hasAlerts }: StylesDeps) => {
marginLeft: size.s,
};

const getButtonStyle = (type: string) => {
const getButtonStyle = (type: string): CSSObject => {
let background = 'rgba(170, 101, 86, 0.04)';
let borderStyle = '1px solid rgba(170, 101, 86, 0.48)';

Expand Down Expand Up @@ -175,7 +175,6 @@ export const useStyles = ({ depth, hasAlerts }: StylesDeps) => {
workingDir,
userEnteredIcon,
buttonArrow,
ButtonType,
getButtonStyle,
alertDetails,
};
Expand Down

0 comments on commit 9b6aed6

Please sign in to comment.