Skip to content
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

fix(pull request): button for comments display #86

Merged
merged 1 commit into from
Oct 23, 2020
Merged
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
37 changes: 22 additions & 15 deletions src/components/CommentsCounter/CommentsCounter.scss
Original file line number Diff line number Diff line change
@@ -1,20 +1,27 @@
.skz-comments-counter {
font-size: 0.8rem;
color: #aaa;
animation: fadeIn 0.2s;
font-size: 0.8rem;
color: #aaa;
animation: fadeIn 0.2s;
padding: 0.2rem 0.5rem;
border-radius: 4px;
transition: background-color linear 0.2s;

&:after {
content: '\EA4C';
margin-left: 0.25rem;
font-family: 'Icons';
vertical-align: bottom;
}
&:after {
content: '\EA4C';
margin-left: 0.25rem;
font-family: 'Icons';
vertical-align: bottom;
}

&--all-resolved {
color: #9fd9b4;
}
&--all-resolved {
color: #9fd9b4;
}

&--responses {
color: #d87c7c;
}
&--responses {
color: #d87c7c;
}

&:hover {
background-color: #eee;
}
}
35 changes: 21 additions & 14 deletions src/components/CommentsCounter/CommentsCounter.svelte
Original file line number Diff line number Diff line change
@@ -1,23 +1,30 @@
<script>
export let comments = [];
export let hasResponse;
export let comments = [];
export let hasResponse;
export let action;

const isDisplayed = comments && comments.length > 0;
const isCommentResolved = ({ status }) =>
status && status !== 'active' && status !== 'pending';
const commentsResolved =
comments.filter(isCommentResolved).length === comments.length;
const classModifier = commentsResolved
? 'skz-comments-counter--all-resolved'
: hasResponse
? 'skz-comments-counter--responses'
: '';
const isDisplayed = comments && comments.length > 0;
const isCommentResolved = ({ status }) =>
status && status !== 'active' && status !== 'pending';
const commentsResolved =
comments.filter(isCommentResolved).length === comments.length;
const classModifier = commentsResolved
? 'skz-comments-counter--all-resolved'
: hasResponse
? 'skz-comments-counter--responses'
: '';

const onClick = e => {
e.preventDefault();
action();
};
</script>

<style src="./CommentsCounter.scss">

</style>

{#if isDisplayed}
<p class={`skz-comments-counter ${classModifier}`}>{comments.length}</p>
<p on:click={onClick} class={`skz-comments-counter ${classModifier}`}>
{comments.length}
</p>
{/if}
15 changes: 12 additions & 3 deletions src/components/Pullrequest/Pullrequest.svelte
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
<script>
const { shell } = require('electron');
import { getContext } from 'svelte';
import { get } from 'svelte/store';
import { getAvatar, fetchPullRequestComments } from '../../shared/requester';
Expand Down Expand Up @@ -96,6 +97,12 @@
open,
);

const openUrl = e => {
if (!e.target.className.includes('skz-comments-counter')) {
shell.openExternal(makeUrl(pullRequest));
}
};

const getAvatarUrl = pr =>
getAvatar(pr.createdBy.id, pr.organizationName, pr.createdBy.descriptor);

Expand All @@ -115,10 +122,9 @@
</script>

<style src="./Pullrequest.scss">

</style>

<div class="skz-pullrequest" on:click={openModal}>
<div class="skz-pullrequest" on:click={openUrl}>
<div class="skz-pullrequest__avatar">
{#await getAvatarUrl(pullRequest)}
<img
Expand Down Expand Up @@ -185,7 +191,10 @@
<h1 class="skz-pullrequest__mention">@</h1>
{/if}
<div>
<CommentsCounter {comments} hasResponse={hasResponse()} />
<CommentsCounter
action={openModal}
{comments}
hasResponse={hasResponse()} />
</div>
{/await}
</div>
Expand Down