From 21a4fe50b9ca1130b49e3342bb2cb4c5c21c6965 Mon Sep 17 00:00:00 2001 From: Aditi76117 Date: Mon, 13 Oct 2025 02:22:58 +0530 Subject: [PATCH] Replace Moment.js with date-fns across Deck codebase Signed-off-by: Aditi76117 --- cypress/e2e/cardFeatures.js | 9 +- package-lock.json | 287 +----------------- package.json | 3 +- server | 1 + src/components/ActivityEntry.vue | 4 +- src/components/card/CardSidebar.vue | 4 +- src/components/card/CardSidebarTabDetails.vue | 6 +- src/components/card/CommentItem.vue | 4 +- src/components/card/DueDateSelector.vue | 74 ++--- src/components/cards/badges/DueDate.vue | 10 +- src/mixins/readableDate.js | 11 +- src/mixins/relativeDate.js | 6 +- src/store/card.js | 6 +- src/views/BoardReferenceWidget.vue | 4 +- src/views/CardReferenceWidget.vue | 10 +- src/views/CommentReferenceWidget.vue | 10 +- 16 files changed, 91 insertions(+), 358 deletions(-) create mode 160000 server diff --git a/cypress/e2e/cardFeatures.js b/cypress/e2e/cardFeatures.js index 5cceda1cfc..2ac281baeb 100644 --- a/cypress/e2e/cardFeatures.js +++ b/cypress/e2e/cardFeatures.js @@ -4,7 +4,7 @@ */ import { randUser } from '../utils/index.js' import { sampleBoard } from '../utils/sampleBoard' -import moment from '@nextcloud/moment' +import { addDays, setHours, setMinutes, setSeconds, format } from 'date-fns' const user = randUser() const boardData = sampleBoard() @@ -271,17 +271,16 @@ describe('Card', function () { // Set a due date through shortcut cy.get('[data-cy-due-date-shortcut="tomorrow"] button').should('be.visible').click() - const tomorrow = moment().add(1, 'days').hour(8).minutes(0).seconds(0) - cy.get('#card-duedate-picker').should('have.value', tomorrow.format('YYYY-MM-DDTHH:mm')) + const tomorrow = setSeconds(setMinutes(setHours(addDays(new Date(), 1), 8), 0), 0) + cy.get('#card-duedate-picker').should('have.value', format(tomorrow, "yyyy-MM-dd'T'HH:mm")) - const now = moment().hour(11).minutes(0).seconds(0).toDate() + const now = setSeconds(setMinutes(setHours(new Date(), 11), 0), 0) cy.clock(now) cy.log(now) cy.tick(60_000) cy.get(`.card:contains("${newCardTitle}")`).find('[data-due-state="Now"]').should('be.visible').should('contain', '21 hours') - // Remove the due date again cy.get('#app-sidebar-vue [data-cy-due-date-actions]').should('be.visible').click() // tick needed to show the popover menu diff --git a/package-lock.json b/package-lock.json index 3a6ca34ce2..b628541480 100644 --- a/package-lock.json +++ b/package-lock.json @@ -19,18 +19,17 @@ "@nextcloud/files": "^3.10.1", "@nextcloud/initial-state": "^2.2.0", "@nextcloud/l10n": "^3.4.0", - "@nextcloud/moment": "^1.3.5", "@nextcloud/notify_push": "^1.3.0", "@nextcloud/router": "^3.0.1", "@nextcloud/vue": "^8.31.0", "blueimp-md5": "^2.19.0", "chroma-js": "^3.1.2", + "date-fns": "^4.1.0", "dompurify": "^3.2.5", "lodash": "^4.17.21", "markdown-it": "^14.1.0", "markdown-it-link-attributes": "^4.0.1", "markdown-it-task-checkbox": "^1.0.6", - "moment": "^2.30.1", "p-queue": "^8.0.1", "url-search-params-polyfill": "^8.2.5", "vue": "^2.7.15", @@ -3876,20 +3875,6 @@ "npm": "^10.0.0" } }, - "node_modules/@nextcloud/moment": { - "version": "1.3.5", - "resolved": "https://registry.npmjs.org/@nextcloud/moment/-/moment-1.3.5.tgz", - "integrity": "sha512-sQjQ/D40sdedtq4ywuANSxqG0VhIB/i+QtZ6Voz3nyZWhkyyqGxdj9rQu9AyEvas3/Jlspdom5chc+a8jOmHxQ==", - "license": "GPL-3.0-or-later", - "dependencies": { - "@nextcloud/l10n": "^3.4.0", - "moment": "^2.30.1" - }, - "engines": { - "node": "^20.0.0", - "npm": "^10.0.0" - } - }, "node_modules/@nextcloud/notify_push": { "version": "1.3.0", "resolved": "https://registry.npmjs.org/@nextcloud/notify_push/-/notify_push-1.3.0.tgz", @@ -4330,258 +4315,6 @@ "@parcel/watcher-win32-x64": "2.4.1" } }, - "node_modules/@parcel/watcher-android-arm64": { - "version": "2.4.1", - "resolved": "https://registry.npmjs.org/@parcel/watcher-android-arm64/-/watcher-android-arm64-2.4.1.tgz", - "integrity": "sha512-LOi/WTbbh3aTn2RYddrO8pnapixAziFl6SMxHM69r3tvdSm94JtCenaKgk1GRg5FJ5wpMCpHeW+7yqPlvZv7kg==", - "cpu": [ - "arm64" - ], - "dev": true, - "optional": true, - "os": [ - "android" - ], - "peer": true, - "engines": { - "node": ">= 10.0.0" - }, - "funding": { - "type": "opencollective", - "url": "https://opencollective.com/parcel" - } - }, - "node_modules/@parcel/watcher-darwin-arm64": { - "version": "2.4.1", - "resolved": "https://registry.npmjs.org/@parcel/watcher-darwin-arm64/-/watcher-darwin-arm64-2.4.1.tgz", - "integrity": "sha512-ln41eihm5YXIY043vBrrHfn94SIBlqOWmoROhsMVTSXGh0QahKGy77tfEywQ7v3NywyxBBkGIfrWRHm0hsKtzA==", - "cpu": [ - "arm64" - ], - "dev": true, - "optional": true, - "os": [ - "darwin" - ], - "peer": true, - "engines": { - "node": ">= 10.0.0" - }, - "funding": { - "type": "opencollective", - "url": "https://opencollective.com/parcel" - } - }, - "node_modules/@parcel/watcher-darwin-x64": { - "version": "2.4.1", - "resolved": "https://registry.npmjs.org/@parcel/watcher-darwin-x64/-/watcher-darwin-x64-2.4.1.tgz", - "integrity": "sha512-yrw81BRLjjtHyDu7J61oPuSoeYWR3lDElcPGJyOvIXmor6DEo7/G2u1o7I38cwlcoBHQFULqF6nesIX3tsEXMg==", - "cpu": [ - "x64" - ], - "dev": true, - "optional": true, - "os": [ - "darwin" - ], - "peer": true, - "engines": { - "node": ">= 10.0.0" - }, - "funding": { - "type": "opencollective", - "url": "https://opencollective.com/parcel" - } - }, - "node_modules/@parcel/watcher-freebsd-x64": { - "version": "2.4.1", - "resolved": "https://registry.npmjs.org/@parcel/watcher-freebsd-x64/-/watcher-freebsd-x64-2.4.1.tgz", - "integrity": "sha512-TJa3Pex/gX3CWIx/Co8k+ykNdDCLx+TuZj3f3h7eOjgpdKM+Mnix37RYsYU4LHhiYJz3DK5nFCCra81p6g050w==", - "cpu": [ - "x64" - ], - "dev": true, - "optional": true, - "os": [ - "freebsd" - ], - "peer": true, - "engines": { - "node": ">= 10.0.0" - }, - "funding": { - "type": "opencollective", - "url": "https://opencollective.com/parcel" - } - }, - "node_modules/@parcel/watcher-linux-arm-glibc": { - "version": "2.4.1", - "resolved": "https://registry.npmjs.org/@parcel/watcher-linux-arm-glibc/-/watcher-linux-arm-glibc-2.4.1.tgz", - "integrity": "sha512-4rVYDlsMEYfa537BRXxJ5UF4ddNwnr2/1O4MHM5PjI9cvV2qymvhwZSFgXqbS8YoTk5i/JR0L0JDs69BUn45YA==", - "cpu": [ - "arm" - ], - "dev": true, - "optional": true, - "os": [ - "linux" - ], - "peer": true, - "engines": { - "node": ">= 10.0.0" - }, - "funding": { - "type": "opencollective", - "url": "https://opencollective.com/parcel" - } - }, - "node_modules/@parcel/watcher-linux-arm64-glibc": { - "version": "2.4.1", - "resolved": "https://registry.npmjs.org/@parcel/watcher-linux-arm64-glibc/-/watcher-linux-arm64-glibc-2.4.1.tgz", - "integrity": "sha512-BJ7mH985OADVLpbrzCLgrJ3TOpiZggE9FMblfO65PlOCdG++xJpKUJ0Aol74ZUIYfb8WsRlUdgrZxKkz3zXWYA==", - "cpu": [ - "arm64" - ], - "dev": true, - "optional": true, - "os": [ - "linux" - ], - "peer": true, - "engines": { - "node": ">= 10.0.0" - }, - "funding": { - "type": "opencollective", - "url": "https://opencollective.com/parcel" - } - }, - "node_modules/@parcel/watcher-linux-arm64-musl": { - "version": "2.4.1", - "resolved": "https://registry.npmjs.org/@parcel/watcher-linux-arm64-musl/-/watcher-linux-arm64-musl-2.4.1.tgz", - "integrity": "sha512-p4Xb7JGq3MLgAfYhslU2SjoV9G0kI0Xry0kuxeG/41UfpjHGOhv7UoUDAz/jb1u2elbhazy4rRBL8PegPJFBhA==", - "cpu": [ - "arm64" - ], - "dev": true, - "optional": true, - "os": [ - "linux" - ], - "peer": true, - "engines": { - "node": ">= 10.0.0" - }, - "funding": { - "type": "opencollective", - "url": "https://opencollective.com/parcel" - } - }, - "node_modules/@parcel/watcher-linux-x64-glibc": { - "version": "2.4.1", - "resolved": "https://registry.npmjs.org/@parcel/watcher-linux-x64-glibc/-/watcher-linux-x64-glibc-2.4.1.tgz", - "integrity": "sha512-s9O3fByZ/2pyYDPoLM6zt92yu6P4E39a03zvO0qCHOTjxmt3GHRMLuRZEWhWLASTMSrrnVNWdVI/+pUElJBBBg==", - "cpu": [ - "x64" - ], - "dev": true, - "optional": true, - "os": [ - "linux" - ], - "peer": true, - "engines": { - "node": ">= 10.0.0" - }, - "funding": { - "type": "opencollective", - "url": "https://opencollective.com/parcel" - } - }, - "node_modules/@parcel/watcher-linux-x64-musl": { - "version": "2.4.1", - "resolved": "https://registry.npmjs.org/@parcel/watcher-linux-x64-musl/-/watcher-linux-x64-musl-2.4.1.tgz", - "integrity": "sha512-L2nZTYR1myLNST0O632g0Dx9LyMNHrn6TOt76sYxWLdff3cB22/GZX2UPtJnaqQPdCRoszoY5rcOj4oMTtp5fQ==", - "cpu": [ - "x64" - ], - "dev": true, - "optional": true, - "os": [ - "linux" - ], - "peer": true, - "engines": { - "node": ">= 10.0.0" - }, - "funding": { - "type": "opencollective", - "url": "https://opencollective.com/parcel" - } - }, - "node_modules/@parcel/watcher-win32-arm64": { - "version": "2.4.1", - "resolved": "https://registry.npmjs.org/@parcel/watcher-win32-arm64/-/watcher-win32-arm64-2.4.1.tgz", - "integrity": "sha512-Uq2BPp5GWhrq/lcuItCHoqxjULU1QYEcyjSO5jqqOK8RNFDBQnenMMx4gAl3v8GiWa59E9+uDM7yZ6LxwUIfRg==", - "cpu": [ - "arm64" - ], - "dev": true, - "optional": true, - "os": [ - "win32" - ], - "peer": true, - "engines": { - "node": ">= 10.0.0" - }, - "funding": { - "type": "opencollective", - "url": "https://opencollective.com/parcel" - } - }, - "node_modules/@parcel/watcher-win32-ia32": { - "version": "2.4.1", - "resolved": "https://registry.npmjs.org/@parcel/watcher-win32-ia32/-/watcher-win32-ia32-2.4.1.tgz", - "integrity": "sha512-maNRit5QQV2kgHFSYwftmPBxiuK5u4DXjbXx7q6eKjq5dsLXZ4FJiVvlcw35QXzk0KrUecJmuVFbj4uV9oYrcw==", - "cpu": [ - "ia32" - ], - "dev": true, - "optional": true, - "os": [ - "win32" - ], - "peer": true, - "engines": { - "node": ">= 10.0.0" - }, - "funding": { - "type": "opencollective", - "url": "https://opencollective.com/parcel" - } - }, - "node_modules/@parcel/watcher-win32-x64": { - "version": "2.4.1", - "resolved": "https://registry.npmjs.org/@parcel/watcher-win32-x64/-/watcher-win32-x64-2.4.1.tgz", - "integrity": "sha512-+DvS92F9ezicfswqrvIRM2njcYJbd5mb9CUgtrHCHmvn7pPPa+nMDRu1o1bYYz/l5IB2NVGNJWiH7h1E58IF2A==", - "cpu": [ - "x64" - ], - "dev": true, - "optional": true, - "os": [ - "win32" - ], - "peer": true, - "engines": { - "node": ">= 10.0.0" - }, - "funding": { - "type": "opencollective", - "url": "https://opencollective.com/parcel" - } - }, "node_modules/@pkgjs/parseargs": { "version": "0.11.0", "resolved": "https://registry.npmjs.org/@pkgjs/parseargs/-/parseargs-0.11.0.tgz", @@ -8551,6 +8284,16 @@ "node": ">= 12" } }, + "node_modules/date-fns": { + "version": "4.1.0", + "resolved": "https://registry.npmjs.org/date-fns/-/date-fns-4.1.0.tgz", + "integrity": "sha512-Ukq0owbQXxa/U3EGtsdVBkR1w7KOQ5gIBqdH2hkvknzZPYvBxb/aa6E8L7tmjFtkwZBu3UXBbjIgPo/Ez4xaNg==", + "license": "MIT", + "funding": { + "type": "github", + "url": "https://github.com/sponsors/kossnocorp" + } + }, "node_modules/date-format-parse": { "version": "0.2.7", "resolved": "https://registry.npmjs.org/date-format-parse/-/date-format-parse-0.2.7.tgz", @@ -15944,14 +15687,6 @@ "dev": true, "license": "MIT" }, - "node_modules/moment": { - "version": "2.30.1", - "resolved": "https://registry.npmjs.org/moment/-/moment-2.30.1.tgz", - "integrity": "sha512-uEmtNhbDOrWPFS+hdjFCBfy9f2YoyzRpwcl+DqpC6taX21FzsTLQVbMV/W7PzNSX6x/bhC1zA3c2UQ5NzH6how==", - "engines": { - "node": "*" - } - }, "node_modules/ms": { "version": "2.1.3", "resolved": "https://registry.npmjs.org/ms/-/ms-2.1.3.tgz", diff --git a/package.json b/package.json index 7446c06e41..35799d4cee 100644 --- a/package.json +++ b/package.json @@ -40,18 +40,17 @@ "@nextcloud/files": "^3.10.1", "@nextcloud/initial-state": "^2.2.0", "@nextcloud/l10n": "^3.4.0", - "@nextcloud/moment": "^1.3.5", "@nextcloud/notify_push": "^1.3.0", "@nextcloud/router": "^3.0.1", "@nextcloud/vue": "^8.31.0", "blueimp-md5": "^2.19.0", "chroma-js": "^3.1.2", + "date-fns": "^4.1.0", "dompurify": "^3.2.5", "lodash": "^4.17.21", "markdown-it": "^14.1.0", "markdown-it-link-attributes": "^4.0.1", "markdown-it-task-checkbox": "^1.0.6", - "moment": "^2.30.1", "p-queue": "^8.0.1", "url-search-params-polyfill": "^8.2.5", "vue": "^2.7.15", diff --git a/server b/server new file mode 160000 index 0000000000..a9d925b873 --- /dev/null +++ b/server @@ -0,0 +1 @@ +Subproject commit a9d925b873099a307316332d1af926fc219fd58f diff --git a/src/components/ActivityEntry.vue b/src/components/ActivityEntry.vue index fa51e10648..1c82843155 100644 --- a/src/components/ActivityEntry.vue +++ b/src/components/ActivityEntry.vue @@ -19,7 +19,7 @@