Skip to content

Commit 901137a

Browse files
📝 Add docstrings to main (#2)
* ci: add CI workflow with type check, build, verify and dry-run publish Runs on every push and PR across all branches. Checks: - TypeScript (server + admin) - Build - Strapi plugin verify - Version not already published on npm - Dry run publish publish.yml now requires CI to pass before publishing to npm. * fix: replace yarn run -T with npx tsc and fix implicit any type errors - Fix test:ts:front and test:ts:back scripts to use npx tsc (was yarn-only syntax) - Add explicit types for implicit any parameters caught by the type check: MouseEvent on DropZone drag handle click boolean on Modal.Root onOpenChange in EmbedModal and FormPreview string | number on SingleSelect onChange in FieldSettingsPanel and SubmissionsPage * ci: add Dependabot for npm and GitHub Actions weekly updates * fix: remove stale compiled JS files from src and ignore them in .gitignore Rollup was resolving register.js (and other compiled .js files) instead of the .ts sources, causing 'default is not exported' build failures in CI. Deleted all .js artifacts from server/src and admin/src and added them to .gitignore so they are never committed again. * fix: add --noEmit to tsc type-check scripts to prevent JS file generation Without --noEmit, tsc outputs .js files next to the .ts sources. Rollup then resolves the CJS .js files instead of the .ts sources and fails with 'default is not exported' on the CommonJS interop boundary. * ci: prevent double CI run on PR branches Push trigger now only fires on main, development and production. Feature branches are covered by the pull_request trigger alone, so CI no longer runs twice when pushing to an open PR. * 📝 Add docstrings to `main` Docstrings generation was requested by @devCluna. * #1 (comment) The following files were modified: * `admin/src/components/DropZone.tsx` * `admin/src/components/EmbedModal.tsx` * `admin/src/components/FieldSettingsPanel.tsx` * `admin/src/components/FormPreview.tsx` * `admin/src/pages/SubmissionsPage.tsx` --------- Co-authored-by: dev.cluna <dev.cluna@gmail.com> Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com>
1 parent 1728e79 commit 901137a

5 files changed

Lines changed: 50 additions & 0 deletions

File tree

admin/src/components/DropZone.tsx

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,17 @@ import { CSS } from '@dnd-kit/utilities';
2020
import { Trash, Drag } from '@strapi/icons';
2121
import { FormField } from '../types';
2222

23+
/**
24+
* Renders a draggable, selectable row that represents a FormField with a delete action.
25+
*
26+
* The row highlights when `selected`. Clicking the row calls `onSelect`; interacting with the drag handle does not toggle selection; clicking the delete button calls `onDelete`.
27+
*
28+
* @param field - The form field to render (label and type are displayed).
29+
* @param selected - Whether this row is currently selected; controls visual highlight.
30+
* @param onSelect - Callback invoked when the row (outside the drag handle and delete button) is clicked.
31+
* @param onDelete - Callback invoked when the delete button is clicked.
32+
* @returns The rendered sortable field row element.
33+
*/
2334
function SortableFieldRow({
2435
field,
2536
selected,

admin/src/components/EmbedModal.tsx

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,17 @@ interface Props {
88
onClose: () => void;
99
}
1010

11+
/**
12+
* Renders a modal that displays an embeddable HTML snippet for a given form and provides a one-click copy action.
13+
*
14+
* The component returns `null` when `open` is `false`. When visible, it shows a preformatted snippet containing a container div
15+
* with `id="sfb-form-<formId>"` and a script tag that loads the embed script from the current origin with `data-form-id` set.
16+
*
17+
* @param formId - The form identifier inserted into the snippet's container id and `data-form-id` attribute
18+
* @param open - Controls whether the modal is visible
19+
* @param onClose - Callback invoked when the modal is closed
20+
* @returns The modal element when `open` is `true`, otherwise `null`
21+
*/
1122
export function EmbedModal({ formId, open, onClose }: Props) {
1223
const [copied, setCopied] = useState(false);
1324

admin/src/components/FieldSettingsPanel.tsx

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,17 @@ function LabeledInput({
4545
);
4646
}
4747

48+
/**
49+
* Render the settings panel UI for editing a single form field.
50+
*
51+
* Displays controls for label, name, placeholder, help text, required/width toggles,
52+
* type-specific inputs (heading, paragraph), option management (add/update/remove),
53+
* validation rule management (add/update/remove) with value/message editing, and CSS class.
54+
*
55+
* @param field - The current FormField to edit.
56+
* @param onChange - Callback invoked with the updated FormField whenever a change is made.
57+
* @returns A React element containing the field settings panel UI.
58+
*/
4859
export function FieldSettingsPanel({ field, onChange }: Props) {
4960
const update = (patch: Partial<FormField>) => onChange({ ...field, ...patch });
5061

admin/src/components/FormPreview.tsx

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -283,6 +283,16 @@ interface Props {
283283
onClose: () => void;
284284
}
285285

286+
/**
287+
* Render a modal preview of a form using the provided title, fields, and settings.
288+
*
289+
* @param title - The preview title displayed in the modal header
290+
* @param fields - The array of form field definitions to render inside the preview
291+
* @param settings - Form-level settings (used for things like the submit button text)
292+
* @param open - Whether the preview modal is visible
293+
* @param onClose - Callback invoked when the preview modal is closed
294+
* @returns The modal element containing the form preview, or `null` when `open` is false
295+
*/
286296
export function FormPreview({ title, fields, settings, open, onClose }: Props) {
287297
if (!open) return null;
288298

admin/src/pages/SubmissionsPage.tsx

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,13 @@ import { useFormsApi } from '../api';
2222
import { Form, FormField, FormSubmission } from '../types';
2323
import { PLUGIN_ID } from '../pluginId';
2424

25+
/**
26+
* Render the submissions management page for a specific form.
27+
*
28+
* Loads and displays form metadata, submission list, and statistics; provides controls to filter by status, view submission details, mark submissions as read, and delete submissions.
29+
*
30+
* @returns The React element for the Submissions page (table, filters, detail modal, and delete confirmation modal).
31+
*/
2532
export function SubmissionsPage() {
2633
const { formId } = useParams<{ formId: string }>();
2734
const navigate = useNavigate();

0 commit comments

Comments
 (0)