-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathedit.vue
More file actions
62 lines (53 loc) · 2.02 KB
/
Copy pathedit.vue
File metadata and controls
62 lines (53 loc) · 2.02 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
// Test outline
// @test e2e: loading this page successfully loads the Rapid editor with the workspace data, and shows the editor UI (playwright snapshot this)
// @test e2e: loading this page with each. value of the "editor" query param (e.g. rapid vs rapid3) loads the correct editor version (playwright snapshot each version's UI)
// @test e2e: loading this page with the "osw" datatype query param loads the OpenSidewalks editor, and without it loads the Pathways editor (playwright snapshot each editor's UI)
// @test e2e: validate that all the API calls used on this page match the Swagger spec (https://new-api.workspaces-stage.sidewalks.washington.edu/openapi.json)
<template>
<div
ref="editorContainer"
class="editorContainer"
/>
</template>
<script setup lang="ts">
import { pathwaysManager, rapidManager, rapid3Manager } from '~/services/index';
const route = useRoute();
const workspaceId = Number(route.params.id);
const datatype = route.query.datatype;
const editor = route.query.editor;
const editorContainer = ref<HTMLDivElement | null>(null);
const oswManager = (editor === 'rapid3' && rapid3Manager) ? rapid3Manager : rapidManager
const manager = datatype === 'osw' ? oswManager : pathwaysManager
function onEditorLoaded() {
editorContainer.value!.appendChild(manager.containerNode);
manager.init(workspaceId);
}
onMounted(() => {
// If a different Rapid version is already loaded, hard-reload to swap.
// Only one version can occupy the global Rapid namespace at a time.
if (datatype === 'osw') {
const otherManager = manager === rapidManager ? rapid3Manager : rapidManager
if (otherManager?.loaded.value) {
window.location.reload()
return
}
}
if (!manager.loaded.value) {
watch(manager.loaded, (val) => {
if (val) {
onEditorLoaded();
}
});
manager.load();
} else {
editorContainer.value!.appendChild(manager.containerNode);
manager.switchWorkspace(workspaceId);
}
});
</script>
<style>
.editorContainer {
width: 100%;
height: 100%;
}
</style>