Skip to content

Commit

Permalink
Merge pull request #871 from glific/feature/webhook-logs
Browse files Browse the repository at this point in the history
Display the webhook logs
  • Loading branch information
mdshamoon authored Jan 4, 2021
2 parents 95f4970 + 002339e commit 2d6e48b
Show file tree
Hide file tree
Showing 30 changed files with 444 additions and 94 deletions.
Binary file added src/assets/images/icons/Copy.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
12 changes: 12 additions & 0 deletions src/assets/images/icons/View.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
16 changes: 16 additions & 0 deletions src/assets/images/icons/Webhook/WebhookDark.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
16 changes: 16 additions & 0 deletions src/assets/images/icons/Webhook/WebhookLight.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
8 changes: 8 additions & 0 deletions src/common/constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,14 @@ export const setColumnToBackendTerms: any = (listName: string, columnName: strin
STATUS: 'status',
BENEFICIARY: 'name',
'PHONE NO': 'phone',
TIME: 'updated_at',
URL: 'url',
'STATUS CODE': 'status_code',
ERROR: 'error',
METHOD: 'method',
'REQUEST HEADER': 'request_headers',
'REQUEST JSON': 'request_json',
'RESPONSE JSON': 'response_json',
};

if (listName === 'Collection') {
Expand Down
2 changes: 1 addition & 1 deletion src/components/UI/Layout/Layout.module.css
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
.Main {
width: calc(100%);
width: calc(100% - 233px);
}
4 changes: 4 additions & 0 deletions src/components/UI/Menu/MenuItem/MenuItem.module.css
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
.Danger {
color: #dd1f1f !important;
}

.Spacing {
margin-left: 12px;
}
2 changes: 1 addition & 1 deletion src/components/UI/Menu/MenuItem/MenuItem.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ const MenuItem: React.SFC<MenuItemProps> = (props) => {
return (
<MenuItemElement onClick={onClickHandler} component={Link} to={path} data-testid="MenuItem">
{icon}
<div className={menuItemClass}>{title}</div>
<div className={`${menuItemClass} ${icon ? styles.Spacing : ''}`}>{title}</div>
</MenuItemElement>
);
};
Expand Down
12 changes: 6 additions & 6 deletions src/components/UI/Pager/Pager.module.css
Original file line number Diff line number Diff line change
Expand Up @@ -32,14 +32,16 @@

.TableContainer {
margin: 14px 24px;
margin-bottom: 10px;
margin-bottom: 50px;
overflow: auto;

}

.TableFooter {
position: absolute;
position: fixed;
display: flex !important;
justify-content: flex-end !important;
width: 80%;
width: calc(100% - 243px);
background: #fafafa;
bottom: 0px;
right: 4px;
Expand All @@ -52,7 +54,7 @@
}

.FooterRow > div {
min-height: 72px;
min-height: 55px;
}

.TableText {
Expand All @@ -76,5 +78,3 @@
margin-bottom: 12px;
line-height: 1;
}


17 changes: 2 additions & 15 deletions src/components/UI/Pager/Pager.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import React, { useEffect, useState } from 'react';
import React from 'react';
import {
Table,
TableHead,
Expand Down Expand Up @@ -205,9 +205,6 @@ export const Pager: React.SFC<PagerProps> = (props) => {
collapseRow,
} = props;

// Creates the rows for the table
const [tableFooterStyle, setTableFooterStyle] = useState<string | undefined>(undefined);

const rows = createRows(data, columnStyles, showCheckbox, collapseOpen, collapseRow);
const tableHead = tableHeadColumns(
columnNames,
Expand All @@ -220,24 +217,14 @@ export const Pager: React.SFC<PagerProps> = (props) => {

const tablePagination = pagination(columnNames, totalRows, handleTableChange, tableVals);

useEffect(() => {
const table = document.querySelector('.MuiTable-root');
const html = document.querySelector('html');
if (table && html) {
if (table.scrollHeight < html.clientHeight - 142) {
setTableFooterStyle(styles.TableFooter);
}
}
}, []);

return (
<div className={styles.TableContainer}>
<Table className={styles.Table} data-testid="table">
<TableHead className={styles.TagListHeader} data-testid="tableHead">
{tableHead}
</TableHead>
<TableBody data-testid="tableBody">{rows}</TableBody>
<TableFooter className={tableFooterStyle} data-testid="tableFooter">
<TableFooter className={styles.TableFooter} data-testid="tableFooter">
<TableRow>{tablePagination}</TableRow>
</TableFooter>
</Table>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ const contactSearchQuery = {
query: CONTACT_SEARCH_QUERY,
variables: {
filter: {
name: '',
status: 'BLOCKED',
},
opts: {
Expand Down Expand Up @@ -43,7 +42,6 @@ const contactSearchQueryBlocked = {
query: CONTACT_SEARCH_QUERY,
variables: {
filter: {
name: '',
status: 'BLOCKED',
},
opts: {
Expand Down Expand Up @@ -79,7 +77,6 @@ const contactCountQuery = {
query: GET_CONTACT_COUNT,
variables: {
filter: {
name: '',
status: 'BLOCKED',
},
opts: { limit: 50, offset: 0, order: 'ASC' },
Expand All @@ -105,7 +102,6 @@ export const CONTACT_LIST_MOCKS = [
query: GET_CONTACT_COUNT,
variables: {
filter: {
name: '',
status: 'BLOCKED',
},
},
Expand Down
15 changes: 15 additions & 0 deletions src/containers/Flow/FlowList/FlowList.module.css
Original file line number Diff line number Diff line change
Expand Up @@ -43,3 +43,18 @@
padding-top: 12px;
color: #93a29b;
}

.Webhook {
color: #119656;
position: fixed;
bottom: 16px;
font-size: 16px;
font-weight: 500;
left: 262px;
cursor: pointer;
text-decoration: none;
}

.Webhook svg {
margin-right: 8px;
}
5 changes: 4 additions & 1 deletion src/containers/Flow/FlowList/FlowList.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,15 @@ import { render } from '@testing-library/react';
import { FlowList } from './FlowList';
import { MockedProvider } from '@apollo/client/testing';
import { getFlowCountQuery } from '../../../mocks/Flow';
import { MemoryRouter } from 'react-router';

const mocks = [getFlowCountQuery];

const flowList = (
<MockedProvider mocks={mocks}>
<FlowList />
<MemoryRouter>
<FlowList />
</MemoryRouter>
</MockedProvider>
);

Expand Down
38 changes: 23 additions & 15 deletions src/containers/Flow/FlowList/FlowList.tsx
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
import React from 'react';
import { useHistory } from 'react-router-dom';
import { Link, useHistory } from 'react-router-dom';
import moment from 'moment';

import styles from './FlowList.module.css';
import { ReactComponent as FlowIcon } from '../../../assets/images/icons/Flow/Dark.svg';
import { ReactComponent as DuplicateIcon } from '../../../assets/images/icons/Flow/Duplicate.svg';
import { ReactComponent as ConfigureIcon } from '../../../assets/images/icons/Configure/UnselectedDark.svg';
import { ReactComponent as WebhookLogsIcon } from '../../../assets/images/icons/Webhook/WebhookLight.svg';
import { List } from '../../List/List';
import { FILTER_FLOW, GET_FLOWS, GET_FLOW_COUNT } from '../../../graphql/queries/Flow';
import { DELETE_FLOW } from '../../../graphql/mutations/Flow';
Expand Down Expand Up @@ -66,19 +67,26 @@ export const FlowList: React.SFC<FlowListProps> = () => {
];

return (
<List
title="Flows"
listItem="flows"
listItemName="flow"
pageLink="flow"
listIcon={flowIcon}
dialogMessage={dialogMessage}
refetchQueries={{ query: GET_FLOWS, variables: setVariables() }}
{...queries}
{...columnAttributes}
searchParameter="name"
additionalAction={additionalAction}
button={{ show: true, label: '+ CREATE FLOW' }}
/>
<>
<List
title="Flows"
listItem="flows"
listItemName="flow"
pageLink="flow"
listIcon={flowIcon}
dialogMessage={dialogMessage}
refetchQueries={{ query: GET_FLOWS, variables: setVariables() }}
{...queries}
{...columnAttributes}
searchParameter="name"
additionalAction={additionalAction}
button={{ show: true, label: '+ CREATE FLOW' }}
/>

<Link to="/webhook-logs" className={styles.Webhook}>
<WebhookLogsIcon />
View webhook logs
</Link>
</>
);
};
10 changes: 3 additions & 7 deletions src/containers/Form/FormLayout.test.helper.ts
Original file line number Diff line number Diff line change
Expand Up @@ -94,9 +94,7 @@ export const LIST_ITEM_MOCKS = [
request: {
query: GET_TAGS_COUNT,
variables: {
filter: {
label: '',
},
filter: {},
},
},
result: {
Expand All @@ -109,14 +107,12 @@ export const LIST_ITEM_MOCKS = [
request: {
query: FILTER_TAGS,
variables: {
filter: {
label: '',
},
filter: {},
opts: {
limit: 50,
offset: 0,
order: 'ASC',
orderWith:'label'
orderWith: 'label',
},
},
},
Expand Down
3 changes: 0 additions & 3 deletions src/containers/Group/GroupList/GroupList.module.css
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,3 @@
height: 32px;
}

.Icon{
margin-right: 12px;
}
4 changes: 2 additions & 2 deletions src/containers/Group/GroupList/GroupList.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -238,12 +238,12 @@ export const GroupList: React.SFC<GroupListProps> = () => {
<Menu
menus={[
{
icon: <ChatDarkIcon className={styles.Icon} />,
icon: <ChatDarkIcon />,
title: 'Send a message',
onClick: () => setSendMessageDialogShow(true),
},
{
icon: <FlowDarkIcon className={styles.Icon} />,
icon: <FlowDarkIcon />,
title: 'Start a flow',
onClick: setFlowDialog,
},
Expand Down
8 changes: 2 additions & 6 deletions src/containers/List/List.test.helper.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,7 @@ const count = {
request: {
query: GET_TAGS_COUNT,
variables: {
filter: {
label: '',
},
filter: {},
},
},
result: {
Expand All @@ -40,9 +38,7 @@ const filter = {
request: {
query: FILTER_TAGS,
variables: {
filter: {
label: '',
},
filter: {},
opts: {
limit: 50,
offset: 0,
Expand Down
Loading

0 comments on commit 2d6e48b

Please sign in to comment.