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

feat(webapp): implement config for date-time format #6985

Merged
merged 11 commits into from
Feb 14, 2024
6 changes: 3 additions & 3 deletions CONTRIBUTING.md
Tirokk marked this conversation as resolved.
Show resolved Hide resolved
Original file line number Diff line number Diff line change
Expand Up @@ -171,11 +171,11 @@ Please copy and paste the following quotes for the languages:

## Docker – More Closely

### Apple M1 Platform
### Apple Silicon Platform

***Attention:** For using Docker commands in Apple M1 environments!*
***ATTENTION:** For using Docker commands in Apple Silicon environments!*

#### Environment Variable For Apple M1 Platform
#### Environment Variable For Apple Silicon Platform (M1, M2 Chips)

If you encounter trouble building the docker containers on an Apple M1 chip you can try to explicitly define the target platform docker builds and pulls images for:

Expand Down
6 changes: 4 additions & 2 deletions README.md
Tirokk marked this conversation as resolved.
Show resolved Hide resolved
Original file line number Diff line number Diff line change
Expand Up @@ -172,7 +172,9 @@ Check the correct Docker installation by checking the version before proceeding.
$ docker --version
```

##### Start Ocelot-Social via Docker-Compose
##### Start Ocelot-Social via Docker Compose

***ATTENTION:** For using Docker commands in Apple Silicon environments see [here](https://github.com/Ocelot-Social-Community/Ocelot-Social/blob/master/CONTRIBUTING.md#apple-silicon-platform).*

Prepare ENVs once beforehand:

Expand Down Expand Up @@ -233,7 +235,7 @@ We are happy if you fork our repository, but we don't recommend it for developme

Clone this repository locally as [described above](#clone-the-repository), create your branch named `<issue-number>-<description>`, add your code and push your branch direct to this repository. Then create a PR by comparing it to our `master`.

**_!!! Be aware:_** Please don't compare from a fork, because the tests are breaking caused by credential problems.
***!!! Be aware:*** Please don't compare from a fork, because the tests are breaking caused by credential problems.

Please run the following commands before you push:

Expand Down
10 changes: 8 additions & 2 deletions deployment/TODO-next-update.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,9 @@

When you introduce a new version and branding and deploy it on your network, you need to consider the following changes and actions:

## Version >= 3.1.3 with 'ocelotDockerVersionTag' 3.1.3-XXX
## Version >= 3.2.0 with 'ocelotDockerVersionTag' 3.2.0-XXX

### Backend and Kubernetes Config `DBMS_DEFAULT_DATABASE`

- We have the new option to configure the default name of the Neo4j database to be used for operations and commands in environment variables (`.env`, `docker-compose.yml` or `values.yaml`).
For more details see [deployment-values.md](deployment-values.md):
Expand All @@ -13,6 +15,10 @@ DBMS_DEFAULT_DATABASE: "graph.db"

The default value is `neo4j` if it is not set.

### Webapp Config `dateTime`

- You can set `RELATIVE_DATETIME` and `ABSOLUT_DATETIME_FORMAT` in `branding/constants/dateTime.js` originally in main code file `webapp/constants/dateTime.js` to your preferred values.

## Version >= 3.1.0 with 'ocelotDockerVersionTag' 3.1.0-555

- We have the new option to configure DKIM for sent e-mails in environment variables (`.env`, `docker-compose.yml` or `values.yaml`), see [deployment-values.md](deployment-values.md):
Expand All @@ -26,7 +32,7 @@ The default value is `neo4j` if it is not set.

## Version >= 2.4.0 with 'ocelotDockerVersionTag' 2.4.0-298

- You have to set `SHOW_CONTENT_FILTER_HEADER_MENU` and `SHOW_CONTENT_FILTER_MASONRY_GRID` in `branding/constants/filter.js` originally in main code file `webapp/constants/filter.js` to your preferred value.
- You have to set `SHOW_CONTENT_FILTER_HEADER_MENU` and `SHOW_CONTENT_FILTER_MASONRY_GRID` in `branding/constants/filter.js` originally in main code file `webapp/constants/filter.js` to your preferred values.

### Main Code PR – feat(webapp): map #5843

Expand Down
15 changes: 15 additions & 0 deletions deployment/deployment-values.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,21 @@
For each deployment, you need to set the environment variables and configurations.
Here is some specific information on how to set the values.

## Webapp

We have several configuration possibilities just in the frontend.

### Date Time

In file `branding/constants/dateTime.js`.

- `RELATIVE_DATETIME`
- `true` (default) or `false`
- `ABSOLUT_DATETIME_FORMAT`
- definition see [date-fns, format](https://date-fns.org/v3.3.1/docs/format):
- `P`: just localized date
- `Pp`: just localized date and time

## E-Mails

You need to set environment variables to send registration and invitation information or notifications to users, for example.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,5 @@
Relative time from 08.03.2017

```
<hc-relative-date-time dateTime="03.08.2017" />
<date-time dateTime="03.08.2017" />
```
33 changes: 33 additions & 0 deletions webapp/components/DateTime/index.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
<template>
<span>{{ dateTimeString }}</span>
</template>

<script>
import { getDateFnsLocale } from '~/locales'
import format from 'date-fns/format'
import formatRelative from 'date-fns/formatRelative'
import dateTimeConstants from '~/constants/dateTime'

export default {
name: 'DateTime',
props: {
dateTime: {
type: [Date, String],
required: true,
},
},
computed: {
dateTimeString() {
if (dateTimeConstants.RELATIVE_DATETIME) {
return formatRelative(new Date(this.dateTime), new Date(), {
locale: getDateFnsLocale(this),
})
} else {
return format(new Date(this.dateTime), dateTimeConstants.ABSOLUT_DATETIME_FORMAT, {
locale: getDateFnsLocale(this),
})
}
},
},
}
</script>
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import { shallowMount } from '@vue/test-utils'
import RelativeDateTime from './'
import DateTime from '.'

const localVue = global.localVue

describe('RelativeDateTime', () => {
describe('DateTime', () => {
let mocks
let locale
let dateTime
Expand All @@ -17,7 +17,7 @@ describe('RelativeDateTime', () => {
})

const Wrapper = () => {
return shallowMount(RelativeDateTime, {
return shallowMount(DateTime, {
mocks,
localVue,
propsData: {
Expand Down
6 changes: 3 additions & 3 deletions webapp/components/Modal/DeleteUserModal.vue
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
<ds-text size="small">
<span class="bold">{{ $t('modals.deleteUser.created') }}</span>
<br />
<relative-date-time :date-time="userdata.createdAt" />
<date-time :date-time="userdata.createdAt" />
</ds-text>
</ds-flex-item>
<ds-flex-item width="15%">
Expand Down Expand Up @@ -49,15 +49,15 @@
import gql from 'graphql-tag'
import { mapMutations } from 'vuex'
import { SweetalertIcon } from 'vue-sweetalert-icons'
import RelativeDateTime from '~/components/RelativeDateTime'
import DateTime from '~/components/DateTime'
import UserTeaser from '~/components/UserTeaser/UserTeaser'

export default {
name: 'DeleteUserModal',
components: {
UserTeaser,
SweetalertIcon,
RelativeDateTime,
DateTime,
},
props: {
userdata: { type: Object, required: true },
Expand Down
6 changes: 3 additions & 3 deletions webapp/components/PostTeaser/PostTeaser.vue
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@
<client-only>
<div class="date-row" v-if="post.createdAt">
<span class="text">
<relative-date-time :date-time="post.createdAt" />
<date-time :date-time="post.createdAt" />
<slot name="dateTime"></slot>
</span>
</div>
Expand All @@ -119,7 +119,7 @@ import CounterIcon from '~/components/_new/generic/CounterIcon/CounterIcon'
import DateTimeRange from '~/components/DateTimeRange/DateTimeRange'
import HcRibbon from '~/components/Ribbon'
import LocationTeaser from '~/components/LocationTeaser/LocationTeaser'
import RelativeDateTime from '~/components/RelativeDateTime'
import DateTime from '~/components/DateTime'
import UserTeaser from '~/components/UserTeaser/UserTeaser'
import { mapGetters } from 'vuex'
import PostMutations from '~/graphql/PostMutations'
Expand All @@ -134,7 +134,7 @@ export default {
DateTimeRange,
HcRibbon,
LocationTeaser,
RelativeDateTime,
DateTime,
UserTeaser,
},
props: {
Expand Down
23 changes: 0 additions & 23 deletions webapp/components/RelativeDateTime/index.vue

This file was deleted.

6 changes: 3 additions & 3 deletions webapp/components/UserTeaser/UserTeaser.vue
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@
</div>
<span v-if="!userOnly && dateTime" class="text">
<base-icon name="clock" />
<relative-date-time :date-time="dateTime" />
<date-time :date-time="dateTime" />
<slot name="dateTime"></slot>
</span>
</div>
Expand All @@ -47,13 +47,13 @@
<script>
import { mapGetters } from 'vuex'

import RelativeDateTime from '~/components/RelativeDateTime'
import DateTime from '~/components/DateTime'
import ProfileAvatar from '~/components/_new/generic/ProfileAvatar/ProfileAvatar'

export default {
name: 'UserTeaser',
components: {
RelativeDateTime,
DateTime,
ProfileAvatar,
},
props: {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
</template>
<template #reportedOn="scope">
<ds-text size="small">
<hc-relative-date-time :date-time="scope.row.createdAt" data-test="filed-date" />
<date-time :date-time="scope.row.createdAt" data-test="filed-date" />
</ds-text>
</template>
<template #reasonCategory="scope">
Expand All @@ -29,12 +29,12 @@
</template>
<script>
import UserTeaser from '~/components/UserTeaser/UserTeaser'
import HcRelativeDateTime from '~/components/RelativeDateTime'
import DateTime from '~/components/DateTime'

export default {
components: {
UserTeaser,
HcRelativeDateTime,
DateTime,
},
props: {
filed: { type: Array, default: () => [] },
Expand Down
5 changes: 5 additions & 0 deletions webapp/constants/dateTime.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
// this file is duplicated in `backend/src/config/metadata.js` and `webapp/constants/metadata.js`
export default {
RELATIVE_DATETIME: true,
ABSOLUT_DATETIME_FORMAT: 'P',
}