From e96ec6ea4be5385b749aa255f00a55cb76e3ed3b Mon Sep 17 00:00:00 2001 From: Charles Dang Date: Fri, 22 May 2020 00:34:32 +1100 Subject: [PATCH 1/3] Admin UI: fixed regression in dashboard sort order --- packages/app-admin-ui/client/components/Nav/index.js | 11 +---------- packages/app-admin-ui/client/providers/AdminMeta.js | 6 +++++- 2 files changed, 6 insertions(+), 11 deletions(-) diff --git a/packages/app-admin-ui/client/components/Nav/index.js b/packages/app-admin-ui/client/components/Nav/index.js index 848fdc54af5..576c1b3167b 100644 --- a/packages/app-admin-ui/client/components/Nav/index.js +++ b/packages/app-admin-ui/client/components/Nav/index.js @@ -443,15 +443,6 @@ const PrimaryNavContent = ({ mouseIsOverNav }) => { authStrategy: { listKey: authListKey } = {}, } = useAdminMeta(); - const sortedListKeys = useMemo( - () => - listKeys - .map(key => getListByKey(key)) - .sort(({ label: a }, { label: b }) => a.localeCompare(b)) // TODO: locale options once intl support is added - .map(({ key }) => key), - [listKeys] - ); - return ( { adminPath={adminPath} authListKey={authListKey} getListByKey={getListByKey} - listKeys={sortedListKeys} + listKeys={listKeys} pages={pages} mouseIsOverNav={mouseIsOverNav} /> diff --git a/packages/app-admin-ui/client/providers/AdminMeta.js b/packages/app-admin-ui/client/providers/AdminMeta.js index edf83d6cf1a..77d26a15584 100644 --- a/packages/app-admin-ui/client/providers/AdminMeta.js +++ b/packages/app-admin-ui/client/providers/AdminMeta.js @@ -78,6 +78,10 @@ export const AdminMetaProvider = ({ children }) => { } ); + const listKeys = Object.values(listsByKey) + .sort(({ label: a }, { label: b }) => a.localeCompare(b)) // TODO: locale options once intl support is added + .map(({ key }) => key); + let hookViews = {}; if (typeof hookView === 'function') { [hookViews] = readViews([hookView]); @@ -94,7 +98,7 @@ export const AdminMetaProvider = ({ children }) => { signoutPath, authStrategy, name, - listKeys: Object.keys(lists || {}), + listKeys, getListByKey, getListByPath: path => listsByPath[path], hooks: hookViews, From 562af39c0bec798110aa32f8106d6e5707b8decf Mon Sep 17 00:00:00 2001 From: Charles Dang <exodia339@gmail.com> Date: Fri, 22 May 2020 05:02:40 +1100 Subject: [PATCH 2/3] Attempt to fixup tests --- .../basic/cypress/integration/create-buttons_spec.js | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/test-projects/basic/cypress/integration/create-buttons_spec.js b/test-projects/basic/cypress/integration/create-buttons_spec.js index 976ab578e63..94e1158752b 100644 --- a/test-projects/basic/cypress/integration/create-buttons_spec.js +++ b/test-projects/basic/cypress/integration/create-buttons_spec.js @@ -18,7 +18,11 @@ describe('Home page', () => { it('Create list buttons exists', () => { cy.visit('/admin'); [{ text: 'User' }, { text: 'Post' }, { text: 'Post Category' }].forEach(({ text }) => { - cy.contains('button', `Create ${text}`).should('have.attr', 'title', `Create ${text}`); + cy.contains('button', new RegExp(`^Create ${text}$g`)).should( + 'have.attr', + 'title', + `Create ${text}` + ); }); }); @@ -35,7 +39,7 @@ describe('Home page', () => { }, { text: 'Post Category', labels: ['Name', 'Slug'] }, ].forEach(({ text, labels }) => { - cy.contains('button', `Create ${text}`).click({ force: true }); + cy.contains('button', new RegExp(`^Create ${text}$g`)).click({ force: true }); cy.contains('div', `Create ${text} Dialog`).contains('h3', `Create ${text}`); cy.contains('div', `Create ${text} Dialog`).contains('button', 'Create'); labels.forEach(label => { From 8806da18049e21cec95252199f9c61ae57198ead Mon Sep 17 00:00:00 2001 From: Charles Dang <exodia339@gmail.com> Date: Fri, 22 May 2020 05:52:49 +1100 Subject: [PATCH 3/3] Fooo --- .../basic/cypress/integration/create-buttons_spec.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/test-projects/basic/cypress/integration/create-buttons_spec.js b/test-projects/basic/cypress/integration/create-buttons_spec.js index 94e1158752b..208c366edb1 100644 --- a/test-projects/basic/cypress/integration/create-buttons_spec.js +++ b/test-projects/basic/cypress/integration/create-buttons_spec.js @@ -18,7 +18,7 @@ describe('Home page', () => { it('Create list buttons exists', () => { cy.visit('/admin'); [{ text: 'User' }, { text: 'Post' }, { text: 'Post Category' }].forEach(({ text }) => { - cy.contains('button', new RegExp(`^Create ${text}$g`)).should( + cy.contains('button', new RegExp(`^Create ${text}$`)).should( 'have.attr', 'title', `Create ${text}` @@ -39,7 +39,7 @@ describe('Home page', () => { }, { text: 'Post Category', labels: ['Name', 'Slug'] }, ].forEach(({ text, labels }) => { - cy.contains('button', new RegExp(`^Create ${text}$g`)).click({ force: true }); + cy.contains('button', new RegExp(`^Create ${text}$`)).click({ force: true }); cy.contains('div', `Create ${text} Dialog`).contains('h3', `Create ${text}`); cy.contains('div', `Create ${text} Dialog`).contains('button', 'Create'); labels.forEach(label => {