Skip to content
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
68 changes: 59 additions & 9 deletions components/layout/connection/ConnectionMain.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@ export default function ConnectionMain() {
handleSlack,
handleGoogleSheets,
handleHubSpot,
handleNotion,
handleAirtable,
} = useSocial();

const connectionTypes = [
Expand Down Expand Up @@ -62,6 +64,16 @@ export default function ConnectionMain() {
key: "hubspot",
type: "redirect",
},
{
name: "Notion",
key: "notion",
type: "redirect",
},
{
name: "Airtable",
key: "airtable",
type: "redirect",
},
];

const connectionType = key
Expand All @@ -76,7 +88,7 @@ export default function ConnectionMain() {
type: "SOCIAL_AUTH_ERROR",
message: "Connection not found",
},
window.location.origin
window.location.origin,
);
}, 3000);
}
Expand Down Expand Up @@ -105,7 +117,7 @@ export default function ConnectionMain() {
type: "SOCIAL_AUTH_ERROR",
message: error.message,
},
window.location.origin
window.location.origin,
);
}
} else if (connectionType.key === "twitter") {
Expand All @@ -124,7 +136,7 @@ export default function ConnectionMain() {
type: "SOCIAL_AUTH_ERROR",
message: error.message,
},
window.location.origin
window.location.origin,
);
}
} else if (connectionType.key === "linkedin") {
Expand All @@ -143,7 +155,7 @@ export default function ConnectionMain() {
type: "SOCIAL_AUTH_ERROR",
message: error.message,
},
window.location.origin
window.location.origin,
);
}
} else if (connectionType.key === "gmail_trigger") {
Expand All @@ -162,7 +174,7 @@ export default function ConnectionMain() {
type: "SOCIAL_AUTH_ERROR",
message: error.message,
},
window.location.origin
window.location.origin,
);
}
} else if (connectionType.key === "gmail_read") {
Expand All @@ -181,7 +193,7 @@ export default function ConnectionMain() {
type: "SOCIAL_AUTH_ERROR",
message: error.message,
},
window.location.origin
window.location.origin,
);
}
} else if (connectionType.key === "slack") {
Expand All @@ -200,7 +212,7 @@ export default function ConnectionMain() {
type: "SOCIAL_AUTH_ERROR",
message: error.message,
},
window.location.origin
window.location.origin,
);
}
} else if (connectionType.key === "google_sheets") {
Expand All @@ -219,7 +231,7 @@ export default function ConnectionMain() {
type: "SOCIAL_AUTH_ERROR",
message: error.message,
},
window.location.origin
window.location.origin,
);
}
} else if (connectionType.key === "hubspot") {
Expand All @@ -238,7 +250,45 @@ export default function ConnectionMain() {
type: "SOCIAL_AUTH_ERROR",
message: error.message,
},
window.location.origin
window.location.origin,
);
}
} else if (connectionType.key === "notion") {
try {
const response = await handleNotion(workflowId);

if (!response.data.success) {
throw new Error(response.data.message);
}

window.location.href = response.data.authURL;
} catch (error) {
console.log(error);
window.opener.postMessage(
{
type: "SOCIAL_AUTH_ERROR",
message: error.message,
},
window.location.origin,
);
}
} else if (connectionType.key === "airtable") {
try {
const response = await handleAirtable(workflowId);

if (!response.data.success) {
throw new Error(response.data.message);
}

window.location.href = response.data.authURL;
} catch (error) {
console.log(error);
window.opener.postMessage(
{
type: "SOCIAL_AUTH_ERROR",
message: error.message,
},
window.location.origin,
);
}
}
Expand Down
23 changes: 13 additions & 10 deletions components/layout/dashboard/files/FileList.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,16 +29,18 @@ const getFilesData = async (page) => {
const limit = 10;

const response = await fetch(
`${process.env.API_URL}/storage/list?page=${currentPage}&limit=${limit}`,
`${process.env.API_URL}/storage/list?page=${currentPage}&limit=${limit}&t=${Date.now()}`,
{
method: "GET",
headers: {
"Content-Type": "application/json",
cookie: cookieHeader,
Pragma: "no-cache",
"Cache-Control": "no-cache, no-store, must-revalidate",
},
credentials: "include",
cache: "no-store",
}
},
);

