Skip to content

Commit 153a2c7

Browse files
authored
Merge pull request #3001 from codecrafters-io/refactor/update-course-stage-slug
refactor: update course stage identifier to use slug format
2 parents 170845b + 933844b commit 153a2c7

File tree

8 files changed

+8
-19
lines changed

8 files changed

+8
-19
lines changed

app/components/course-admin/stage-insights-page/header.hbs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
<div class="flex flex-col items-end">
1919
<LinkTo
2020
@route="course.stage.instructions"
21-
@models={{array @stage.course.slug @stage.identifierForURL}}
21+
@models={{array @stage.course.slug @stage.slug}}
2222
class="text-gray-400 flex items-center hover:text-gray-600"
2323
target="_blank"
2424
rel="noopener noreferrer"

app/components/track-page/course-card/stage-list-item.hbs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<LinkTo
22
@route="course.stage.instructions"
3-
@models={{array @stage.course.slug @stage.identifierForURL}}
3+
@models={{array @stage.course.slug @stage.slug}}
44
class="block hover:bg-gray-50 dark:hover:bg-gray-700/50 py-1.5 -mx-1.5 px-1.5 rounded-sm"
55
data-test-stage-list-item
66
...attributes

app/models/course-stage.ts

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -70,10 +70,6 @@ export default class CourseStageModel extends Model {
7070
return this.screencasts.length > 0;
7171
}
7272

73-
get identifierForURL() {
74-
return this.slug;
75-
}
76-
7773
get isBaseStage() {
7874
return !this.primaryExtensionSlug;
7975
}

app/router.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -50,8 +50,7 @@ Router.map(function () {
5050
this.route('introduction');
5151
this.route('setup');
5252

53-
// Stage identifier either be '1' (for base stages) or 'ext2:1' (for extension stages)
54-
this.route('stage', { path: '/stages/:stage_identifier' }, function () {
53+
this.route('stage', { path: '/stages/:stage_slug' }, function () {
5554
this.route('code-examples');
5655
this.route('concepts');
5756
this.route('instructions', { path: '/' });

app/routes/course/stage.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ export default class CourseStageRoute extends BaseRoute {
2424
async model(params) {
2525
const courseRouteModel = this.modelFor('course');
2626

27-
const courseStage = courseRouteModel.course.stages.find((courseStage) => courseStage.identifierForURL === params.stage_identifier);
27+
const courseStage = courseRouteModel.course.stages.find((courseStage) => courseStage.slug === params.stage_slug);
2828

2929
return {
3030
courseStage: courseStage,

app/services/course-page-state.ts

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -51,12 +51,11 @@ export default class CoursePageStateService extends Service {
5151
} else if (this.router.currentRouteName && this.router.currentRouteName.startsWith('course.stage')) {
5252
const courseStageRoute = this.router.currentRoute.find((route: { name: string }) => route.name === 'course.stage');
5353

54-
const routeParams = courseStageRoute!.params as { stage_identifier: string };
55-
const stageIdentifier = routeParams.stage_identifier;
54+
const routeParams = courseStageRoute!.params as { stage_slug: string };
5655

5756
return (
5857
this.stepList!.steps.find(
59-
(step) => step.type === 'CourseStageStep' && (step as CourseStageStep).courseStage.identifierForURL === stageIdentifier,
58+
(step) => step.type === 'CourseStageStep' && (step as CourseStageStep).courseStage.slug === routeParams.stage_slug,
6059
) || null
6160
);
6261
} else {

app/templates/course-admin/code-example.hbs

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,7 @@
11
<div class="bg-white min-h-screen">
22
<div class="container mx-auto pt-4 pb-10 px-6">
33
<div class="py-3 border-b border-gray-200 mb-6">
4-
<TertiaryLinkButton
5-
@route="course.stage.code-examples"
6-
@models={{array @model.solution.courseStage.identifierForURL}}
7-
@size="small"
8-
class="pl-1.5 mb-3"
9-
>
4+
<TertiaryLinkButton @route="course.stage.code-examples" @models={{array @model.solution.courseStage.slug}} @size="small" class="pl-1.5 mb-3">
105
<div class="flex items-center">
116
{{svg-jar "arrow-circle-left" class="w-4 h-4 mr-1.5 text-gray-500"}}
127

app/utils/course-page-step-list/course-stage-step.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -121,7 +121,7 @@ Check the [How to pass this stage](#first-stage-tutorial-card) section for instr
121121
get routeParams() {
122122
return {
123123
route: 'course.stage.instructions',
124-
models: [this.courseStage.course.slug, this.courseStage.identifierForURL],
124+
models: [this.courseStage.course.slug, this.courseStage.slug],
125125
};
126126
}
127127

0 commit comments

Comments
 (0)