Skip to content

Commit

Permalink
Merge branch 'develop' into issue-3578
Browse files Browse the repository at this point in the history
  • Loading branch information
prashant-shahi authored Sep 27, 2023
2 parents f1a4497 + bccefc6 commit 91bcadf
Show file tree
Hide file tree
Showing 76 changed files with 1,733 additions and 595 deletions.
1 change: 1 addition & 0 deletions .github/workflows/build.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ jobs:
run: |
echo 'INTERCOM_APP_ID="${{ secrets.INTERCOM_APP_ID }}"' > frontend/.env
echo 'SEGMENT_ID="${{ secrets.SEGMENT_ID }}"' >> frontend/.env
echo 'CLARITY_PROJECT_ID="${{ secrets.CLARITY_PROJECT_ID }}"' >> frontend/.env
- name: Install dependencies
run: cd frontend && yarn install
- name: Run ESLint
Expand Down
1 change: 1 addition & 0 deletions .github/workflows/push.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -133,6 +133,7 @@ jobs:
run: |
echo 'INTERCOM_APP_ID="${{ secrets.INTERCOM_APP_ID }}"' > frontend/.env
echo 'SEGMENT_ID="${{ secrets.SEGMENT_ID }}"' >> frontend/.env
echo 'CLARITY_PROJECT_ID="${{ secrets.CLARITY_PROJECT_ID }}"' >> frontend/.env
- name: Install dependencies
working-directory: frontend
run: yarn install
Expand Down
4 changes: 4 additions & 0 deletions frontend/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -84,9 +84,11 @@
"react-helmet-async": "1.3.0",
"react-i18next": "^11.16.1",
"react-intersection-observer": "9.4.1",
"react-markdown": "8.0.7",
"react-query": "^3.34.19",
"react-redux": "^7.2.2",
"react-router-dom": "^5.2.0",
"react-syntax-highlighter": "15.5.0",
"react-use": "^17.3.2",
"react-virtuoso": "4.0.3",
"redux": "^4.0.5",
Expand Down Expand Up @@ -150,6 +152,7 @@
"@types/react-redux": "^7.1.11",
"@types/react-resizable": "3.0.3",
"@types/react-router-dom": "^5.1.6",
"@types/react-syntax-highlighter": "15.5.7",
"@types/styled-components": "^5.1.4",
"@types/uuid": "^8.3.1",
"@types/webpack": "^5.28.0",
Expand Down Expand Up @@ -183,6 +186,7 @@
"lint-staged": "^12.5.0",
"portfinder-sync": "^0.0.2",
"prettier": "2.2.1",
"raw-loader": "4.0.2",
"react-hooks-testing-library": "0.6.0",
"react-hot-loader": "^4.13.0",
"react-resizable": "3.0.4",
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
.code-snippet-container {
position: relative;
background-color: rgb(43, 43, 43);
}

