Skip to content

Commit

Permalink
Revert ":sparkles: New features"
Browse files Browse the repository at this point in the history
This reverts commit c8a89a0.
  • Loading branch information
naelob committed Jun 14, 2024
1 parent c8a89a0 commit 08e423e
Show file tree
Hide file tree
Showing 17 changed files with 2,399 additions and 2,490 deletions.
2 changes: 0 additions & 2 deletions .env.example
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,6 @@ POSTGRES_DB=panora_db
POSTGRES_HOST=postgres
POSTGRES_PASSWORD=my_password

# Endpoint on which realtime webhooks are sent to
WEBHOOK_INGRESS=http://localhost:3000

# Each Provider is of form PROVIDER_VERTICAL_SOFTWAREMODE_ATTRIBUTE
# ================================================
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import { Form, FormControl, FormField, FormItem, FormLabel, FormMessage } from "
import { PasswordInput } from "@/components/ui/password-input"
import { z } from "zod"
import config from "@/lib/config"
import { AuthStrategy, providerToType, Provider, extractProvider, extractVertical, needsSubdomain } from "@panora/shared"
import { AuthStrategy, providerToType, Provider, extractProvider, extractVertical } from "@panora/shared"
import { useEffect, useState } from "react"
import useProjectStore from "@/state/projectStore"
import { usePostHog } from 'posthog-js/react'
Expand All @@ -26,27 +26,24 @@ interface ItemDisplayProps {
}

const formSchema = z.object({
subdomain: z.string({
required_error: "Please Enter a Subdomain",
}).optional(),
client_id : z.string({
required_error: "Please Enter a Client ID",
}).optional(),
}),
client_secret : z.string({
required_error: "Please Enter a Client Secret",
}).optional(),
}),
scope : z.string({
required_error: "Please Enter a scope",
}).optional(),
}),
api_key: z.string({
required_error: "Please Enter a API Key",
}).optional(),
}),
username: z.string({
required_error: "Please Enter Username",
}).optional(),
}),
secret: z.string({
required_error: "Please Enter Secret",
}).optional(),
}),
})

