forked from twentyhq/twenty
-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added Trigger Campaign UI and functionality
- Loading branch information
1 parent
99b2359
commit ecc8b92
Showing
27 changed files
with
2,055 additions
and
616 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
93 changes: 82 additions & 11 deletions
93
packages/twenty-front/src/modules/ui/layout/page/PageAddButton.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,18 +1,89 @@ | ||
import { useColumnDefinitionsFromFieldMetadata } from '@/object-metadata/hooks/useColumnDefinitionsFromFieldMetadata'; | ||
import { useObjectMetadataItem } from '@/object-metadata/hooks/useObjectMetadataItem'; | ||
import { useObjectNameSingularFromPlural } from '@/object-metadata/hooks/useObjectNameSingularFromPlural'; | ||
import { useCreateOneRecord } from '@/object-record/hooks/useCreateOneRecord'; | ||
import { useRecordTable } from '@/object-record/record-table/hooks/useRecordTable'; | ||
import { IconPlus } from '@/ui/display/icon'; | ||
import { Button } from '@/ui/input/button/components/Button'; | ||
import { IconButton } from '@/ui/input/button/components/IconButton'; | ||
import { useViewBar } from '@/views/hooks/useViewBar'; | ||
import { | ||
IconPlayCard, | ||
IconPlayerPlay, | ||
IconPlayerPlayFilled, | ||
} from '@tabler/icons-react'; | ||
import React from 'react'; | ||
import { useEffect } from 'react'; | ||
import { useParams } from 'react-router-dom'; | ||
import { useRecoilValue } from 'recoil'; | ||
|
||
type PageAddButtonProps = { | ||
onClick: () => void; | ||
}; | ||
|
||
export const PageAddButton = ({ onClick }: PageAddButtonProps) => ( | ||
<IconButton | ||
Icon={IconPlus} | ||
dataTestId="add-button" | ||
size="medium" | ||
variant="secondary" | ||
accent="default" | ||
onClick={onClick} | ||
ariaLabel="Add" | ||
/> | ||
); | ||
export const PageAddButton = ({ onClick }: PageAddButtonProps) => { | ||
const [enableTrigger, setEnableTrigger] = React.useState(false); | ||
|
||
const objectNamePlural = useParams().objectNamePlural ?? ''; | ||
|
||
const { objectNameSingular } = useObjectNameSingularFromPlural({ | ||
objectNamePlural, | ||
}); | ||
|
||
const { createOneRecord: createOneObject } = useCreateOneRecord({ | ||
objectNameSingular, | ||
}); | ||
|
||
const recordIndexId = objectNamePlural ?? ''; | ||
const { | ||
setTableFilters, | ||
setTableSorts, | ||
setTableColumns, | ||
getSelectedRowIdsSelector, | ||
} = useRecordTable({ | ||
recordTableId: recordIndexId, | ||
}); | ||
|
||
const { objectMetadataItem } = useObjectMetadataItem({ | ||
objectNameSingular, | ||
}); | ||
|
||
const { columnDefinitions } = | ||
useColumnDefinitionsFromFieldMetadata(objectMetadataItem); | ||
|
||
const selectedRowIds = useRecoilValue(getSelectedRowIdsSelector()); | ||
console.log('=========', selectedRowIds); | ||
|
||
useEffect(() => { | ||
if (objectNamePlural === 'campaignLists') { | ||
if (selectedRowIds.length == 1) { | ||
setEnableTrigger(true); | ||
} else { | ||
setEnableTrigger(false); | ||
} | ||
} | ||
}, [selectedRowIds]); | ||
|
||
return ( | ||
<> | ||
<IconButton | ||
Icon={IconPlus} | ||
dataTestId="add-button" | ||
size="medium" | ||
variant="secondary" | ||
accent="default" | ||
onClick={onClick} | ||
ariaLabel="Add" | ||
/> | ||
|
||
{enableTrigger && ( | ||
<Button | ||
title="Run Campaign" | ||
variant="primary" | ||
accent="dark" | ||
Icon={IconPlayerPlay} | ||
/> | ||
)} | ||
</> | ||
); | ||
}; |
104 changes: 7 additions & 97 deletions
104
packages/twenty-front/src/modules/users/graphql/queries/addCampaign.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,99 +1,9 @@ | ||
import { gql } from '@apollo/client'; | ||
export const ADD_CAMPAIGN = gql` | ||
mutation CreateOneCampaignList($input: CampaignListCreateInput!) { | ||
createCampaignList(data: $input) { | ||
id | ||
name | ||
updatedAt | ||
subSpecialtyType | ||
position | ||
endDate | ||
campaignName | ||
specialtyType | ||
leads | ||
activityTargets { | ||
edges { | ||
node { | ||
__typename | ||
id | ||
person { | ||
__typename | ||
id | ||
} | ||
id | ||
createdAt | ||
personId | ||
campaignList { | ||
__typename | ||
id | ||
} | ||
activity { | ||
__typename | ||
id | ||
} | ||
company { | ||
__typename | ||
id | ||
} | ||
opportunityId | ||
updatedAt | ||
activityId | ||
opportunity { | ||
__typename | ||
id | ||
} | ||
companyId | ||
campaignListId | ||
} | ||
__typename | ||
} | ||
__typename | ||
} | ||
startDate | ||
messagingMedia | ||
id | ||
createdAt | ||
description | ||
favorites { | ||
edges { | ||
node { | ||
__typename | ||
id | ||
campaignList { | ||
__typename | ||
id | ||
} | ||
opportunityId | ||
company { | ||
__typename | ||
id | ||
} | ||
updatedAt | ||
createdAt | ||
workspaceMember { | ||
__typename | ||
id | ||
} | ||
person { | ||
__typename | ||
id | ||
} | ||
workspaceMemberId | ||
personId | ||
id | ||
position | ||
opportunity { | ||
__typename | ||
id | ||
} | ||
companyId | ||
campaignListId | ||
} | ||
__typename | ||
} | ||
__typename | ||
} | ||
__typename | ||
} | ||
} | ||
`; | ||
mutation CreateOneCampaignList($input: CampaignListCreateInput!) { | ||
createCampaignList(data: $input) { | ||
id | ||
}}`; | ||
|
||
|
||
|
7 changes: 7 additions & 0 deletions
7
packages/twenty-front/src/modules/users/graphql/queries/addSegment.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
import { gql } from '@apollo/client'; | ||
export const ADD_SEGMENT = gql` | ||
mutation CreateOneSegmentList($input: SegmentListCreateInput!) { | ||
createSegmentList(data: $input) { | ||
id | ||
} | ||
}`; |
44 changes: 44 additions & 0 deletions
44
packages/twenty-front/src/modules/users/graphql/queries/getCampaignList.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
import { gql } from '@apollo/client'; | ||
|
||
export const GET_CAMPAIGN_LISTS = gql` | ||
query FindManyCampaignLists($filter: CampaignListFilterInput, $orderBy: CampaignListOrderByInput, $lastCursor: String, $limit: Float) { | ||
campaignLists( | ||
filter: $filter | ||
orderBy: $orderBy | ||
first: $limit | ||
after: $lastCursor | ||
) { | ||
edges { | ||
node { | ||
id | ||
name | ||
subSpecialtyType | ||
formUrl | ||
description | ||
formNameId | ||
createdAt | ||
updatedAt | ||
campaignName | ||
messagingMedia | ||
specialtyType | ||
startDate | ||
endDate | ||
leads | ||
segment { | ||
id | ||
segmentName | ||
segmentDescription | ||
filters | ||
} | ||
} | ||
} | ||
pageInfo { | ||
hasNextPage | ||
startCursor | ||
endCursor | ||
__typename | ||
} | ||
totalCount | ||
__typename | ||
} | ||
}` |
Oops, something went wrong.