Skip to content

Commit

Permalink
Link to added/removed files.
Browse files Browse the repository at this point in the history
  • Loading branch information
Damnae committed Apr 8, 2024
1 parent 2df1564 commit 4e62dd5
Show file tree
Hide file tree
Showing 4 changed files with 25 additions and 4 deletions.
5 changes: 5 additions & 0 deletions src/common/datasource.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,11 @@ const repository = settings.useCustomRepo ? settings.customRepo : 'Dimbreath/Sta
const apiBase = 'https://api.github.com/repos/' + repository
const jsonBase = 'https://raw.githubusercontent.com/' + repository

export function getRepositoryFileUrl(commitId:string,path:string)
{
return `https://github.com/${repository}blob/${commitId}/${path}`
}

const configDBVersion = 1
interface ConfigDBv1 extends DBSchema
{
Expand Down
13 changes: 13 additions & 0 deletions src/components/RepositoryFileLink.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
<script setup lang="ts">
import { getRepositoryFileUrl } from '@/common/datasource';
defineProps<{commitId:string,path:string}>()
</script>

<template>
<a :href="getRepositoryFileUrl(commitId, path)" target="_blank" rel="noreferrer noopener">
<slot />
</a>
</template>

<style scoped>
</style>
7 changes: 5 additions & 2 deletions src/views/pages/changes/FileItem.vue
Original file line number Diff line number Diff line change
@@ -1,13 +1,16 @@
<script setup lang="ts">
import { DataSourceCompareFile } from '@/common/datasource';
import RepositoryFileLink from '@/components/RepositoryFileLink.vue';
defineProps<{file:DataSourceCompareFile}>()
defineProps<{commitId:string,file:DataSourceCompareFile}>()
</script>

<template>

<div class="block">
<em>{{ file.Path }}</em>
<RepositoryFileLink :commitId="commitId" :path="file.Path">
<em>{{ file.Path }}</em>
</RepositoryFileLink>
</div>

</template>
Expand Down
4 changes: 2 additions & 2 deletions src/views/pages/changes/Files.vue
Original file line number Diff line number Diff line change
Expand Up @@ -26,12 +26,12 @@

<h3>{{ compare.AddedFiles.length }} Added</h3>
<template v-for="file in compare.AddedFiles">
<FileItem :file="file" />
<FileItem :commitId="commitId" :file="file" />
</template>

<h3>{{ compare.RemovedFiles.length }} Removed</h3>
<template v-for="file in compare.RemovedFiles">
<FileItem :file="file" />
<FileItem :commitId="fromCommitId" :file="file" />
</template>
</LoadingArea>

Expand Down

0 comments on commit 4e62dd5

Please sign in to comment.