Skip to content

Commit

Permalink
Merge branch 'feature/add-lead-assignee-info' into develop
Browse files Browse the repository at this point in the history
  • Loading branch information
tnagorra committed Jun 26, 2020
2 parents f1525c5 + ab880ed commit a27080e
Show file tree
Hide file tree
Showing 19 changed files with 159 additions and 59 deletions.
7 changes: 6 additions & 1 deletion src/components/general/EntryCommentModal/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ const propTypes = {
projectId: PropTypes.number, // eslint-disable-line react/no-unused-prop-types
entryServerId: PropTypes.number,
onCommentsCountChange: PropTypes.func.isRequired,
defaultAssignee: PropTypes.number,
requests: PropTypes.object.isRequired, // eslint-disable-line react/forbid-prop-types
};

Expand All @@ -51,6 +52,7 @@ const defaultProps = {
projectId: undefined,
entryServerId: undefined,
closeModal: undefined,
defaultAssignee: undefined,
};

const RESOLVED = 'resolved';
Expand Down Expand Up @@ -150,6 +152,7 @@ export default class EntryCommentModal extends React.PureComponent {
requests: {
entryCommentsGet,
},
defaultAssignee,
} = this.props;

entryCommentsGet.setDefaultParams({
Expand All @@ -160,7 +163,9 @@ export default class EntryCommentModal extends React.PureComponent {
activeTabKey: UNRESOLVED,
comments: [],
currentEdit: undefined,
faramValues: {},
faramValues: {
assignee: defaultAssignee,
},
faramErrors: {},
globalPristine: true,
pristine: true,
Expand Down
13 changes: 11 additions & 2 deletions src/components/input/GeoInput/GeoModal/GeoInputList/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -231,6 +231,9 @@ const GeoInputList = (props) => {
);
const groupKeySelector = useCallback(
(selection) => {
if (!geoOptionsById[selection.id]) {
return undefined;
}
const { adminLevel, region } = geoOptionsById[selection.id];
return `${region}-${adminLevel}`;
},
Expand All @@ -245,14 +248,20 @@ const GeoInputList = (props) => {
disabled: !!value.polygons || isNotDefined(onSelectionsChange),
readOnly,

value: geoOptionsById[key].title,
value: geoOptionsById[key] ? geoOptionsById[key].title : undefined,
polygons: value.polygons,
}),
[handleSelectionRemove, geoOptionsById, onSelectionsChange, readOnly],
);

const groupRendererParams = useCallback(
(groupKey) => {
if (!groupKey) {
return {
children: 'Ungrouped',
};
}

const [regionKey, adminLevelKey] = groupKey.split('-');
// FIXME: this can be made efficient
const adminLevel = adminLevelTitles.find(
Expand All @@ -262,7 +271,7 @@ const GeoInputList = (props) => {
return {
children: adminLevel
? `${adminLevel.regionTitle} / ${adminLevel.title}`
: '',
: 'Ungrouped',
};
},
[adminLevelTitles],
Expand Down
26 changes: 1 addition & 25 deletions src/components/input/GeoInput/index.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import PropTypes from 'prop-types';
import React from 'react';
import { connect } from 'react-redux';
import memoize from 'memoize-one';
import {
_cs,
Expand All @@ -14,9 +13,6 @@ import { FaramInputElement } from '@togglecorp/faram';

import AccentButton from '#rsca/Button/AccentButton';
import SearchMultiSelectInput from '#rsci/SearchMultiSelectInput';
import featuresMapping from '#constants/features';

import { activeUserSelector } from '#redux';

import GeoInputList from './GeoModal/GeoInputList';
import GeoModal from './GeoModal';
Expand All @@ -26,15 +22,8 @@ const MAX_DISPLAY_OPTIONS = 100;

const keySelector = v => v.key;

const mapStateToProps = state => ({
activeUser: activeUserSelector(state),
});

const propTypes = {
className: PropTypes.string,
activeUser: PropTypes.shape({
accessibleFeatures: PropTypes.array,
}),

onChange: PropTypes.func,
geoOptionsByRegion: PropTypes.object, // eslint-disable-line react/forbid-prop-types
Expand Down Expand Up @@ -66,7 +55,6 @@ const defaultProps = {
className: undefined,
label: undefined,
showLabel: true,
activeUser: {},
onChange: undefined,
geoOptionsByRegion: {},
disabled: false,
Expand All @@ -86,7 +74,6 @@ const defaultProps = {
};

@FaramInputElement
@connect(mapStateToProps, undefined)
export default class GeoInput extends React.PureComponent {
static propTypes = propTypes;
static defaultProps = defaultProps;
Expand Down Expand Up @@ -215,9 +202,6 @@ export default class GeoInput extends React.PureComponent {
hideList,

polygonsEnabled,
activeUser: {
accessibleFeatures = [],
},
icons,
} = this.props;

Expand All @@ -233,14 +217,6 @@ export default class GeoInput extends React.PureComponent {
const polygons = this.getPolygons(value);
const options = this.getAllGeoOptions(geoOptionsByRegion);

// NOTE: why not move this to GeoModal
const polygonSupportIndex = accessibleFeatures
.findIndex(f => f.key === featuresMapping.polygonSupportGeo);

const isPolygonFeatureEnabled = polygonSupportIndex !== -1;

const shouldEnablePolygon = isPolygonFeatureEnabled && polygonsEnabled;

return (
<div className={className}>
<div className={styles.inputContainer}>
Expand Down Expand Up @@ -308,7 +284,7 @@ export default class GeoInput extends React.PureComponent {

onApply={this.handleModalApply}
onCancel={this.handleModalCancel}
polygonsEnabled={shouldEnablePolygon}
polygonsEnabled={polygonsEnabled}
/>
)}
</div>
Expand Down
30 changes: 30 additions & 0 deletions src/components/viewer/EntityLink/index.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
import React from 'react';
import { Link } from 'react-router-dom';
import { _cs } from '@togglecorp/fujs';

import styles from './styles.scss';

interface Props {
className?: string;
title: string;
link: string;
}

function EntityLink(props: Props) {
const {
className,
title,
link,
} = props;

return (
<Link
className={_cs(className, styles.link)}
to={link}
>
{title}
</Link>
);
}

export default EntityLink;
6 changes: 6 additions & 0 deletions src/components/viewer/EntityLink/styles.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
@import '~base-scss/utils';

.link {
@extend %accent-color-link;
padding: var(--spacing-extra-small);
}
1 change: 0 additions & 1 deletion src/constants/features.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
// eslint-disable-next-line import/prefer-default-export
const featuresMapping = {
polygonSupportGeo: 'polygon_support_geo',
zoomableImage: 'zoomable_image',
privateProject: 'private_project',
entryVizConfig: 'entry_visualization_configuration',
Expand Down
2 changes: 2 additions & 0 deletions src/entities/editEntries.js
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ export const entryAccessor = {
tabularField: entry => getDataSafe(entry).tabularField,
order: entry => getDataSafe(entry).order,
serverId: entry => getDataSafe(entry).id,
createdBy: entry => getDataSafe(entry).createdBy,

unresolvedCommentCount: entry => getServerDataSafe(entry).unresolvedCommentCount || 0,
versionId: entry => getServerDataSafe(entry).versionId,
Expand Down Expand Up @@ -179,6 +180,7 @@ export const createEntry = ({
'exportData',
'filterData',
'createdAt',
'createdBy',
];
const pickedData = pick(data, keysToPick);

Expand Down
12 changes: 8 additions & 4 deletions src/redux/initial-state/dev-lang.json
Original file line number Diff line number Diff line change
Expand Up @@ -738,7 +738,7 @@
"-43376795": "Failed to fetch cluster data.",
"-72859218": "Project options",
"-45091634": "Failed to get project options.",
"-44183195": "Modifying this framework may affect {count} entries. Are you sure you want to save these changes?",
"-44183195": "Warning: {count} number of entries will be affected if you've edited or removed widgets. Would you like to continue?",
"-82545000": "Default",
"-70199668": "No notifications to display",
"-53914293": "Are you sure you want to remove the connector {connector}?",
Expand Down Expand Up @@ -1128,7 +1128,8 @@
"-72546396": "{privateProjects} Private Projects",
"-59460837": "This framework is used by private projects you are not a part of.",
"-61550815": "Widgets Preview",
"-40186961": "View Details"
"-40186961": "View Details",
"-91728706": "Extract lead information from attached document\t"
},
"links": {
"browserExtension": {
Expand Down Expand Up @@ -1585,7 +1586,9 @@
"entryGroupsFilterPlaceholder": 14,
"entryLabelsFilterPlaceholder": 14,
"entryLabelsFilterLabel": -80269151,
"entryGroupsHeaderTooltip": -47675119
"entryGroupsHeaderTooltip": -47675119,
"assigneeIconTitle": 6,
"calendarIconTitle": 163
},
"export": {
"headerExport": 600,
Expand Down Expand Up @@ -1864,7 +1867,8 @@
"searchInputEmptyText": -24511724,
"authorPlaceholder": -4332303,
"formatButtonTitle": -50025578,
"suggestionsLabel": -75552913
"suggestionsLabel": -75552913,
"extractLeadFromDocument": -91728706
},
"addLeads.actions": {
"deleteLeadConfirmText": 133,
Expand Down
2 changes: 1 addition & 1 deletion src/redux/reducers/siloDomainData/analysisFramework.js
Original file line number Diff line number Diff line change
Expand Up @@ -234,7 +234,7 @@ const afViewUpdateWidget = (state, action) => {
{
properties: { $auto: {
data: { $auto: {
$merge: widgetData,
$set: widgetData,
} },
} },
},
Expand Down
15 changes: 15 additions & 0 deletions src/schema/entries.js
Original file line number Diff line number Diff line change
Expand Up @@ -144,6 +144,21 @@ const entrySchema = [];
createdAt: { type: 'string', required: true }, // date
// createdBy: { type: 'uint' },
id: { type: 'uint', required: true },
assignee: { type: 'array.uint' },
assigneeDetails: {
type: {
doc: {
name: 'assigneeDetails',
description: 'Assignee details of lead',
},
fields: {
id: { type: 'uint' },
displayName: { type: 'string' },
displayPicture: { type: 'uint' },
email: { type: 'string' },
},
},
},
// source: { type: 'string' },
title: { type: 'string' },
url: { type: 'string' },
Expand Down
1 change: 1 addition & 0 deletions src/views/EditEntries/List/WidgetFaramContainer/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -228,6 +228,7 @@ export default class WidgetFaramContainer extends React.PureComponent {
<EntryCommentModal
entryServerId={entryServerId}
onCommentsCountChange={this.handleCommentsCountChange}
defaultAssignee={entryAccessor.createdBy(entry)}
/>
}
iconName="chat"
Expand Down
2 changes: 1 addition & 1 deletion src/views/EditEntries/Overview/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -235,7 +235,6 @@ export default class Overview extends React.PureComponent {
const {
entry,
leadId,
entries,
lead,
analysisFramework,
statuses,
Expand Down Expand Up @@ -335,6 +334,7 @@ export default class Overview extends React.PureComponent {
onCommentsCountChange={
this.handleCommentsCountChange
}
defaultAssignee={entryAccessor.createdBy(entry)}
/>
}
iconName="chat"
Expand Down
2 changes: 1 addition & 1 deletion src/views/Entries/FilterEntriesForm/GeoFilter.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ const defaultProps = {
label: '',
disabled: false,
value: {
includeSubRegions: false,
includeSubRegions: true,
areas: [],
},
};
Expand Down
2 changes: 2 additions & 0 deletions src/views/Entries/LeadGroupedEntries/Entry/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -189,6 +189,7 @@ export default class Entry extends React.PureComponent {
widgets,
entry: {
id: entryId,
createdBy,
attributes,
unresolvedCommentCount: commentCount,
projectLabels,
Expand Down Expand Up @@ -221,6 +222,7 @@ export default class Entry extends React.PureComponent {
<EntryCommentModal
entryServerId={entryId}
onCommentsCountChange={this.handleCommentsCountChange}
defaultAssignee={createdBy}
/>
}
iconName="chat"
Expand Down
Loading

0 comments on commit a27080e

Please sign in to comment.