This repository has been archived by the owner on Apr 17, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 472
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
js: created <tag> component with copy to clipboard
- Loading branch information
1 parent
9d6cc25
commit acad5b6
Showing
15 changed files
with
142 additions
and
25 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
19 changes: 19 additions & 0 deletions
19
app/assets/javascripts/modules/explore/components/result-item.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
import moment from 'moment'; | ||
|
||
import Tag from '~/modules/repositories/components/tag'; | ||
|
||
export default { | ||
template: '#js-result-item-tmpl', | ||
|
||
props: ['repository'], | ||
|
||
components: { | ||
Tag, | ||
}, | ||
|
||
computed: { | ||
updatedAt() { | ||
return moment(this.repository.updated_at).fromNow(); | ||
}, | ||
}, | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
import './pages/index'; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
import Vue from 'vue'; | ||
|
||
import ResultItem from '../components/result-item'; | ||
|
||
const { set } = Vue; | ||
|
||
$(() => { | ||
if (!$('body[data-route="explore/index"]').length) { | ||
return; | ||
} | ||
|
||
// eslint-disable-next-line no-new | ||
new Vue({ | ||
el: 'body[data-route="explore/index"] .vue-root', | ||
|
||
components: { | ||
ResultItem, | ||
}, | ||
|
||
data() { | ||
return { | ||
repositories: [], | ||
}; | ||
}, | ||
|
||
mounted() { | ||
set(this, 'repositories', window.repositories); | ||
}, | ||
}); | ||
}); |
42 changes: 42 additions & 0 deletions
42
app/assets/javascripts/modules/repositories/components/tag.vue
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
<style scoped> | ||
.label { | ||
cursor: pointer; | ||
} | ||
</style> | ||
|
||
<template> | ||
<div class="label label-success" title="Copy to clipboard" @click="copyToClipboard"> | ||
{{ tag.name }} | ||
</div> | ||
</template> | ||
|
||
<script> | ||
import Alert from '~/shared/components/alert'; | ||
export default { | ||
props: ['tag', 'repository'], | ||
computed: { | ||
commandToPull() { | ||
const hostname = this.repository.registry_hostname; | ||
const repoName = this.repository.full_name; | ||
const tagName = this.tag.name; | ||
return `docker pull ${hostname}/${repoName}:${tagName}`; | ||
}, | ||
}, | ||
methods: { | ||
copyToClipboard() { | ||
const $temp = $('<input>'); | ||
$('body').append($temp); | ||
$temp.val(this.commandToPull).select(); | ||
document.execCommand('copy'); | ||
$temp.remove(); | ||
Alert.show('Copied pull command to clipboard'); | ||
}, | ||
}, | ||
}; | ||
</script> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
li.result-item.text-left | ||
.clearfix | ||
h4.result-item-name.pull-left | ||
| {{ repository.full_name }} | ||
|
||
.result-item-stars.pull-right | ||
| {{ repository.stars }} | ||
| | ||
i.fa.fa-star | ||
|
||
.clearfix | ||
.tags.pull-left | ||
<tag :tag="tag" v-for="tag in repository.tags[0]" :key="tag.id" :repository="repository"></tag> | ||
|
||
.pull-right | ||
| Updated {{ updatedAt }} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3,8 +3,16 @@ | |
- repo_count = @repositories.count | ||
| #{pluralize(repo_count, 'repository')} #{repo_count == 1 ? "was" : "were"} found | ||
ul.result-list | ||
- @repositories.each do |r| | ||
= render partial: 'explore/partials/result_item', locals: { repository: r } | ||
<result-item :repository="repository" v-for="repository in repositories" :key="repository.full_name"></result-item> | ||
|
||
- if params[:explore] && [email protected]? | ||
h2 Your search did not match any repositories. | ||
|
||
- content_for :js_header do | ||
javascript: | ||
window.repositories = #{raw @repositories.to_json}; | ||
- content_for :js_body do | ||
- cache "explore/components/templates" do | ||
script#js-result-item-tmpl type="text/x-template" | ||
= render "explore/components/result_item" |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters