Skip to content

Commit

Permalink
normal commit
Browse files Browse the repository at this point in the history
  • Loading branch information
Peng Kaifan committed Aug 24, 2020
1 parent eeaf277 commit 9bae9bf
Show file tree
Hide file tree
Showing 8 changed files with 94 additions and 43 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@
<EditorHeader class="editor-header" v-if="changedFiles.data.length > 0 && repoOwnerType() == 'User'">
Submit your review
</EditorHeader>
<ReviewSubmitter v-if="changedFiles.data.length > 0 && repoOwnerType() == 'User'"></ReviewSubmitter>
<ReviewSubmitter v-if="changedFiles.data.length > 0 && repoOwnerType() == 'User'" @review-submitted.native.stop="reviewSubmittedHook"></ReviewSubmitter>

<!-- <Editor v-if="changedFiles.data.length > 0"
class="m-3"
Expand Down Expand Up @@ -381,7 +381,17 @@
pendingReviewCommentDeletedEventHandler(){
this.network_getPendingReview()
},
reviewSubmittedHook(payload) {
this.dirty = true
this.$router.push(`/${this.owner}/${this.repo}/pull/${this.number}?new_created_timeline_item=${payload.detail.id}`)
}
},
async activated() {
if(this.dirty) {
this.pendingReview.reviewComments = []
await this.network_getPendingReview()
this.dirty = false
}
},
components: {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<template>
<Container v-if="!deleted" class="p-3">
<Container v-if="!deleted" class="p-3 position-relative">
<div class="bubble m-0 bg-white">
<HideAndShowPane v-if="extraData.isMinimized" class="p-3 d-flex flex-justify-between p-3 text-gray text-small border-bottom">
<span class="text-italic">
Expand Down Expand Up @@ -183,10 +183,8 @@
}
}
)
console.log(this.extraData.state)
if(this.extraData.state == 'PENDING') {
await this.pendingReviewGetter()()
console.log('pendingReviewGetter finish!!')
}else{
await this.reviewCommentDeletedHook()()
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
import * as api from '@/network/api'
import * as graphql from '../../graphql.js'
export default {
inject: ['pendingReview','pendingReviewGetter','reviewCommentCreatedHook'],
inject: ['pendingReview','pendingReviewGetter','reviewCommentCreatedHook','pullRequestProvided'],
props: {
comment: Object,
path: String,
Expand Down Expand Up @@ -164,9 +164,6 @@
]
}
)
return res.data
}
},
components: {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,9 @@
}
)
this.$router.push(`/${this.owner}/${this.repo}/pull/${this.number}?new_created_timeline_item=${res.data.id}`)
let event = new CustomEvent('review-submitted',{bubbles:true,detail:res.data})
} catch (e) {
this.handleError(e)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,8 @@
async network_createCommentReview() {
try {
this.loadingAddComment = true
let reviewCreated = await this.network_createReview('COMMENT')
await this.network_createReview('COMMENT')
await this.commentReviewCreatedHook()()
this.content = ''
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
<template>
<Container class="flex-grow-1">
<CommonLoadingWrapper :loading="pullRequestProvided().loading || timeline.loading || timeline.extraData.loading || reviewCommentReplies.loading"
:position="pullRequestProvided().loading ? 'center' : 'corner'"
class="flex-grow-1">
<Header class="px-3 pt-3">
<!-- <HeaderActions class="d-flex flex-justify-between flex-items-center">
<State class="State mr-2 d-inline-flex flex-items-center"
Expand Down Expand Up @@ -85,15 +87,14 @@
</div>
</transition-group>

<HiddenItemLoading v-if="(timeline.pageInfo.next && timeline.pageInfo.next.page != timeline.pageInfo.last.page) || timeline.loading"
<HiddenItemLoading v-if="(timeline.pageInfo.next || timeline.loading) && !timeline.data.includes(timeline.newestTimeline[0])"
class="border-top"
:loading="timeline.loading"
:dataGetter="loadingMore">
<span v-if="timelineRemainedCount > 0">{{timelineRemainedCount}} {{timelineRemainedCount > 1 ? 'items' : 'item'}} remained.</span>
</HiddenItemLoading>

<transition-group tag="div" appear name="fade-group">
<div v-for="(item,index) in timeline.newestTimeline.data" :key="(item.id || '') + index">
<div v-for="(item,index) in timeline.newestTimeline.filter(i => !timeline.newestTimeline.includes(i))" :key="(item.id || '') + index">
<TimelineItem :data="item" class="border-top" style="background:#fafbfc"/>
</div>
</transition-group>
Expand Down Expand Up @@ -148,12 +149,6 @@

</div>

<transition name="fade" appear>
<CommonLoading v-if="!pullRequestProvided().data.node_id || timeline.loading || timeline.extraData.loading || reviewCommentReplies.loading"
:preventClickEvent="false"
:position="loading ? 'center' : 'corner'"/>
</transition>

<transition name="fade" appear>
<StickyTop v-if="scrollTop > 300" class="sticky-top px-3 py-2">
<StickyTopContent class="d-flex flex-items-center flex-justify-between">
Expand Down Expand Up @@ -182,12 +177,12 @@
</StickyTop>
</transition>

</Container>
</CommonLoadingWrapper>
</template>

<script>
import styled from 'vue-styled-components'
import {CommonLoading,Label,AnimatedHeightWrapper,ImgWrapper,LoadingIconEx,Progress,IssueIcon,Subscription,SkeletonCircle,SkeletonRectangle} from '@/components'
import {CommonLoadingWrapper,Label,AnimatedHeightWrapper,ImgWrapper,LoadingIconEx,Progress,IssueIcon,Subscription,SkeletonCircle,SkeletonRectangle} from '@/components'
import {ScrollTopListenerMixin,RouteUpdateAwareMixin} from '@/mixins'
import {TimelineItem,Comment,HiddenItemLoading,PullRequestCommentCreator,ProjectCard,PullRequestBody} from './components'
import {IssueNotificationSettingPane,LockIssueButton} from '../../../components'
Expand Down Expand Up @@ -235,10 +230,7 @@
data: 0,
loading: false
},
newestTimeline: {
data: [],
loading: false
}
newestTimeline: []
},
timelineTypes: [
{
Expand Down Expand Up @@ -338,7 +330,6 @@
rest:'review_requested',
}
],
commentsJustCreated: []
}
},
Expand Down Expand Up @@ -469,10 +460,12 @@
if(res_timeline.data.length > 0) this.network_getTimelineExtraData(res_timeline.data)
if(this.timeline.pageInfo.next && this.timeline.pageInfo.next.page == 2) {
/* if(this.timeline.pageInfo.next && this.timeline.pageInfo.next.page == 2) {
await this.network_getNewestTimeline()
}
*/
if(this.newCreatedTimelineItem) this.scrollToNewestTimelineItem()
}catch(e){
Expand All @@ -482,7 +475,7 @@
this.timeline.extraData.loading = false
}
},
async network_getNewestTimeline() {
/* async network_getNewestTimeline() {
try{
this.timeline.newestTimeline.loading = true
let url_timeline = api.API_ISSUE_TIMELINE({
Expand Down Expand Up @@ -515,6 +508,42 @@
}finally{
this.timeline.newestTimeline.loading = false
}
}, */
async network_getNewestTimeline() {
let url_pageInfo = api.API_ISSUE_TIMELINE({
repo: this.repo,
owner: this.owner,
number: this.number,
params: {
per_page: 1
}
})
let res_pageInfo = await authRequiredGet(
url_pageInfo,
{
headers: {
"accept": "application/vnd.github.mockingbird-preview"
}
}
)
let pageInfo = parse(res_pageInfo.headers.link) || {}
if(!pageInfo.last) return
let url = pageInfo.last.url
let res = await authRequiredGet(
url,
{
headers: {
"accept": "application/vnd.github.mockingbird-preview"
}
}
)
return res.data[0]
},
async network_getTimelineExtraData(timeline) {
let ids = timeline && timeline.map(i => i.node_id).filter(i => i)
Expand Down Expand Up @@ -761,23 +790,27 @@
theEl && theEl.scrollIntoView({block:'center'})
},0)
}
}
},
},
watch: {
newCreatedTimelineItem(newOne, oldOne) {
if(this.timeline.data.length > 0 && !this.timeline.pageInfo.next) {
this.scrollToTop()
this.network_getTimeline()
return
}
if(this.timeline.pageInfo.last) {
this.scrollToTop()
this.network_getNewestTimeline()
}
async newCreatedTimelineItem(newOne, oldOne) {
try{
this.timeline.data.length > 0 && this.timeline.data.forEach((item,index) => {
if(item.node_id == newOne) {
this.timeline.data.splice(index,1)
throw new Error('forEach abort')
}
})
}catch(e) {}
this.scrollToTop()
let newestTimeline = await this.network_getNewestTimeline()
newestTimeline && this.timeline.newestTimeline.push(newestTimeline)
}
},
components: {
CommonLoading,
CommonLoadingWrapper,
Label,
Comment,
TimelineItem,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@
</BodyHTML>
</Body>

<LoadingWrapper v-if="comments.loading" class="loading-wrapper py-3 d-flex flex-justify-center flex-items-center">
<LoadingWrapper v-if="comments.loading" class="loading-wrapper pt-3 d-flex flex-justify-center flex-items-center">
Loading...
</LoadingWrapper>

Expand Down
11 changes: 11 additions & 0 deletions src/pages/Repository/PullRequests/PullRequestDetail/graphql.js
Original file line number Diff line number Diff line change
Expand Up @@ -293,4 +293,15 @@ export const GRAPHQL_PULL_TIMELINE = `
}
}
}
`

export const GRAPHQL_ADD_PULL_REQUEST_REVIEW = `
mutation($input:AddPullRequestReviewInput!) {
addPullRequestReview(input:$input) {
pullRequestReview {
databaseId
state
}
}
}
`

0 comments on commit 9bae9bf

Please sign in to comment.