Skip to content

Commit

Permalink
normal commit
Browse files Browse the repository at this point in the history
  • Loading branch information
Peng Kaifan committed Nov 17, 2020
1 parent 7a7b236 commit b30b442
Show file tree
Hide file tree
Showing 71 changed files with 4,439 additions and 1,764 deletions.
3 changes: 2 additions & 1 deletion src/components/Editor.vue
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,8 @@

<LockedNotice v-else-if="!viewerIsCollaborator" class="locked-notice">
<svg height="32" class="octicon octicon-lock" viewBox="0 0 12 16" version="1.1" width="24" aria-hidden="true"><path fill-rule="evenodd" d="M4 13H3v-1h1v1zm8-6v7c0 .55-.45 1-1 1H1c-.55 0-1-.45-1-1V7c0-.55.45-1 1-1h1V4c0-2.2 1.8-4 4-4s4 1.8 4 4v2h1c.55 0 1 .45 1 1zM3.8 6h4.41V4c0-1.22-.98-2.2-2.2-2.2-1.22 0-2.2.98-2.2 2.2v2H3.8zM11 7H2v7h9V7zM4 8H3v1h1V8zm0 2H3v1h1v-1z"></path></svg>
<p>This conversation has been locked <span v-if="lockedReason">as</span> <strong>{{lockedReason}}</strong> and limited to collaborators.</p>
<p v-if="lockedReason">This conversation has been locked <span>as</span> <strong>{{lockedReason}}</strong> and limited to collaborators.</p>
<p v-else>You can't perform this action at this time.</p>
</LockedNotice>

