@plusscommunities/pluss-core-web 1.1.1 → 1.1.5

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@plusscommunities/pluss-core-web",
3
- "version": "1.1.1",
3
+ "version": "1.1.5",
4
4
  "description": "Core extension package for Pluss Communities platform",
5
5
  "main": "dist/index.cjs.js",
6
6
  "scripts": {
@@ -26,15 +26,15 @@
26
26
  },
27
27
  "dependencies": {
28
28
  "@babel/runtime": "^7.14.0",
29
- "lodash": "^4.17.4",
30
29
  "jquery": "^3.2.1",
30
+ "js-cookie": "^2.2.0",
31
+ "lodash": "^4.17.4",
31
32
  "moment": "^2.18.1",
32
33
  "react": "^16.14.0",
33
34
  "react-dropzone": "^7.0.1",
34
35
  "react-fontawesome": "^1.6.1",
35
36
  "react-redux": "^5.0.6",
36
- "react-textarea-autosize": "^7.1.0-1",
37
- "js-cookie": "^2.2.0"
37
+ "react-textarea-autosize": "^7.1.0-1"
38
38
  },
39
39
  "keywords": []
40
40
  }
@@ -3,11 +3,7 @@ import Config from '../config';
3
3
  import { Storage } from 'aws-amplify';
4
4
  import CanvasImageUploader from '../helper/files/canvasImageUploader';
5
5
  import $ from 'jquery';
6
- import {
7
- //generateImageName,
8
- randomString,
9
- getUrl,
10
- } from '../helper';
6
+ import { generateImageName, randomString, getUrl } from '../helper';
11
7
 
12
8
  export const fileActions = {
13
9
  uploadMediaAsync: async (file, filename) => {
@@ -56,33 +52,33 @@ export const fileActions = {
56
52
  });
57
53
  });
58
54
  },
