Skip to content

Commit fa8994f

Browse files
committed
feat(driver.js): showing driverjs tutorial for e2e link
1 parent af440c4 commit fa8994f

File tree

6 files changed

+56
-6
lines changed

6 files changed

+56
-6
lines changed

helpers/driverjsTutorials.ts

Lines changed: 32 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,17 @@ const copyLinkShortcutTutorial: Tutorial[] = [
7575
},
7676
]
7777

78-
const diffTutorials: TutorialMetadata[] = [
78+
const CopyE2ELinkTutorial: Tutorial[] = [
79+
{
80+
element: '#copyLinkButton',
81+
popover: {
82+
title: 'Copy E2E link',
83+
description: 'Now links for large data comparison are end-to-end encrytpted automatically. Read more about it on github repo.',
84+
},
85+
},
86+
]
87+
88+
const diffV1Tutorials: TutorialMetadata[] = [
7989
{
8090
tutorial: actionBarTutorial,
8191
cookieName: 'isSkipScrollInSyncTutorial',
@@ -88,6 +98,25 @@ const diffTutorials: TutorialMetadata[] = [
8898
tutorial: copyLinkShortcutTutorial,
8999
cookieName: 'isSkipCopyLinkShortcutTutorial',
90100
},
101+
{
102+
tutorial: CopyE2ELinkTutorial,
103+
cookieName: 'isSkipCopyE2ELinkTutorial',
104+
}
105+
]
106+
107+
const diffV2Tutorials: TutorialMetadata[] = [
108+
{
109+
tutorial: CopyE2ELinkTutorial,
110+
cookieName: 'isSkipCopyE2ELinkTutorial',
111+
},
112+
{
113+
tutorial: backButtonTutorial,
114+
cookieName: 'isSkipBackButtonPersistsDataTutorial',
115+
},
116+
{
117+
tutorial: copyLinkShortcutTutorial,
118+
cookieName: 'isSkipCopyLinkShortcutTutorial',
119+
},
91120
]
92121

93122
const comparePageTutorials: TutorialMetadata[] = [
@@ -102,8 +131,8 @@ const comparePageTutorials: TutorialMetadata[] = [
102131
]
103132

104133
const tutorialsMetadata: TutorialsMetadata = {
105-
'/v1/diff': diffTutorials,
106-
'/v2/diff': diffTutorials,
134+
'/v1/diff': diffV1Tutorials,
135+
'/v2/diff': diffV2Tutorials,
107136
'/': comparePageTutorials,
108137
'/v2': comparePageTutorials,
109138
}
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
export default function () {
2+
const cookies = document.cookie.split(';')
3+
const cookieMap: {
4+
isSkipCopyE2ELinkTutorial?: string
5+
} = {
6+
isSkipCopyE2ELinkTutorial: 'false',
7+
}
8+
cookies.forEach((element) => {
9+
const [name, val] = element.split('=')
10+
const trimmedName = name.trim()
11+
if (trimmedName === 'isSkipCopyE2ELinkTutorial') {
12+
cookieMap[trimmedName] = val
13+
}
14+
})
15+
return cookieMap.isSkipCopyE2ELinkTutorial === 'true'
16+
}

helpers/types.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ export interface Cookies {
55
isSkipBackButtonPersistsDataTutorial: boolean
66
isSkipSubmitKbdShortcutTutorial: boolean
77
isSkipCopyLinkShortcutTutorial: boolean
8+
isSkipCopyE2ELinkTutorial: boolean
89
}
910

1011
export interface Tutorial {

pages/v2/diff.vue

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,7 @@ import {
7979
E2E_DATA_LOADING_INFO,
8080
E2E_DATA_NO_LONGER_AVAILABLE_ERROR,
8181
} from '~/constants/messages'
82+
import showTutorials from '~/helpers/driverjsTutorials'
8283
export default Vue.extend({
8384
components: { DiffActionBar, Navbar, Footer },
8485
layout: 'main',
@@ -138,8 +139,8 @@ export default Vue.extend({
138139
const url = new URL(window.location.href)
139140
const id = url.searchParams.get('id')
140141
const key = url.hash.replace(/^#/, '')
141-
let response = null;
142-
let data = null
142+
let response = null
143+
let data = null
143144
try {
144145
response = await fetch(`/api/getLink?id=${id}`)
145146
data = await response.json()
@@ -200,6 +201,7 @@ export default Vue.extend({
200201
)
201202
}
202203
}
204+
showTutorials(this.$cookies, this.$route.path, this.$cookies.isDarkMode)
203205
})
204206
},
205207
unzipCommitData(data: string) {

pages/v2/index.vue

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -144,14 +144,14 @@ export default Vue.extend({
144144
},
145145
},
146146
mounted() {
147-
showTutorials(this.$cookies, this.$route.path, this.$cookies.isDarkMode)
148147
document.addEventListener('keydown', this.handleCtrlEnter)
149148
// Hover on each property to see its docs!
150149
const lhs = document.getElementById('lhs')
151150
const rhs = document.getElementById('rhs')
152151
const theme = this.$cookies.isDarkMode ? 'vs-dark' : 'light'
153152
const monacoEditorOptions = getMonacoEditorDefaultOptions(theme)
154153
loader.init().then((monaco) => {
154+
showTutorials(this.$cookies, this.$route.path, this.$cookies.isDarkMode)
155155
if (lhs) {
156156
this.lhsEditor = monaco.editor.create(lhs, {
157157
...monacoEditorOptions,

plugins/cookie-injector.client.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ import isSkipBackButtonPersistsDataTutorial from '~/helpers/isSkipBackButtonPers
66
import isSkipSubmitKbdShortcutTutorial from '~/helpers/isSkipSubmitKbdShortcutTutorial'
77
import { Cookies } from '~/helpers/types'
88
import isSkipCopyLinkShortcutTutorial from '~/helpers/isSkipCopyLinkShortcutTutorial'
9+
import isSkipCopyE2ELinkTutorial from '~/helpers/isSkipCopyE2ELinkTutorial'
910

1011
declare module 'vue/types/vue' {
1112
interface Vue {
@@ -40,6 +41,7 @@ const cookieInjectorPlugin: Plugin = (_context, inject) => {
4041
isSkipBackButtonPersistsDataTutorial(),
4142
isSkipSubmitKbdShortcutTutorial: isSkipSubmitKbdShortcutTutorial(),
4243
isSkipCopyLinkShortcutTutorial: isSkipCopyLinkShortcutTutorial(),
44+
isSkipCopyE2ELinkTutorial: isSkipCopyE2ELinkTutorial(),
4345
})
4446
}
4547

0 commit comments

Comments
 (0)