<Action v-if="!locked || viewerIsCollaborator">
Expand Down
8 changes: 4 additions & 4 deletions src/components/IssueIcon.vue
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
<template>
<svg v-if="!issue || !issue.state" class="opened" viewBox="0 0 14 16" fill="currentColor" version="1.1" width="14" height="16" aria-hidden="true"><path fill-rule="evenodd" d="M7 2.3c3.14 0 5.7 2.56 5.7 5.7s-2.56 5.7-5.7 5.7A5.71 5.71 0 011.3 8c0-3.14 2.56-5.7 5.7-5.7zM7 1C3.14 1 0 4.14 0 8s3.14 7 7 7 7-3.14 7-7-3.14-7-7-7zm1 3H6v5h2V4zm0 6H6v2h2v-2z"></path></svg>
<svg v-else-if="issue.merged" :style="color && {color:color}" class="merged" fill="currentColor" viewBox="0 0 12 16" version="1.1" width="12" height="16" aria-hidden="true"><path fill-rule="evenodd" d="M10 7c-.73 0-1.38.41-1.73 1.02V8C7.22 7.98 6 7.64 5.14 6.98c-.75-.58-1.5-1.61-1.89-2.44A1.993 1.993 0 002 .99C.89.99 0 1.89 0 3a2 2 0 001 1.72v6.56c-.59.35-1 .99-1 1.72 0 1.11.89 2 2 2a1.993 1.993 0 001-3.72V7.67c.67.7 1.44 1.27 2.3 1.69.86.42 2.03.63 2.97.64v-.02c.36.61 1 1.02 1.73 1.02 1.11 0 2-.89 2-2 0-1.11-.89-2-2-2zm-6.8 6c0 .66-.55 1.2-1.2 1.2-.65 0-1.2-.55-1.2-1.2 0-.65.55-1.2 1.2-1.2.65 0 1.2.55 1.2 1.2zM2 4.2C1.34 4.2.8 3.65.8 3c0-.65.55-1.2 1.2-1.2.65 0 1.2.55 1.2 1.2 0 .65-.55 1.2-1.2 1.2zm8 6c-.66 0-1.2-.55-1.2-1.2 0-.65.55-1.2 1.2-1.2.65 0 1.2.55 1.2 1.2 0 .65-.55 1.2-1.2 1.2z"></path></svg>
<svg v-else-if="(issue.pull_request && !issue.merged) || issue.merged !== undefined" :style="color && {color:color}" :class="{opened:issue.state.toLowerCase() === 'open',closed:issue.state.toLowerCase() === 'closed'}" fill="currentColor" viewBox="0 0 12 16" version="1.1" width="12" height="16" aria-hidden="true"><path fill-rule="evenodd" d="M11 11.28V5c-.03-.78-.34-1.47-.94-2.06C9.46 2.35 8.78 2.03 8 2H7V0L4 3l3 3V4h1c.27.02.48.11.69.31.21.2.3.42.31.69v6.28A1.993 1.993 0 0010 15a1.993 1.993 0 001-3.72zm-1 2.92c-.66 0-1.2-.55-1.2-1.2 0-.65.55-1.2 1.2-1.2.65 0 1.2.55 1.2 1.2 0 .65-.55 1.2-1.2 1.2zM4 3c0-1.11-.89-2-2-2a1.993 1.993 0 00-1 3.72v6.56A1.993 1.993 0 002 15a1.993 1.993 0 001-3.72V4.72c.59-.34 1-.98 1-1.72zm-.8 10c0 .66-.55 1.2-1.2 1.2-.65 0-1.2-.55-1.2-1.2 0-.65.55-1.2 1.2-1.2.65 0 1.2.55 1.2 1.2zM2 4.2C1.34 4.2.8 3.65.8 3c0-.65.55-1.2 1.2-1.2.65 0 1.2.55 1.2 1.2 0 .65-.55 1.2-1.2 1.2z"></path></svg>
<svg v-else-if="issue.state.toLowerCase() === 'open'" :style="color && {color:color}" class="opened" viewBox="0 0 14 16" fill="currentColor" version="1.1" width="14" height="16" aria-hidden="true"><path fill-rule="evenodd" d="M7 2.3c3.14 0 5.7 2.56 5.7 5.7s-2.56 5.7-5.7 5.7A5.71 5.71 0 011.3 8c0-3.14 2.56-5.7 5.7-5.7zM7 1C3.14 1 0 4.14 0 8s3.14 7 7 7 7-3.14 7-7-3.14-7-7-7zm1 3H6v5h2V4zm0 6H6v2h2v-2z"></path></svg>
<svg v-if="!issue || !issue.state" class="octicon opened" viewBox="0 0 14 16" fill="currentColor" version="1.1" width="14" height="16" aria-hidden="true"><path fill-rule="evenodd" d="M7 2.3c3.14 0 5.7 2.56 5.7 5.7s-2.56 5.7-5.7 5.7A5.71 5.71 0 011.3 8c0-3.14 2.56-5.7 5.7-5.7zM7 1C3.14 1 0 4.14 0 8s3.14 7 7 7 7-3.14 7-7-3.14-7-7-7zm1 3H6v5h2V4zm0 6H6v2h2v-2z"></path></svg>
<svg v-else-if="issue.merged" :style="color && {color:color}" class="octicon merged" fill="currentColor" height="14" viewBox="0 0 16 16" version="1.1" width="14" aria-hidden="true"><path fill-rule="evenodd" d="M5 3.254V3.25v.005a.75.75 0 110-.005v.004zm.45 1.9a2.25 2.25 0 10-1.95.218v5.256a2.25 2.25 0 101.5 0V7.123A5.735 5.735 0 009.25 9h1.378a2.251 2.251 0 100-1.5H9.25a4.25 4.25 0 01-3.8-2.346zM12.75 9a.75.75 0 100-1.5.75.75 0 000 1.5zm-8.5 4.5a.75.75 0 100-1.5.75.75 0 000 1.5z"></path></svg>
<svg v-else-if="(issue.pull_request && !issue.merged) || issue.merged !== undefined" :style="color && {color:color}" class="octicon" :class="{opened:issue.state.toLowerCase() === 'open',closed:issue.state.toLowerCase() === 'closed'}" fill="currentColor" viewBox="0 0 12 16" version="1.1" width="12" height="16" aria-hidden="true"><path fill-rule="evenodd" d="M11 11.28V5c-.03-.78-.34-1.47-.94-2.06C9.46 2.35 8.78 2.03 8 2H7V0L4 3l3 3V4h1c.27.02.48.11.69.31.21.2.3.42.31.69v6.28A1.993 1.993 0 0010 15a1.993 1.993 0 001-3.72zm-1 2.92c-.66 0-1.2-.55-1.2-1.2 0-.65.55-1.2 1.2-1.2.65 0 1.2.55 1.2 1.2 0 .65-.55 1.2-1.2 1.2zM4 3c0-1.11-.89-2-2-2a1.993 1.993 0 00-1 3.72v6.56A1.993 1.993 0 002 15a1.993 1.993 0 001-3.72V4.72c.59-.34 1-.98 1-1.72zm-.8 10c0 .66-.55 1.2-1.2 1.2-.65 0-1.2-.55-1.2-1.2 0-.65.55-1.2 1.2-1.2.65 0 1.2.55 1.2 1.2zM2 4.2C1.34 4.2.8 3.65.8 3c0-.65.55-1.2 1.2-1.2.65 0 1.2.55 1.2 1.2 0 .65-.55 1.2-1.2 1.2z"></path></svg>
<svg v-else-if="issue.state.toLowerCase() === 'open'" :style="color && {color:color}" class="octicon opened" viewBox="0 0 14 16" fill="currentColor" version="1.1" width="14" height="16" aria-hidden="true"><path fill-rule="evenodd" d="M7 2.3c3.14 0 5.7 2.56 5.7 5.7s-2.56 5.7-5.7 5.7A5.71 5.71 0 011.3 8c0-3.14 2.56-5.7 5.7-5.7zM7 1C3.14 1 0 4.14 0 8s3.14 7 7 7 7-3.14 7-7-3.14-7-7-7zm1 3H6v5h2V4zm0 6H6v2h2v-2z"></path></svg>
<svg v-else-if="issue.state.toLowerCase() === 'closed'" :style="color && {color:color}" class="octicon octicon-issue-closed closed" viewBox="0 0 16 16" version="1.1" width="16" height="16" aria-hidden="true"><path fill-rule="evenodd" d="M7 10h2v2H7v-2zm2-6H7v5h2V4zm1.5 1.5l-1 1L12 9l4-4.5-1-1L12 7l-1.5-1.5zM8 13.7A5.71 5.71 0 012.3 8c0-3.14 2.56-5.7 5.7-5.7 1.83 0 3.45.88 4.5 2.2l.92-.92A6.947 6.947 0 008 1C4.14 1 1 4.14 1 8s3.14 7 7 7 7-3.14 7-7l-1.52 1.52c-.66 2.41-2.86 4.19-5.48 4.19v-.01z"></path></svg>
</template>

