feat: show related flows for connections

This commit is contained in:
Ali BARIN
2022-08-11 18:44:44 +02:00
parent a5b6e66e22
commit ad97fae883
4 changed files with 10 additions and 4 deletions

View File

@@ -40,7 +40,7 @@ export default function ContextMenu(props: ContextMenuProps): React.ReactElement
>
<MenuItem
component={Link}
to={URLS.APP_FLOWS(appKey)}
to={URLS.APP_FLOWS_FOR_CONNECTION(appKey, connectionId)}
onClick={createActionHandler({ type: 'viewFlows' })}
>
{formatMessage('connection.viewFlows')}

View File

@@ -21,8 +21,13 @@ const getLimitAndOffset = (page: number) => ({
export default function AppFlows(props: AppFlowsProps): React.ReactElement {
const { appKey } = props;
const [searchParams, setSearchParams] = useSearchParams();
const connectionId = searchParams.get('connectionId') || null;
const page = parseInt(searchParams.get('page') || '', 10) || 1;
const { data } = useQuery(GET_FLOWS, { variables: { appKey, ...getLimitAndOffset(page) }});
const { data } = useQuery(GET_FLOWS, { variables: {
appKey,
connectionId,
...getLimitAndOffset(page)
}});
const getFlows = data?.getFlows || {};
const { pageInfo, edges } = getFlows;

View File

@@ -16,6 +16,7 @@ export const APP_ADD_CONNECTION_PATTERN = '/app/:appKey/connections/add';
export const APP_RECONNECT_CONNECTION = (appKey: string, connectionId: string): string => `/app/${appKey}/connections/${connectionId}/reconnect`;
export const APP_RECONNECT_CONNECTION_PATTERN = '/app/:appKey/connections/:connectionId/reconnect';
export const APP_FLOWS = (appKey: string): string => `/app/${appKey}/flows`;
export const APP_FLOWS_FOR_CONNECTION = (appKey: string, connectionId: string): string => `/app/${appKey}/flows?connectionId=${connectionId}`;
export const APP_FLOWS_PATTERN = '/app/:appKey/flows';
export const EDITOR = '/editor';

View File

@@ -1,8 +1,8 @@
import { gql } from '@apollo/client';
export const GET_FLOWS = gql`
query GetFlows($limit: Int!, $offset: Int!, $appKey: String, $name: String) {
getFlows(limit: $limit, offset: $offset, appKey: $appKey, name: $name) {
query GetFlows($limit: Int!, $offset: Int!, $appKey: String, $connectionId: String, $name: String) {
getFlows(limit: $limit, offset: $offset, appKey: $appKey, connectionId: $connectionId, name: $name) {
pageInfo {
currentPage
totalPages