@eeacms/volto-clms-theme 1.0.114 → 1.0.115

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -4,8 +4,22 @@ All notable changes to this project will be documented in this file. Dates are d
4
4
 
5
5
  Generated by [`auto-changelog`](https://github.com/CookPete/auto-changelog).
6
6
 
7
+ #### [1.0.115](https://github.com/eea/volto-clms-theme/compare/1.0.114...1.0.115)
8
+
9
+ - dispatch logout [`6f05001`](https://github.com/eea/volto-clms-theme/commit/6f0500198ac72145adbc0d4779b60760a4771527)
10
+ - delete profile tab inside profile [`4dedca5`](https://github.com/eea/volto-clms-theme/commit/4dedca5f32ef01e0f11b6a3cacc8272964000d0f)
11
+ - date formatting [`93514f7`](https://github.com/eea/volto-clms-theme/commit/93514f789c0a0d7282a2d620d13bf4996ffc28df)
12
+ - get user from state for UniversalLink [`d3f2d64`](https://github.com/eea/volto-clms-theme/commit/d3f2d64a92b4537b8a80319e9a34e6515c863e84)
13
+ - routingHOC condition [`8331195`](https://github.com/eea/volto-clms-theme/commit/8331195c27e2d9c10fa4b0cd7f4ef72473bf1331)
14
+ - upgrade volto-form-block version [`8bb77fa`](https://github.com/eea/volto-clms-theme/commit/8bb77fa83b1a2e270824f0de261627928308a147)
15
+ - use new time handler [`44edb37`](https://github.com/eea/volto-clms-theme/commit/44edb378d4a3c0a4e3c352ef141e37a6dab5883d)
16
+ - new date handler that respects user's timezone [`b2d8143`](https://github.com/eea/volto-clms-theme/commit/b2d814331bd2a4f7bb6d7a3312e41d3a0fa52ddf)
17
+
7
18
  #### [1.0.114](https://github.com/eea/volto-clms-theme/compare/1.0.113...1.0.114)
8
19
 
20
+ > 4 August 2022
21
+
22
+ - Develop [`#288`](https://github.com/eea/volto-clms-theme/pull/288)
9
23
  - show the message coming from backend [`da826b3`](https://github.com/eea/volto-clms-theme/commit/da826b3c9adab0091f643c326cbd716dd523e2a8)
10
24
  - remove the years from the title DoubleRangeFacet [`e32c20e`](https://github.com/eea/volto-clms-theme/commit/e32c20e6cd3a1f096da242ce9f0c5518794a26fd)
11
25
  - HomeUsersBlock improvements [`a05b1fb`](https://github.com/eea/volto-clms-theme/commit/a05b1fb16ef3d736ffc486f2a82b0c5014f102b6)
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@eeacms/volto-clms-theme",
3
- "version": "1.0.114",
3
+ "version": "1.0.115",
4
4
  "description": "volto-clms-theme: Volto theme for CLMS site",
5
5
  "main": "src/index.js",
6
6
  "author": "CodeSyntax for the European Environment Agency",
@@ -55,7 +55,7 @@
55
55
  "react-svg": "14.0.4",
56
56
  "slick-carousel": "1.8.1",
57
57
  "volto-dropdownmenu": "2.2.7",
58
- "volto-form-block": "2.2.2",
58
+ "volto-form-block": "2.4.1",
59
59
  "react-input-range": "^1.3.0",
60
60
  "lightgallery": "^2.4.0",
61
61
  "validator": "13.7.0"
@@ -92,3 +92,5 @@ export {
92
92
  POST_IMPORT_WMS_FIELDS,
93
93
  postImportWMSFields,
94
94
  } from './import_wms_fields/import_wms_fields';
95
+
96
+ export { DELETE_PROFILE, delProfile } from './profile/delete_profile';
@@ -0,0 +1,20 @@
1
+ /**
2
+ * Delete profle.
3
+ * @module actions/newsletter
4
+ */
5
+ export const DELETE_PROFILE = 'DELETE_PROFILE';
6
+
7
+ /**
8
+ * Delete profle.
9
+ * @function delProfile
10
+ * @returns {Object} Get extra items action.
11
+ */
12
+ export function delProfile() {
13
+ return {
14
+ type: DELETE_PROFILE,
15
+ request: {
16
+ op: 'del',
17
+ path: `/@delete-user-profile`,
18
+ },
19
+ };
20
+ }
@@ -3,6 +3,7 @@ import PropTypes from 'prop-types';
3
3
  import { defineMessages, useIntl } from 'react-intl';
4
4
  import { useSelector } from 'react-redux';
5
5
  import { Link } from 'react-router-dom';
6
+ import { workOpportunitiesCclDateTimeFormat } from '@eeacms/volto-clms-theme/components/CclUtils';
6
7
 
7
8
  const messages = defineMessages({
8
9
  ProcurementNo: {
@@ -21,6 +22,8 @@ const messages = defineMessages({
21
22
 
22
23
  const CclWorkOpportunity = (props) => {
23
24
  const { item, intl, user } = props;
25
+ const lang = useSelector((state) => state.intl.locale);
26
+
24
27
  return (
25
28
  <div className="card-work">
26
29
  {user.roles && user.roles.includes('Manager') && (
@@ -52,7 +55,7 @@ const CclWorkOpportunity = (props) => {
52
55
  <span className="card-work-title">
53
56
  {intl.formatMessage(messages.SubmissionDeadline)}
54
57
  </span>
55
- {new Date(item.submission_deadline).toLocaleString()}
58
+ {workOpportunitiesCclDateTimeFormat(item.submission_deadline, lang)}
56
59
  </div>
57
60
  </div>
58
61
  );
@@ -16,7 +16,12 @@ const RoutingHOC = (TabView) =>
16
16
  ) {
17
17
  return rTabsList[0];
18
18
  }
19
- return rTabsList[window.location.hash.match(/.*&?#?tab=(.*)/)[1] - 1];
19
+ if (
20
+ window.location.hash.match(/.*&?#?tab=(.*)/) &&
21
+ window.location.hash.match(/.*&?#?tab=(.*)/).length > 1
22
+ ) {
23
+ return rTabsList[window.location.hash.match(/.*&?#?tab=(.*)/)[1] - 1];
24
+ }
20
25
  }
21
26
  React.useEffect(() => {
22
27
  const isReload =
@@ -0,0 +1,53 @@
1
+ /**
2
+ * CLMSProfileView container.
3
+ * @module components/CLMSProfileView/CLMSProfileView
4
+ */
5
+
6
+ import React from 'react';
7
+
8
+ import { injectIntl } from 'react-intl';
9
+ import { Container } from 'semantic-ui-react';
10
+ import CclButton from '@eeacms/volto-clms-theme/components/CclButton/CclButton';
11
+ import { delProfile } from '../../actions';
12
+ import { useDispatch, useSelector } from 'react-redux';
13
+ import { useHistory } from 'react-router-dom';
14
+ import { logout } from '@plone/volto/actions';
15
+
16
+ export const CLMSDeleteProfileView = (props) => {
17
+ const dispatch = useDispatch();
18
+ let history = useHistory();
19
+
20
+ const isDeleted = useSelector((state) => state.profile_delete.loaded)
21
+ ? true
22
+ : false;
23
+
24
+ function handleClick() {
25
+ dispatch(delProfile());
26
+ }
27
+
28
+ if (isDeleted === true) {
29
+ history.push('/');
30
+ dispatch(logout());
31
+ }
32
+
33
+ return (
34
+ <Container>
35
+ <div>
36
+ <h1 className="page-title">Delete your profile</h1>
37
+ <p>Click in the button bellow to your profile.</p>
38
+
39
+ <CclButton
40
+ to="profile#Delete-profile"
41
+ mode={'filled'}
42
+ onClick={() => {
43
+ handleClick();
44
+ }}
45
+ >
46
+ Delete
47
+ </CclButton>
48
+ </div>
49
+ </Container>
50
+ );
51
+ };
52
+
53
+ export default injectIntl(CLMSDeleteProfileView);
@@ -11,6 +11,7 @@ import {
11
11
  CLMSApiTokensView,
12
12
  CLMSNewsletterSubscriberView,
13
13
  CLMSUserProfileView,
14
+ CLMSDeleteProfileView,
14
15
  } from '@eeacms/volto-clms-theme/components/CLMSProfileView';
15
16
  import React, { Component } from 'react';
16
17
 
@@ -75,6 +76,9 @@ class CLMSProfileView extends Component {
75
76
  <SubscriptionView type={subscription?.type} />
76
77
  </div>
77
78
  ))}
79
+ <div tabTitle="Delete profile">
80
+ <CLMSDeleteProfileView />
81
+ </div>
78
82
  </CclTabs>
79
83
  ) : (
80
84
  <Unauthorized />
@@ -2,3 +2,4 @@ export CLMSProfileView from './CLMSProfileView';
2
2
  export CLMSUserProfileView from './CLMSUserProfileView';
3
3
  export CLMSApiTokensView from './CLMSApiTokensView';
4
4
  export CLMSNewsletterSubscriberView from './CLMSNewsletterSubscriberView';
5
+ export CLMSDeleteProfileView from './CLMSDeleteProfileView';
@@ -1,5 +1,7 @@
1
1
  import React from 'react';
2
2
  import { defineMessages, useIntl } from 'react-intl';
3
+ import { workOpportunitiesCclDateTimeFormat } from '@eeacms/volto-clms-theme/components/CclUtils';
4
+ import { useSelector } from 'react-redux';
3
5
 
4
6
  const messages = defineMessages({
5
7
  ProcurementNo: {
@@ -24,6 +26,7 @@ const CLMSWorkOpportunityView = (props) => {
24
26
  ? content.items.map((item) => (item['@type'] === 'File' ? item : null))
25
27
  : [];
26
28
  const index = files.indexOf(null);
29
+ const lang = useSelector((state) => state.intl.locale);
27
30
  if (index > -1) {
28
31
  files.splice(index, 1);
29
32
  }
@@ -46,7 +49,10 @@ const CLMSWorkOpportunityView = (props) => {
46
49
  <span className="card-work-title">
47
50
  {intl.formatMessage(messages.SubmissionDeadline)}
48
51
  </span>
49
- {new Date(content.submission_deadline).toLocaleString()}
52
+ {workOpportunitiesCclDateTimeFormat(
53
+ content.submission_deadline,
54
+ lang,
55
+ )}
50
56
  </div>
51
57
  </div>
52
58
  </>
@@ -1,3 +1,11 @@
1
+ import { parseDateTime } from '@plone/volto/helpers';
2
+ import moment from 'moment';
3
+
4
+ const getInternalValue = (value, lang) => {
5
+ moment.locale(lang);
6
+ return parseDateTime(lang, value, undefined, moment);
7
+ };
8
+
1
9
  export const cclDateTimeFormat = (date) => {
2
10
  const dateObj = new Date(date);
3
11
  const day = ('0' + dateObj.getDate()).slice(-2);
@@ -8,6 +16,11 @@ export const cclDateTimeFormat = (date) => {
8
16
  return `${day}.${month}.${year} ${hours}.${minutes}`;
9
17
  };
10
18
 
19
+ export const workOpportunitiesCclDateTimeFormat = (date, lang) => {
20
+ const internal = getInternalValue(date, lang);
21
+ return internal.format('DD.MM.YYYY hh.mm A');
22
+ };
23
+
11
24
  export const cclDateFormat = (date) => {
12
25
  const dateObj = new Date(date);
13
26
  const day = dateObj.getDate();
@@ -15,3 +28,8 @@ export const cclDateFormat = (date) => {
15
28
  const year = dateObj.getFullYear();
16
29
  return `${day}.${month}.${year}`;
17
30
  };
31
+
32
+ export const workOpportunitiesCclDateFormat = (date, lang) => {
33
+ const internal = getInternalValue(date, lang);
34
+ return internal.format('DD.MM.YYYY');
35
+ };
@@ -2,4 +2,9 @@ import StringToHTML from './StringToHTML';
2
2
 
3
3
  export { StringToHTML };
4
4
 
5
- export { cclDateFormat, cclDateTimeFormat } from './dateFormats';
5
+ export {
6
+ workOpportunitiesCclDateFormat,
7
+ workOpportunitiesCclDateTimeFormat,
8
+ cclDateFormat,
9
+ cclDateTimeFormat,
10
+ } from './dateFormats';
@@ -27,6 +27,7 @@ const UniversalLink = ({
27
27
  ...props
28
28
  }) => {
29
29
  const token = useSelector((state) => state.userSession?.token);
30
+ const user = useSelector((state) => state.users.user);
30
31
 
31
32
  let url = href;
32
33
  if (!href && item) {
@@ -51,7 +52,7 @@ const UniversalLink = ({
51
52
 
52
53
  //case: item of type 'File'
53
54
  if (
54
- !this.props.roles?.includes('Manager') &&
55
+ !user?.roles?.includes('Manager') &&
55
56
  config.settings.downloadableObjects.includes(item['@type'])
56
57
  ) {
57
58
  url = `${url}/@@download/file`;
@@ -17,6 +17,7 @@ import tokens from './tokens/tokens';
17
17
  import { userschemaReducer } from './userschema/userschema';
18
18
  import { importWMSLayersReducer } from './import_wms_layers/import_wms_layers_reducer';
19
19
  import { importWMSFieldsReducer } from './import_wms_fields/import_wms_fields_reducer';
20
+ import { deleteProfileReducer } from './profile/delete_profile_reducer';
20
21
 
21
22
  /**
22
23
  * Root reducer.
@@ -43,6 +44,7 @@ const reducers = {
43
44
  subscription: subscribeToReducer,
44
45
  importWMSLayers: importWMSLayersReducer,
45
46
  importWMSFields: importWMSFieldsReducer,
47
+ profile_delete: deleteProfileReducer,
46
48
  };
47
49
 
48
50
  export default reducers;
@@ -0,0 +1,41 @@
1
+ /**
2
+ * Profile reducer.
3
+ * @module profile/profile_reducer
4
+ */
5
+
6
+ import { DELETE_PROFILE } from '../../actions';
7
+
8
+ const getInitialState = {
9
+ error: null,
10
+ loaded: false,
11
+ loading: false,
12
+ items: [],
13
+ };
14
+
15
+ export const deleteProfileReducer = (state = getInitialState, action = {}) => {
16
+ switch (action.type) {
17
+ case `${DELETE_PROFILE}_PENDING`:
18
+ return {
19
+ ...state,
20
+ error: null,
21
+ loaded: false,
22
+ loading: true,
23
+ };
24
+ case `${DELETE_PROFILE}_FAIL`:
25
+ return {
26
+ ...state,
27
+ error: true,
28
+ loaded: false,
29
+ loading: false,
30
+ };
31
+ case `${DELETE_PROFILE}_SUCCESS`:
32
+ return {
33
+ ...state,
34
+ error: null,
35
+ loaded: true,
36
+ loading: false,
37
+ };
38
+ default:
39
+ return state;
40
+ }
41
+ };