-
Notifications
You must be signed in to change notification settings - Fork 13
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
intro cleanup proto #2472
base: main
Are you sure you want to change the base?
intro cleanup proto #2472
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
<div ...attributes> | ||
<div class="prose dark:prose-invert mb-4"> | ||
<p> | ||
Welcome to the | ||
{{@repository.course.name}} | ||
challenge! | ||
</p> | ||
|
||
{{markdown-to-html @repository.course.descriptionMarkdown}} | ||
</div> | ||
|
||
<CoursePage::IntroductionStep::Legacy::CreateRepositoryCard::SelectLanguageSection | ||
@preferredLanguageSlug={{undefined}} | ||
@errorMessage={{undefined}} | ||
@repository={{@repository}} | ||
@onLanguageSelection={{this.handleLanguageSelection}} | ||
/> | ||
</div> |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
import * as Sentry from '@sentry/ember'; | ||
import Component from '@glimmer/component'; | ||
import LanguageModel from 'codecrafters-frontend/models/language'; | ||
import type RepositoryModel from 'codecrafters-frontend/models/repository'; | ||
import type RouterService from '@ember/routing/router-service'; | ||
import { action } from '@ember/object'; | ||
import { service } from '@ember/service'; | ||
import { tracked } from '@glimmer/tracking'; | ||
|
||
export interface Signature { | ||
Element: HTMLDivElement; | ||
|
||
Args: { | ||
repository: RepositoryModel; | ||
}; | ||
} | ||
|
||
export default class WelcomeSectionComponent extends Component<Signature> { | ||
@service declare router: RouterService; | ||
|
||
@tracked repositoryCreationErrorMessage?: string; | ||
|
||
@action | ||
async handleLanguageSelection(language: LanguageModel) { | ||
this.repositoryCreationErrorMessage = undefined; | ||
this.args.repository.language = language; | ||
|
||
try { | ||
await this.args.repository.save(); // TODO: This is kinda slow, investigate ways to make it faster | ||
} catch (error) { | ||
this.args.repository.language = undefined; | ||
this.repositoryCreationErrorMessage = | ||
'Failed to create repository, please try again? Contact us at [email protected] if this error persists.'; | ||
Sentry.captureException(error); | ||
|
||
return; | ||
} | ||
Comment on lines
+28
to
+37
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🛠️ Refactor suggestion Enhance error handling and user feedback The error handling could be improved in several ways:
try {
await this.args.repository.save();
} catch (error) {
this.args.repository.language = undefined;
+ const errorMessage = error instanceof Error ? error.message : 'Unknown error occurred';
this.repositoryCreationErrorMessage =
- 'Failed to create repository, please try again? Contact us at [email protected] if this error persists.';
+ `Failed to create repository: ${errorMessage}. Your language selection has been reset. Please try again or contact us at [email protected] if this error persists.`;
Sentry.captureException(error);
+
+ // Log additional context for debugging
+ Sentry.setContext("repository", {
+ id: this.args.repository.id,
+ selectedLanguage: language.id
+ });
return;
}
|
||
|
||
// this.expandNextSection(); | ||
|
||
this.router.transitionTo({ queryParams: { repo: this.args.repository.id, track: null } }); | ||
} | ||
} | ||
|
||
declare module '@glint/environment-ember-loose/registry' { | ||
export default interface Registry { | ||
'CoursePage::IntroductionStep::WelcomeSection': typeof WelcomeSectionComponent; | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
import Controller from '@ember/controller'; | ||
import { inject as service } from '@ember/service'; | ||
import type AuthenticatorService from 'codecrafters-frontend/services/authenticator'; | ||
import type CoursePageStateService from 'codecrafters-frontend/services/course-page-state'; | ||
import type { ModelType as CourseRouteModelType } from 'codecrafters-frontend/routes/course'; | ||
import type Step from 'codecrafters-frontend/utils/course-page-step-list/step'; | ||
|
||
export default class PreChallengeAssessmentController extends Controller { | ||
declare model: CourseRouteModelType; | ||
|
||
@service declare authenticator: AuthenticatorService; | ||
@service declare coursePageState: CoursePageStateService; | ||
|
||
get currentStep(): Step { | ||
return this.coursePageState.currentStep as Step; | ||
} | ||
Comment on lines
+14
to
+16
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🛠️ Refactor suggestion Add type safety checks for currentStep getter The type casting with Consider adding type guards and error handling: get currentStep(): Step {
- return this.coursePageState.currentStep as Step;
+ const step = this.coursePageState.currentStep;
+ if (!step) {
+ throw new Error('Current step is not defined');
+ }
+ if (!(step instanceof Step)) {
+ throw new Error('Current step is not a valid Step instance');
+ }
+ return step;
}
|
||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
<CoursePage::CurrentStepCompleteOverlay @currentStep={{this.currentStep}}> | ||
<div class="w-full pt-8 pb-32 px-3 md:px-6 lg:px-10"> | ||
<div class="prose dark:prose-invert mb-4"> | ||
Complete the pre-challenge assessment below to proceed: | ||
</div> | ||
|
||
<CoursePage::IntroductionStep::Legacy::CreateRepositoryCard | ||
@repository={{@model.activeRepository}} | ||
@preferredLanguageSlug={{undefined}} | ||
class="mb-6" | ||
/> | ||
</div> | ||
</CoursePage::CurrentStepCompleteOverlay> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
💡 Codebase verification
Performance concern identified in multiple repository save operations
The same TODO comment about slow repository saves appears in two locations:
app/components/course-page/introduction-step/welcome-section.ts
app/components/course-page/introduction-step/legacy/create-repository-card.ts
The codebase shows extensive use of repository saves across different components, suggesting this is a systemic performance concern that deserves attention. Since this appears in both current and legacy code paths, it likely affects user experience during course initialization.
🔗 Analysis chain
Address TODO comment about slow repository save
The TODO comment indicates a performance issue that should be investigated.
Would you like me to help create a GitHub issue to track this performance investigation?
🏁 Scripts executed
The following scripts were executed for the analysis:
Script:
Length of output: 40
Script:
Length of output: 9080