Expand Down
15 changes: 3 additions & 12 deletions src/components/Label.vue
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<template>
<span class="d-inline-block label css-truncate" :style="{color:fontColor,background:`${color}!important`}">
<span class="d-inline-block css-truncate IssueLabel" :style="{color:fontColor,background:`${color}!important`}">
<span class="css-truncate-target" style="max-width: 100%">{{emojiHandledName}}</span>
</span>
</template>
Expand Down Expand Up @@ -44,15 +44,6 @@

<style scoped lang="scss">
@import 'node_modules/@primer/css/truncate/index.scss';
.label{
padding-right: 7px!important;
padding-left: 7px!important;
padding-top: 0px!important;
padding-bottom: 0px!important;
font-size: 12px;
font-weight: 500;
line-height: 18px!important;
border-radius: 2em!important;
box-shadow: inset 0 -1px 0 rgba(27,31,35,.12);
}
@import 'node_modules/@primer/css/labels/index.scss';
</style>
2 changes: 1 addition & 1 deletion src/filter.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import {util_numberFormat,util_dateFormat,util_fileSize,util_markdownParse} from
Vue.filter('capitalize', function (value) {
if (!value) return ''
value = value.toString()
return value.charAt(0).toUpperCase() + value.slice(1)
return value.charAt(0).toUpperCase() + value.slice(1).toLowerCase()
})