59
- // blobToFile: (theBlob, fileName) => {
60
- // const file = new File([theBlob], fileName, { lastModified: new Date() });
61
- // console.log(file);
62
- // return file;
63
- // },
64
- // putCanvas: (canvas, filename) => {
65
- // return new Promise((resolve, reject) => {
66
- // const img = canvas.getTrimmedCanvas().toDataURL('image/png');
67
- // const imageData = Buffer.from(img.replace(/^data:image\/\w+;base64,/, ''), 'base64');
55
+ blobToFile: (theBlob, fileName) => {
56
+ const file = new File([theBlob], fileName, { lastModified: new Date() });
57
+ console.log(file);
58
+ return file;
59
+ },
60
+ putCanvas: (canvas, filename) => {
61
+ return new Promise((resolve, reject) => {
62
+ const img = canvas.getTrimmedCanvas().toDataURL('image/png');
63
+ const imageData = Buffer.from(img.replace(/^data:image\/\w+;base64,/, ''), 'base64');
68
64
 
69
- // canvas.off();
65
+ canvas.off();
70
66
 
71
- // const imgName = generateImageName(filename);
67
+ const imgName = generateImageName(filename);
72
68
 
73
- // Storage.put(`images/${imgName}.png`, imageData, {
74
- // contentType: 'image/png',
75
- // level: 'public',
76
- // })
77
- // .then((res) => {
78
- // console.log('put the image');
79
- // return resolve(res);
80
- // })
81
- // .catch((err) => {
82
- // return reject(err);
83
- // });
84
- // });
85
- // },
69
+ Storage.put(`images/${imgName}.png`, imageData, {
70
+ contentType: 'image/png',
71
+ level: 'public',
72
+ })
73
+ .then((res) => {
74
+ console.log('put the image');
75
+ return resolve(res);
76
+ })
77
+ .catch((err) => {
78
+ return reject(err);
79
+ });
80
+ });
81
+ },
86
82
  getMediaFolders: (site) => {
87
83
  // console.log('getMediaFolders', 'site', site);
88
84
  const query = { site };
@@ -3,7 +3,8 @@ import { DropdownButton, MenuItem } from 'react-bootstrap';
3
3
  import _ from 'lodash';
4
4
  import moment from 'moment';
5
5
  import { getAnalyticsFilterOptions } from '../analytics';
6
- import { GenericInput, DatePicker } from './';
6
+ import { GenericInput } from './GenericInput';
7
+ import { DatePicker } from './DatePicker';
7
8
 
8
9
  class AnalyticsFilter extends PureComponent {
9
10
  constructor(props) {
@@ -2,9 +2,10 @@ import React, { Component } from 'react';
2
2
  import _ from 'lodash';
3
3
  import { withRouter } from 'react-router';
4
4
  import { connect } from 'react-redux';
5
- import { GenericInput, Text } from './';
6
5
  import Config from '../config';
7
6
  import { SVGIcon } from './SVGIcon';
7
+ import { GenericInput } from './GenericInput';
8
+ import { Text } from './Text';
8
9
  import { COLOUR_DUSK } from '../colours';
9
10
 
10
11
  class AudienceIncluder extends Component {
@@ -3,11 +3,12 @@ import FontAwesome from 'react-fontawesome';
3
3
  import _ from 'lodash';
4
4
  import { connect } from 'react-redux';
5
5
  import { setAuth } from '../actions';
6
- import { RadioButton, DropdownInput } from './';
7
6
  import { profileActions, typeActions, userActions } from '../apis';
8
7
  import { COLOUR_DUSK } from '../colours';
9
8
  import { AudienceIncluder } from './AudienceIncluder';
10
- import { Text } from './';
9
+ import { Text } from './Text';
10
+ import { RadioButton } from './RadioButton';
11
+ import { DropdownInput } from './DropdownInput';
11
12
 
12
13
  class AudienceSelector extends Component {
13
14
  state = {
@@ -1,7 +1,7 @@
1
1
  import React, { Component } from 'react';
2
2
  import moment from 'moment';
3
3
  import _ from 'lodash';
4
- import { P60Icon } from './';
4
+ import { P60Icon } from './P60Icon';
5
5
 
6
6
  class DatePicker extends Component {
7
7
  state = {
@@ -3,7 +3,7 @@ import { connect } from 'react-redux';
3
3
  import _ from 'lodash';
4
4
  import Dropzone from 'react-dropzone';
5
5
  import FontAwesome from 'react-fontawesome';
6
- import { Button } from './';
6
+ import { Button } from './Button';
7
7
  import { fileActions } from '../apis';
8
8
  import { getFileName } from '../helper';
9
9
 
@@ -94,7 +94,8 @@ class GenericInput extends Component {
94
94
  className={`genericInput ${this.props.inputClass}`}
95
95
  value={this.props.value || ''}
96
96
  onChange={this.props.onChange}
97
- onKeyPress={this.props.onEnter}
97
+ onKeyPress={this.props.onKeyPress || this.props.onEnter}
98
+ onKeyDown={this.props.onKeyDown}
98
99
  style={{ ...this.props.inputStyle }}
99
100
  readOnly={!_.isUndefined(this.props.readOnly) ? this.props.readOnly : false}
100
101
  disabled={!_.isUndefined(this.props.disabled) ? this.props.disabled : false}
@@ -120,7 +121,8 @@ class GenericInput extends Component {
120
121
  value={this.props.value || ''}
121
122
  onChange={this.props.onChange}
122
123
  onClick={this.props.onClick}
123
- onKeyPress={this.props.onEnter}
124
+ onKeyPress={this.props.onKeyPress || this.props.onEnter}
125
+ onKeyDown={this.props.onKeyDown}
124
126
  style={{ ...this.props.inputStyle }}
125
127
  readOnly={!_.isUndefined(this.props.readOnly) ? this.props.readOnly : false}
126
128
  disabled={!_.isUndefined(this.props.disabled) ? this.props.disabled : false}
@@ -17,6 +17,20 @@ class Header extends Component {
17
17
  this.props.setNavData({ isSideMenuOpen: !this.props.isSideMenuOpen });
18
18
  };
19
19
 
20
+ renderRight() {
21
+ if (this.props.rightContent) {
22
+ return this.props.rightContent;
23
+ }
24
+ return (
25
+ <div className="flex flex-center">
26
+ <Button buttonType="primary" onClick={this.goToRoadmap} narrow isActive className="marginRight-16">
27
+ Roadmap
28
+ </Button>
29
+ <div className="sideMenuButtonContainer"></div>
30
+ </div>
31
+ );
32
+ }
33
+
20
34
  renderHeader() {
21
35
  return (
22
36
  <div className="header">
@@ -25,12 +39,7 @@ class Header extends Component {
25
39
  <div style={{ display: 'flex', height: '100%', alignItems: 'center', marginLeft: 16 }}>{this.props.children}</div>
26
40
  )}
27
41
  </div>
28
- <div className="flex flex-center">
29
- <Button buttonType="primary" onClick={this.goToRoadmap} narrow isActive className="marginRight-16">
30
- Roadmap
31
- </Button>
32
- <div className="sideMenuButtonContainer"></div>
33
- </div>
42
+ {this.renderRight()}
34
43
  </div>
35
44
  );
36
45
  }
@@ -49,10 +58,17 @@ class Header extends Component {
49
58
  );
50
59
  }
51
60
 
61
+ renderContainerHeader() {
62
+ return <div className={`header header-simple ${this.props.fixed ? 'header-fixed' : ''}`}>{this.props.children}</div>;
63
+ }
64
+
52
65
  render() {
53
66
  if (this.props.simple) {
54
67
  return this.renderSimpleHeader();
55
68
  }
69
+ if (this.props.onlyContainer) {
70
+ return this.renderContainerHeader();
71
+ }
56
72
  return this.renderHeader();
57
73
  }
58
74
  }
@@ -5,11 +5,12 @@ import $ from 'jquery';
5
5
  import moment from 'moment';
6
6
  import Dropzone from 'react-dropzone';
7
7
  import FontAwesome from 'react-fontawesome';
8
- import { Button, GenericInput } from './';
9
8
  import { get1400, getThumb300, isVideo } from '../helper';
10
9
  import { fileActions } from '../apis';
11
10
  import { validateAccess, getApiError } from '../session';
12
11
  import { Popup } from './Popup';
12
+ import { Button } from './Button';
13
+ import { GenericInput } from './GenericInput';
13
14
 
14
15
  const DEFAULT_INPUT = {
15
16
  uploadingImage: false,
@@ -432,10 +433,8 @@ class ImageInputComponent extends Component {
432
433
  newState.inputs = newInputs;
433
434
 
434
435
  this.setState(newState);
435
- // for single item
436
- if (!_.isUndefined(this.props.refreshCallback)) {
437
- this.props.refreshCallback();
438
- }
436
+
437
+ this.checkRefreshCallback(newInputs);
439
438
  }
440
439
 
441
440
  selectTab(tab) {
@@ -5,7 +5,7 @@ import _ from 'lodash';
5
5
  import { unauthedFunction } from '../session';
6
6
  import { Popup } from './Popup';
7
7
  import { GenericInput } from './GenericInput';
8
- import { Text } from './';
8
+ import { Text } from './Text';
9
9
  import { Button } from './Button';
10
10
  import { DropdownInput } from './DropdownInput';
11
11
  import { typeActions, utilityActions } from '../apis';
@@ -2,7 +2,7 @@ import React, { Component } from 'react';
2
2
  import _ from 'lodash';
3
3
  import { COLOUR_BRANDING_MAIN } from '../colours';
4
4
  import { SVGIcon } from './SVGIcon';
5
- import { Text } from './';
5
+ import { Text } from './Text';
6
6
 
7
7
  class OptionsSection extends Component {
8
8
  getTitle() {
@@ -26,6 +26,17 @@ class OverlayPage extends Component {
26
26
  this.setState({ width: window.innerWidth, height: window.innerHeight });
27
27
  }
28
28
 
29
+ renderContent() {
30
+ if (this.props.fullPage) {
31
+ return (
32
+ <div className="overlayPage-full" style={this.props.fullPageStyle}>
33
+ {this.props.children}
34
+ </div>
35
+ );
36
+ }
37
+ return this.props.children;
38
+ }
39
+
29
40
  render() {
30
41
  return (
31
42
  <div style={{ ...styles.pageWrapper, ...this.props.style }}>
@@ -35,7 +46,7 @@ class OverlayPage extends Component {
35
46
  ...this.props.backgroundStyle,
36
47
  }}
37
48
  />
38
- {this.props.children}
49
+ {this.renderContent()}
39
50
  </div>
40
51
  );
41
52
  }
@@ -2,7 +2,7 @@ import React, { Component } from 'react';
2
2
  import _ from 'lodash';
3
3
  import { connect } from 'react-redux';
4
4
  import Config from '../config';
5
- import getAppColourFromState from '../helper/colours.js/getAppColourFromState';
5
+ import { getAppColourFromState } from '../helper';
6
6
 
7
7
  class ProfilePicComponent extends Component {
8
8
  render() {
@@ -0,0 +1,22 @@
1
+ import React, { Component } from 'react';
2
+
3
+ class StatusButton extends Component {
4
+ render() {
5
+ if (this.props.isActive) {
6
+ return (
7
+ <div className="tagWrapper tagWrapper--active" onClick={this.props.deactivate}>
8
+ <p className="tagWrapper__content tagWrapper__text">{this.props.activeText}</p>
9
+ <p className="tagWrapper__hoverContent tagWrapper__text">{this.props.deactivateText}</p>
10
+ </div>
11
+ );
12
+ }
13
+ return (
14
+ <div className="tagWrapper tagWrapper--inactive" onClick={this.props.activate}>
15
+ <p className="tagWrapper__content tagWrapper__text">{this.props.inactiveText}</p>
16
+ <p className="tagWrapper__hoverContent tagWrapper__text">{this.props.activateText}</p>
17
+ </div>
18
+ );
19
+ }
20
+ }
21
+
22
+ export { StatusButton };
@@ -1,5 +1,6 @@
1
1
  import React, { Component } from 'react';
2
- import Config from '../config';
2
+ import { Text } from './Text';
3
+ import { ProfilePic } from './ProfilePic';
3
4
 
4
5
  class UserListing extends Component {
5
6
  getSize() {
@@ -23,35 +24,21 @@ class UserListing extends Component {
23
24
  render() {
24
25
  return (
25
26
  <div
27
+ key={this.props.user.userId || this.props.user.Id || this.props.user.id}
28
+ className="userListing"
26
29
  style={{
27
30
  minHeight: this.getSize() + 5,
28
- display: 'flex',
29
- cursor: this.props.onClick ? 'pointer' : 'default',
30
- flexDirection: 'row',
31
- justifyContent: 'space-between',
32
- alignItems: 'center',
33
- marginTop: 10,
31
+ cursor: this.props.onClick ? 'pointer' : 'inherit',
34
32
  opacity: this.props.user && this.props.user.loading ? 0.5 : 1,
35
33
  }}
36
34
  onClick={this.props.onClick}
37
35
  >
38
- <div key={this.props.user.id} style={{ display: 'flex', flexDirection: 'row', alignItems: 'center' }}>
39
- <div
40
- style={{
41
- height: this.getSize(),
42
- width: this.getSize(),
43
- borderRadius: this.getSize() / 2,
44
- marginRight: 16,
45
- backgroundSize: 'cover',
46
- backgroundPosition: 'center',
47
- backgroundImage: `url(${this.props.user.profilePic != null ? this.props.user.profilePic : Config.env.defaultProfileImage})`,
48
- }}
49
- alt="user profile pic"
50
- />
51
- <div style={{ flex: 1, display: 'flex', flexDirection: 'column', justifyContent: 'center', height: this.getSize() }}>
52
- <p className={`fontMedium fontSize-16 ${this.props.whiteText ? 'text-white' : 'text-dark'}`} style={{ margin: 0 }}>
36
+ <div className="userListing_inner">
37
+ <ProfilePic size={this.getSize()} className="userListing_profilePic" image={this.props.user.profilePic} />
38
+ <div className="userListing_middle" style={{ height: this.getSize() }}>
39
+ <Text type="name" style={this.props.whiteText ? { color: '#fff' } : null} className={this.props.textClass}>
53
40
  {this.props.user.displayName}
54
- </p>
41
+ </Text>
55
42
  {this.renderSub()}
56
43
  </div>
57
44
  </div>
@@ -2,6 +2,7 @@ export * from './AddButton';
2
2
  export * from './Attachment';
3
3
  export * from './Button';
4
4
  export * from './CheckBox';
5
+ export * from './DatePicker';
5
6
  export * from './FileInput';
6
7
  export * from './GenericInput';
7
8
  export * from './Header';
@@ -13,11 +14,13 @@ export * from './OverlayPageSection';
13
14
  export * from './OverlayPageBottomButtons';
14
15
  export * from './PageTitle';
15
16
  export * from './Popup';
17
+ export * from './P60Icon';
16
18
  export * from './ProfilePic';
17
19
  export * from './RadioButton';
18
20
  export * from './SVGIcon';
19
21
  export * from './Tag';
20
22
  export * from './Text';
23
+ export * from './StatusButton';
21
24
  export * from './SuccessPopup';
22
25
  export * from './Reactions';
23
26
  export * from './P60Icon';
package/src/config.js CHANGED
@@ -7,8 +7,7 @@ const CoreConfig = {
7
7
  colourBrandingMain: '',
8
8
  colourBrandingOff: '',
9
9
  colourBrandingApp: '',
10
- defaultProfileImage:
11
- 'https://pluss-prd-uploads.s3.ap-southeast-2.amazonaws.com/uploads/users/ap-southeast-2:80aecdcb-9955-493e-a341-2f2263f64777/public/31164ebf4807a5f0de438dd02a/profilepic2.png',
10
+ defaultProfileImage: 'https://s3-ap-southeast-2.amazonaws.com/pluss60-dev-uploads/android/TinyDefaultProfile.png',
12
11
  utcOffset: '',
13
12
  hasAvailableNews: false,
14
13
  newsHaveTags: true,
@@ -0,0 +1,8 @@
1
+ const getUserFromState = (state) => {
2
+ if (!state || !state.auth || !state.auth.user) {
3
+ return {};
4
+ }
5
+ return state.auth.user;
6
+ };
7
+
8
+ export default getUserFromState;
@@ -1,4 +1,4 @@
1
- import { Config } from '../..';
1
+ import Config from '../../config';
2
2
 
3
3
  const getAppColourFromState = (state) => {
4
4
  if (!state || !state.auth || !state.auth.siteBranding || !state.auth.siteBranding.MainBrandingColour) {
@@ -0,0 +1,10 @@
1
+ const generateImageName = (name) => {
2
+ return `xxxxxxxx4xxxyxxxxxxxxxxxxx${name}`.replace(/[xy]/g, (c) => {
3
+ // eslint-disable-next-line
4
+ var r = (Math.random() * 16) | 0,
5
+ v = c === 'x' ? r : (r & 0x3) | 0x8;
6
+ return v.toString(16);
7
+ });
8
+ };
9
+
10
+ export default generateImageName;
@@ -3,8 +3,15 @@ export { default as getUrl } from './api/getUrl';
3
3
  export { default as getUrlParams } from './api/getUrlParams';
4
4
  export { default as safeReadParams } from './api/safeReadParams';
5
5
 
6
+ // auth
7
+ export { default as getUserFromState } from './auth/getUserFromState';
8
+
9
+ // colours
10
+ export { default as getAppColourFromState } from './colours/getAppColourFromState';
11
+
6
12
  // files
7
13
  export { default as get1400 } from './files/get1400';
14
+ export { default as generateImageName } from './files/generateImageName';
8
15
  export { default as getExtension } from './files/getExtension';
9
16
  export { default as getFileName } from './files/getFileName';
10
17
  export { default as getThumb300 } from './files/getThumb300';
package/src/session.js CHANGED
@@ -24,6 +24,7 @@ export const authedFunction = async (request) => {
24
24
  return await axios(request);
25
25
  } catch (error) {
26
26
  console.error('authedFunction error', error, request);
27
+ throw error;
27
28
  }
28
29
  };
29
30