.code-copy-btn {
position: absolute;
top: 8px;
right: 8px;
display: flex;
justify-content: flex-end;
align-items: center;

button {
cursor: pointer;

background-color: rgba($color: #1d1d1d, $alpha: 0.7);
color: white;
border: none;
padding: 8px;
border-radius: 3px;
transition: all 0.1s;

&:hover {
background-color: rgba($color: #1d1d1d, $alpha: 1);
}
}

&.copied {
button {
background-color: rgba($color: #52c41a, $alpha: 1);
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
import './CodeCopyBtn.scss';

import { CheckOutlined, CopyOutlined } from '@ant-design/icons';
import cx from 'classnames';
import { useState } from 'react';

export default function CodeCopyBtn({
children,
}: {
children: React.ReactNode;
}): JSX.Element {
const [isSnippetCopied, setIsSnippetCopied] = useState(false);

const handleClick = (): void => {
if (children && Array.isArray(children)) {
setIsSnippetCopied(true);
navigator.clipboard.writeText(children[0].props.children[0]).finally(() => {
setTimeout(() => {
setIsSnippetCopied(false);
}, 1000);
});
}
};

return (
<div className={cx('code-copy-btn', isSnippetCopied ? 'copied' : '')}>
<button type="button" onClick={handleClick}>
{!isSnippetCopied ? <CopyOutlined /> : <CheckOutlined />}
</button>
</div>
);
}
43 changes: 43 additions & 0 deletions frontend/src/components/MarkdownRenderer/MarkdownRenderer.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
/* eslint-disable react/jsx-props-no-spreading */
import { CodeProps } from 'react-markdown/lib/ast-to-react';
import { Prism as SyntaxHighlighter } from 'react-syntax-highlighter';
import { a11yDark } from 'react-syntax-highlighter/dist/cjs/styles/prism';

import CodeCopyBtn from './CodeCopyBtn/CodeCopyBtn';

function Pre({ children }: { children: React.ReactNode }): JSX.Element {
return (
<pre className="code-snippet-container">
<CodeCopyBtn>{children}</CodeCopyBtn>
{children}
</pre>
);
}

function Code({
node,
inline,
className = 'blog-code',
children,
...props
}: CodeProps): JSX.Element {
const match = /language-(\w+)/.exec(className || '');
return !inline && match ? (
<SyntaxHighlighter
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
// @ts-ignore
style={a11yDark}
language={match[1]}
PreTag="div"
{...props}
>
{String(children).replace(/\n$/, '')}
</SyntaxHighlighter>
) : (
<code className={className} {...props}>
{children}
</code>
);
}

export { Code, Pre };
20 changes: 19 additions & 1 deletion frontend/src/constants/queryBuilder.ts
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ export const mapOfOperators = {
traces: tracesAggregateOperatorOptions,
};

export const mapOfFilters: Record<DataSource, QueryAdditionalFilter[]> = {
export const mapOfQueryFilters: Record<DataSource, QueryAdditionalFilter[]> = {
metrics: [
// eslint-disable-next-line sonarjs/no-duplicate-string
{ text: 'Aggregation interval', field: 'stepInterval' },
Expand All @@ -94,6 +94,24 @@ export const mapOfFilters: Record<DataSource, QueryAdditionalFilter[]> = {
],
};

const commonFormulaFilters: QueryAdditionalFilter[] = [
{
text: 'Having',
field: 'having',
},
{ text: 'Order by', field: 'orderBy' },
{ text: 'Limit', field: 'limit' },
];

export const mapOfFormulaToFilters: Record<
DataSource,
QueryAdditionalFilter[]
> = {
metrics: commonFormulaFilters,
logs: commonFormulaFilters,
traces: commonFormulaFilters,
};

export const REDUCE_TO_VALUES: SelectOption<ReduceOperators, string>[] = [
{ value: 'last', label: 'Latest of values in timeframe' },
{ value: 'sum', label: 'Sum of values in timeframe' },
Expand Down
6 changes: 5 additions & 1 deletion frontend/src/container/ErrorDetails/index.tsx
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import './styles.scss';

import { Button, Divider, Space, Typography } from 'antd';
import getNextPrevId from 'api/errors/getNextPrevId';
import Editor from 'components/Editor';
Expand Down Expand Up @@ -161,7 +163,9 @@ function ErrorDetails(props: ErrorDetailsProps): JSX.Element {
</DashedContainer>

<Typography.Title level={4}>{t('stack_trace')}</Typography.Title>
<Editor onChange={(): void => {}} value={stackTraceValue} readOnly />
<div className="error-container">
<Editor value={stackTraceValue} readOnly />
</div>

<EditorContainer>
<Space direction="vertical">
Expand Down
3 changes: 3 additions & 0 deletions frontend/src/container/ErrorDetails/styles.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
.error-container {
height: 50vh;
}
4 changes: 2 additions & 2 deletions frontend/src/container/LiveLogs/constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import {
initialQueriesMap,
initialQueryBuilderFormValuesMap,
} from 'constants/queryBuilder';
import { FILTERS } from 'container/QueryBuilder/filters/OrderByFilter/config';
import { ORDERBY_FILTERS } from 'container/QueryBuilder/filters/OrderByFilter/config';
import {
BaseAutocompleteData,
DataTypes,
Expand All @@ -14,7 +14,7 @@ export const defaultLiveQueryDataConfig: Partial<IBuilderQuery> = {
aggregateOperator: LogsAggregatorOperator.NOOP,
disabled: true,
pageSize: 10,
orderBy: [{ columnName: 'timestamp', order: FILTERS.DESC }],
orderBy: [{ columnName: 'timestamp', order: ORDERBY_FILTERS.DESC }],
};

type GetDefaultCompositeQueryParams = {
Expand Down
4 changes: 2 additions & 2 deletions frontend/src/container/LogsContextList/ShowButton.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { Button, Typography } from 'antd';
import { FILTERS } from 'container/QueryBuilder/filters/OrderByFilter/config';
import { ORDERBY_FILTERS } from 'container/QueryBuilder/filters/OrderByFilter/config';

import { ShowButtonWrapper } from './styles';

Expand All @@ -19,7 +19,7 @@ function ShowButton({
return (
<ShowButtonWrapper>
<Typography>
Showing 10 lines {order === FILTERS.ASC ? 'after' : 'before'} match
Showing 10 lines {order === ORDERBY_FILTERS.ASC ? 'after' : 'before'} match
</Typography>
<Button
size="small"
Expand Down
12 changes: 6 additions & 6 deletions frontend/src/container/LogsContextList/index.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import RawLogView from 'components/Logs/RawLogView';
import Spinner from 'components/Spinner';
import { PANEL_TYPES } from 'constants/queryBuilder';
import { FILTERS } from 'container/QueryBuilder/filters/OrderByFilter/config';
import { ORDERBY_FILTERS } from 'container/QueryBuilder/filters/OrderByFilter/config';
import { useGetExplorerQueryRange } from 'hooks/queryBuilder/useGetExplorerQueryRange';
import { useIsDarkMode } from 'hooks/useDarkMode';
import { memo, useCallback, useEffect, useMemo, useState } from 'react';
Expand Down Expand Up @@ -87,7 +87,7 @@ function LogsContextList({
timestamp: item.timestamp,
}));

if (order === FILTERS.ASC) {
if (order === ORDERBY_FILTERS.ASC) {
const reversedCurrentLogs = currentLogs.reverse();
setLogs((prevLogs) => [...reversedCurrentLogs, ...prevLogs]);
} else {
Expand All @@ -111,7 +111,7 @@ function LogsContextList({
const handleShowNextLines = useCallback(() => {
if (isDisabledFetch) return;

const log = order === FILTERS.ASC ? firstLog : lastLog;
const log = order === ORDERBY_FILTERS.ASC ? firstLog : lastLog;

const newRequestData = getRequestData({
stagedQueryData: currentStagedQueryData,
Expand Down Expand Up @@ -167,7 +167,7 @@ function LogsContextList({

return (
<>
{order === FILTERS.ASC && (
{order === ORDERBY_FILTERS.ASC && (
<ShowButton
isLoading={isFetching}
isDisabled={isDisabledFetch}
Expand All @@ -186,11 +186,11 @@ function LogsContextList({
initialTopMostItemIndex={0}
data={logs}
itemContent={getItemContent}
followOutput={order === FILTERS.DESC}
followOutput={order === ORDERBY_FILTERS.DESC}
/>
</ListContainer>

{order === FILTERS.DESC && (
{order === ORDERBY_FILTERS.DESC && (
<ShowButton
isLoading={isFetching}
isDisabled={isDisabledFetch}
Expand Down
6 changes: 3 additions & 3 deletions frontend/src/container/LogsExplorerContext/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { Typography } from 'antd';
import Modal from 'antd/es/modal/Modal';
import RawLogView from 'components/Logs/RawLogView';
import LogsContextList from 'container/LogsContextList';
import { FILTERS } from 'container/QueryBuilder/filters/OrderByFilter/config';
import { ORDERBY_FILTERS } from 'container/QueryBuilder/filters/OrderByFilter/config';
import QueryBuilderSearch from 'container/QueryBuilder/filters/QueryBuilderSearch';
import { useIsDarkMode } from 'hooks/useDarkMode';
import { memo, useCallback, useState } from 'react';
Expand Down Expand Up @@ -87,7 +87,7 @@ function LogsExplorerContext({
/>
)}
<LogsContextList
order={FILTERS.ASC}
order={ORDERBY_FILTERS.ASC}
filters={filters}
isEdit={isEdit}
log={log}
Expand All @@ -103,7 +103,7 @@ function LogsExplorerContext({
/>
</LogContainer>
<LogsContextList
order={FILTERS.DESC}
order={ORDERBY_FILTERS.DESC}
filters={filters}
isEdit={isEdit}
log={log}
Expand Down
14 changes: 10 additions & 4 deletions frontend/src/container/OnboardingContainer/APM/GoLang/GoLang.tsx
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
import './GoLang.styles.scss';

import { MDXProvider } from '@mdx-js/react';
import { Form, Input } from 'antd';
import { Code, Pre } from 'components/MarkdownRenderer/MarkdownRenderer';
import Header from 'container/OnboardingContainer/common/Header/Header';
import ReactMarkdown from 'react-markdown';

import ConnectionStatus from '../common/ConnectionStatus/ConnectionStatus';
import GoLangDocs from './goLang.md';
Expand Down Expand Up @@ -44,9 +45,14 @@ export default function GoLang({
</div>

<div className="content-container">
<MDXProvider>
<GoLangDocs />
</MDXProvider>
<ReactMarkdown
components={{
pre: Pre,
code: Code,
}}
>
{GoLangDocs}
</ReactMarkdown>
</div>
</div>
)}
Expand Down
Loading

0 comments on commit 91bcadf

Please sign in to comment.