Skip to content

Commit

Permalink
[#98] polish logic of editor links within preview cards
Browse files Browse the repository at this point in the history
  • Loading branch information
Kreezag committed Jul 3, 2024
1 parent b2a7747 commit 793a411
Showing 1 changed file with 8 additions and 4 deletions.
12 changes: 8 additions & 4 deletions src/shared/ui/preview-card/preview-card-footer.vue
Original file line number Diff line number Diff line change
Expand Up @@ -55,8 +55,8 @@ const editorLink = computed(() => {
return "";
}
const fileName = props.originConfig.file || "";
const line = props.originConfig.line || "";
const fileName = mappedOrigins.value.file || "";
const line = mappedOrigins.value.line || "";
if (!fileName || fileName === "unknown") {
return "";
Expand All @@ -66,6 +66,9 @@ const editorLink = computed(() => {
line ? `&line=${line}` : ""
}`;
});
const isEditorLink = (key: string) =>
!!editorLink.value && (key === "file" || key === "line");
</script>

<template>
Expand All @@ -74,19 +77,20 @@ const editorLink = computed(() => {
<template v-if="mappedOrigins">
<template v-for="(value, key) in mappedOrigins" :key="key">
<div
v-if="key !== 'file' || !editorLink"
v-if="!isEditorLink(String(key))"
class="preview-card-footer__tag"
>
<span class="preview-card-footer__tag-key">{{ key }}:</span>
<span class="preview-card-footer__tag-value">{{ value }}</span>
</div>

<a
v-if="key === 'file' && editorLink"
v-if="isEditorLink(String(key))"
:href="editorLink"
target="_blank"
class="preview-card-footer__tag"
>
12314
<span class="preview-card-footer__tag-key">{{ key }}:</span>
<span class="preview-card-footer__tag-value">{{ value }}</span>
</a>
Expand Down

0 comments on commit 793a411

Please sign in to comment.