Skip to content

Kaitie/add resoruces button#71741

Open
kobryan0619 wants to merge 3 commits intostagingfrom
kaitie/add-resoruces-button
Open

Kaitie/add resoruces button#71741
kobryan0619 wants to merge 3 commits intostagingfrom
kaitie/add-resoruces-button

Conversation

@kobryan0619
Copy link
Copy Markdown
Contributor

Links

  • Jira:

Testing story

Deployment notes

Privacy and security

Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Adds a “Lesson Resources” button (linking to student_lesson_plan_html_url) to progress UI, and introduces an isOnLevelView flag to suppress that button when progress is rendered in the level/header MiniView.

Changes:

  • Add Lesson Resources button rendering in SummaryProgressRow and gate resources buttons on !isOnLevelView.
  • Thread isOnLevelView through ProgressTable → group/table/row components and set it in MiniView.
  • Add/extend unit tests for the new resources-button behavior.

Reviewed changes

Copilot reviewed 9 out of 9 changed files in this pull request and generated 3 comments.

Show a summary per file
File Description
apps/test/unit/templates/progress/SummaryProgressRowTest.js Adds tests asserting resources button presence/absence.
apps/test/unit/templates/progress/ProgressLessonTest.js Adds a test asserting resources button hidden when isOnLevelView is true.
apps/src/templates/progress/SummaryProgressTable.jsx Accepts and forwards isOnLevelView to rows.
apps/src/templates/progress/SummaryProgressRow.jsx Adds resources button to summary rows; introduces layout styles and isOnLevelView gating.
apps/src/templates/progress/ProgressTable.jsx Accepts isOnLevelView and forwards it (currently only to summary table in one branch).
apps/src/templates/progress/ProgressLesson.jsx Hides existing resources button when isOnLevelView is true.
apps/src/templates/progress/LessonGroup.jsx Forwards isOnLevelView to the selected table type.
apps/src/templates/progress/DetailProgressTable.jsx Accepts/forwards isOnLevelView to ProgressLesson.
apps/src/code-studio/components/progress/MiniView.jsx Passes isOnLevelView={true} into ProgressTable.
Comments suppressed due to low confidence (1)

apps/src/templates/progress/ProgressTable.jsx:63

  • isOnLevelView is passed to SummaryProgressTable in this branch but not to DetailProgressTable, so when the table is toggled to detail view (and especially in MiniView) ProgressLesson will still render the Lesson Resources button. Pass isOnLevelView={isOnLevelView} through here as well so both summary and detail views consistently hide/show resources.
            <SummaryProgressTable
              groupedLesson={groupedLessons[0]}
              minimal={minimal}
              isOnLevelView={isOnLevelView}
            />
          </div>
          <div style={isSummaryView ? styles.hidden : {}}>
            <DetailProgressTable groupedLesson={groupedLessons[0]} />
          </div>

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines +84 to +117
it('shows lesson resources button when lesson has student_lesson_plan_html_url', () => {
const lessonWithUrl = {
...fakeLesson('Maze', 1, false, 3),
student_lesson_plan_html_url: 'https://example.com/lesson-plan',
};
const wrapper = setUp({
lesson: lessonWithUrl,
});

const button = wrapper.find('Button');
expect(button).toHaveLength(1);
expect(button.props().href).toEqual('https://example.com/lesson-plan');
expect(button.props().className).toEqual('ui-test-lesson-resources');
});

it('does not show lesson resources button when lesson has no student_lesson_plan_html_url', () => {
const wrapper = setUp();

expect(wrapper.find('Button')).toHaveLength(0);
});

it('does not show lesson resources button when lesson has student_lesson_plan_html_url and isOnLevelView is true', () => {
const lessonWithUrl = {
...fakeLesson('Maze', 1, false, 3),
student_lesson_plan_html_url: 'https://example.com/lesson-plan',
};
const wrapper = setUp({
lesson: lessonWithUrl,
isOnLevelView: true,
});

const button = wrapper.find('Button');
expect(button).toHaveLength(0);
});
Copy link

Copilot AI Mar 27, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These new tests are under describe('when viewing as Participant'), but they don't set viewAs: ViewType.Participant (baseProps defaults to Instructor). If the intent is to validate participant-only behavior, explicitly set viewAs for these cases (and consider adding a complementary instructor assertion, consistent with ProgressLesson).

Copilot uses AI. Check for mistakes.
Comment on lines +321 to +333
it('does not show Lesson Resources button when viewing as a participant and student_lesson_plan_html_url is not null, and isOnLevelView is true', () => {
let myLesson = defaultProps.lesson;
myLesson.student_lesson_plan_html_url = 'test-url';
const wrapper = shallow(
<ProgressLesson
{...defaultProps}
lesson={myLesson}
viewAs={ViewType.Participant}
isOnLevelView={true}
/>
);
expect(wrapper.find('Button').length).toEqual(0);
});
Copy link

Copilot AI Mar 27, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This test mutates defaultProps.lesson in-place (let myLesson = defaultProps.lesson; myLesson.student_lesson_plan_html_url = ...) and doesn't clean it up. That can leak state across tests, especially when an assertion fails mid-test. Prefer cloning ({...defaultProps.lesson, student_lesson_plan_html_url: 'test-url'}) or deleting the property in a finally/afterEach.

Copilot uses AI. Check for mistakes.
Comment on lines +131 to +142
{lesson.student_lesson_plan_html_url && !isOnLevelView && (
<Button
__useDeprecatedTag
className="ui-test-lesson-resources"
href={lesson.student_lesson_plan_html_url}
text={i18n.lessonResources()}
icon="file-text"
color="white"
target="_blank"
style={styles.buttonStyle}
/>
)}
Copy link

Copilot AI Mar 27, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The Lesson Resources button here is gated only on student_lesson_plan_html_url and !isOnLevelView, so it will also appear for instructors. ProgressLesson gates the same button on viewAs === ViewType.Participant; consider adding the same viewAs check here to keep behavior consistent between summary and detail progress views.

Suggested change
{lesson.student_lesson_plan_html_url && !isOnLevelView && (
<Button
__useDeprecatedTag
className="ui-test-lesson-resources"
href={lesson.student_lesson_plan_html_url}
text={i18n.lessonResources()}
icon="file-text"
color="white"
target="_blank"
style={styles.buttonStyle}
/>
)}
{lesson.student_lesson_plan_html_url &&
!isOnLevelView &&
viewAs === ViewType.Participant && (
<Button
__useDeprecatedTag
className="ui-test-lesson-resources"
href={lesson.student_lesson_plan_html_url}
text={i18n.lessonResources()}
icon="file-text"
color="white"
target="_blank"
style={styles.buttonStyle}
/>
)}

Copilot uses AI. Check for mistakes.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants