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:
85 - `docs/role-scope-matrix.md` — role access matrix for pages/nav/dashboard cards.85 - `docs/role-scope-matrix.md` — role access matrix for pages/nav/dashboard cards.
86 - `docs/backend-ui-alignment-plan.md` — completed backend-alignment archive; do not treat it as active work unless backend scope changes.86 - `docs/backend-ui-alignment-plan.md` — completed backend-alignment archive; do not treat it as active work unless backend scope changes.
87 - Durable resources use full detail pages. Short create/edit/filter work uses `SidePanel`. Destructive actions use confirm dialogs.87 - 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.
89 - Application tables must use `src/components/ui/data-table.tsx` `DataTable`.89 - Application tables must use `src/components/ui/data-table.tsx` `DataTable`.
90 Pages/domain components must not import or render `Table` primitives directly;90 Pages/domain components must not import or render `Table` primitives directly;
91 only the `DataTable` wrapper and table primitive files may do that.91 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: {
18 courseId: string;18 courseId: string;
19 teachers: PersonRef[];19 teachers: PersonRef[];
20 canStaff: boolean;20 canStaff: boolean;
21+ assignOpen: boolean;
22+ onAssignOpenChange: (open: boolean) => void;
21 onCourseUpdated: () => void;23 onCourseUpdated: () => void;
22 }) {24 }) {
23 const t = useT();25 const t = useT();
24- const [showAssignPanel, setShowAssignPanel] = createSignal(false);
25 const [selectedTeacherId, setSelectedTeacherId] = createSignal("");26 const [selectedTeacherId, setSelectedTeacherId] = createSignal("");
26 const [removeTarget, setRemoveTarget] = createSignal<PersonRef | null>(null);27 const [removeTarget, setRemoveTarget] = createSignal<PersonRef | null>(null);
27 const [error, setError] = createSignal("");28 const [error, setError] = createSignal("");
@@ -79,7 +80,7 @@ export function CourseTeachersPanel(props: {
79 await postCourseTeacher(props.courseId, teacherId);80 await postCourseTeacher(props.courseId, teacherId);
80 setFlash(t("courses.teacherAssigned"));81 setFlash(t("courses.teacherAssigned"));
81 setSelectedTeacherId("");82 setSelectedTeacherId("");
82- setShowAssignPanel(false);83+ props.onAssignOpenChange(false);
83 props.onCourseUpdated();84 props.onCourseUpdated();
84 } catch (err) {85 } catch (err) {
85 setError(formatApiError(err));86 setError(formatApiError(err));
@@ -116,16 +117,6 @@ export function CourseTeachersPanel(props: {
116 <Alert variant="destructive">{error()}</Alert>117 <Alert variant="destructive">{error()}</Alert>
117 </Show>118 </Show>
118 119
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-
129 <Show120 <Show
130 when={props.teachers.length > 0}121 when={props.teachers.length > 0}
131 fallback={122 fallback={
@@ -134,7 +125,7 @@ export function CourseTeachersPanel(props: {
134 description=""125 description=""
135 action={126 action={
136 props.canStaff ? (127 props.canStaff ? (
137- <Button size="sm" onClick={() => setShowAssignPanel(true)}>128+ <Button size="sm" onClick={() => props.onAssignOpenChange(true)}>
138 <IconPlus class="mr-1.5 h-4 w-4" />129 <IconPlus class="mr-1.5 h-4 w-4" />
139 {t("courses.assignTeacher")}130 {t("courses.assignTeacher")}
140 </Button>131 </Button>
@@ -147,9 +138,9 @@ export function CourseTeachersPanel(props: {
147 </Show>138 </Show>
148 139
149 <SidePanel140 <SidePanel
150- open={showAssignPanel()}141+ open={props.assignOpen}
151 onOpenChange={(open) => {142 onOpenChange={(open) => {
152- setShowAssignPanel(open);143+ props.onAssignOpenChange(open);
153 if (!open) {144 if (!open) {
154 setSelectedTeacherId("");145 setSelectedTeacherId("");
155 setError("");146 setError("");
@@ -177,7 +168,7 @@ export function CourseTeachersPanel(props: {
177 <Button168 <Button
178 type="button"169 type="button"
179 variant="outline"170 variant="outline"
180- onClick={() => setShowAssignPanel(false)}171+ onClick={() => props.onAssignOpenChange(false)}
181 disabled={pending()}172 disabled={pending()}
182 >173 >
183 {t("common.cancel")}174 {t("common.cancel")}
src/pages/course-detail-page.tsxmodified+12 -1
@@ -68,6 +68,7 @@ function CourseDetailContent() {
68 return params().id;68 return params().id;
69 });69 });
70 70
71+ const [openSections, setOpenSections] = createSignal({ teachers: false, subjects: false, exams: false, sessions: false, roster: false });
71 const [course, { refetch: refetchCourse }] = createResource(id, (courseId) => getCourseById(courseId));72 const [course, { refetch: refetchCourse }] = createResource(id, (courseId) => getCourseById(courseId));
72 const [terms] = createResource(async () => (await getTerms()).items);73 const [terms] = createResource(async () => (await getTerms()).items);
73 const [settings] = createResource(() => getSettings());74 const [settings] = createResource(() => getSettings());
@@ -113,8 +114,8 @@ function CourseDetailContent() {
113 const [createdCourseExam, setCreatedCourseExam] = createSignal<Exam | null>(null);114 const [createdCourseExam, setCreatedCourseExam] = createSignal<Exam | null>(null);
114 const [showSubjectForm, setShowSubjectForm] = createSignal(false);115 const [showSubjectForm, setShowSubjectForm] = createSignal(false);
115 const [showSessionForm, setShowSessionForm] = createSignal(false);116 const [showSessionForm, setShowSessionForm] = createSignal(false);
117+ const [showTeacherForm, setShowTeacherForm] = createSignal(false);
116 const [showEnrollPanel, setShowEnrollPanel] = createSignal(false);118 const [showEnrollPanel, setShowEnrollPanel] = createSignal(false);
117- const [openSections, setOpenSections] = createSignal({ teachers: false, subjects: false, exams: false, sessions: false, roster: false });
118 const [subjectCount, setSubjectCount] = createSignal(0);119 const [subjectCount, setSubjectCount] = createSignal(0);
119 const [sessionCount, setSessionCount] = createSignal(0);120 const [sessionCount, setSessionCount] = createSignal(0);
120 const [enrollUserId, setEnrollUserId] = createSignal("");121 const [enrollUserId, setEnrollUserId] = createSignal("");
@@ -557,11 +558,21 @@ function CourseDetailContent() {
557 onToggle={() => toggleSection("teachers")}558 onToggle={() => toggleSection("teachers")}
558 title={t("courses.teachers")}559 title={t("courses.teachers")}
559 description={countDescription((c().teachers ?? []).length, t("courses.teachers"))}560 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+ }
560 >569 >
561 <CourseTeachersPanel570 <CourseTeachersPanel
562 courseId={id()}571 courseId={id()}
563 teachers={c().teachers ?? []}572 teachers={c().teachers ?? []}
564 canStaff={canStaffCourse()}573 canStaff={canStaffCourse()}
574+ assignOpen={showTeacherForm()}
575+ onAssignOpenChange={setShowTeacherForm}
565 onCourseUpdated={refetchCourse}576 onCourseUpdated={refetchCourse}
566 />577 />
567 </SectionDisclosure>578 </SectionDisclosure>