Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: Drop dependency on moment.js #1155

Merged
merged 1 commit into from
Apr 13, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
39 changes: 29 additions & 10 deletions lib/components/NodesPicker.vue
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,14 @@
<!-- Description -->
<span class="node-picker__desc">
<span class="node-picker__name">{{ t('New version') }}</span>
<span class="node-picker__mtime">{{ lastModified(incoming) }}</span>
<NcDateTime v-if="incomingLastModified"
:timestamp="incomingLastModified"
:relative-time="false"
:format="{ timeStyle: 'short', dateStyle: 'medium' }"
class="node-picker__mtime" />
<span v-else class="node-picker__mtime">
{{ t('Last modified date unknown') }}
</span>
<span class="node-picker__size">{{ size(incoming) }}</span>
</span>
</span>
Expand All @@ -48,7 +55,14 @@
<!-- Description -->
<span class="node-picker__desc">
<span class="node-picker__name">{{ t('Existing version') }}</span>
<span class="node-picker__mtime">{{ lastModified(existing) }}</span>
<NcDateTime v-if="existingLastModified"
:timestamp="existingLastModified"
:relative-time="false"
:format="{ timeStyle: 'short', dateStyle: 'medium' }"
class="node-picker__mtime" />
<span v-else class="node-picker__mtime">
{{ t('Last modified date unknown') }}
</span>
<span class="node-picker__size">{{ size(existing) }}</span>
</span>
</span>
Expand All @@ -62,10 +76,10 @@ import type { PropType } from 'vue'
import { defineComponent } from 'vue'
import { formatFileSize, FileType, Node } from '@nextcloud/files'
import { generateUrl } from '@nextcloud/router'
import moment from '@nextcloud/moment'

import FileSvg from 'vue-material-design-icons/File.vue'
import FolderSvg from 'vue-material-design-icons/Folder.vue'
import NcDateTime from '@nextcloud/vue/dist/Components/NcDateTime.js'
import NcCheckboxRadioSwitch from '@nextcloud/vue/dist/Components/NcCheckboxRadioSwitch.js'

import { t } from '../utils/l10n.ts'
Expand All @@ -79,6 +93,7 @@ export default defineComponent({
FileSvg,
FolderSvg,
NcCheckboxRadioSwitch,
NcDateTime,
},

props: {
Expand All @@ -102,7 +117,7 @@ export default defineComponent({

data() {
return {
asyncPreview: null,
asyncPreview: null as string | null,
}
},

Expand All @@ -127,17 +142,21 @@ export default defineComponent({
existingPreview() {
return this.previewUrl(this.existing)
},

incomingLastModified() {
return this.lastModified(this.incoming)
},
existingLastModified() {
return this.lastModified(this.existing)
},
},

methods: {
lastModified(node: File|Node): string {
lastModified(node: File|Node): Date | null {
const lastModified = node instanceof File
? new Date(node.lastModified)
: node.mtime
if (lastModified) {
return moment(lastModified).format('LLL')
}
return t('Last modified date unknown')
return lastModified ?? null
},
size(node: File|Node): string {
if (node.size) {
Expand All @@ -147,7 +166,7 @@ export default defineComponent({
},
previewUrl(node: File|Node) {
if (node instanceof File) {
this.previewImage(node).then((url: string) => {
this.previewImage(node).then((url: string | null) => {
this.asyncPreview = url
})
return
Expand Down
23 changes: 0 additions & 23 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 0 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,6 @@
"@nextcloud/files": "^3.1.1",
"@nextcloud/l10n": "^2.2.0",
"@nextcloud/logger": "^2.7.0",
"@nextcloud/moment": "^1.3.1",
"@nextcloud/paths": "^2.1.0",
"@nextcloud/router": "^3.0.0",
"axios": "^1.6.8",
Expand Down
Loading