Skip to content

Commit 274f658

Browse files
committed
feat: add telegram account selector
1 parent df5eed3 commit 274f658

File tree

4 files changed

+80
-1
lines changed

4 files changed

+80
-1
lines changed

components/workflow-nodes/drawer/steps/credentials/SelectCustomCredentials.tsx

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import { Alert } from 'antd'
22
import { AccountCredential, IntegrationAccount } from '../../../../../graphql'
33
import { SelectLensCredentials } from './SelectLensCredentials'
4+
import { SelectTelegramCredentials } from './SelectTelegramCredentials'
45
import { SelectXmtpCredentials } from './SelectXmtpCredentials'
56

67
interface Props {
@@ -27,6 +28,14 @@ export function SelectCustomCredentials({ integrationAccount, reconnectAccount,
2728
reconnectAccount={reconnectAccount}
2829
/>
2930
)
31+
case 'telegram':
32+
return (
33+
<SelectTelegramCredentials
34+
integrationAccount={integrationAccount}
35+
onCredentialsSelected={onCredentialsSelected}
36+
reconnectAccount={reconnectAccount}
37+
/>
38+
)
3039
}
3140

3241
return <Alert type="error" message={`Authentication ${integrationAccount.key} not implemented yet.`} />
Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
import { Alert, Button } from 'antd'
2+
import { AccountCredential, IntegrationAccount } from '../../../../../graphql'
3+
import { useAccountCreationData } from '../../../../../src/services/AccountCredentialHooks'
4+
5+
interface Props {
6+
integrationAccount: IntegrationAccount
7+
reconnectAccount?: AccountCredential
8+
onCredentialsSelected: (id: string) => any
9+
}
10+
11+
export function SelectTelegramCredentials({}: Props) {
12+
const { data, loading, error } = useAccountCreationData('telegram')
13+
14+
const connectTelegramData = data?.accountCreationData?.data?.key
15+
16+
return (
17+
<div>
18+
<div className="mb-4">
19+
<a href={`https://t.me/ChainJetBot?startgroup=${connectTelegramData}`} target="_blank" rel="noreferrer">
20+
<Button type="primary" loading={loading}>
21+
Connect to group or channel
22+
</Button>
23+
</a>
24+
</div>
25+
<div>
26+
<a href={`https://t.me/ChainJetBot?start=${connectTelegramData}`} target="_blank" rel="noreferrer">
27+
<Button type="primary" loading={loading}>
28+
Connect to private chat
29+
</Button>
30+
</a>
31+
</div>
32+
{error && (
33+
<div className="mb-8">
34+
<Alert message={error} type="error" showIcon />
35+
</div>
36+
)}
37+
</div>
38+
)
39+
}

graphql.ts

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ export enum IntegrationTriggerSortFields {
2323
integration = "integration",
2424
key = "key",
2525
name = "name",
26+
unlisted = "unlisted",
2627
deprecated = "deprecated",
2728
category = "category",
2829
skipAuth = "skipAuth"
@@ -49,6 +50,7 @@ export enum IntegrationActionSortFields {
4950
integration = "integration",
5051
key = "key",
5152
name = "name",
53+
unlisted = "unlisted",
5254
deprecated = "deprecated",
5355
category = "category",
5456
type = "type",
@@ -157,6 +159,7 @@ export interface IntegrationTriggerFilter {
157159
integration?: Nullable<IDFilterComparison>;
158160
key?: Nullable<StringFieldComparison>;
159161
name?: Nullable<StringFieldComparison>;
162+
unlisted?: Nullable<BooleanFieldComparison>;
160163
deprecated?: Nullable<BooleanFieldComparison>;
161164
category?: Nullable<StringFieldComparison>;
162165
skipAuth?: Nullable<BooleanFieldComparison>;
@@ -235,6 +238,7 @@ export interface IntegrationActionFilter {
235238
integration?: Nullable<IDFilterComparison>;
236239
key?: Nullable<StringFieldComparison>;
237240
name?: Nullable<StringFieldComparison>;
241+
unlisted?: Nullable<BooleanFieldComparison>;
238242
deprecated?: Nullable<BooleanFieldComparison>;
239243
category?: Nullable<StringFieldComparison>;
240244
type?: Nullable<OperationTypeFilterComparison>;
@@ -555,6 +559,7 @@ export interface CreateWorkflowInput {
555559
name: string;
556560
runOnFailure?: Nullable<string>;
557561
isPublic?: Nullable<boolean>;
562+
templateSchema?: Nullable<JSONObject>;
558563
}
559564

560565
export interface CreateManyWorkflowsInput {
@@ -570,6 +575,7 @@ export interface UpdateWorkflowInput {
570575
name?: Nullable<string>;
571576
runOnFailure?: Nullable<string>;
572577
isPublic?: Nullable<boolean>;
578+
templateSchema?: Nullable<JSONObject>;
573579
}
574580

575581
export interface UpdateManyWorkflowsInput {
@@ -729,8 +735,9 @@ export interface User {
729735
id: string;
730736
createdAt: DateTime;
731737
email?: Nullable<string>;
738+
externalApps?: Nullable<JSONObject>;
732739
operationsUsedMonth: number;
733-
plan?: Nullable<string>;
740+
plan: string;
734741
nextPlan?: Nullable<string>;
735742
planPeriodEnd?: Nullable<DateTime>;
736743
name?: Nullable<string>;
@@ -780,6 +787,7 @@ export interface IntegrationTrigger {
780787
key: string;
781788
name: string;
782789
description?: Nullable<string>;
790+
unlisted: boolean;
783791
deprecated: boolean;
784792
category?: Nullable<string>;
785793
skipAuth: boolean;
@@ -825,6 +833,7 @@ export interface IntegrationAction {
825833
key: string;
826834
name: string;
827835
description?: Nullable<string>;
836+
unlisted: boolean;
828837
deprecated: boolean;
829838
category?: Nullable<string>;
830839
type: OperationType;
@@ -1161,6 +1170,10 @@ export interface WorkflowNextActionConnection {
11611170
edges: WorkflowNextActionEdge[];
11621171
}
11631172

1173+
export interface ConnectAccountDataPayload {
1174+
data: JSONObject;
1175+
}
1176+
11641177
export interface AccountCredentialDeleteResponse {
11651178
id?: Nullable<string>;
11661179
createdAt?: Nullable<DateTime>;
@@ -1198,6 +1211,7 @@ export interface IQuery {
11981211
viewer(): User | Promise<User>;
11991212
accountCredential(id: string): AccountCredential | Promise<AccountCredential>;
12001213
accountCredentials(paging?: Nullable<CursorPaging>, filter?: Nullable<AccountCredentialFilter>, sorting?: Nullable<AccountCredentialSort[]>): AccountCredentialConnection | Promise<AccountCredentialConnection>;
1214+
accountCreationData(key: string): ConnectAccountDataPayload | Promise<ConnectAccountDataPayload>;
12011215
integration(id: string): Integration | Promise<Integration>;
12021216
integrations(search?: Nullable<string>, paging?: Nullable<CursorPaging>, filter?: Nullable<IntegrationFilter>, sorting?: Nullable<IntegrationSort[]>): IntegrationConnection | Promise<IntegrationConnection>;
12031217
integrationCategories(): IntegrationCategory[] | Promise<IntegrationCategory[]>;

src/services/AccountCredentialHooks.ts

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -90,3 +90,20 @@ export function useDeleteOneAccountCredential() {
9090
},
9191
)
9292
}
93+
94+
const accountCreationDataQuery = gql`
95+
query accountCreationData($key: String!) {
96+
accountCreationData(key: $key) {
97+
data
98+
}
99+
}
100+
`
101+
102+
export const useAccountCreationData = (key: string, skip: boolean = false) => {
103+
return useQuery(accountCreationDataQuery, {
104+
variables: {
105+
key,
106+
},
107+
skip,
108+
})
109+
}

0 commit comments

Comments
 (0)