From 34af5d3a76203559c0055961bfef0ef1949edcb0 Mon Sep 17 00:00:00 2001 From: Mark Dawson Date: Mon, 8 Apr 2024 09:48:50 +0100 Subject: [PATCH 01/16] Use initialOptions prop to save view state --- src/views/Analysis.vue | 31 +++++++++++++++++++++++++------ 1 file changed, 25 insertions(+), 6 deletions(-) diff --git a/src/views/Analysis.vue b/src/views/Analysis.vue index b2c5fc1ad..ea17f2c2a 100644 --- a/src/views/Analysis.vue +++ b/src/views/Analysis.vue @@ -125,6 +125,10 @@ import { import gql from 'graphql-tag' import { getPageTitle } from '@/utils/index' import graphqlMixin from '@/mixins/graphql' +import { + initialOptions, + useInitialOptions +} from '@/utils/initialOptions' import AnalysisTable from '@/components/cylc/analysis/AnalysisTable.vue' import BoxPlot from '@/components/cylc/analysis/BoxPlot.vue' import { @@ -227,18 +231,33 @@ export default { this.historicalQuery() }, + props: { initialOptions }, + + setup (props, { emit }) { + /** + * The task name, timing option and platform filter state. + * @type {import('vue').Ref} + */ + const tasksFilter = useInitialOptions('tasksFilter', { props, emit }, { name: '', timingOption: 'totalTimes', platformOption: -1 }) + + /** + * If true the anaysis will be shown in table format + * @type {import('vue').Ref} + */ + const table = useInitialOptions('tasksFilter', { props, emit }, true) + + return { + tasksFilter, + table + } + }, + data () { const tasks = [] return { callback: new AnalysisCallback(tasks), /** Object containing all of the tasks added by the callback */ tasks, - tasksFilter: { - name: '', - timingOption: 'totalTimes', - platformOption: -1, - }, - table: true, } }, From 0e7e36850061acd81426c84c8afbde12470d80c8 Mon Sep 17 00:00:00 2001 From: Mark Dawson Date: Tue, 9 Apr 2024 10:53:35 +0100 Subject: [PATCH 02/16] added tests --- src/views/Analysis.vue | 6 +-- tests/e2e/specs/analysis.cy.js | 88 ++++++++++++++++++++++++++++++++++ 2 files changed, 91 insertions(+), 3 deletions(-) diff --git a/src/views/Analysis.vue b/src/views/Analysis.vue index ea17f2c2a..031230d7e 100644 --- a/src/views/Analysis.vue +++ b/src/views/Analysis.vue @@ -103,12 +103,12 @@ along with this program. If not, see . } */ - const table = useInitialOptions('tasksFilter', { props, emit }, true) + const table = useInitialOptions('table', { props, emit }, true) return { tasksFilter, diff --git a/tests/e2e/specs/analysis.cy.js b/tests/e2e/specs/analysis.cy.js index 4b568be12..d3286a7a8 100644 --- a/tests/e2e/specs/analysis.cy.js +++ b/tests/e2e/specs/analysis.cy.js @@ -265,3 +265,91 @@ describe('Analysis view', () => { }) }) }) + +function addView (view) { + cy.get('[data-cy=add-view-btn]').click() + cy.get(`#toolbar-add-${view}-view`).click() + // wait for menu to close + .should('not.be.exist') +} + +describe('Filters and Options save state', () => { + const numTasks = sortedTasks.length + describe('Options save state', () => { + it.only('remembers table and box & whiskers toggle option when switching between workflows', () => { + cy.visit('/#/workspace/one') + addView('Analysis') + cy.get('.c-analysis [data-cy=box-plot-toggle]') + .click() + .get('.vue-apexcharts') + .should('be.visible') + // Navigate away + cy.visit('/#/') + cy.get('.c-dashboard') + // Navigate back + cy.visit('/#/workspace/one') + cy.get('.vue-apexcharts') + .should('be.visible') + }) + }) + describe('Filters save state', () => { + it('remembers task name, platform and timings when switching between workflows', () => { + cy.visit('/#/workspace/one') + addView('Analysis') + // Check default options + cy + .get('.c-analysis table > tbody > tr') + .should('have.length', numTasks) + .should('be.visible') + cy + .get('td') + .contains('30') + .should('be.visible') + // Set platform filter options + cy + .get('#c-analysis-filter-task-platforms') + .click({ force: true }) + cy + .get('.v-list-item') + .contains('platform_1') + .click({ force: true }) + // Set queue task name filter options + cy + .get('#c-analysis-filter-task-name') + .type('wait') + // Set task times filter options + cy + .get('#c-analysis-filter-task-timings') + .click({ force: true }) + cy + .get('.v-list-item') + .contains('Queue') + .click({ force: true }) + // Navigate away + cy.visit('/#/') + cy.get('.c-dashboard') + // Navigate back + cy.visit('/#/workspace/one') + // Check name filter + cy + .get('td') + .contains('waiting') + .should('be.visible') + // Check timing filter + cy + .get('td') + .contains('00:00:12') + .should('be.visible') + // Check platform filter + cy + .get('td') + .contains('platform_1') + .should('be.visible') + // Other checks + cy + .get('.c-analysis table > tbody > tr') + .should('have.length', 1) + .should('be.visible') + }) + }) +}) From a26db04dec44a4b2b23288ffba15480558d84998 Mon Sep 17 00:00:00 2001 From: Mark Dawson Date: Tue, 9 Apr 2024 11:19:40 +0100 Subject: [PATCH 03/16] fix linting issue --- tests/e2e/specs/analysis.cy.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/e2e/specs/analysis.cy.js b/tests/e2e/specs/analysis.cy.js index d3286a7a8..83cca85e2 100644 --- a/tests/e2e/specs/analysis.cy.js +++ b/tests/e2e/specs/analysis.cy.js @@ -276,7 +276,7 @@ function addView (view) { describe('Filters and Options save state', () => { const numTasks = sortedTasks.length describe('Options save state', () => { - it.only('remembers table and box & whiskers toggle option when switching between workflows', () => { + it('remembers table and box & whiskers toggle option when switching between workflows', () => { cy.visit('/#/workspace/one') addView('Analysis') cy.get('.c-analysis [data-cy=box-plot-toggle]') From 96f5d1ae49a042ebc9b6211035034137285a12f4 Mon Sep 17 00:00:00 2001 From: Mark Dawson Date: Tue, 9 Apr 2024 11:27:25 +0100 Subject: [PATCH 04/16] updated change log --- changes.d/1717.feat.md | 1 + changes.d/1744.feat.md | 1 + 2 files changed, 2 insertions(+) create mode 100644 changes.d/1717.feat.md create mode 100644 changes.d/1744.feat.md diff --git a/changes.d/1717.feat.md b/changes.d/1717.feat.md new file mode 100644 index 000000000..7938e3f9b --- /dev/null +++ b/changes.d/1717.feat.md @@ -0,0 +1 @@ +More view options are now remembered & restored when navigating between workflows. \ No newline at end of file diff --git a/changes.d/1744.feat.md b/changes.d/1744.feat.md new file mode 100644 index 000000000..7938e3f9b --- /dev/null +++ b/changes.d/1744.feat.md @@ -0,0 +1 @@ +More view options are now remembered & restored when navigating between workflows. \ No newline at end of file From 9cfd4c09bc5d4c1daebbe3d87688f1e32c18816d Mon Sep 17 00:00:00 2001 From: Mark Dawson Date: Wed, 10 Apr 2024 12:59:50 +0100 Subject: [PATCH 05/16] review amends --- tests/e2e/specs/analysis.cy.js | 28 ++++++++-------------------- 1 file changed, 8 insertions(+), 20 deletions(-) diff --git a/tests/e2e/specs/analysis.cy.js b/tests/e2e/specs/analysis.cy.js index 83cca85e2..967a5f47d 100644 --- a/tests/e2e/specs/analysis.cy.js +++ b/tests/e2e/specs/analysis.cy.js @@ -292,19 +292,18 @@ describe('Filters and Options save state', () => { .should('be.visible') }) }) + describe('Filters save state', () => { it('remembers task name, platform and timings when switching between workflows', () => { cy.visit('/#/workspace/one') addView('Analysis') + // Check default options cy .get('.c-analysis table > tbody > tr') .should('have.length', numTasks) .should('be.visible') - cy - .get('td') - .contains('30') - .should('be.visible') + // Set platform filter options cy .get('#c-analysis-filter-task-platforms') @@ -313,10 +312,12 @@ describe('Filters and Options save state', () => { .get('.v-list-item') .contains('platform_1') .click({ force: true }) + // Set queue task name filter options cy .get('#c-analysis-filter-task-name') .type('wait') + // Set task times filter options cy .get('#c-analysis-filter-task-timings') @@ -325,27 +326,14 @@ describe('Filters and Options save state', () => { .get('.v-list-item') .contains('Queue') .click({ force: true }) + // Navigate away cy.visit('/#/') cy.get('.c-dashboard') // Navigate back cy.visit('/#/workspace/one') - // Check name filter - cy - .get('td') - .contains('waiting') - .should('be.visible') - // Check timing filter - cy - .get('td') - .contains('00:00:12') - .should('be.visible') - // Check platform filter - cy - .get('td') - .contains('platform_1') - .should('be.visible') - // Other checks + + // Check number of tasks cy .get('.c-analysis table > tbody > tr') .should('have.length', 1) From 8159920e7090de8d1bbacf36e2b2ec85f466b897 Mon Sep 17 00:00:00 2001 From: Ronnie Dutta <61982285+MetRonnie@users.noreply.github.com> Date: Wed, 10 Apr 2024 16:39:43 +0100 Subject: [PATCH 06/16] Analysis view: fix teleport of box & whiskers sort input when mounted Use a template ref to ensure we only teleport once analysis view has been mounted --- src/components/cylc/analysis/BoxPlot.vue | 4 ++-- src/views/Analysis.vue | 14 ++++++++++---- 2 files changed, 12 insertions(+), 6 deletions(-) diff --git a/src/components/cylc/analysis/BoxPlot.vue b/src/components/cylc/analysis/BoxPlot.vue index 734b4115b..f92f1146e 100644 --- a/src/components/cylc/analysis/BoxPlot.vue +++ b/src/components/cylc/analysis/BoxPlot.vue @@ -18,7 +18,7 @@ along with this program. If not, see .