summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPhil Hughes <me@iamphill.com>2017-11-21 11:43:35 +0000
committerPhil Hughes <me@iamphill.com>2017-11-21 11:43:35 +0000
commite9c405bbed1ec765b7514de57d7ff21b4e2a70d8 (patch)
treea6342d64debda685f524f311a7587a7d6afd08c1
parent0eff9816ab7ffc6ee5d5017f433053edbb0c49e9 (diff)
downloadgitlab-ce-multi-file-blob-viewer.tar.gz
fixed up copy button click methodmulti-file-blob-viewer
moved classes to computed props
-rw-r--r--app/assets/javascripts/repo/components/blob_viewer_switch.vue10
-rw-r--r--app/assets/javascripts/repo/components/source_copy_button.vue17
2 files changed, 19 insertions, 8 deletions
diff --git a/app/assets/javascripts/repo/components/blob_viewer_switch.vue b/app/assets/javascripts/repo/components/blob_viewer_switch.vue
index 0b4379773a6..29efecb3235 100644
--- a/app/assets/javascripts/repo/components/blob_viewer_switch.vue
+++ b/app/assets/javascripts/repo/components/blob_viewer_switch.vue
@@ -16,6 +16,12 @@
richTooltip() {
return `Display ${this.activeFile.rich.switcherTitle}`;
},
+ simpleIconClass() {
+ return `fa-${this.activeFile.simple.icon}`;
+ },
+ richIconClass() {
+ return `fa-${this.activeFile.rich.icon}`;
+ },
},
methods: {
...mapActions([
@@ -44,7 +50,7 @@
>
<i
class="fa"
- :class="'fa-' + activeFile.simple.icon"
+ :class="simpleIconClass"
aria-hidden="true"
>
</i>
@@ -63,7 +69,7 @@
>
<i
class="fa"
- :class="'fa-' + activeFile.rich.icon"
+ :class="richIconClass"
aria-hidden="true"
>
</i>
diff --git a/app/assets/javascripts/repo/components/source_copy_button.vue b/app/assets/javascripts/repo/components/source_copy_button.vue
index 3a21c214fa1..672bf01ef76 100644
--- a/app/assets/javascripts/repo/components/source_copy_button.vue
+++ b/app/assets/javascripts/repo/components/source_copy_button.vue
@@ -29,10 +29,10 @@
'changeFileViewer',
]),
clickCopy(e) {
- if (this.activeFile.currentViewer !== 'simple') {
+ if (this.activeFile.currentViewer !== 'simple' && this.activeFile.simple.html !== '') {
e.stopPropagation();
- this.changeFileViewer({
+ return this.changeFileViewer({
file: this.activeFile,
type: 'simple',
}).then(() => {
@@ -43,8 +43,13 @@
setTimeout(() => {
this.$refs.clipboardBtn.click();
});
- }).catch(() => {});
+ });
+ } else if (this.activeFile.currentViewer !== 'simple' && this.activeFile.simple.html === '') {
+ e.stopPropagation();
+ return false;
}
+
+ return true;
},
},
};
@@ -61,9 +66,9 @@
:title="copySourceButtonTitle"
:aria-label="copySourceButtonTitle"
data-container="body"
- :data-clipboard-target="blobContentElementSelector"
- @click="clickCopy($event)"
- ref="clipboardBtn"
+ :data-clipboard-target="blobContentElementSelector"
+ @click="clickCopy($event)"
+ ref="clipboardBtn"
>
<i
aria-hidden="true"