From 97e33fd4b4c8dc3ab3b3728e6f6f6cc0718fda88 Mon Sep 17 00:00:00 2001
From: Ronnie Dutta <61982285+MetRonnie@users.noreply.github.com>
Date: Tue, 13 Feb 2024 17:16:59 +0000
Subject: [PATCH 1/7] Use `initialOptions` prop to save view state
This is saved along with the Lumino layout for restoring after navigation.
Implemented for the log view only so far.
---
src/components/cylc/cylcObject/Menu.vue | 2 +-
src/components/cylc/workflow/Lumino.vue | 14 +--
src/views/Log.vue | 124 +++++++++++++++---------
src/views/initialOptions.js | 62 ++++++++++++
tests/e2e/specs/log.cy.js | 49 ++++++++++
tests/unit/views/initialOptions.spec.js | 51 ++++++++++
tests/unit/views/log.vue.spec.js | 45 +++++++--
7 files changed, 283 insertions(+), 64 deletions(-)
create mode 100644 src/views/initialOptions.js
create mode 100644 tests/unit/views/initialOptions.spec.js
diff --git a/src/components/cylc/cylcObject/Menu.vue b/src/components/cylc/cylcObject/Menu.vue
index 8c6f2c293..a62b6e75a 100644
--- a/src/components/cylc/cylcObject/Menu.vue
+++ b/src/components/cylc/cylcObject/Menu.vue
@@ -279,7 +279,7 @@ export default {
{
name: 'Log',
initialOptions: {
- relativeID: this.node.tokens.relativeID
+ relativeID: this.node.tokens.relativeID || null
}
}
)
diff --git a/src/components/cylc/workflow/Lumino.vue b/src/components/cylc/workflow/Lumino.vue
index 65151f188..61cea3d87 100644
--- a/src/components/cylc/workflow/Lumino.vue
+++ b/src/components/cylc/workflow/Lumino.vue
@@ -19,14 +19,14 @@ along with this program. If not, see .
@@ -62,7 +62,7 @@ import { useDefaultView } from '@/views/views'
* Mitt event for adding a view to the workspace.
* @typedef {Object} AddViewEvent
* @property {string} name - the view to add
- * @property {Object=} initialOptions - prop passed to the view component
+ * @property {Record} initialOptions - prop passed to the view component
*/
const $eventBus = inject('eventBus')
@@ -135,16 +135,16 @@ onBeforeUnmount(() => {
/**
* Create a widget and add it to the dock.
*
- * @param {AddViewEvent} view
+ * @param {AddViewEvent} event
* @param {boolean} onTop
*/
-const addView = (view, onTop = true) => {
+const addView = ({ name, initialOptions = {} }, onTop = true) => {
const id = uniqueId('widget')
- const luminoWidget = new LuminoWidget(id, startCase(view.name), /* closable */ true)
+ const luminoWidget = new LuminoWidget(id, startCase(name), /* closable */ true)
dockPanel.addWidget(luminoWidget, { mode: 'tab-after' })
// give time for Lumino's widget DOM element to be created
nextTick(() => {
- views.value.set(id, view)
+ views.value.set(id, { name, initialOptions })
addWidgetEventListeners(id)
if (onTop) {
dockPanel.selectWidget(luminoWidget)
diff --git a/src/views/Log.vue b/src/views/Log.vue
index 39ff79307..ea89a51a5 100644
--- a/src/views/Log.vue
+++ b/src/views/Log.vue
@@ -56,7 +56,8 @@ along with this program. If not, see .
v-if="jobLog"
data-cy="job-id-input"
class="flex-grow-1 flex-column"
- v-model="relativeID"
+ :model-value="relativeID"
+ @update:modelValue="debouncedUpdateRelativeID"
placeholder="cycle/task/job"
clearable
/>
@@ -143,6 +144,8 @@ along with this program. If not, see .