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 Copy button to broker client username #4701

Merged
merged 3 commits into from
Oct 25, 2024
Merged
Changes from 1 commit
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
24 changes: 19 additions & 5 deletions frontend/src/pages/team/Broker/index.vue
Original file line number Diff line number Diff line change
Expand Up @@ -69,8 +69,11 @@
<li v-for="client in filteredClients" :key="client.id" class="client" data-el="client">
<ff-accordion class="max-w-full w-full">
<template #label>
<div class="username text-left">
{{ client.username }}<span class="italic">@{{ team.id }}</span>
<div class="username text-left flex">
<span class="mt-1 font-bold">{{ client.username }}</span><span class="italic mt-1">@{{ team.id }}</span>
<ff-button v-if="!!clipboardSupported" class="ml-2" kind="tertiary" size="small" @click.prevent.stop="copy(client)">
<template #icon-right><ClipboardCopyIcon /></template>
</ff-button>
</div>
<div class="rules text-left">
<span>{{ client.acls.length }} Rule{{ client.acls.length > 1 ? 's' : '' }}</span>
Expand Down Expand Up @@ -174,12 +177,13 @@
</template>

<script>
import { CheckIcon, PencilIcon, PlusSmIcon, SearchIcon, TrashIcon, XIcon } from '@heroicons/vue/outline'
import { CheckIcon, ClipboardCopyIcon, PencilIcon, PlusSmIcon, SearchIcon, TrashIcon, XIcon } from '@heroicons/vue/outline'
import { mapState } from 'vuex'

import brokerApi from '../../../api/broker.js'
import FfAccordion from '../../../components/Accordion.vue'
import EmptyState from '../../../components/EmptyState.vue'
import clipboardMixin from '../../../mixins/Clipboard.js'
import featuresMixin from '../../../mixins/Features.js'
import permissionsMixin from '../../../mixins/Permissions.js'
import Alerts from '../../../services/alerts.js'
Expand All @@ -199,9 +203,10 @@ export default {
CheckIcon,
XIcon,
EmptyState,
ClientDialog
ClientDialog,
ClipboardCopyIcon
},
mixins: [permissionsMixin, featuresMixin],
mixins: [permissionsMixin, featuresMixin, clipboardMixin],
data () {
return {
loading: false,
Expand Down Expand Up @@ -268,6 +273,15 @@ export default {
await this.fetchData()
Alerts.emit('Successfully deleted Client.', 'confirmation')
})
},
copy (client) {
const username = `${client.username}@${this.team.id}`
this.copyToClipboard(username).then(() => {
Alerts.emit('Coppied to Clipboard.', 'confirmation')
knolleary marked this conversation as resolved.
Show resolved Hide resolved
}).catch((err) => {
console.warn('Clipboard write permission denied: ', err)
Alerts.emit('Clipboard write permission denied.', 'warning')
})
}
}
}
Expand Down
Loading