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

Commit

Permalink
botway(core): restore to old opening ce function
Browse files Browse the repository at this point in the history
  • Loading branch information
abdfnx committed Oct 22, 2023
1 parent 31288a2 commit 028d92d
Show file tree
Hide file tree
Showing 6 changed files with 348 additions and 230 deletions.
259 changes: 122 additions & 137 deletions core/app/project/[id]/code-editor/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ const CE = ({ user, projectId }: any) => {
toast.error(ce.error, toastStyle);
}

setCE(`https://${ce.domain}`);
router.push(`https://${ce.domain}`);
} else {
body = {
password: await new EncryptJWT({
Expand Down Expand Up @@ -127,150 +127,135 @@ const CE = ({ user, projectId }: any) => {
projectZBID={project?.zeabur_project_id}
noMargin={ce != ""}
>
{ce != "" ? (
<div className="border-t h-full">
<iframe
className="min-w-full min-h-[94.8vh] md:min-h-[94vh] xl:min-h-[94.8vh]"
src={ce}
<div className="mx-6 my-16 flex items-center space-x-6">
<h1 className="text-3xl text-white">Code Editor</h1>
</div>
<div className="mx-6">
<div className="w-full h-60 grid lg:grid-cols-2 lt-md:!grid-cols-1 items-center justify-center gap-4">
<img
src="https://cdn-botway.deno.dev/images/coder.svg"
alt="Botway CE"
/>
</div>
) : (
<>
<div className="mx-6 my-16 flex items-center space-x-6">
<h1 className="text-3xl text-white">Code Editor</h1>
</div>
<div className="mx-6">
<div className="w-full h-60 grid lg:grid-cols-2 lt-md:!grid-cols-1 items-center justify-center gap-4">
<img
src="https://cdn-botway.deno.dev/images/coder.svg"
alt="Botway CE"
/>

<div className="pb-4">
<h2 className="text-md text-gray-400 text-center">
{project?.enable_ce
? "Botway CE is enabled 👍"
: "Your project needs to enable Botway CE"}
</h2>

<h2 className="text-sm text-gray-500 text-center">
Botway CE is a code editor that built on top of{" "}
<Link
href="https://coder.com"
target="_blank"
className="text-blue-700"
>
Coder
</Link>
, with a lot of useful packages 🖥️
</h2>

{project?.enable_ce ? (
<Button
htmlType="submit"
onClick={enableCE}
type="success"
loading={isLoading}
>
Open My Editor
</Button>
) : (
<Button
htmlType="submit"
onClick={openModal}
type="success"
>
Enable & Deploy
</Button>
)}
</div>
</div>
</div>

<Transition appear show={isOpen} as={Fragment}>
<Dialog as="div" className="relative z-10" onClose={closeModal}>
<div className="pb-4">
<h2 className="text-md text-gray-400 text-center">
{project?.enable_ce
? "Botway CE is enabled 👍"
: "Your project needs to enable Botway CE"}
</h2>

<h2 className="text-sm text-gray-500 text-center">
Botway CE is a code editor that built on top of{" "}
<Link
href="https://coder.com"
target="_blank"
className="text-blue-700"
>
Coder
</Link>
, with a lot of useful packages 🖥️
</h2>

{project?.enable_ce ? (
<Button
htmlType="submit"
onClick={enableCE}
type="success"
loading={isLoading}
>
Open My Editor
</Button>
) : (
<Button htmlType="submit" onClick={openModal} type="success">
Enable & Deploy
</Button>
)}
</div>
</div>
</div>

<Transition appear show={isOpen} as={Fragment}>
<Dialog as="div" className="relative z-10" onClose={closeModal}>
<Transition.Child
as={Fragment}
enter="ease-out duration-300"
enterFrom="opacity-0"
enterTo="opacity-100"
leave="ease-in duration-200"
leaveFrom="opacity-100"
leaveTo="opacity-0"
>
<div className="fixed inset-0 bg-bwdefualt bg-opacity-50 transition-opacity" />
</Transition.Child>

<div className="fixed inset-0 overflow-y-auto">
<div className="flex min-h-full items-center justify-center p-4 text-center">
<Transition.Child
as={Fragment}
enter="ease-out duration-300"
enterFrom="opacity-0"
enterTo="opacity-100"
enterFrom="opacity-0 scale-95"
enterTo="opacity-100 scale-100"
leave="ease-in duration-200"
leaveFrom="opacity-100"
leaveTo="opacity-0"
leaveFrom="opacity-100 scale-100"
leaveTo="opacity-0 scale-95"
>
<div className="fixed inset-0 bg-bwdefualt bg-opacity-50 transition-opacity" />
</Transition.Child>

<div className="fixed inset-0 overflow-y-auto">
<div className="flex min-h-full items-center justify-center p-4 text-center">
<Transition.Child
as={Fragment}
enter="ease-out duration-300"
enterFrom="opacity-0 scale-95"
enterTo="opacity-100 scale-100"
leave="ease-in duration-200"
leaveFrom="opacity-100 scale-100"
leaveTo="opacity-0 scale-95"
<Dialog.Panel className="w-full bg-bwdefualt bg-grid-gray-800/[0.4] max-w-md transform overflow-hidden rounded-2xl p-6 text-left align-middle shadow-xl transition-all border border-gray-800">
<Dialog.Title
as="h3"
className="text-lg font-medium pb-2 leading-6 text-white"
>
<Dialog.Panel className="w-full bg-bwdefualt bg-grid-gray-800/[0.4] max-w-md transform overflow-hidden rounded-2xl p-6 text-left align-middle shadow-xl transition-all border border-gray-800">
<Dialog.Title
as="h3"
className="text-lg font-medium pb-2 leading-6 text-white"
>
Add Password to your Code Editor
</Dialog.Title>
<div className="mt-2">
<Formik
initialValues={{
password: "",
}}
onSubmit={enableCE}
>
{({ errors }) => (
<Form className="column w-full">
<Field
className="input"
id="password"
name="password"
type="password"
/>

{errors.password ? (
<div className="text-red-600 text-sm font-semibold pt-2">
{errors.password}
</div>
) : null}

<br />

<div className="flex w-full items-center gap-2 justify-end">
<div className="flex items-center gap-2">
<button
className="relative text-white cursor-pointer bg-blue-700 inline-flex items-center space-x-2 text-center font-regular ease-out duration-200 rounded outline-none transition-all outline-0 focus-visible:outline-4 focus-visible:outline-offset-1 shadow-sm text-xs px-2.5 py-1"
type="submit"
>
{isLoading && (
<LoadingDots
className={styles.loading}
children
/>
)}
<span className="truncate">Done</span>
</button>
</div>
</div>
</Form>
)}
</Formik>
</div>
</Dialog.Panel>
</Transition.Child>
</div>
</div>
</Dialog>
</Transition>
</>
)}
Add Password to your Code Editor
</Dialog.Title>
<div className="mt-2">
<Formik
initialValues={{
password: "",
}}
onSubmit={enableCE}
>
{({ errors }) => (
<Form className="column w-full">
<Field
className="input"
id="password"
name="password"
type="password"
/>

{errors.password ? (
<div className="text-red-600 text-sm font-semibold pt-2">
{errors.password}
</div>
) : null}

<br />

<div className="flex w-full items-center gap-2 justify-end">
<div className="flex items-center gap-2">
<button
className="relative text-white cursor-pointer bg-blue-700 inline-flex items-center space-x-2 text-center font-regular ease-out duration-200 rounded outline-none transition-all outline-0 focus-visible:outline-4 focus-visible:outline-offset-1 shadow-sm text-xs px-2.5 py-1"
type="submit"
>
{isLoading && (
<LoadingDots
className={styles.loading}
children
/>
)}
<span className="truncate">Done</span>
</button>
</div>
</div>
</Form>
)}
</Formik>
</div>
</Dialog.Panel>
</Transition.Child>
</div>
</div>
</Dialog>
</Transition>
</ProjectLayout>
)}
</>
Expand Down
4 changes: 2 additions & 2 deletions core/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
"@supabase/auth-helpers-nextjs": "^0.8.1",
"@supabase/supabase-js": "^2.38.2",
"@tanstack/react-query": "^5.0.0",
"ai": "^2.2.16",
"ai": "^2.2.17",
"ajv": "^8.12.0",
"autoprefixer": "10.4.16",
"bcryptjs": "^2.4.3",
Expand Down Expand Up @@ -52,7 +52,7 @@
"@types/bcryptjs": "^2.4.5",
"@types/marked": "^6.0.0",
"@types/node": "^20.8.7",
"@types/react": "18.2.30",
"@types/react": "18.2.31",
"@types/react-dom": "18.2.14",
"@types/slug": "^5.0.6",
"@types/ws": "^8.5.8",
Expand Down
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ require (
github.com/davecgh/go-spew v1.1.2-0.20180830191138-d8f796af33cc // indirect
github.com/dlclark/regexp2 v1.10.0 // indirect
github.com/fatih/color v1.15.0 // indirect
github.com/fsnotify/fsnotify v1.6.0 // indirect
github.com/fsnotify/fsnotify v1.7.0 // indirect
github.com/gdamore/encoding v1.0.0 // indirect
github.com/gdamore/tcell/v2 v2.6.0 // indirect
github.com/google/go-github v17.0.0+incompatible // indirect
Expand Down
2 changes: 2 additions & 0 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -149,6 +149,8 @@ github.com/fatih/color v1.15.0/go.mod h1:0h5ZqXfHYED7Bhv2ZJamyIOUej9KtShiJESRwBD
github.com/frankban/quicktest v1.14.4 h1:g2rn0vABPOOXmZUj+vbmUp0lPoXEMuhTpIluN0XL9UY=
github.com/fsnotify/fsnotify v1.6.0 h1:n+5WquG0fcWoWp6xPWfHdbskMCQaFnG6PfBrh1Ky4HY=
github.com/fsnotify/fsnotify v1.6.0/go.mod h1:sl3t1tCWJFWoRz9R8WJCbQihKKwmorjAbSClcnxKAGw=
github.com/fsnotify/fsnotify v1.7.0 h1:8JEhPFa5W2WU7YfeZzPNqzMP6Lwt7L2715Ggo0nosvA=
github.com/fsnotify/fsnotify v1.7.0/go.mod h1:40Bi/Hjc2AVfZrqy+aj+yEI+/bRxZnMJyTJwOpGvigM=
github.com/gdamore/encoding v1.0.0 h1:+7OoQ1Bc6eTm5niUzBa0Ctsh6JbMW6Ra+YNuAtDBdko=
github.com/gdamore/encoding v1.0.0/go.mod h1:alR0ol34c49FCSBLjhosxzcPHQbf2trDkoo5dl+VrEg=
github.com/gdamore/tcell/v2 v2.6.0 h1:OKbluoP9VYmJwZwq/iLb4BxwKcwGthaa1YNBJIyCySg=
Expand Down
4 changes: 2 additions & 2 deletions packages/botway.js/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,8 @@
"js-yaml": "^4.1.0"
},
"devDependencies": {
"@types/js-yaml": "^4.0.6",
"@types/node": "^20.7.2",
"@types/js-yaml": "^4.0.8",
"@types/node": "^20.8.7",
"typescript": "^5.2.2"
},
"engines": {
Expand Down
Loading

0 comments on commit 028d92d

Please sign in to comment.