-
Notifications
You must be signed in to change notification settings - Fork 51
QoL: Settings page remembers tab #154
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,40 @@ | ||
| import axios from "axios"; | ||
| import React from "react"; | ||
| import type toast from "react-hot-toast"; | ||
| import { useRecoilState } from "recoil"; | ||
| import SwitchComponenet from "@/components/switch"; | ||
| import { workspacestate } from "@/state"; | ||
| import { FC } from '@/types/settingsComponent' | ||
| import { IconForms } from "@tabler/icons-react"; | ||
|
|
||
| type props = { | ||
| triggerToast: typeof toast; | ||
| } | ||
|
|
||
| const Forms: FC<props> = (props) => { | ||
| const triggerToast = props.triggerToast; | ||
| const [workspace, setWorkspace] = useRecoilState(workspacestate); | ||
|
|
||
| return ( | ||
| <div className="flex items-center justify-between px-5 py-4"> | ||
| <div className="flex items-center gap-3"> | ||
| <div className="p-2 bg-primary/10 rounded-lg"> | ||
| <IconForms size={18} className="text-primary" /> | ||
| </div> | ||
| <div> | ||
| <p className="text-sm font-medium text-zinc-900 dark:text-white">Forms</p> | ||
| <p className="text-xs text-zinc-500 dark:text-zinc-400">Create, customize, and manage workspace forms for collecting structured data, submissions, and user input across your workspace</p> | ||
| </div> | ||
| </div> | ||
| <SwitchComponenet | ||
| checked={workspace.settings?.policiesEnabled} | ||
| label="" | ||
| classoverride="mt-0" | ||
| /> | ||
| </div> | ||
| ); | ||
| }; | ||
|
|
||
| Forms.title = "Forms"; | ||
|
|
||
| export default Forms; | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,52 @@ | ||
| /** | ||
| * Orbit Forms | ||
| * Licensed under GPL-3.0 (see LICENSE for details) | ||
| * | ||
| * Helpers to make life easier in the other scripts | ||
| * | ||
| * | ||
| * @module api/forms | ||
| * @author BuddyWinte | ||
| * @since 2.1.10-beta20 | ||
| */ | ||
|
|
||
| type Permission = string; | ||
| interface Role { | ||
| permissions: Permission[]; | ||
| } | ||
| interface UserWithRoles { | ||
| roles: Role[]; | ||
| } | ||
|
|
||
| /** | ||
| * Checks if a user has a given permission. | ||
| * | ||
| * Supports: | ||
| * - Exact matches: "Form.View" | ||
| * - Wildcards: "Form.*" | ||
| * | ||
| * @returns true if the user has permissions | ||
| * @returns false if the user doesn't have permissions | ||
| * @readonly | ||
| */ | ||
| export function hasPerms( | ||
| user: UserWithRoles, | ||
| permission: string | ||
| ): boolean { | ||
| if (!user?.roles?.length) return false; | ||
| for (const role of user.roles) { | ||
| if (!role?.permissions?.length) continue; | ||
|
|
||
| for (const perm of role.permissions) { | ||
| if (perm === permission) return true; | ||
| if (perm.endsWith(".*")) { | ||
| const prefix = perm.slice(0,-2); | ||
| if (permission.startsWith(prefix + ".")) { | ||
| return true; | ||
| } | ||
| } | ||
| } | ||
| } | ||
|
|
||
| return false; | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,21 @@ | ||
| /** | ||
| * Orbit Forms | ||
| * Licensed under GPL-3.0 (see LICENSE for details) | ||
| * | ||
| * Form collection endpoint. | ||
| * Used for listing existing forms and creating new forms. | ||
| * | ||
| * Routes: | ||
| * GET /api/forms | ||
| * POST /api/forms | ||
| * | ||
| * Permissions: | ||
| * - Forms.View | ||
| * - Forms.Create | ||
| * | ||
| * @module api/forms | ||
| * @author BuddyWinte | ||
| * @since 2.1.10-beta20 | ||
| */ | ||
|
|
||
| import { withAuth } from "@/lib/withAuth"; |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,20 @@ | ||
| /** | ||
| * Orbit Forms | ||
| * Licensed under GPL-3.0 (see LICENSE for details) | ||
| * | ||
| * Form collection endpoint. | ||
| * Used for listing existing forms and creating new forms. | ||
| * | ||
| * Routes: | ||
| * GET /api/forms/:formId | ||
| * PATCH /api/forms/:formId | ||
| * DELETE /api/forms/:formId | ||
| * | ||
| * Permissions: | ||
| * - Forms.View | ||
| * - Forms.Create | ||
| * | ||
| * @module api/forms | ||
| * @author BuddyWinte | ||
| * @since 2.1.10-beta20 | ||
| */ | ||
|
Comment on lines
+1
to
+20
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🧩 Analysis chain🏁 Script executed: find . -name "specific.ts" -path "*/api/forms/*" -type fRepository: PlanetaryOrbit/orbit Length of output: 94 🏁 Script executed: cat pages/api/forms/specific.tsRepository: PlanetaryOrbit/orbit Length of output: 450 Add default handler export to complete the API route File contains only module documentation with no handler function. Next.js Pages Router API routes require a default export; without it, the 🤖 Prompt for AI Agents |
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Forms toggle is wired to the wrong setting and has no update path
Line 30 binds to
workspace.settings?.policiesEnabled, so this switch reflects Policies state, not Forms state. Also, noonChangeis passed, so users cannot actually toggle Forms behavior from this panel.🤖 Prompt for AI Agents