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 28, 2020
1 parent 9bae9bf commit e588167
Show file tree
Hide file tree
Showing 12 changed files with 106 additions and 50 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,6 @@
data: [],
loading: false
},
dirty: false
}
},
computed: {
Expand Down Expand Up @@ -382,17 +381,12 @@
this.network_getPendingReview()
},
reviewSubmittedHook(payload) {
this.dirty = true
this.pendingReview.data = {}
this.pendingReview.reviewComments = []
this.pendingReview.emptyFlag = 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: {
CommonLoadingWrapper,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -82,19 +82,19 @@
class="bg-white" />

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

<HiddenItemLoading v-if="(timeline.pageInfo.next || timeline.loading) && !timeline.data.includes(timeline.newestTimeline[0])"
<HiddenItemLoading v-if="(timeline.pageInfo.next || timeline.loading) && !timeline.data.some(i => timeline.newestTimeline.data[0] && i.node_id == timeline.newestTimeline.data[0].node_id)"
class="border-top"
:loading="timeline.loading"
:dataGetter="loadingMore">
</HiddenItemLoading>

<transition-group tag="div" appear name="fade-group">
<div v-for="(item,index) in timeline.newestTimeline.filter(i => !timeline.newestTimeline.includes(i))" :key="(item.id || '') + index">
<div v-for="(item,index) in timeline.newestTimeline.data" :key="(item.id || '') + index">
<TimelineItem :data="item" class="border-top" style="background:#fafbfc"/>
</div>
</transition-group>
Expand Down Expand Up @@ -230,7 +230,10 @@
data: 0,
loading: false
},
newestTimeline: []
newestTimeline: {
data: [],
loading: false
}
},
timelineTypes: [
{
Expand Down Expand Up @@ -460,12 +463,10 @@
if(res_timeline.data.length > 0) this.network_getTimelineExtraData(res_timeline.data)
/* if(this.timeline.pageInfo.next && this.timeline.pageInfo.next.page == 2) {
await this.network_getNewestTimeline()
if(this.timeline.pageInfo.next && this.timeline.pageInfo.next.page == 2) {
await this.network_getNewestTimelines()
}
*/
if(this.newCreatedTimelineItem) this.scrollToNewestTimelineItem()
}catch(e){
Expand All @@ -475,31 +476,22 @@
this.timeline.extraData.loading = false
}
},
/* async network_getNewestTimeline() {
try{
async network_getNewestTimelines() {
if(!this.timeline.pageInfo.last) return
try{
this.timeline.newestTimeline.loading = true
let url_timeline = api.API_ISSUE_TIMELINE({
repo: this.repo,
owner: this.owner,
number: this.number,
params: {
per_page: this.timeline.perPage,
page: this.timeline.pageInfo.last.page
}
})
let url = this.timeline.pageInfo.last.url
let config = {
cancelToken: this.cancelAndUpdateAxiosCancelTokenSource(this.$options.name + ' get_newest_timeline'),
cancelToken: this.cancelAndUpdateAxiosCancelTokenSource(this.$options.name + ' get_newest_timelines'),
headers:{
'Accept': 'application/vnd.github.mockingbird-preview,application/vnd.github.starfox-preview+json'
}
}
let res_timeline = await authRequiredGet(url_timeline,config)
this.timeline.newestTimeline.data = res_timeline.data
let res = await authRequiredGet(url,config)
this.timeline.newestTimeline.data = res.data
if(this.timeline.newestTimeline.data.length > 0) this.network_getTimelineExtraData(this.timeline.newestTimeline.data)
Expand All @@ -508,7 +500,7 @@
}finally{
this.timeline.newestTimeline.loading = false
}
}, */
},
async network_getNewestTimeline() {
let url_pageInfo = api.API_ISSUE_TIMELINE({
repo: this.repo,
Expand Down Expand Up @@ -805,8 +797,8 @@
this.scrollToTop()
let newestTimeline = await this.network_getNewestTimeline()
newestTimeline && this.timeline.newestTimeline.push(newestTimeline)
newestTimeline && this.timeline.newestTimeline.data.push(newestTimeline)
newestTimeline && this.network_getTimelineExtraData([newestTimeline])
}
},
components: {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
#{{data.source.issue.number}} {{data.source.issue.title}}
</router-link>
</strong>
<span v-if="data.source.issue.repository.full_name != `${owner}/${repo}`">in {{data.source.issue.repository.full_name}}</span>
</Body>
</AnimatedHeightWrapper>
</Inner>
Expand Down Expand Up @@ -44,7 +45,12 @@
}
},
computed: {
owner() {
return this.$route.params.owner
},
repo() {
return this.$route.params.repo
},
},
methods: {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
<template>
<Container class="bubble bg-white" style="margin-top:15px">

<FileHeader class="file-header" :class="{pending:reviewProvided().state == 'pending'}">
<button class="btn-link text-gray float-right f6 d-block" v-if="reviewComment.outdated" @click="triggerShowOutdated">
<svg class="octicon octicon-fold position-relative mr-1" viewBox="0 0 14 16" version="1.1" width="14" height="16" aria-hidden="true"><path fill-rule="evenodd" d="M7 9l3 3H8v3H6v-3H4l3-3zm3-6H8V0H6v3H4l3 3 3-3zm4 2c0-.55-.45-1-1-1h-2.5l-1 1h3l-2 2h-7l-2-2h3l-1-1H1c-.55 0-1 .45-1 1l2.5 2.5L0 10c0 .55.45 1 1 1h2.5l1-1h-3l2-2h7l2 2h-3l1 1H13c.55 0 1-.45 1-1l-2.5-2.5L14 5z"></path></svg>
Expand All @@ -8,10 +9,15 @@
<router-link to="/" class="link-gray-dark">
{{path}}
</router-link>

<button v-if="outdated" @click="triggerShowOutdated" type="button" class="btn-link text-gray float-right f6 outdated-comment-label show-outdated-button">
<svg class="octicon octicon-unfold position-relative mr-1" viewBox="0 0 16 16" version="1.1" width="16" height="16" aria-hidden="true"><path fill-rule="evenodd" d="M8.177.677l2.896 2.896a.25.25 0 01-.177.427H8.75v1.25a.75.75 0 01-1.5 0V4H5.104a.25.25 0 01-.177-.427L7.823.677a.25.25 0 01.354 0zM7.25 10.75a.75.75 0 011.5 0V12h2.146a.25.25 0 01.177.427l-2.896 2.896a.25.25 0 01-.354 0l-2.896-2.896A.25.25 0 015.104 12H7.25v-1.25zm-5-2a.75.75 0 000-1.5h-.5a.75.75 0 000 1.5h.5zM6 8a.75.75 0 01-.75.75h-.5a.75.75 0 010-1.5h.5A.75.75 0 016 8zm2.25.75a.75.75 0 000-1.5h-.5a.75.75 0 000 1.5h.5zM12 8a.75.75 0 01-.75.75h-.5a.75.75 0 010-1.5h.5A.75.75 0 0112 8zm2.25.75a.75.75 0 000-1.5h-.5a.75.75 0 000 1.5h.5z"></path></svg>
{{showOutdated ? 'Hide' : 'Show'}} outdated
</button>
</FileHeader>


<DiffView class="diff-view" v-if="!reviewComment.outdated || showOutdated">
<div v-if="!outdated || showOutdated">
<DiffView class="diff-view">
<div :class="{'d-inline-block':!isProseFileType}" style="min-width: 100%;">
<LinesNotShown class="text-shadow-light d-flex width-full" v-if="diffHunkEntries.hidden.length > 0 && !showHiddenDiffHunk" @click="triggerShowHiddenDiffHunk">
<BlobNum class="blob-num position-sticky bg-white" style="left:0px" data-line-number="..."></BlobNum>
Expand Down Expand Up @@ -86,10 +92,7 @@
</button>

<ReviewCommentReplyCreator v-if="showReviewCommentReplyCreator" class="border-top" :commentId="reviewComment.id" @cancel="() => triggerShowReviewCommentReplyCreator(false)" @reply-success="createReplySuccessHandler"></ReviewCommentReplyCreator>

<ResolveConversation>

</ResolveConversation>
</div>

</Container>
</template>
Expand All @@ -111,7 +114,7 @@
inject: ['reviewCommentReplies','commentsOfPendingReview','reviewProvided','pullRequestProvided','repoOwnerType','viewerIsCollaborator'],
provide() {
return {
repliesExtraData: () => this.repliesExtraData.data
repliesExtraData: () => this.repliesExtraData.data,
}
},
data() {
Expand All @@ -131,7 +134,8 @@
loading: false
},
repliesJustCreated: [],
showReviewCommentReplyCreator: false
showReviewCommentReplyCreator: false,
}
},
props: {
Expand Down Expand Up @@ -205,15 +209,25 @@
return `...${this.reviewComment.path.match(/(\/(([^\/])+)){3}$/g)[0]}`
},
replies() {
let replies = [...this.reviewCommentReplies(),...this.commentsOfPendingReview(),...this.repliesJustCreated].filter(item => {
let replies_ = [...this.reviewCommentReplies(),...this.commentsOfPendingReview(),...this.repliesJustCreated].filter(item => {
return item.in_reply_to_id == this.reviewComment.id
})
return replies || []
let replies = []
replies_.forEach(i => {
if(!replies.some(i_ => i_.id == i.id)) {
replies.push(i)
}
})
return replies
},
isProseFileType() {
if(!this.reviewComment.path) return
return util_analyseFileType.isProse(this.reviewComment.path)
},
outdated() {
return this.repliesExtraData.data[0] && this.repliesExtraData.data[0].outdated
}
},
created() {
this.network_getData()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -352,6 +352,18 @@
<strong>{{data.requested_reviewer ? data.requested_reviewer.login : data.requested_team.login}}</strong>
</template>
</SimpleTimelineItem>

<!-- base_ref_force_pushed -->
<SimpleTimelineItem v-else-if="data.event === 'base_ref_force_pushed'" :data="data">
<template v-slot:icon>
<svg class="octicon octicon-repo-push issue-event-icon" viewBox="0 0 16 16" version="1.1" width="16" height="16" aria-hidden="true"><path fill-rule="evenodd" d="M1 2.5A2.5 2.5 0 013.5 0h8.75a.75.75 0 01.75.75v3.5a.75.75 0 01-1.5 0V1.5h-8a1 1 0 00-1 1v6.708A2.492 2.492 0 013.5 9h3.25a.75.75 0 010 1.5H3.5a1 1 0 100 2h5.75a.75.75 0 010 1.5H3.5A2.5 2.5 0 011 11.5v-9zm13.23 7.79a.75.75 0 001.06-1.06l-2.505-2.505a.75.75 0 00-1.06 0L9.22 9.229a.75.75 0 001.06 1.061l1.225-1.224v6.184a.75.75 0 001.5 0V9.066l1.224 1.224z"></path></svg>
</template>
<template v-slot:action>
force pushed changes tto the base branch
</template>
</SimpleTimelineItem>


<!-- review_request_removed -->
<!-- <SimpleTimelineItem v-else-if="data.event === 'review_request_removed'" :data="data">
<template v-slot:icon>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,7 @@ export const GRAPHQL_PULL_TIMELINE = `
viewerCanDelete
minimizedReason
isMinimized
outdated
}
}
}
Expand Down
20 changes: 18 additions & 2 deletions src/plugin/common/index.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
import {mapState} from 'vuex'
import {mapState, mapMutations} from 'vuex'
import axios from 'axios'
import * as api from '@/network/api'
import {util_throttle} from '@/util'
import { MUTATION_UPDATE_DIRTY } from '@/store/modules/dirty/mutationTypes'
export default {
install: (Vue) => {
Vue.mixin({
Expand All @@ -14,10 +15,17 @@ export default {
computed: {
...mapState({
accessToken: state => state.oauth.accessToken.accessToken,
viewer: state => state.oauth.viewerInfo
viewer: state => state.oauth.viewerInfo,
dirtyPool: state => state.dirty
}),
dirty() {
return this.dirtyPool[this.$options.name]
}
},
methods: {
...mapMutations({
mutation_updateDirty: MUTATION_UPDATE_DIRTY
}),
handleError(e,config) {
config = {
handle404: false,
Expand Down Expand Up @@ -106,6 +114,14 @@ export default {
getPageScrollTop() {
return window.pageYOffset || document.documentElement.scrollTop || document.body.scrollTop || 0
},
updateDirty(payload) {
payload = {
key: this.$options.name,
value: true,
...payload
}
this.mutation_updateDirty(payload)
}
},
created() {
if(this.documentTitle) document.title = this.documentTitle
Expand Down
7 changes: 7 additions & 0 deletions src/store/modules/dirty/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
import mutations from './mutations'
import state from './state'

export default {
state: state,
mutations: mutations
}
1 change: 1 addition & 0 deletions src/store/modules/dirty/mutationTypes.js
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export const MUTATION_UPDATE_DIRTY = 'MUTATION_UPDATE_DIRTY'
8 changes: 8 additions & 0 deletions src/store/modules/dirty/mutations.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
import {MUTATION_UPDATE_DIRTY} from './mutationTypes'
import Vue from 'vue'

export default {
[MUTATION_UPDATE_DIRTY] (state,payload) {
Vue.set(state,payload.key,payload.value)
}
}
4 changes: 4 additions & 0 deletions src/store/modules/dirty/state.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@

export default {

}
3 changes: 2 additions & 1 deletion src/store/modules/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,6 @@ import repositoryStore from './repository'
import issuesStore from './issues'
import notificationsStore from './notifications'
import topNoticeStore from './topNotice'
import dirty from './dirty'

export {oauthStore,homeStore,searchStore,repositoryStore,issuesStore,notificationsStore,topNoticeStore}
export {oauthStore,homeStore,searchStore,repositoryStore,issuesStore,notificationsStore,topNoticeStore,dirty}

0 comments on commit e588167

Please sign in to comment.