Skip to content

Commit

Permalink
Refactor feature flag checks for stage 2 solutions to improve logic c…
Browse files Browse the repository at this point in the history
…larity.
  • Loading branch information
rohitpaulk committed Nov 16, 2024
1 parent 6c06114 commit d45b2d2
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 2 deletions.
3 changes: 2 additions & 1 deletion app/controllers/course/stage/instructions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -61,8 +61,9 @@ export default class CourseStageInstructionsController extends Controller {
return !!this.prerequisiteInstructionsMarkdown;
}

// Check for solution first so that we don't trigger "Feature flag called" events when solutions aren't present
get shouldShowStage2Solution() {
return this.featureFlags.canSeeSolutionsForStage2 && !!this.model.activeRepository.secondStageSolution;
return !!this.model.activeRepository.secondStageSolution && this.featureFlags.canSeeSolutionsForStage2;
}

get shouldShowTestRunnerCard() {
Expand Down
3 changes: 2 additions & 1 deletion app/services/feature-flags.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,9 @@ export default class FeatureFlagsService extends Service {
return this.currentUser && (this.currentUser.isStaff || this.currentUser.isConceptAuthor);
}

// Check for staff first so that we don't trigger "Feature flag called" events for staff users
get canSeeSolutionsForStage2() {
return this.getFeatureFlagValue('can-see-solutions-for-stage-2') === 'test' || this.currentUser?.isStaff;
return this.currentUser?.isStaff || this.getFeatureFlagValue('can-see-solutions-for-stage-2') === 'test';
}

get currentUser() {
Expand Down

0 comments on commit d45b2d2

Please sign in to comment.