Skip to content
This repository has been archived by the owner on Jul 20, 2024. It is now read-only.

Commit

Permalink
botway(core): some improvements
Browse files Browse the repository at this point in the history
  • Loading branch information
abdfnx committed Jun 26, 2023
1 parent 77f3cdd commit df51d55
Show file tree
Hide file tree
Showing 6 changed files with 103 additions and 57 deletions.
22 changes: 12 additions & 10 deletions core/app/project/[id]/logs/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,16 @@ const Project = ({ user, projectId }: any) => {
);
};

const NoLogs = () => {
return (
<div className="rounded-2xl overflow-hidden p-5 w-full h-60 flex flex-col items-center justify-center gap-4">
<h2 className="text-md text-gray-400 text-center">
There is no logs 📜
</h2>
</div>
);
};

return (
<>
{projectIsLoading ? (
Expand Down Expand Up @@ -132,18 +142,10 @@ const Project = ({ user, projectId }: any) => {
</div>
))
) : (
<div className="rounded-2xl overflow-hidden p-5 cursor-pointer w-full h-60 flex flex-col items-center justify-center gap-4">
<h2 className="text-md text-gray-400 text-center">
There is no logs 📜
</h2>
</div>
<NoLogs />
)
) : (
<div className="rounded-2xl overflow-hidden p-5 cursor-pointer w-full h-60 flex flex-col items-center justify-center gap-4">
<h2 className="text-md text-gray-400 text-center">
There is no logs 📜
</h2>
</div>
<NoLogs />
)}
</div>
</div>
Expand Down
42 changes: 40 additions & 2 deletions core/app/project/[id]/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,15 @@ import {
QueryClientProvider,
} from "@tanstack/react-query";
import { fetcher } from "@/tools/fetch";
import { ContainerIcon } from "@primer/octicons-react";
import {
CheckIcon,
GearIcon,
MarkGithubIcon,
XCircleIcon,
} from "@primer/octicons-react";
import Link from "next/link";
import { CheckTokens } from "./settings/page";
import { Tooltip } from "flowbite-react";

export const revalidate = 0;

Expand Down Expand Up @@ -86,7 +94,7 @@ const Project = ({ user, projectId }: any) => {
projectRWID={project?.railway_project_id}
grid={true}
>
<div className="mx-6 my-16 flex items-center space-x-6">
<div className="mx-6 mt-16 flex items-center space-x-6">
<div className="">
<img src="https://cdn-botway.deno.dev/icons/bot.svg" width={67} />
</div>
Expand All @@ -95,6 +103,36 @@ const Project = ({ user, projectId }: any) => {
<h1 className="text-base text-gray-400">Bot Project</h1>
</div>
</div>
<div className="mx-6 bg-secondary justify-between flex border border-gray-800 rounded-lg p-4">
<div className="flex">
<MarkGithubIcon size={20} className="fill-gray-400" />
<Link
href={`https://github.com/${project?.repo}`}
target="_blank"
>
<h1 className="pl-2 text-sm text-white">{project?.repo}</h1>
</Link>
</div>
<div className="flex">
<button>
<Tooltip content="Tokens Status" arrow={false} placement="top">
{CheckTokens(project) ? (
<>
<CheckIcon size={20} className="fill-green-600" />
</>
) : (
<>
<XCircleIcon size={20} className="fill-red-600" />
</>
)}
</Tooltip>
</button>

<a href={`/project/${projectId}/settings`}>
<GearIcon size={20} className="ml-3 fill-white" />
</a>
</div>
</div>
<div className="mx-6"></div>
</ProjectLayout>
)}
Expand Down
52 changes: 23 additions & 29 deletions core/app/project/[id]/settings/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,28 @@ const UpdateNameSchema = Yup.object().shape({
rootDir: Yup.string(),
});