export function ConnectorDisplay({ item }: ItemDisplayProps) {
Expand All @@ -65,7 +62,6 @@ export function ConnectorDisplay({ item }: ItemDisplayProps) {
const form = useForm<z.infer<typeof formSchema>>({
resolver: zodResolver(formSchema),
defaultValues: {
subdomain: "",
client_id: "",
client_secret: "",
scope: "",
Expand All @@ -92,11 +88,10 @@ export function ConnectorDisplay({ item }: ItemDisplayProps) {
};

function onSubmit(values: z.infer<typeof formSchema>) {
const { client_id, client_secret, scope, api_key, secret, username, subdomain } = values;
const { client_id, client_secret, scope, api_key, secret, username } = values;
const performUpdate = mappingConnectionStrategies && mappingConnectionStrategies.length > 0;
switch (item?.authStrategy) {
case AuthStrategy.oauth2:
const needs_subdomain = needsSubdomain(item.name.toLowerCase(), item.vertical!.toLowerCase());
if (client_id === "" || client_secret === "" || scope === "") {
if (client_id === "") {
form.setError("client_id", { "message": "Please Enter Client ID" });
Expand All @@ -109,27 +104,15 @@ export function ConnectorDisplay({ item }: ItemDisplayProps) {
}
break;
}
if(needs_subdomain && subdomain == ""){
form.setError("subdomain", { "message": "Please Enter Subdomain" });
}
let ATTRIBUTES = [];
let VALUES = [];
if(needs_subdomain){
ATTRIBUTES = ["subdomain", "client_id", "client_secret", "scope"],
VALUES = [subdomain!, client_id!, client_secret!, scope!]
}else{
ATTRIBUTES = ["client_id", "client_secret", "scope"],
VALUES = [client_id!, client_secret!, scope!]
}
if (performUpdate) {
const dataToUpdate = mappingConnectionStrategies[0];
toast.promise(
updateCsPromise({
id_cs: dataToUpdate.id_connection_strategy,
updateToggle: false,
status: dataToUpdate.status,
attributes: ATTRIBUTES,
values: VALUES
attributes: ["client_id", "client_secret", "scope"],
values: [client_id, client_secret, scope]
}),
{
loading: 'Loading...',
Expand Down Expand Up @@ -157,8 +140,8 @@ export function ConnectorDisplay({ item }: ItemDisplayProps) {
toast.promise(
createCsPromise({
type: providerToType(item?.name, item?.vertical!, AuthStrategy.oauth2),
attributes: ATTRIBUTES,
values: VALUES
attributes: ["client_id", "client_secret", "scope"],
values: [client_id, client_secret, scope]
}),
{
loading: 'Loading...',
Expand Down Expand Up @@ -200,7 +183,7 @@ export function ConnectorDisplay({ item }: ItemDisplayProps) {
updateToggle: false,
status: dataToUpdate.status,
attributes: ["api_key"],
values: [api_key!]
values: [api_key]
}),
{
loading: 'Loading...',
Expand Down Expand Up @@ -229,7 +212,7 @@ export function ConnectorDisplay({ item }: ItemDisplayProps) {
createCsPromise({
type: providerToType(item?.name, item?.vertical!, AuthStrategy.api_key),
attributes: ["api_key"],
values: [api_key!]
values: [api_key]
}),
{
loading: 'Loading...',
Expand Down Expand Up @@ -276,7 +259,7 @@ export function ConnectorDisplay({ item }: ItemDisplayProps) {
updateToggle: false,
status: dataToUpdate.status,
attributes: ["username", "secret"],
values: [username!, secret!]
values: [username, secret]
}),
{
loading: 'Loading...',
Expand Down Expand Up @@ -306,7 +289,7 @@ export function ConnectorDisplay({ item }: ItemDisplayProps) {
createCsPromise({
type: providerToType(item?.name, item?.vertical!, AuthStrategy.basic),
attributes: ["username", "secret"],
values: [username!, secret!]
values: [username, secret]
}),
{
loading: 'Loading...',
Expand Down Expand Up @@ -341,19 +324,14 @@ export function ConnectorDisplay({ item }: ItemDisplayProps) {
if (mappingConnectionStrategies && mappingConnectionStrategies.length > 0) {
fetchCredentials({
type: mappingConnectionStrategies[0].type,
attributes: item?.authStrategy === AuthStrategy.oauth2 ? needsSubdomain(item.name.toLowerCase(), item.vertical!.toLowerCase()) ? ["subdomain", "client_id", "client_secret", "scope"] : ["client_id", "client_secret", "scope"]
attributes: item?.authStrategy === AuthStrategy.oauth2 ? ["client_id", "client_secret", "scope"]
: item?.authStrategy === AuthStrategy.api_key ? ["api_key"] : ["username", "secret"]
}, {
onSuccess(data) {
if (item?.authStrategy === AuthStrategy.oauth2) {
let i = 0;
if(needsSubdomain(item.name.toLowerCase(), item.vertical!.toLowerCase())){
form.setValue("subdomain", data[i]);
i = 1;
}
form.setValue("client_id", data[i]);
form.setValue("client_secret", data[i + 1]);
form.setValue("scope", data[i + 2]);
form.setValue("client_id", data[0]);
form.setValue("client_secret", data[1]);
form.setValue("scope", data[2]);
}
if (item?.authStrategy === AuthStrategy.api_key) {
form.setValue("api_key", data[0]);
Expand Down Expand Up @@ -437,25 +415,6 @@ export function ConnectorDisplay({ item }: ItemDisplayProps) {
<form onSubmit={form.handleSubmit(onSubmit)}>
{ item.authStrategy == AuthStrategy.oauth2 &&
<>

{ needsSubdomain(item.name.toLowerCase(), item.vertical!.toLowerCase()) &&
<div className="flex flex-col">
<FormField
name="subdomain"
control={form.control}
render={({field}) => (
<FormItem>
<FormLabel className="flex flex-col">Subdomain</FormLabel>
<FormControl>
<PasswordInput {...field} placeholder="Enter Subdomain (such as https://my-zendesk.com)" />
</FormControl>
<FormMessage/>
</FormItem>
)}
/>
</div>
}

<div className="flex flex-col">
<FormField
name="client_id"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ export default function ConnectionTable() {
date: connection.created_at,
connectionToken: connection.connection_token!
}))
console.log("connections are" + JSON.stringify(ts))


return (
<>
Expand Down
1 change: 0 additions & 1 deletion apps/client-ts/src/hooks/get/useConnections.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ import Cookies from 'js-cookie';


const useConnections = () => {
console.log(Cookies.get('access_token'))
return useQuery({
queryKey: ['connections'],
queryFn: async (): Promise<Connection[]> => {
Expand Down
34 changes: 16 additions & 18 deletions docker-compose.dev.yml
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,6 @@ services:
REDIS_PORT: ${REDIS_PORT}
#REDIS_TLS: 1 # set this variable to 1 when Redis is AWS hosted
REDIS_DB: ${REDIS_DB}
WEBHOOK_INGRESS: ${WEBHOOK_INGRESS}
ENCRYPT_CRYPTO_SECRET_KEY: ${ENCRYPT_CRYPTO_SECRET_KEY}
HUBSPOT_CRM_CLOUD_CLIENT_ID: ${HUBSPOT_CRM_CLOUD_CLIENT_ID}
HUBSPOT_CRM_CLOUD_CLIENT_SECRET: ${HUBSPOT_CRM_CLOUD_CLIENT_SECRET}
Expand Down Expand Up @@ -189,23 +188,22 @@ services:
volumes:
- .:/app

ngrok:
image: ngrok/ngrok:latest
restart: always
command:
- "start"
- "--all"
- "--config"
- "/etc/ngrok.yml"
volumes:
- ./ngrok.yml:/etc/ngrok.yml
ports:
- 4040:4040
depends_on:
api:
condition: service_healthy
network_mode: "host"

#ngrok:
#image: ngrok/ngrok:latest
#restart: always
#command:
# - "start"
# - "--all"
# - "--config"
# - "/etc/ngrok.yml"
# volumes:
# - ./ngrok.yml:/etc/ngrok.yml
# ports:
# - 4040:4040
#depends_on:
# api:
# condition: service_healthy
# network_mode: "host"

docs:
build:
Expand Down
1 change: 0 additions & 1 deletion docker-compose.source.yml
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,6 @@ services:
REDIS_PASS: ${REDIS_PASS}
BACKEND_PORT: ${BACKEND_PORT}
REDIS_DB: ${REDIS_DB}
WEBHOOK_INGRESS: ${WEBHOOK_INGRESS}
ENCRYPT_CRYPTO_SECRET_KEY: ${ENCRYPT_CRYPTO_SECRET_KEY}
HUBSPOT_CRM_CLOUD_CLIENT_ID: ${HUBSPOT_CRM_CLOUD_CLIENT_ID}
HUBSPOT_CRM_CLOUD_CLIENT_SECRET: ${HUBSPOT_CRM_CLOUD_CLIENT_SECRET}
Expand Down
1 change: 0 additions & 1 deletion docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,6 @@ services:
REDIS_PASS: ${REDIS_PASS}
REDIS_PORT: ${REDIS_PORT}
REDIS_DB: ${REDIS_DB}
WEBHOOK_INGRESS: ${WEBHOOK_INGRESS}
ENCRYPT_CRYPTO_SECRET_KEY: ${ENCRYPT_CRYPTO_SECRET_KEY}
HUBSPOT_CRM_CLOUD_CLIENT_ID: ${HUBSPOT_CRM_CLOUD_CLIENT_ID}
HUBSPOT_CRM_CLOUD_CLIENT_SECRET: ${HUBSPOT_CRM_CLOUD_CLIENT_SECRET}
Expand Down
4 changes: 2 additions & 2 deletions ngrok.yml
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
version: 2
authtoken: 2hkEp1JOOyYzutRyUa5f74UWll5_7oDCZH2Rd5bryqKj9geTV
authtoken: YOUR_NGROK_KEY_HERE
log_level: debug
log: stdout

tunnels:
api-tunnel:
proto: http
addr: 3000
domain: prepared-wildcat-infinitely.ngrok-free.app
domain: your_ngrok_domain_here
Loading

0 comments on commit 08e423e

Please sign in to comment.