Skip to content

Commit

Permalink
Merge branch 'main' into feature/gunicorn-tests
Browse files Browse the repository at this point in the history
  • Loading branch information
shahargl authored Nov 30, 2023
2 parents a490de1 + 61e8640 commit 3bbf067
Show file tree
Hide file tree
Showing 14 changed files with 285 additions and 480 deletions.
4 changes: 2 additions & 2 deletions examples/workflows/new_github_stars.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# Alert when there are new GitHub Stars utilizing keepstate
workflow:
id: new-github-stars
description: Get new GitHub Stars
description: Notify Slack about new GitHub star for keephq/keep
triggers:
- type: interval
value: 300
Expand All @@ -20,7 +20,7 @@ workflow:
condition:
- name: assert-condition
type: assert
assert: "{{ steps.get-github-stars.results.new_stargazers_count }} == 0" # if there are more than 0 new stargazers, trigger the action
assert: "{{ steps.get-github-stars.results.new_stargazers_count }} > 0" # if there are more than 0 new stargazers, trigger the action
provider:
type: slack
config: " {{ providers.slack-demo }} "
Expand Down
14 changes: 0 additions & 14 deletions keep-ui/app/providers/page.client.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
"use client";
import { FrigadeAnnouncement } from "@frigade/react";
import {
Providers,
defaultProvider,
Expand Down Expand Up @@ -200,19 +199,6 @@ export default function ProvidersPage({

return (
<>
<FrigadeAnnouncement
flowId="flow_VpefBUPWpliWceBm"
modalPosition="center"
onButtonClick={(stepData, index, cta) => {
if (cta === "primary") {
window.open(
"https://calendly.com/d/4p7-8dg-399/keep-onboarding",
"_blank"
);
}
return true;
}}
/>
{installedProviders.length > 0 && (
<ProvidersTiles
providers={installedProviders}
Expand Down
15 changes: 1 addition & 14 deletions keep-ui/app/providers/page.tsx
Original file line number Diff line number Diff line change
@@ -1,27 +1,14 @@
import { FrigadeProvider } from "@frigade/react";
import { getServerSession } from "next-auth/next";
import { authOptions } from "pages/api/auth/[...nextauth]";
import ProvidersPage from "./page.client";
import Cookies from "js-cookie";

export default async function Page({
searchParams,
}: {
searchParams?: { [key: string]: string };
}) {
const session = await getServerSession(authOptions);
return (
<FrigadeProvider
publicApiKey="api_public_6BKR7bUv0YZ5dqnjLGeHpRWCHaDWeb5cVobG3A9YkW0gOgafOEBvtJGZgvhp8PGb"
userId={session?.user?.email || Cookies.get("anonymousId")}
config={{
debug: true,
defaultAppearance: { theme: { colorPrimary: "#F97316" } },
}}
>
<ProvidersPage searchParams={searchParams} />
</FrigadeProvider>
);
return <ProvidersPage searchParams={searchParams} />;
}

export const metadata = {
Expand Down
10 changes: 6 additions & 4 deletions keep-ui/app/settings/api-key-settings.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,13 +13,15 @@ interface ApiKeyResponse {

interface Props {
accessToken: string;
selectedTab: string;
}

export default function ApiKeySettings({ accessToken }: Props) {
export default function ApiKeySettings({ accessToken, selectedTab }: Props) {
const apiUrl = getApiURL();
const { data, error, isLoading } = useSWR<ApiKeyResponse>(
`${apiUrl}/settings/apikey`,
(url) => fetcher(url, accessToken)
selectedTab === "api-key" ? `${apiUrl}/settings/apikey` : null,
(url) => fetcher(url, accessToken),
{ revalidateOnFocus: false }
);

if (isLoading) return <Loading />;
Expand All @@ -28,7 +30,7 @@ export default function ApiKeySettings({ accessToken }: Props) {
const copyBlockApiKeyProps = {
theme: { ...a11yLight },
language: "text",
text: data?.apiKey || '',
text: data?.apiKey || "",
codeBlock: true,
showLineNumbers: false,
};
Expand Down
61 changes: 50 additions & 11 deletions keep-ui/app/settings/settings.client.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,19 +4,40 @@ import {
GlobeAltIcon,
UserGroupIcon,
EnvelopeIcon,
KeyIcon
KeyIcon,
} from "@heroicons/react/24/outline";
import UsersSettings from "./users-settings";
import WebhookSettings from "./webhook-settings";
import APIKeySettings from "./api-key-settings";
import { useSession } from "next-auth/react"
import { useSession } from "next-auth/react";
import Loading from "app/loading";
import SmtpSettings from "./smtp-settings";
import { useRouter } from "next/navigation";
import { usePathname, useRouter, useSearchParams } from "next/navigation";
import { useState } from "react";

export default function SettingsPage() {
const { data: session, status } = useSession();
const router = useRouter();
const searchParams = useSearchParams()!;
const pathname = usePathname();
const [selectedTab, setSelectedTab] = useState<string>(
searchParams?.get("selectedTab") || "users"
);

const handleTabChange = (tab: string) => {
setSelectedTab(tab);
router.push(`${pathname}?selectedTab=${tab}`);
};

// TODO: more robust way to handle this
const tabIndex =
selectedTab === "users"
? 0
: selectedTab === "webhook"
? 1
: selectedTab === "smtp"
? 2
: 3;

if (status === "loading") return <Loading />;
if (status === "unauthenticated") router.push("/signin");
Expand All @@ -28,28 +49,46 @@ export default function SettingsPage() {
* Think about a proper way to implement it.
*/
return (
<TabGroup>
<TabGroup index={tabIndex}>
<TabList color="orange">
<Tab icon={UserGroupIcon}>Users</Tab>
<Tab icon={GlobeAltIcon}>Webhook</Tab>
<Tab icon={EnvelopeIcon}>SMTP</Tab>
<Tab icon={KeyIcon}>Api Key</Tab>
<Tab icon={UserGroupIcon} onClick={() => handleTabChange("users")}>
Users
</Tab>
<Tab icon={GlobeAltIcon} onClick={() => handleTabChange("webhook")}>
Webhook
</Tab>
<Tab icon={EnvelopeIcon} onClick={() => handleTabChange("smtp")}>
SMTP
</Tab>
<Tab icon={KeyIcon} onClick={() => handleTabChange("api-key")}>
API Key
</Tab>
</TabList>
<TabPanels>
<TabPanel>
<UsersSettings
accessToken={session?.accessToken!}
currentUser={session?.user}
selectedTab={selectedTab}
/>
</TabPanel>
<TabPanel>
<WebhookSettings accessToken={session?.accessToken!} />
<WebhookSettings
accessToken={session?.accessToken!}
selectedTab={selectedTab}
/>
</TabPanel>
<TabPanel>
<SmtpSettings accessToken={session?.accessToken!} />
<SmtpSettings
accessToken={session?.accessToken!}
selectedTab={selectedTab}
/>
</TabPanel>
<TabPanel>
<APIKeySettings accessToken={session?.accessToken!} />
<APIKeySettings
accessToken={session?.accessToken!}
selectedTab={selectedTab}
/>
</TabPanel>
</TabPanels>
</TabGroup>
Expand Down
Loading

0 comments on commit 3bbf067

Please sign in to comment.