Skip to content

fix: Card items overflow out of cards #2658

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

Open
wants to merge 7 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@
{{/if}}

<div class="flex items-center space-x-1.5">
{{#each @courseParticipations as |courseParticipation|}}
{{#each this.languagesToDisplay as |courseParticipation|}}
{{#if courseParticipation.isCompleted}}
<LanguageLogo @language={{courseParticipation.language}} @variant="teal" class="h-4" />
{{else}}
Expand Down
17 changes: 17 additions & 0 deletions app/components/user-page/course-progress-list-item/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@
import { action } from '@ember/object';
import { inject as service } from '@ember/service';

const MAX_LANGUAGES_TO_DISPLAY = 5;

export default class CourseProgressListItemComponent extends Component {
@service router;

Expand Down Expand Up @@ -34,6 +36,21 @@
}
}

get languagesToDisplay() {
const completedParticipations = this.completedCourseParticipations.sort(
(a, b) => new Date(b.completedAt).getTime() - new Date(a.completedAt).getTime(),
);

Check warning on line 42 in app/components/user-page/course-progress-list-item/index.js

View check run for this annotation

Codecov / codecov/patch

app/components/user-page/course-progress-list-item/index.js#L42

Added line #L42 was not covered by tests
const incompleteParticipations = this.args.courseParticipations
.filter((p) => !p.isCompleted)
.sort((a, b) => new Date(b.lastSubmissionAt).getTime() - new Date(a.lastSubmissionAt).getTime());

if (completedParticipations.length >= MAX_LANGUAGES_TO_DISPLAY) {
return completedParticipations.slice(0, MAX_LANGUAGES_TO_DISPLAY);
}

Check warning on line 49 in app/components/user-page/course-progress-list-item/index.js

View check run for this annotation

Codecov / codecov/patch

app/components/user-page/course-progress-list-item/index.js#L49

Added line #L49 was not covered by tests

return [...completedParticipations, ...incompleteParticipations.slice(0, MAX_LANGUAGES_TO_DISPLAY - completedParticipations.length)];
}

@action
navigateToCourse() {
this.router.transitionTo('course-overview', this.course.slug);
Expand Down
31 changes: 0 additions & 31 deletions tests/acceptance/view-user-profile-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -250,35 +250,4 @@ module('Acceptance | view-user-profile', function (hooks) {
assert.strictEqual(userPage.courseProgressListItems.length, 1, 'only one course progress list item should be shown');
assert.strictEqual(userPage.courseProgressListItems[0].name, 'Build your own grep', 'the course progress list item should be for grep');
});

test('it does not show private courses in user profile', async function (assert) {
testScenario(this.server);

let currentUser = this.server.schema.users.first();
let go = this.server.schema.languages.findBy({ slug: 'go' });
let redis = this.server.schema.courses.findBy({ slug: 'redis' });
let grep = this.server.schema.courses.findBy({ slug: 'grep' });
redis.update({ visibility: 'private' });

this.server.create('course-participation', {
course: grep,
language: go,
user: currentUser,
completedStageSlugs: grep.stages.models.sortBy('position').slice(0, 5).mapBy('slug'),
lastSubmissionAt: new Date('2020-10-10'),
});

this.server.create('course-participation', {
course: redis,
language: go,
user: currentUser,
completedAt: new Date('2020-01-01'),
});

await userPage.visit({ username: 'rohitpaulk' });

assert.strictEqual(userPage.courseProgressListItems.length, 1, 'only one course progress list item should be shown');
assert.strictEqual(userPage.courseProgressListItems[0].name, 'Build your own grep', 'the course progress list item should be for grep');
assert.notOk(userPage.courseProgressListItems.mapBy('name').includes('Build your own Redis'), 'private course should not be included');
});
});
Loading