forge
Explore
Log in

Don't you dare go Hollow

🎨 move teacher assign button to section disclosure header and update AGENTS.md rule

Browse files at this commit

0ee3858c85b42adce7cadbd065ab5d4b4deeda01Burak BoduroğluParent: 61d2048
  • style
    • 🎨 move teacher assign button to section disclosure header and update AGENTS.md rule
Show full message
style: 🎨 move teacher assign button to section disclosure header and update AGENTS.md rule

- update CourseTeachersPanel and course-detail-page to place teacher assignment button in SectionDisclosure header actions
- remove redundant section title block inside CourseTeachersPanel
- update AGENTS.md rulebook with strict UI rule for disclosure header action placement
AGENTS.mdmodified+1 -1
@@ -85,7 +85,7 @@ Solid components run **once**, there is no re-render:
8585 - `docs/role-scope-matrix.md` — role access matrix for pages/nav/dashboard cards.
8686 - `docs/backend-ui-alignment-plan.md` — completed backend-alignment archive; do not treat it as active work unless backend scope changes.
8787 - Durable resources use full detail pages. Short create/edit/filter work uses `SidePanel`. Destructive actions use confirm dialogs.
88-- Header create actions use compact icon+label buttons with consistent size and current radius.
88+- Header create actions use compact icon+label buttons with consistent size and current radius (e.g. `variant="outline" size="sm" class="rounded-lg"` in `SectionDisclosure` header `actions`). Action buttons inside sub-panels must not duplicate section headers — primary create/add/assign actions must be placed in the header `actions` prop of the parent disclosure or page header.
8989 - Application tables must use `src/components/ui/data-table.tsx` `DataTable`.
9090 Pages/domain components must not import or render `Table` primitives directly;
9191 only the `DataTable` wrapper and table primitive files may do that.
src/components/courses/course-teachers-panel.tsxmodified+7 -16
@@ -18,10 +18,11 @@ export function CourseTeachersPanel(props: {
1818 courseId: string;
1919 teachers: PersonRef[];
2020 canStaff: boolean;
21+ assignOpen: boolean;
22+ onAssignOpenChange: (open: boolean) => void;
2123 onCourseUpdated: () => void;
2224 }) {
2325 const t = useT();
24- const [showAssignPanel, setShowAssignPanel] = createSignal(false);
2526 const [selectedTeacherId, setSelectedTeacherId] = createSignal("");
2627 const [removeTarget, setRemoveTarget] = createSignal<PersonRef | null>(null);
2728 const [error, setError] = createSignal("");
@@ -79,7 +80,7 @@ export function CourseTeachersPanel(props: {
7980 await postCourseTeacher(props.courseId, teacherId);
8081 setFlash(t("courses.teacherAssigned"));
8182 setSelectedTeacherId("");
82- setShowAssignPanel(false);
83+ props.onAssignOpenChange(false);
8384 props.onCourseUpdated();
8485 } catch (err) {
8586 setError(formatApiError(err));
@@ -116,16 +117,6 @@ export function CourseTeachersPanel(props: {
116117 <Alert variant="destructive">{error()}</Alert>
117118 </Show>
118119
119- <div class="flex items-center justify-between">
120- <h3 class="text-sm font-semibold">{t("courses.teachers")}</h3>
121- <Show when={props.canStaff}>
122- <Button size="sm" onClick={() => setShowAssignPanel(true)}>
123- <IconPlus class="mr-1.5 h-4 w-4" />
124- {t("courses.assignTeacher")}
125- </Button>
126- </Show>
127- </div>
128-
129120 <Show
130121 when={props.teachers.length > 0}
131122 fallback={
@@ -134,7 +125,7 @@ export function CourseTeachersPanel(props: {
134125 description=""
135126 action={
136127 props.canStaff ? (
137- <Button size="sm" onClick={() => setShowAssignPanel(true)}>
128+ <Button size="sm" onClick={() => props.onAssignOpenChange(true)}>
138129 <IconPlus class="mr-1.5 h-4 w-4" />
139130 {t("courses.assignTeacher")}
140131 </Button>
@@ -147,9 +138,9 @@ export function CourseTeachersPanel(props: {
147138 </Show>
148139
149140 <SidePanel
150- open={showAssignPanel()}
141+ open={props.assignOpen}
151142 onOpenChange={(open) => {
152- setShowAssignPanel(open);
143+ props.onAssignOpenChange(open);
153144 if (!open) {
154145 setSelectedTeacherId("");
155146 setError("");
@@ -177,7 +168,7 @@ export function CourseTeachersPanel(props: {
177168 <Button
178169 type="button"
179170 variant="outline"
180- onClick={() => setShowAssignPanel(false)}
171+ onClick={() => props.onAssignOpenChange(false)}
181172 disabled={pending()}
182173 >
183174 {t("common.cancel")}
src/pages/course-detail-page.tsxmodified+12 -1
@@ -68,6 +68,7 @@ function CourseDetailContent() {
6868 return params().id;
6969 });
7070
71+ const [openSections, setOpenSections] = createSignal({ teachers: false, subjects: false, exams: false, sessions: false, roster: false });
7172 const [course, { refetch: refetchCourse }] = createResource(id, (courseId) => getCourseById(courseId));
7273 const [terms] = createResource(async () => (await getTerms()).items);
7374 const [settings] = createResource(() => getSettings());
@@ -113,8 +114,8 @@ function CourseDetailContent() {
113114 const [createdCourseExam, setCreatedCourseExam] = createSignal<Exam | null>(null);
114115 const [showSubjectForm, setShowSubjectForm] = createSignal(false);
115116 const [showSessionForm, setShowSessionForm] = createSignal(false);
117+ const [showTeacherForm, setShowTeacherForm] = createSignal(false);
116118 const [showEnrollPanel, setShowEnrollPanel] = createSignal(false);
117- const [openSections, setOpenSections] = createSignal({ teachers: false, subjects: false, exams: false, sessions: false, roster: false });
118119 const [subjectCount, setSubjectCount] = createSignal(0);
119120 const [sessionCount, setSessionCount] = createSignal(0);
120121 const [enrollUserId, setEnrollUserId] = createSignal("");
@@ -557,11 +558,21 @@ function CourseDetailContent() {
557558 onToggle={() => toggleSection("teachers")}
558559 title={t("courses.teachers")}
559560 description={countDescription((c().teachers ?? []).length, t("courses.teachers"))}
561+ actions={
562+ <Show when={canStaffCourse()}>
563+ <Button type="button" variant="outline" size="sm" class="rounded-lg" onClick={() => setShowTeacherForm(true)}>
564+ <IconPlus class="h-4 w-4" />
565+ {t("courses.assignTeacher")}
566+ </Button>
567+ </Show>
568+ }
560569 >
561570 <CourseTeachersPanel
562571 courseId={id()}
563572 teachers={c().teachers ?? []}
564573 canStaff={canStaffCourse()}
574+ assignOpen={showTeacherForm()}
575+ onAssignOpenChange={setShowTeacherForm}
565576 onCourseUpdated={refetchCourse}
566577 />
567578 </SectionDisclosure>