if (!response.ok) {
Expand Down Expand Up @@ -76,7 +78,7 @@ const FileList = async ({ page, query }) => {

if (query) {
files = files.filter((file) =>
file.fileName.toLowerCase().includes(query.toLowerCase())
file.fileName.toLowerCase().includes(query.toLowerCase()),
);
}

Expand Down Expand Up @@ -203,19 +205,20 @@ const FileList = async ({ page, query }) => {
</div>

<div className="flex items-center gap-3">
{file.scrapeStatus && (
{file.sourceUrl && (
<ScrapeStatusDisplay
fileKey={file.fileKey}
scrapeStatus={file.scrapeStatus}
/>
)}

{file.ragStatus && (
<RagStatusDisplay
fileKey={file.fileKey}
ragStatus={file.ragStatus}
/>
)}
{(file.sourceUrl ? file.scrapeStatus === "done" : true) &&
file.ragStatus && (
<RagStatusDisplay
fileKey={file.fileKey}
initialRagStatus={file.ragStatus}
/>
)}
</div>
</div>
</div>
Expand Down
34 changes: 27 additions & 7 deletions components/layout/dashboard/files/FileMenuBox.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,14 @@ import RagConversionDialog from "./RagConversionDialog";
const baseMenuBtn =
"data-highlighted:bg-foreground/5 not-disabled:not-active:not-data-pressed:before:shadow-none px-2 min-h-5 font-normal rounded-sm text-xs [&_svg:not([class*='size-'])]:size-3 dark:not-disabled:not-active:not-data-pressed:before:shadow-none data-highlighted:text-destructive cursor-pointer dark:bg-transparent shadow-none! bg-transparent hover:bg-transparent w-full justify-start border-none";

const FileMenuBox = ({ fileKey, fileName, ragStatus, ragTableName }) => {
const FileMenuBox = ({
fileKey,
fileName,
ragStatus,
ragTableName,
sourceUrl,
scrapeStatus,
}) => {
const [showRagDialog, setShowRagDialog] = useState(false);
const [showEditDialog, setShowEditDialog] = useState(false);
const [showDeleteDialog, setShowDeleteDialog] = useState(false);
Expand All @@ -29,6 +36,15 @@ const FileMenuBox = ({ fileKey, fileName, ragStatus, ragTableName }) => {
e.stopPropagation();
};

const handleRagDialogOpen = () => {
if (sourceUrl && scrapeStatus !== "done") {
toast.error("Scrape not completed");
return;
}

setShowRagDialog(!showRagDialog);
};

const handleDownload = useCallback(
async (e) => {
stop(e);
Expand All @@ -41,7 +57,7 @@ const FileMenuBox = ({ fileKey, fileName, ragStatus, ragTableName }) => {
credentials: "include",
headers: { "Content-Type": "application/json" },
body: JSON.stringify({ fileKey }),
}
},
);

const data = await res.json();
Expand Down Expand Up @@ -74,7 +90,7 @@ const FileMenuBox = ({ fileKey, fileName, ragStatus, ragTableName }) => {
toast.error("Failed to download file");
}
},
[fileKey, fileName]
[fileKey, fileName],
);

const handleEdit = useCallback((e) => {
Expand All @@ -87,10 +103,14 @@ const FileMenuBox = ({ fileKey, fileName, ragStatus, ragTableName }) => {
setShowDeleteDialog(true);
}, []);

const handleRagConversion = useCallback((e) => {
stop(e);
const handleRagConversion = () => {
if (sourceUrl && scrapeStatus !== "done") {
toast.error("Scrape not completed");
return;
}

setShowRagDialog(true);
}, []);
};

return (
<>
Expand Down Expand Up @@ -182,7 +202,7 @@ const FileMenuBox = ({ fileKey, fileName, ragStatus, ragTableName }) => {
ragStatus={ragStatus}
ragTableName={ragTableName}
open={showRagDialog}
onOpenChange={setShowRagDialog}
onOpenChange={handleRagDialogOpen}
/>
</>
);
Expand Down
Loading
Loading