summaryrefslogtreecommitdiff
path: root/app/assets/javascripts/code_navigation/components/popover.vue
diff options
context:
space:
mode:
Diffstat (limited to 'app/assets/javascripts/code_navigation/components/popover.vue')
-rw-r--r--app/assets/javascripts/code_navigation/components/popover.vue33
1 files changed, 26 insertions, 7 deletions
diff --git a/app/assets/javascripts/code_navigation/components/popover.vue b/app/assets/javascripts/code_navigation/components/popover.vue
index b4d9bc7b181..7147ce227e8 100644
--- a/app/assets/javascripts/code_navigation/components/popover.vue
+++ b/app/assets/javascripts/code_navigation/components/popover.vue
@@ -1,9 +1,9 @@
<script>
-import { GlDeprecatedButton } from '@gitlab/ui';
+import { GlButton } from '@gitlab/ui';
export default {
components: {
- GlDeprecatedButton,
+ GlButton,
},
props: {
position: {
@@ -18,6 +18,10 @@ export default {
type: String,
required: true,
},
+ blobPath: {
+ type: String,
+ required: true,
+ },
},
data() {
return {
@@ -32,9 +36,18 @@ export default {
};
},
definitionPath() {
- return (
- this.data.definition_path && `${this.definitionPathPrefix}/${this.data.definition_path}`
- );
+ if (!this.data.definition_path) {
+ return null;
+ }
+
+ if (this.isDefinitionCurrentBlob) {
+ return `#${this.data.definition_path.split('#').pop()}`;
+ }
+
+ return `${this.definitionPathPrefix}/${this.data.definition_path}`;
+ },
+ isDefinitionCurrentBlob() {
+ return this.data.definition_path.indexOf(this.blobPath) === 0;
},
},
watch: {
@@ -77,9 +90,15 @@ export default {
</p>
</div>
<div v-if="definitionPath" class="popover-body">
- <gl-deprecated-button :href="definitionPath" target="_blank" class="w-100" variant="default">
+ <gl-button
+ :href="definitionPath"
+ :target="isDefinitionCurrentBlob ? null : '_blank'"
+ class="w-100"
+ variant="default"
+ data-testid="go-to-definition-btn"
+ >
{{ __('Go to definition') }}
- </gl-deprecated-button>
+ </gl-button>
</div>
</div>
</template>