Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature/update queries for automations #230

Merged
merged 3 commits into from
Jul 28, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions src/containers/Automation/AutomationList/AutomationList.tsx
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
import React from 'react';
import { GET_TAGS_COUNT } from '../../../graphql/queries/Tag';
import styles from './AutomationList.module.css';
import { ReactComponent as AutomationIcon } from '../../../assets/images/icons/Automations/Selected.svg';
import { List } from '../../List/List';
import { GET_AUTOMATIONS } from '../../../graphql/queries/Automation';
import { FILTER_AUTOMATION, GET_AUTOMATION_COUNT } from '../../../graphql/queries/Automation';
import { DELETE_AUTOMATION } from '../../../graphql/mutations/Automation';

export interface AutomationListProps {}
Expand All @@ -22,8 +21,8 @@ const columnStyles = [styles.Shortcode, styles.Name, styles.Actions];
const automationIcon = <AutomationIcon className={styles.AutomationIcon} />;

const queries = {
countQuery: GET_TAGS_COUNT,
filterItemsQuery: GET_AUTOMATIONS,
countQuery: GET_AUTOMATION_COUNT,
filterItemsQuery: FILTER_AUTOMATION,
deleteItemQuery: DELETE_AUTOMATION,
};

Expand All @@ -45,6 +44,7 @@ export const AutomationList: React.SFC<AutomationListProps> = (props) => (
dialogMessage={dialogMessage}
{...queries}
{...columnAttributes}
searchParameter="name"
additionalAction={additionalAction}
/>
);
16 changes: 7 additions & 9 deletions src/containers/List/List.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ export interface ListProps {
listIcon: any;
columnStyles: any;
title: string;
searchParameter?: string;
filters?: any;
additionalAction?: {
parameter: string;
Expand Down Expand Up @@ -55,6 +56,7 @@ export const List: React.SFC<ListProps> = ({
columns,
columnStyles,
title,
searchParameter = 'label',
filters = null,
additionalAction = null,
}: ListProps) => {
Expand Down Expand Up @@ -87,13 +89,12 @@ export const List: React.SFC<ListProps> = ({
[attribute]: newVal,
});
};

let filter: any = {};
filter[searchParameter] = searchVal;
filter = { ...filter, ...filters };
const filterPayload = useCallback(() => {
return {
filter: {
label: searchVal,
...filters,
},
filter,
opts: {
limit: tableVals.pageRows,
offset: tableVals.pageNum * tableVals.pageRows,
Expand All @@ -105,10 +106,7 @@ export const List: React.SFC<ListProps> = ({
// Get the total number of items here
const { loading: l, error: e, data: countData, refetch: refetchCount } = useQuery(countQuery, {
variables: {
filter: {
label: searchVal,
...filters,
},
filter,
},
});

Expand Down
14 changes: 7 additions & 7 deletions src/graphql/queries/Automation.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,18 +25,18 @@ export const GET_AUTOMATION = gql`
`;

export const GET_AUTOMATION_COUNT = gql`
query countTags($filter: TagFilter!) {
countTags(filter: $filter)
query countFlows($filter: FlowFilter!) {
countFlows(filter: $filter)
}
`;

export const FILTER_AUTOMATION = gql`
query tags($filter: TagFilter!, $opts: Opts!) {
tags(filter: $filter, opts: $opts) {
query tags($filter: FlowFilter!, $opts: Opts!) {
flows(filter: $filter, opts: $opts) {
id
label
description
keywords
name
shortcode
uuid
}
}
`;