export const CheckTokens = (project: any) => {
if (project?.platform === "telegram") {
if (project?.bot_token.length != 0) {
return true;
}
} else if (project?.platform === "discord") {
if (project?.bot_token.length != 0 && project?.bot_app_token.length != 0) {
return true;
}
} else if (project?.platform === "slack" || project?.platform === "twitch") {
if (
project?.bot_token.length != 0 &&
project?.bot_app_token.length != 0 &&
project?.bot_secret_token.length != 0
) {
return true;
}
}

return false;
};

const queryClient = new QueryClient();

const Project = ({ user, projectId }: any) => {
Expand Down Expand Up @@ -178,34 +200,6 @@ const Project = ({ user, projectId }: any) => {
}
}

const checkTokens = () => {
if (project?.platform === "telegram") {
if (project?.bot_token.length != 0) {
return true;
}
} else if (project?.platform === "discord") {
if (
project?.bot_token.length != 0 &&
project?.bot_app_token.length != 0
) {
return true;
}
} else if (
project?.platform === "slack" ||
project?.platform === "twitch"
) {
if (
project?.bot_token.length != 0 &&
project?.bot_app_token.length != 0 &&
project?.bot_secret_token.length != 0
) {
return true;
}
}

return false;
};

if (!project && !projectIsLoading) {
redirect("/");
}
Expand Down Expand Up @@ -580,7 +574,7 @@ const Project = ({ user, projectId }: any) => {
className="py-3 px-4 overflow-hidden overflow-ellipsis whitespace-nowrap text-gray-500"
style={{ minWidth: "64px", maxWidth: "400px" }}
>
{checkTokens() ? (
{CheckTokens(project) ? (
<>
<CheckIcon
size={18}
Expand Down
2 changes: 1 addition & 1 deletion core/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
"@primer/octicons-react": "^19.4.0",
"@supabase/auth-helpers-nextjs": "^0.7.2",
"@supabase/supabase-js": "^2.26.0",
"@tanstack/react-query": "^4.29.15",
"@tanstack/react-query": "^4.29.17",
"ajv": "^8.12.0",
"autoprefixer": "10.4.14",
"bcryptjs": "^2.4.3",
Expand Down
11 changes: 11 additions & 0 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -130,6 +130,8 @@ github.com/containerd/console v1.0.3 h1:lIr7SlA5PxZyMV30bDW0MGbiOPXwc63yRuCP0ARu
github.com/containerd/console v1.0.3/go.mod h1:7LqA/THxQ86k76b8c/EMSiaJ3h1eZkMkXar0TQ1gf3U=
github.com/containerd/console v1.0.4-0.20230313162750-1ae8d489ac81 h1:q2hJAaP1k2wIvVRd/hEHD7lacgqrCPS+k8g1MndzfWY=
github.com/containerd/console v1.0.4-0.20230313162750-1ae8d489ac81/go.mod h1:YynlIjWYF8myEu6sdkwKIvGQq+cOckRm6So2avqoYAk=
github.com/coreos/go-semver v0.3.0/go.mod h1:nnelYz7RCh+5ahJtPPxZlU+153eP4D4r3EedlOD2RNk=
github.com/coreos/go-systemd/v22 v22.3.2/go.mod h1:Y58oyj3AT4RCenI/lSvhwexgC+NSVTIJ3seZv2GcEnc=
github.com/cpuguy83/go-md2man/v2 v2.0.2/go.mod h1:tgQtvFlXSQOSOSIRvRPT7W67SCa46tRHOmNcaadrF8o=
github.com/creack/pty v1.1.17 h1:QeVUsEDNrLBW4tMgZHvxy18sKtr6VI492kBhUfhDJNI=
github.com/creack/pty v1.1.17/go.mod h1:MOBLtS5ELjhRRrroQr9kyvTxUAFNvYEK993ew/Vr4O4=
Expand Down Expand Up @@ -160,10 +162,12 @@ github.com/gdamore/tcell/v2 v2.6.0/go.mod h1:be9omFATkdr0D9qewWW3d+MEvl5dha+Etb5
github.com/go-gl/glfw v0.0.0-20190409004039-e6da0acd62b1/go.mod h1:vR7hzQXu2zJy9AVAgeJqvqgH9Q5CA+iKCZ2gyEVpxRU=
github.com/go-gl/glfw/v3.3/glfw v0.0.0-20191125211704-12ad95a8df72/go.mod h1:tQ2UAYgL5IevRw8kRxooKSPJfGvJ9fJQFa0TUsXzTg8=
github.com/go-gl/glfw/v3.3/glfw v0.0.0-20200222043503-6f7a984d4dc4/go.mod h1:tQ2UAYgL5IevRw8kRxooKSPJfGvJ9fJQFa0TUsXzTg8=
github.com/gogo/protobuf v1.3.2/go.mod h1:P1XiOD3dCwIKUDQYPy72D8LYyHL2YPYrpS2s69NZV8Q=
github.com/golang/glog v0.0.0-20160126235308-23def4e6c14b/go.mod h1:SBH7ygxi8pfUlaOkMMuAQtPIUF8ecWP5IEl/CR7VP2Q=
github.com/golang/groupcache v0.0.0-20190702054246-869f871628b6/go.mod h1:cIg4eruTrX1D+g88fzRXU5OdNfaM+9IcxsU14FzY7Hc=
github.com/golang/groupcache v0.0.0-20191227052852-215e87163ea7/go.mod h1:cIg4eruTrX1D+g88fzRXU5OdNfaM+9IcxsU14FzY7Hc=
github.com/golang/groupcache v0.0.0-20200121045136-8c9f03a8e57e/go.mod h1:cIg4eruTrX1D+g88fzRXU5OdNfaM+9IcxsU14FzY7Hc=
github.com/golang/groupcache v0.0.0-20210331224755-41bb18bfe9da/go.mod h1:cIg4eruTrX1D+g88fzRXU5OdNfaM+9IcxsU14FzY7Hc=
github.com/golang/mock v1.1.1/go.mod h1:oTYuIxOrZwtPieC+H1uAHpcLFnEyAGVDL/k47Jfbm0A=
github.com/golang/mock v1.2.0/go.mod h1:oTYuIxOrZwtPieC+H1uAHpcLFnEyAGVDL/k47Jfbm0A=
github.com/golang/mock v1.3.1/go.mod h1:sBzyDLLjw3U8JLTeZvSv8jJB+tU5PVekmnlKIyFUx0Y=
Expand Down Expand Up @@ -227,8 +231,12 @@ github.com/googleapis/gax-go/v2 v2.0.5/go.mod h1:DWXyrwAJ9X0FpwwEdw+IPEYBICEFu5m
github.com/googleapis/google-cloud-go-testing v0.0.0-20200911160855-bcd43fbb19e8/go.mod h1:dvDLG8qkwmyD9a/MJJN3XJcT3xFxOKAvTZGvuZmac9g=
github.com/gorilla/css v1.0.0 h1:BQqNyPTi50JCFMTw/b67hByjMVXZRwGha6wxVGkeihY=
github.com/gorilla/css v1.0.0/go.mod h1:Dn721qIggHpt4+EFCcTLTU/vk5ySda2ReITrtgBl60c=
github.com/hashicorp/go-cleanhttp v0.5.2/go.mod h1:kO/YDlP8L1346E6Sodw+PrpBSV4/SoxCXGY6BqNFT48=
github.com/hashicorp/go-immutable-radix v1.3.1/go.mod h1:0y9vanUI8NX6FsYoO3zeMjhV/C5i9g4Q3DwcSNZ4P60=
github.com/hashicorp/go-rootcerts v1.0.2/go.mod h1:pqUvnprVnM5bf7AOirdbb01K4ccR319Vf4pU3K5EGc8=
github.com/hashicorp/golang-lru v0.5.0/go.mod h1:/m3WP610KZHVQ1SGc6re/UDhFvYD7pJ4Ao+sR/qLZy8=
github.com/hashicorp/golang-lru v0.5.1/go.mod h1:/m3WP610KZHVQ1SGc6re/UDhFvYD7pJ4Ao+sR/qLZy8=
github.com/hashicorp/golang-lru v0.5.4/go.mod h1:iADmTwqILo4mZ8BN3D2Q6+9jd8WM5uGBxy+E8yxSoD4=
github.com/hashicorp/hcl v1.0.0 h1:0Anlzjpi4vEasTeNFn2mLJgTSwt0+6sfsiTG8qcWGx4=
github.com/hashicorp/hcl v1.0.0/go.mod h1:E5yfLk+7swimpb2L/Alb/PJmXilQ/rhwaUYs4T20WEQ=
github.com/henvic/httpretty v0.1.0 h1:Htk66UUEbXTD4JR0qJZaw8YAMKw+9I24ZZOnDe/ti+E=
Expand All @@ -251,6 +259,7 @@ github.com/jedib0t/go-pretty/v6 v6.4.6 h1:v6aG9h6Uby3IusSSEjHaZNXpHFhzqMmjXcPq1R
github.com/jedib0t/go-pretty/v6 v6.4.6/go.mod h1:Ndk3ase2CkQbXLLNf5QDHoYb6J9WtVfmHZu9n8rk2xs=
github.com/joho/godotenv v1.5.1 h1:7eLL/+HRGLY0ldzfGMeQkb7vMd0as4CfYvUVzLqw0N0=
github.com/joho/godotenv v1.5.1/go.mod h1:f4LDr5Voq0i2e/R5DDNOoa2zzDfwtkZa6DnEwAbqwq4=
github.com/json-iterator/go v1.1.12/go.mod h1:e30LSqwooZae/UwlEbR2852Gd8hjQvJoHmT4TnhNGBo=
github.com/jstemmer/go-junit-report v0.0.0-20190106144839-af01ea7f8024/go.mod h1:6v2b51hI/fHJwM22ozAgKL4VKDeJcHhJFhtBdhmNjmU=
github.com/jstemmer/go-junit-report v0.9.1/go.mod h1:Brl9GWCQeLvo8nXZwPNNblvFj/XSXhF0NWZEnDohbsk=
github.com/kballard/go-shellquote v0.0.0-20180428030007-95032a82bc51 h1:Z9n2FFNUXsshfwJMBgNA0RU6/i7WVaAegv3PtuIHPMs=
Expand Down Expand Up @@ -304,6 +313,8 @@ github.com/mitchellh/go-homedir v1.1.0 h1:lukF9ziXFxDFPkA1vsr5zpc1XuPDn/wFntq5mG
github.com/mitchellh/go-homedir v1.1.0/go.mod h1:SfyaCUpYCn1Vlf4IUYiD9fPX4A5wJrkLzIz1N1q0pr0=
github.com/mitchellh/mapstructure v1.5.0 h1:jeMsZIYE/09sWLaz43PL7Gy6RuMjD2eJVyuac5Z2hdY=
github.com/mitchellh/mapstructure v1.5.0/go.mod h1:bFUtVrKA4DC2yAKiSyO/QUcy7e+RRV2QTWOzhPopBRo=
github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd/go.mod h1:6dJC0mAP4ikYIbvyc7fijjWJddQyLn8Ig3JB5CqoB9Q=
github.com/modern-go/reflect2 v1.0.2/go.mod h1:yWuevngMOJpCy52FWWMvUC8ws7m/LJsjYzDa0/r8luk=
github.com/muesli/ansi v0.0.0-20211018074035-2e021307bc4b/go.mod h1:fQuZ0gauxyBcmsdE3ZT4NasjaRdxmbCS0jRHsrWu3Ho=
github.com/muesli/ansi v0.0.0-20230316100256-276c6243b2f6 h1:ZK8zHtRHOkbHy6Mmr5D264iyp3TiX5OmNcI5cIARiQI=
github.com/muesli/ansi v0.0.0-20230316100256-276c6243b2f6/go.mod h1:CJlz5H+gyd6CUWT45Oy4q24RdLyn7Md9Vj2/ldJBSIo=
Expand Down
31 changes: 16 additions & 15 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit df51d55

Please sign in to comment.