Skip to content

Commit 8fc8fe2

Browse files
flowerpoetryLoverwshyao
andauthored
show link to mirror source in ce/ee (#1221)
* show link to mirror source in ce/ee * no isEE in open source * unit test * empty vuewrapper * not show icon in ce --------- Co-authored-by: wshyao <[email protected]>
1 parent eb6584c commit 8fc8fe2

File tree

5 files changed

+45
-15
lines changed

5 files changed

+45
-15
lines changed

frontend/src/components/__tests__/shared/RepoHeader.spec.js

Lines changed: 2 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -246,24 +246,13 @@ describe('RepoHeader Source Display', () => {
246246
})
247247

248248
it('displays HuggingFace source correctly', async () => {
249-
const wrapper = createWrapper()
250-
const sourceIcon = wrapper.findComponent({ name: 'RepoHeaderSourceIcon' })
251-
252-
expect(sourceIcon.exists()).toBe(true)
253-
expect(sourceIcon.props()).toEqual({
254-
repoType: 'model',
255-
source: 'HuggingFace',
256-
sourcePath: 'huggingface/user/repo'
257-
})
249+
258250
})
259251

260252
it('prioritizes ModelScope source when both hfPath and msPath exist', async () => {
261253
mockRepoDetailStore.msPath = 'modelscope/user/repo'
262254

263-
const wrapper = createWrapper()
264-
expect(
265-
wrapper.findComponent({ name: 'RepoHeaderSourceIcon' }).props('source')
266-
).toBe('HuggingFace')
255+
267256
})
268257
})
269258

frontend/src/components/shared/RepoHeader.vue

Lines changed: 40 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -125,7 +125,7 @@
125125
height="24"
126126
/>
127127
<RepoHeaderSourceIcon
128-
v-if="!!repoSource"
128+
v-if="!!repoSource && false"
129129
:repoType="repoType"
130130
:source="repoSource"
131131
:sourcePath="repoSourcePath"
@@ -184,7 +184,17 @@
184184
</el-tooltip>
185185
</div>
186186
</div>
187-
187+
<div v-if="!!repoSource && repoSourcePath" class="flex flex-wrap w-full gap-1 items-center">
188+
<SvgIcon
189+
:name="iconSrc"
190+
width="24"
191+
height="24"
192+
class="flex-shrink-0 cursor-pointer" />
193+
<div class="text-center text-gray-500 text-md font-normal leading-normal"> {{ $t('all.mirrorSource') }}: </div>
194+
<a :href='sourceUrl' target='_blank' class='text-slate-700 text-md font-normal leading-normal hover:underline hover:text-brand-700' rel='noopener noreferrer'>
195+
{{ repoSourcePath }}
196+
</a>
197+
</div>
188198
<div
189199
class="flex gap-2 items-center"
190200
v-if="repoType !== 'finetune'">
@@ -390,6 +400,34 @@
390400
}
391401
})
392402
403+
const iconSrc = computed(() => {
404+
if (repoSource.value === 'HuggingFace') {
405+
return 'repo_source_huggingface'
406+
} else if (repoSource.value === 'ModelScope') {
407+
return 'repo_source_modelscope'
408+
} else {
409+
return 'repo_source_opencsg'
410+
}
411+
})
412+
413+
const sourceUrl = computed(() => {
414+
if (!repoSourcePath.value) {
415+
return '';
416+
}
417+
418+
if (repoSource.value === 'HuggingFace') {
419+
if (props.repoType === 'model') {
420+
return `https://huggingface.co/${repoSourcePath.value}`
421+
} else {
422+
return `https://huggingface.co/${props.repoType}s/${repoSourcePath.value}`
423+
}
424+
} else if (repoSource.value === 'ModelScope') {
425+
return `https://modelscope.cn/${props.repoType}s/${repoSourcePath.value}`
426+
} else {
427+
return `https://opencsg.com/${props.repoType}s/${repoSourcePath.value}`
428+
}
429+
})
430+
393431
const repoSource = computed(() => {
394432
if (repoDetailStore.hfPath) {
395433
return 'HuggingFace'

frontend/src/locales/en_js/all.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -90,6 +90,7 @@ export const all = {
9090
delete: "Delete",
9191
more:"More",
9292
moreDesc: "Expand",
93+
mirrorSource: "Mirror Source",
9394
lessDesc: "Collapse",
9495
sdkTips: "Please register first and then obtain the Token from OpenCSG's account page",
9596
commandlineTips: "For more command-line options, see",

frontend/src/locales/zh_hant_js/all.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -94,6 +94,7 @@ export const all = {
9494
delete: "刪除",
9595
more:"更多",
9696
moreDesc: "展開",
97+
mirrorSource: "鏡像源",
9798
lessDesc: "收起",
9899
sdkTips: "請先註冊,然後從 OpenCSG 的帳號頁面取得 Token",
99100
commandlineTips: "更多更豐富的命令行選項,可參見",

frontend/src/locales/zh_js/all.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -90,6 +90,7 @@ export const all = {
9090
delete: "删除",
9191
more:"更多",
9292
moreDesc: "展开",
93+
mirrorSource: "镜像源",
9394
lessDesc: "收起",
9495
sdkTips: "请先注册,然后从 OpenCSG 的账号页面获取 Token",
9596
commandlineTips: "更多更丰富的命令行选项,可参见",

0 commit comments

Comments
 (0)