|
@@ -2,21 +2,20 @@ import React from 'react';
|
|
|
import styled from '@emotion/styled';
|
|
|
import {browserHistory} from 'react-router';
|
|
|
|
|
|
-import {SubHeading} from 'app/components/charts/styles';
|
|
|
-import Link from 'app/components/links/link';
|
|
|
+import ActivityAvatar from 'app/components/activity/item/avatar';
|
|
|
import overflowEllipsis from 'app/styles/overflowEllipsis';
|
|
|
-import theme from 'app/utils/theme';
|
|
|
-import {IconBookmark} from 'app/icons/iconBookmark';
|
|
|
+import Link from 'app/components/links/link';
|
|
|
import space from 'app/styles/space';
|
|
|
import {callIfFunction} from 'app/utils/callIfFunction';
|
|
|
+import {User} from 'app/types';
|
|
|
import Card from 'app/components/card';
|
|
|
|
|
|
type Props = {
|
|
|
title?: string;
|
|
|
subtitle?: string;
|
|
|
queryDetail?: string;
|
|
|
- starred?: boolean;
|
|
|
to: object;
|
|
|
+ createdBy?: User | undefined;
|
|
|
onEventClick?: () => void;
|
|
|
renderGraph: () => React.ReactNode;
|
|
|
renderContextMenu?: () => React.ReactNode;
|
|
@@ -35,27 +34,27 @@ class QueryCard extends React.PureComponent<Props> {
|
|
|
const {
|
|
|
title,
|
|
|
subtitle,
|
|
|
- starred,
|
|
|
queryDetail,
|
|
|
renderContextMenu,
|
|
|
renderGraph,
|
|
|
+ createdBy,
|
|
|
} = this.props;
|
|
|
|
|
|
return (
|
|
|
<Link data-test-id={`card-${title}`} onClick={this.handleClick} to={this.props.to}>
|
|
|
<StyledQueryCard interactive>
|
|
|
<QueryCardHeader>
|
|
|
- <CardHeading>
|
|
|
- {title}
|
|
|
- {starred && (
|
|
|
- <StyledIconBookmark
|
|
|
- color={theme.yellow}
|
|
|
- data-test-id="is-saved-query"
|
|
|
- solid
|
|
|
- />
|
|
|
+ <QueryCardContent>
|
|
|
+ <QueryTitle>{title}</QueryTitle>
|
|
|
+ <QueryDetail>{queryDetail}</QueryDetail>
|
|
|
+ </QueryCardContent>
|
|
|
+ <AvatarWrapper>
|
|
|
+ {createdBy ? (
|
|
|
+ <ActivityAvatar type="user" user={createdBy} size={34} />
|
|
|
+ ) : (
|
|
|
+ <ActivityAvatar type="system" size={34} />
|
|
|
)}
|
|
|
- </CardHeading>
|
|
|
- <StyledQueryDetail>{queryDetail}</StyledQueryDetail>
|
|
|
+ </AvatarWrapper>
|
|
|
</QueryCardHeader>
|
|
|
<QueryCardBody>{renderGraph()}</QueryCardBody>
|
|
|
<QueryCardFooter>
|
|
@@ -68,6 +67,18 @@ class QueryCard extends React.PureComponent<Props> {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+const AvatarWrapper = styled('span')`
|
|
|
+ border: 3px solid ${p => p.theme.offWhite2};
|
|
|
+ border-radius: 50%;
|
|
|
+ height: 100%;
|
|
|
+`;
|
|
|
+
|
|
|
+const QueryCardContent = styled('div')`
|
|
|
+ flex-grow: 1;
|
|
|
+ overflow: hidden;
|
|
|
+ margin-right: ${space(1)};
|
|
|
+`;
|
|
|
+
|
|
|
const StyledQueryCard = styled(Card)`
|
|
|
justify-content: space-between;
|
|
|
height: 100%;
|
|
@@ -78,31 +89,21 @@ const StyledQueryCard = styled(Card)`
|
|
|
`;
|
|
|
|
|
|
const QueryCardHeader = styled('div')`
|
|
|
- position: relative;
|
|
|
+ display: flex;
|
|
|
padding: ${space(1.5)} ${space(2)};
|
|
|
- overflow: hidden;
|
|
|
- line-height: 1.4;
|
|
|
- flex-grow: 1;
|
|
|
-`;
|
|
|
-
|
|
|
-const StyledIconBookmark = styled(IconBookmark)`
|
|
|
- position: absolute;
|
|
|
- top: 14px;
|
|
|
- right: ${space(2)};
|
|
|
`;
|
|
|
|
|
|
-const CardHeading = styled(SubHeading)`
|
|
|
- width: 95%;
|
|
|
+const QueryTitle = styled('div')`
|
|
|
+ color: ${p => p.theme.textColor};
|
|
|
+ ${overflowEllipsis};
|
|
|
`;
|
|
|
|
|
|
-const StyledQueryDetail = styled('div')`
|
|
|
+const QueryDetail = styled('div')`
|
|
|
font-family: ${p => p.theme.text.familyMono};
|
|
|
font-size: ${p => p.theme.fontSizeSmall};
|
|
|
color: ${p => p.theme.gray2};
|
|
|
- overflow: hidden;
|
|
|
- text-overflow: ellipsis;
|
|
|
- white-space: nowrap;
|
|
|
- width: 100%;
|
|
|
+ line-height: 1.5;
|
|
|
+ ${overflowEllipsis};
|
|
|
`;
|
|
|
|
|
|
const QueryCardBody = styled('div')`
|