Vue.filter('thousands', function (number) {
Expand Down
14 changes: 14 additions & 0 deletions src/network/api.js
Original file line number Diff line number Diff line change
Expand Up @@ -365,6 +365,15 @@ export const API_ISSUE_REACTIONS = payload => {
return `${GITHUB_REST_API_BASE}/repos/${payload.owner}/${payload.repo}/issues/${payload.number}/reactions?${query}`
}

export const API_ISSUE_REACTION = payload => `${GITHUB_REST_API_BASE}/repos/${payload.owner}/${payload.repo}/issues/${payload.number}/reactions/${payload.reactionId}`

export const API_ISSUE_COMMENT_REACTION = payload => `${GITHUB_REST_API_BASE}/repos/${payload.owner}/${payload.repo}/issues/comments/${payload.commentId}/reactions/${payload.reactionId}`

export const API_REVIEW_COMMENT_REACTION = payload => `${GITHUB_REST_API_BASE}/repos/${payload.owner}/${payload.repo}/pulls/comments/${payload.commentId}/reactions/${payload.reactionId}`

export const API_COMMIT_COMMENT_REACTION = payload => `${GITHUB_REST_API_BASE}/repos/${payload.owner}/${payload.repo}/comments/${payload.commentId}/reactions/${payload.reactionId}`


export const API_ISSUE_COMMENT_REACTIONS = payload => {
let query = util_queryParse.querify(payload.params)
return `${GITHUB_REST_API_BASE}/repos/${payload.owner}/${payload.repo}/issues/comments/${payload.commentId}/reactions?${query}`
Expand All @@ -375,6 +384,11 @@ export const API_PULL_REVIEW_COMMENT_REACTIONS = payload => {
return `${GITHUB_REST_API_BASE}/repos/${payload.owner}/${payload.repo}/pulls/comments/${payload.comment}/reactions?${query}`
}

export const API_COMMIT_COMMENT_REACTIONS = payload => {
let query = util_queryParse.querify(payload.params)
return `${GITHUB_REST_API_BASE}/repos/${payload.owner}/${payload.repo}/comments/${payload.commentId}/reactions?${query}`
}

export const API_PROXY_ISSUE_COMMENT_EDIT_HISTORIES = payload => `${PROXY_API_BASE}/_render_node/${payload}/comments/comment_edit_history_log`

export const API_PROXY_FILE_CONTRIBUTION_MESSAGE = payload => `${PROXY_API_BASE}/${payload.owner}/${payload.repo}/contributors/${payload.ref}/${payload.path}`
Expand Down
39 changes: 5 additions & 34 deletions src/pages/Repository/Code/CodeFileDetail/CodeFileDetail.vue
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,7 @@
<span v-if="contributionMessage.latestCommitStatus !== undefined" class="ml-2">
<svg v-if="contributionMessage.latestCommitStatus == 'SUCCESS'" class="octicon octicon-check text-green" viewBox="0 0 16 16" version="1.1" width="16" height="16" role="img"><path fill-rule="evenodd" d="M13.78 4.22a.75.75 0 010 1.06l-7.25 7.25a.75.75 0 01-1.06 0L2.22 9.28a.75.75 0 011.06-1.06L6 10.94l6.72-6.72a.75.75 0 011.06 0z"></path></svg>
<svg v-else-if="contributionMessage.latestCommitStatus == 'FAILURE'" class="octicon octicon-x v-align-middle text-red" viewBox="0 0 16 16" version="1.1" width="16" height="16" aria-hidden="true"><path fill-rule="evenodd" d="M3.72 3.72a.75.75 0 011.06 0L8 6.94l3.22-3.22a.75.75 0 111.06 1.06L9.06 8l3.22 3.22a.75.75 0 11-1.06 1.06L8 9.06l-3.22 3.22a.75.75 0 01-1.06-1.06L6.94 8 3.72 4.78a.75.75 0 010-1.06z"></path></svg>
<CommitStatusIcon :sha="contributionMessage.latestCommit.data.sha"></CommitStatusIcon>
</span>

<router-link :to="`/${owner}/${repo}/commits/${currentRef}/${path}`" class="d-block ml-3 d-flex flex-shrink-0 flex-items-center flex-justify-end text-gray no-wrap">
Expand Down Expand Up @@ -212,14 +213,14 @@
import {Breadcrumb,Modal,SelectMenuItem,LoadingIconEx,CommonLoadingWrapper,AnimatedHeightWrapper,ImgWrapper,Popover,SkeletonCircle,SkeletonRectangle} from '@/components'
import {Content} from './components'
import {cancelAndUpdateAxiosCancelTokenSource,authRequiredGitHubGraphqlApiQuery,authRequiredGet,commonGet} from '@/network'
import {RouteUpdateAwareMixin,ComponentActiveAwareMixin} from '@/mixins'
import {WithRefDistinguishMixin} from '../../components'
import {RouteUpdateAwareMixin} from '@/mixins'
import {WithRefDistinguishMixin,CommitStatusIcon} from '../../components'
import * as graphql from '../graphql'
import * as api from '@/network/api'
let parse = require('parse-link-header')
export default {
name: 'repository_code_file_detail_page',
mixins: [RouteUpdateAwareMixin,WithRefDistinguishMixin,ComponentActiveAwareMixin],
mixins: [RouteUpdateAwareMixin,WithRefDistinguishMixin],
inject: ['repoBasicInfo'],
data() {
return {
Expand Down Expand Up @@ -341,7 +342,6 @@
)
this.contributionMessage.latestCommit.data = res.data[0]
this.network_getLatestCommitStatus()
}catch(e) {
console.log(e)
}finally{
Expand All @@ -367,27 +367,6 @@
this.contributionMessage.loading = false
}
},
async network_getLatestCommitStatus() {
try{
let url = api.API_PROXY_COMMIT_STATUS({
repo: this.repo,
owner: this.owner,
sha: this.contributionMessage.latestCommit.data.sha
})
let res = await commonGet(
url,
{
cancelToken: this.cancelAndUpdateAxiosCancelTokenSource(this.$options.name + ' get_latest_commit_status')
}
)
if(res.data) this.parseLatestCommitStatus(res.data)
}catch(e) {
console.log(e)
}
},
async network_tryToGetContentHTML() {
try{
this.loading = true
Expand Down Expand Up @@ -539,15 +518,6 @@
}
this.modalContributors.data = contributors
},
parseLatestCommitStatus(HTML) {
let failurePattern = /octicon-x/g
let successPattern = /octicon-check/g
if(HTML.match(failurePattern) != null) {
this.contributionMessage.latestCommitStatus = 'FAILURE'
}else if(HTML.match(successPattern) != null) {
this.contributionMessage.latestCommitStatus = 'SUCCESS'
}
},
switchModalTab(payload) {
this.switchBranchOrTagModalTab = payload
this.network_getAvailableRefs()
Expand Down Expand Up @@ -685,6 +655,7 @@
ImgWrapper,
Popover,
SkeletonCircle,
CommitStatusIcon,
SkeletonRectangle,
Container: styled.div``,
FileNavigation: styled.div``,
Expand Down
34 changes: 3 additions & 31 deletions src/pages/Repository/Code/CodeMain/components/FileBrowser.vue
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@
</button>
<svg v-if="latestCommit.status == 'SUCCESS'" class="octicon text-green octicon-check v-align-middle flex-shrink-0 ml-2" viewBox="0 0 16 16" version="1.1" width="16" height="16" aria-hidden="true"><path fill-rule="evenodd" d="M13.78 4.22a.75.75 0 010 1.06l-7.25 7.25a.75.75 0 01-1.06 0L2.22 9.28a.75.75 0 011.06-1.06L6 10.94l6.72-6.72a.75.75 0 011.06 0z"></path></svg>
<svg v-else-if="latestCommit.status == 'FAILURE'" viewBox="0 0 12 16" version="1.1" width="12" height="16" aria-hidden="true" class="octicon octicon-x v-align-middle text-red flex-shrink-0 ml-2"><path data-v-74bab622="" fill-rule="evenodd" d="M7.48 8l3.75 3.75-1.48 1.48L6 9.48l-3.75 3.75-1.48-1.48L4.52 8 .77 4.25l1.48-1.48L6 6.52l3.75-3.75 1.48 1.48L7.48 8z"></path></svg>
<CommitStatusIcon :sha="latestCommit.data.sha"></CommitStatusIcon>
<span class="no-wrap ml-2" v-if="latestCommit.data.commit">{{latestCommit.data.commit.committer.date | getDateDiff}}</span>
</div>

Expand Down Expand Up @@ -111,6 +112,7 @@
import {authRequiredGet,authRequiredGitHubGraphqlApiQuery,commonGet,cancelAndUpdateAxiosCancelTokenSource } from '@/network'
import {RouteUpdateAwareMixin} from '@/mixins'
import ContentListItem from './ContentListItem'
import {CommitStatusIcon} from '../../../components'
let parse = require('parse-link-header')
import Vue from 'vue'
export default {
Expand Down Expand Up @@ -196,34 +198,12 @@
)
this.latestCommit.data = res.data[0]
this.network_getLatestCommitStatus()
}catch(e) {
console.log(e)
}finally{
this.latestCommit.loading = false
}
},
async network_getLatestCommitStatus() {
try{
let url = api.API_PROXY_COMMIT_STATUS({
repo: this.repo,
owner: this.owner,
sha: this.latestCommit.data.sha
})
let res = await commonGet(
url,
{
cancelToken: cancelAndUpdateAxiosCancelTokenSource(this.$options.name + ' get_latest_commit_status').cancelToken
}
)
if(res.data) this.parseLatestCommitStatus(res.data)
}catch(e) {
console.log(e)
}
},
triggerShowLatestCommitMessage() {
this.latestCommit.showMessage = !this.latestCommit.showMessage
},
Expand Down Expand Up @@ -356,15 +336,6 @@
showContents() {
this.contents.show = true
},
parseLatestCommitStatus(HTML) {
let failurePattern = /octicon-x/g
let successPattern = /octicon-check/g
if(HTML.match(failurePattern) != null) {
this.latestCommit.status = 'FAILURE'
}else if(HTML.match(successPattern) != null) {
this.latestCommit.status = 'SUCCESS'
}
},
routeUpdateHook() {
this.network_getContents()
this.network_getLatestCommit()
Expand Down Expand Up @@ -405,6 +376,7 @@
ImgWrapper,
SkeletonRectangle,
AnimatedHeightWrapper,
CommitStatusIcon,
Container: styled.div``,
Skeleton: styled.div``,
CompareWithDefaultRef: styled.div``,
Expand Down
39 changes: 1 addition & 38 deletions src/pages/Repository/Commit/Commit.vue
Original file line number Diff line number Diff line change
Expand Up @@ -200,10 +200,6 @@
data: [],
loading: false
},
status: {
data: undefined,
loading: false
},
extraData: {
data: {},
loading: false
Expand Down Expand Up @@ -294,9 +290,8 @@
this.network_getData()
},
methods: {
network_getData() {
async network_getData() {
this.network_getBasicData()
this.network_getCommitStatus()
this.network_getAssociatedBranchAndTags()
},
async network_getBasicData() {
Expand Down Expand Up @@ -327,29 +322,6 @@
this.loading = false
}
},
async network_getCommitStatus() {
try {
this.status.loading = true
let url = api.API_PROXY_COMMIT_STATUS({
repo: this.repo,
owner: this.owner,
sha: this.sha
})
let res = await commonGet(
url,
{
cancelToken: this.cancelAndUpdateAxiosCancelTokenSource(this.$options.name + ' get_commit_status')
}
)
this.parseCommitStatus(res.data)
} catch (e) {
console.log(e)
}finally{
this.status.loading = false
}
},
async network_getAssociatedBranchAndTags() {
try {
this.associatedRefs.loading = true
Expand Down Expand Up @@ -454,15 +426,6 @@
this.comments.loading = false
}
},
parseCommitStatus(HTML) {
let failurePattern = /octicon-x/g
let successPattern = /octicon-check/g
if(HTML.match(failurePattern) != null) {
this.status.data = 'FAILURE'
}else if(HTML.match(successPattern) != null) {
this.status.data = 'SUCCESS'
}
},
parseAssociatedRefs(HTML) {
let branchPattern = /<li class="branch"><a href="(.*?)">(.*?)<\/a><\/li>/g
let branchExecResult
Expand Down
Loading

0 comments on commit b30b442

Please sign in to comment.