Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add a copy method to task run result locations #1033

Merged
merged 13 commits into from
Sep 2, 2021
Merged
Show file tree
Hide file tree
Changes from 10 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions Changelog.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@

### Features and Improvements

- Add a copy method to task run result locations - [#1033](https://github.com/PrefectHQ/ui/pull/1033)
- Route to task run page on timeline click - [#1024](https://github.com/PrefectHQ/ui/pull/1024
- Increase default number of flows shown in the flow table - [#1027](https://github.com/PrefectHQ/ui/pull/1027)
- Remove global max width on dashboard etc screens - [#1026](https://github.com/PrefectHQ/ui/pull/1026)
- Route to task run page on timeline click - [#1024](https://github.com/PrefectHQ/ui/pull/1024)
Expand Down
49 changes: 47 additions & 2 deletions src/pages/TaskRun/Details-Tile.vue
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,9 @@ export default {
}
},
data() {
return {}
return {
copiedText: {}
}
},
computed: {
expectedRuns() {
Expand All @@ -35,6 +37,20 @@ export default {
]
}
}
},
methods: {
copyTextToClipboard(text) {
if (!text) return

this.copiedText = {}
this.copiedText[text] = true
navigator.clipboard.writeText(text)

setTimeout(() => {
this.copiedText = {}
this.copiedText[text] = false
}, 1000)
}
}
}
</script>
Expand Down Expand Up @@ -227,7 +243,23 @@ export default {
<v-col cols="6" class="text-right font-weight-bold">
<v-tooltip top>
<template #activator="{ on }">
<span v-on="on">
<span
class="cursor-pointer show-icon-hover-focus-only pa-2px"
role="button"
@click="
copyTextToClipboard(
taskRun.serialized_state._result.location
)
"
v-on="on"
>
<v-icon x-small class="mb-2px mr-2" tabindex="0">
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should we add a v-if here to check if there's actually a result location to copy?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah that's sensible - the copy method won't throw an error since it checks for text to copy but I like hiding the icon in the case as well.

{{
copiedText[taskRun.serialized_state._result.location]
? 'check'
: 'file_copy'
}}
</v-icon>
{{ taskRun.serialized_state._result.location || 'None' }}
</span>
</template>
Expand Down Expand Up @@ -284,4 +316,17 @@ a {
content: '' !important;
}
}

.show-icon-hover-focus-only {
.v-icon {
visibility: hidden;
}

&:hover,
&:focus {
.v-icon {
visibility: visible;
}
}
}
</style>