Skip to content

Commit 2f207d5

Browse files
committed
feat(ui): add tooltip to SessionPlay for not recorded sessions
- moved the play button tooltip to SessionPlay - add tooltip text for not recorded sessions - refactor SessionPlay props
1 parent b39dfa2 commit 2f207d5

File tree

2 files changed

+42
-54
lines changed

2 files changed

+42
-54
lines changed

ui/src/components/Sessions/SessionList.vue

Lines changed: 6 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -18,22 +18,12 @@
1818
<template v-slot:rows>
1919
<tr v-for="(session, index) in sessions" :key="index">
2020
<td class="text-center">
21-
<v-tooltip location="bottom" :disabled="hasAuthorizationPlay()">
22-
<template v-slot:activator="{ props }">
23-
<div v-bind="props">
24-
<SessionPlay
25-
:disabled="!session.authenticated || !session.recorded"
26-
:uid="session.uid"
27-
:device="session.device"
28-
:notHasAuthorization="!hasAuthorizationPlay()"
29-
:recorded="session.authenticated && session.recorded"
30-
@update="refreshSessions"
31-
data-test="sessionPlay-component"
32-
/>
33-
</div>
34-
</template>
35-
<span> You don't have this kind of authorization. </span>
36-
</v-tooltip>
21+
<SessionPlay
22+
:authenticated="session.authenticated"
23+
:uid="session.uid"
24+
:recorded="session.recorded"
25+
data-test="session-play-component"
26+
/>
3727
</td>
3828

3929
<td class="text-center" v-if="session.device">
@@ -273,15 +263,6 @@ const hasAuthorizationRemoveRecord = () => {
273263
274264
return false;
275265
};
276-
277-
const hasAuthorizationPlay = () => {
278-
const role = store.getters["auth/role"];
279-
if (role !== "") {
280-
return hasPermission(authorizer.role[role], actions.session.play);
281-
}
282-
283-
return false;
284-
};
285266
</script>
286267

287268
<style scoped>

ui/src/components/Sessions/SessionPlay.vue

Lines changed: 36 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,23 @@
11
<template>
22
<div>
3-
<v-btn
4-
color="primary"
5-
prepend-icon="mdi-play"
6-
variant="outlined"
7-
density="comfortable"
8-
data-test="connect-btn"
9-
@click="openDialog"
10-
:disabled="!isCommunity && props.disabled"
11-
>
12-
Play
13-
</v-btn>
3+
<v-tooltip location="bottom" :disabled="disableTooltip">
4+
<template v-slot:activator="{ props }">
5+
<div v-bind="props">
6+
<v-btn
7+
color="primary"
8+
prepend-icon="mdi-play"
9+
variant="outlined"
10+
density="comfortable"
11+
data-test="connect-btn"
12+
@click="openDialog"
13+
:disabled="!isCommunity && disabled"
14+
>
15+
Play
16+
</v-btn>
17+
</div>
18+
</template>
19+
<span>{{ tooltipMessage }}</span>
20+
</v-tooltip>
1421

1522
<v-dialog
1623
:transition="false"
@@ -37,36 +44,36 @@ import {
3744
computed,
3845
ref,
3946
} from "vue";
47+
import hasPermission from "@/utils/permission";
48+
import { actions, authorizer } from "@/authorizer";
4049
import { envVariables } from "@/envVariables";
4150
import { useStore } from "@/store";
4251
import handleError from "@/utils/handleError";
4352
import Player from "./Player.vue";
4453
import useSnackbar from "@/helpers/snackbar";
4554
46-
const props = defineProps({
47-
uid: {
48-
type: String,
49-
required: true,
50-
},
51-
recorded: {
52-
type: Boolean,
53-
required: true,
54-
},
55-
notHasAuthorization: {
56-
type: Boolean,
57-
default: false,
58-
},
59-
disabled: {
60-
type: Boolean,
61-
default: false,
62-
},
63-
});
55+
const props = defineProps<{
56+
uid: string;
57+
recorded: boolean;
58+
authenticated: boolean;
59+
}>();
6460
6561
const showDialog = ref(false);
6662
const store = useStore();
6763
const snackbar = useSnackbar();
64+
const disabled = computed(() => !props.recorded || !props.authenticated);
6865
const logs = ref<string | null>(null);
6966
const isCommunity = computed(() => envVariables.isCommunity);
67+
const tooltipMessage = computed(() => props.recorded
68+
? "You don't have permission to play this session."
69+
: "This session was not recorded.");
70+
71+
const hasAuthorizationToPlay = () => {
72+
const role = store.getters["auth/role"];
73+
return !!role && hasPermission(authorizer.role[role], actions.session.play);
74+
};
75+
76+
const disableTooltip = computed(() => isCommunity.value || (hasAuthorizationToPlay() && props.recorded));
7077
7178
const getSessionLogs = async () => {
7279
if (props.recorded) {

0 commit comments

Comments
 (0)