diff options
Diffstat (limited to 'app/assets/javascripts/code_navigation/components')
-rw-r--r-- | app/assets/javascripts/code_navigation/components/app.vue | 8 | ||||
-rw-r--r-- | app/assets/javascripts/code_navigation/components/popover.vue | 33 |
2 files changed, 33 insertions, 8 deletions
diff --git a/app/assets/javascripts/code_navigation/components/app.vue b/app/assets/javascripts/code_navigation/components/app.vue index d738c914125..85ec0a60ec5 100644 --- a/app/assets/javascripts/code_navigation/components/app.vue +++ b/app/assets/javascripts/code_navigation/components/app.vue @@ -8,7 +8,12 @@ export default { Popover, }, computed: { - ...mapState(['currentDefinition', 'currentDefinitionPosition', 'definitionPathPrefix']), + ...mapState([ + 'currentDefinition', + 'currentDefinitionPosition', + 'currentBlobPath', + 'definitionPathPrefix', + ]), }, mounted() { this.body = document.body; @@ -44,5 +49,6 @@ export default { :position="currentDefinitionPosition" :data="currentDefinition" :definition-path-prefix="definitionPathPrefix" + :blob-path="currentBlobPath" /> </template> 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> |