@kineticdata/react 5.1.2 → 6.0.1
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/assets/task/icons/drag-handle.svg +3 -0
- package/assets/task/icons/plus_small.svg +2 -4
- package/lib/apis/agent/adapters.js +16 -12
- package/lib/apis/agent/bridges.js +54 -41
- package/lib/apis/agent/handlers.js +51 -38
- package/lib/apis/core/activity.js +19 -11
- package/lib/apis/core/attributeDefinitions.js +54 -46
- package/lib/apis/core/attributeDefinitions.test.js +47 -55
- package/lib/apis/core/authentication.js +58 -63
- package/lib/apis/core/backgroundJobs.js +38 -30
- package/lib/apis/core/bridgeModelAttributeMappings.js +42 -34
- package/lib/apis/core/bridgeModelAttributes.js +47 -37
- package/lib/apis/core/bridgeModelMappings.js +42 -34
- package/lib/apis/core/bridgeModelQualificationMappings.js +42 -34
- package/lib/apis/core/bridgeModelQualifications.js +42 -34
- package/lib/apis/core/bridgeModels.js +56 -46
- package/lib/apis/core/bridgeModels.test.js +64 -80
- package/lib/apis/core/bridgedresources.js +64 -72
- package/lib/apis/core/bridgedresources.test.js +33 -30
- package/lib/apis/core/categories.js +59 -52
- package/lib/apis/core/categories.test.js +36 -33
- package/lib/apis/core/fileResources.js +41 -33
- package/lib/apis/core/filestores.js +42 -34
- package/lib/apis/core/formTypes.js +50 -44
- package/lib/apis/core/forms.js +53 -49
- package/lib/apis/core/forms.test.js +60 -74
- package/lib/apis/core/kapps.js +45 -39
- package/lib/apis/core/kapps.test.js +45 -52
- package/lib/apis/core/logs.js +20 -16
- package/lib/apis/core/memberships.js +23 -20
- package/lib/apis/core/meta.js +31 -19
- package/lib/apis/core/notices.js +17 -9
- package/lib/apis/core/oauthClients.js +49 -45
- package/lib/apis/core/platformComponents.js +73 -57
- package/lib/apis/core/platformItems.js +22 -13
- package/lib/apis/core/profile.js +28 -21
- package/lib/apis/core/profile.test.js +20 -17
- package/lib/apis/core/securityPolicyDefinitions.js +48 -41
- package/lib/apis/core/securityPolicyDefinitions.test.js +50 -60
- package/lib/apis/core/space.js +23 -16
- package/lib/apis/core/space.test.js +31 -38
- package/lib/apis/core/submissions.js +213 -186
- package/lib/apis/core/submissions.test.js +39 -36
- package/lib/apis/core/teams.js +51 -44
- package/lib/apis/core/teams.test.js +42 -39
- package/lib/apis/core/translations.js +123 -130
- package/lib/apis/core/translations.test.js +278 -368
- package/lib/apis/core/users.js +56 -49
- package/lib/apis/core/users.test.js +42 -39
- package/lib/apis/core/version.js +20 -11
- package/lib/apis/core/webApis.js +42 -34
- package/lib/apis/core/webhooks.js +48 -41
- package/lib/apis/core/webhooks.test.js +50 -60
- package/lib/apis/core/webhooksJobs.js +30 -26
- package/lib/apis/core/workflows.js +52 -44
- package/lib/apis/http.js +121 -80
- package/lib/apis/http.test.js +137 -38
- package/lib/apis/index.js +506 -50
- package/lib/apis/system/index.js +363 -215
- package/lib/apis/task/index.js +294 -227
- package/lib/components/agent/bridge/BridgeForm.js +50 -50
- package/lib/components/agent/bridge/BridgeTable.js +16 -9
- package/lib/components/agent/filestore/FilestoreForm.js +49 -48
- package/lib/components/agent/filestore/FilestoreTable.js +16 -9
- package/lib/components/agent/handler/AgentHandlerForm.js +24 -27
- package/lib/components/agent/handler/AgentHandlerTable.js +17 -10
- package/lib/components/common/AttributeSelect.js +15 -9
- package/lib/components/common/BridgeSelect.js +48 -43
- package/lib/components/common/ComponentConfigContext.js +9 -2
- package/lib/components/common/ContentEditable.js +36 -60
- package/lib/components/common/FormSelect.js +70 -58
- package/lib/components/common/NodeSelect.js +23 -19
- package/lib/components/common/Scroller.js +24 -23
- package/lib/components/common/StaticSelect.js +57 -50
- package/lib/components/common/TableInput.js +54 -57
- package/lib/components/common/TeamSelect.js +42 -39
- package/lib/components/common/ToastContainer.js +170 -0
- package/lib/components/common/Typeahead.js +121 -138
- package/lib/components/common/UserSelect.js +42 -41
- package/lib/components/common/authentication/AuthInterceptor.js +15 -19
- package/lib/components/common/authentication/AuthInterceptor.test.js +46 -64
- package/lib/components/common/authentication/AuthenticationContainer.js +350 -454
- package/lib/components/common/authentication/RequestInterceptor.js +16 -19
- package/lib/components/common/code_input/CodeInput.js +92 -122
- package/lib/components/common/code_input/draftHelpers.js +96 -90
- package/lib/components/common/code_input/languageHelpers.js +49 -47
- package/lib/components/common/code_input/languageHelpers.test.js +21 -16
- package/lib/components/common/defaults/Toast.js +26 -0
- package/lib/components/common/defaults/index.js +13 -0
- package/lib/components/core/CoreFormModal.js +26 -24
- package/lib/components/core/CoreModal.js +37 -31
- package/lib/components/core/attribute_definition/AttributeDefinitionForm.js +24 -23
- package/lib/components/core/attribute_definition/AttributeDefinitionTable.js +25 -18
- package/lib/components/core/bridge_model/BridgeModelForm.js +27 -37
- package/lib/components/core/bridge_model/BridgeModelTable.js +17 -10
- package/lib/components/core/bridge_model_attribute/BridgeModelAttributeForm.js +17 -16
- package/lib/components/core/bridge_model_attribute/BridgeModelAttributeTable.js +25 -21
- package/lib/components/core/bridge_model_qualification/BridgeModelQualificationForm.js +20 -20
- package/lib/components/core/bridge_model_qualification/BridgeModelQualificationTable.js +27 -22
- package/lib/components/core/category/CategoryForm.js +22 -22
- package/lib/components/core/category/CategoryTable.js +28 -16
- package/lib/components/core/core_form/CoreForm.js +209 -285
- package/lib/components/core/core_form/CoreForm.test.js +12 -10
- package/lib/components/core/core_form/defaults/index.js +52 -44
- package/lib/components/core/core_form/globals.js +14 -5
- package/lib/components/core/field_definition/FieldDefinitionForm.js +23 -21
- package/lib/components/core/field_definition/FieldDefinitionTable.js +26 -15
- package/lib/components/core/file_resource/FileResourceForm.js +38 -37
- package/lib/components/core/file_resource/FileResourceTable.js +16 -12
- package/lib/components/core/form/FormForm.js +56 -61
- package/lib/components/core/form/FormTable.js +47 -33
- package/lib/components/core/form_type/FormTypeForm.js +14 -13
- package/lib/components/core/form_type/FormTypeTable.js +15 -9
- package/lib/components/core/i18n/I18n.js +54 -61
- package/lib/components/core/i18n/I18nContext.js +9 -2
- package/lib/components/core/i18n/I18nProvider.js +40 -43
- package/lib/components/core/i18n/Moment.js +40 -50
- package/lib/components/core/index_definition/IndexDefinitionForm.js +23 -24
- package/lib/components/core/index_definition/IndexDefinitionTable.js +31 -16
- package/lib/components/core/index_job/IndexJobTable.js +20 -15
- package/lib/components/core/kapp/KappForm.js +57 -58
- package/lib/components/core/kapp/KappTable.js +34 -44
- package/lib/components/core/log/LogTable.js +42 -34
- package/lib/components/core/oauth_client/OAuthClientForm.js +17 -17
- package/lib/components/core/oauth_client/OAuthClientTable.js +12 -8
- package/lib/components/core/platform_component/AgentComponentForm.js +15 -15
- package/lib/components/core/platform_component/AgentComponentTable.js +10 -5
- package/lib/components/core/platform_component/TaskComponentForm.js +14 -14
- package/lib/components/core/profile/ProfileForm.js +40 -39
- package/lib/components/core/security_definition/SecurityDefinitionForm.js +28 -25
- package/lib/components/core/security_definition/SecurityDefinitionTable.js +27 -17
- package/lib/components/core/space/SpaceForm.js +79 -90
- package/lib/components/core/submission/DatastoreSubmissionFilters.js +39 -40
- package/lib/components/core/submission/DatastoreSubmissionTable.js +37 -34
- package/lib/components/core/submission/FormSubmissionFilters.js +79 -75
- package/lib/components/core/submission/FormSubmissionTable.js +64 -39
- package/lib/components/core/submission/KappSubmissionTable.js +67 -48
- package/lib/components/core/submission/SubmissionForm.js +126 -55
- package/lib/components/core/submission/SubmissionTable.js +24 -20
- package/lib/components/core/submission/helpers.js +37 -33
- package/lib/components/core/submission/helpers.test.js +69 -20
- package/lib/components/core/team/TeamForm.js +24 -21
- package/lib/components/core/team/TeamTable.js +27 -16
- package/lib/components/core/translation/ContextForm.js +13 -10
- package/lib/components/core/translation/ContextTable.js +13 -10
- package/lib/components/core/translation/EntryForm.js +27 -24
- package/lib/components/core/translation/EntryTable.js +19 -16
- package/lib/components/core/translation/LocaleForm.js +16 -13
- package/lib/components/core/translation/LocaleTable.js +12 -8
- package/lib/components/core/user/UserForm.js +38 -37
- package/lib/components/core/user/UserTable.js +42 -20
- package/lib/components/core/webapi/WebApiForm.js +87 -80
- package/lib/components/core/webapi/WebApiTable.js +28 -17
- package/lib/components/core/webhook/WebhookForm.js +33 -32
- package/lib/components/core/webhook/WebhookTable.js +41 -29
- package/lib/components/core/webhook_job/WebhookJobTable.js +58 -35
- package/lib/components/form/Form.helpers.js +182 -108
- package/lib/components/form/Form.js +467 -524
- package/lib/components/form/Form.models.js +39 -24
- package/lib/components/form/FormState.js +8 -5
- package/lib/components/form/KitchenSinkForm.js +135 -4
- package/lib/components/form/defaults/AttributesField.js +48 -59
- package/lib/components/form/defaults/CheckboxField.js +14 -6
- package/lib/components/form/defaults/CodeField.js +15 -7
- package/lib/components/form/defaults/FormButtons.js +12 -4
- package/lib/components/form/defaults/FormError.js +12 -4
- package/lib/components/form/defaults/FormField.js +15 -7
- package/lib/components/form/defaults/FormLayout.js +12 -4
- package/lib/components/form/defaults/FormMultiField.js +15 -7
- package/lib/components/form/defaults/PasswordField.js +14 -6
- package/lib/components/form/defaults/RadioField.js +15 -7
- package/lib/components/form/defaults/SampleTeamsRolesFIeld.js +17 -9
- package/lib/components/form/defaults/SelectField.js +16 -8
- package/lib/components/form/defaults/SelectMultiField.js +15 -7
- package/lib/components/form/defaults/TableField.js +14 -6
- package/lib/components/form/defaults/TeamField.js +15 -7
- package/lib/components/form/defaults/TeamMultiField.js +15 -7
- package/lib/components/form/defaults/TextField.js +14 -6
- package/lib/components/form/defaults/TextMultiField.js +26 -28
- package/lib/components/form/defaults/UserField.js +15 -7
- package/lib/components/form/defaults/UserMultiField.js +15 -7
- package/lib/components/form/defaults/index.js +48 -41
- package/lib/components/form/tests/Form.test.js +568 -864
- package/lib/components/form/tests/components.js +15 -25
- package/lib/components/form/tests/helpers.test.js +35 -33
- package/lib/components/index.js +1034 -135
- package/lib/components/system/SystemBackgroundTasksTable.js +14 -10
- package/lib/components/system/SystemCassandraForm.js +98 -0
- package/lib/components/system/SystemElasticSearchForm.js +98 -0
- package/lib/components/system/SystemFilestoreForm.js +36 -28
- package/lib/components/system/SystemForm.js +19 -16
- package/lib/components/system/SystemIngressForm.js +85 -36
- package/lib/components/system/SystemSecurityForm.js +17 -14
- package/lib/components/system/SystemSmtpForm.js +13 -13
- package/lib/components/system/SystemTaskAdapterForm.js +49 -21
- package/lib/components/system/SystemTrustedCertificateForm.js +40 -0
- package/lib/components/system/SystemTrustedCertificatesTable.js +74 -0
- package/lib/components/system/SystemUserForm.js +15 -14
- package/lib/components/system/helpers.js +281 -98
- package/lib/components/system/helpers.test.js +16 -12
- package/lib/components/system/spaces/SystemSpaceForm.js +25 -24
- package/lib/components/system/spaces/SystemTenantForm.js +112 -68
- package/lib/components/system/spaces/SystemTenantTable.js +12 -8
- package/lib/components/table/Table.js +295 -227
- package/lib/components/table/Table.redux.js +339 -355
- package/lib/components/table/Table.redux.test.js +49 -47
- package/lib/components/table/Table.test.js +146 -132
- package/lib/components/table/defaults/BodyCell.js +12 -6
- package/lib/components/table/defaults/BodyRow.js +10 -4
- package/lib/components/table/defaults/BooleanFilter.js +17 -11
- package/lib/components/table/defaults/ColumnControl.js +26 -0
- package/lib/components/table/defaults/EmptyBodyRow.js +12 -6
- package/lib/components/table/defaults/FilterLayout.js +17 -11
- package/lib/components/table/defaults/Footer.js +11 -5
- package/lib/components/table/defaults/FooterCell.js +10 -4
- package/lib/components/table/defaults/FooterRow.js +10 -4
- package/lib/components/table/defaults/Header.js +10 -4
- package/lib/components/table/defaults/HeaderCell.js +16 -10
- package/lib/components/table/defaults/HeaderRow.js +10 -4
- package/lib/components/table/defaults/PaginationControl.js +18 -9
- package/lib/components/table/defaults/TableBody.js +10 -4
- package/lib/components/table/defaults/TableLayout.js +12 -6
- package/lib/components/table/defaults/TextFilter.js +16 -10
- package/lib/components/table/defaults/index.js +43 -33
- package/lib/components/task/builder/Connector.js +100 -111
- package/lib/components/task/builder/ConnectorForm.js +17 -11
- package/lib/components/task/builder/Node.js +101 -83
- package/lib/components/task/builder/NodeForm.js +30 -27
- package/lib/components/task/builder/NodeParametersForm.js +27 -24
- package/lib/components/task/builder/SvgCanvas.js +67 -96
- package/lib/components/task/builder/SvgText.js +19 -134
- package/lib/components/task/builder/TaskDefinitionConfigForm.js +27 -22
- package/lib/components/task/builder/TreeBuilder.js +140 -115
- package/lib/components/task/builder/builder.redux.js +311 -326
- package/lib/components/task/builder/constants.js +94 -45
- package/lib/components/task/builder/helpers.js +184 -173
- package/lib/components/task/builder/helpers.test.js +20 -18
- package/lib/components/task/builder/models.js +121 -98
- package/lib/components/task/category/TaskCategoryForm.js +31 -29
- package/lib/components/task/category/TaskCategoryTable.js +12 -8
- package/lib/components/task/common/UsageTable.js +16 -12
- package/lib/components/task/engine/EngineSettingsForm.js +13 -11
- package/lib/components/task/errors/RunErrorTable.js +50 -27
- package/lib/components/task/errors/SystemErrorsTable.js +13 -9
- package/lib/components/task/handlers/HandlerForm.js +55 -55
- package/lib/components/task/handlers/HandlerTable.js +35 -19
- package/lib/components/task/handlers/MissingHandlerTable.js +12 -8
- package/lib/components/task/policy_rule/PolicyRuleForm.js +33 -32
- package/lib/components/task/policy_rule/PolicyRuleTable.js +12 -8
- package/lib/components/task/runs/CreateManualTriggerForm.js +17 -15
- package/lib/components/task/runs/RunTable.js +45 -29
- package/lib/components/task/runs/RunTaskTable.js +10 -6
- package/lib/components/task/sources/SourceForm.js +47 -47
- package/lib/components/task/sources/SourceTable.js +29 -18
- package/lib/components/task/triggers/TriggerTable.js +71 -41
- package/lib/components/task/workflows/LinkedWorkflowForm.js +48 -54
- package/lib/components/task/workflows/LinkedWorkflowTable.js +46 -26
- package/lib/components/task/workflows/MissingRoutineTable.js +12 -8
- package/lib/components/task/workflows/WorkflowForm.js +49 -44
- package/lib/components/task/workflows/WorkflowTable.js +47 -29
- package/lib/helpers/SearchBuilder.js +73 -127
- package/lib/helpers/SearchBuilder.test.js +184 -175
- package/lib/helpers/index.js +116 -74
- package/lib/index.js +87 -38
- package/lib/reducer.js +11 -3
- package/lib/saga.js +42 -38
- package/lib/store.js +59 -35
- package/package.json +17 -29
- package/proxyhelper.js +122 -57
- package/assets/discussions/images/avi_128.png +0 -0
- package/assets/discussions/images/excel_128.png +0 -0
- package/assets/discussions/images/html_128.png +0 -0
- package/assets/discussions/images/illustrator_128.png +0 -0
- package/assets/discussions/images/indesign_128.png +0 -0
- package/assets/discussions/images/movie_128.png +0 -0
- package/assets/discussions/images/mpeg_128.png +0 -0
- package/assets/discussions/images/pdf_128.png +0 -0
- package/assets/discussions/images/photoshop_128.png +0 -0
- package/assets/discussions/images/powerpoint_128.png +0 -0
- package/assets/discussions/images/txt_128.png +0 -0
- package/assets/discussions/images/unknown_128.png +0 -0
- package/assets/discussions/images/word_128.png +0 -0
- package/assets/discussions/styles/_discussion.scss +0 -506
- package/lib/apis/discussions/index.js +0 -395
- package/lib/apis/socket/index.js +0 -77
- package/lib/apis/socket/socket.js +0 -350
- package/lib/apis/socket/socket.test.js +0 -90
- package/lib/apis/socket/timer.js +0 -45
- package/lib/apis/socket/timer.test.js +0 -51
- package/lib/apis/socket/topic.js +0 -185
- package/lib/apis/topics/index.js +0 -19
- package/lib/components/discussions/ChatInputForm.js +0 -424
- package/lib/components/discussions/DateBanner.js +0 -10
- package/lib/components/discussions/Discussion.js +0 -202
- package/lib/components/discussions/DiscussionForm.js +0 -227
- package/lib/components/discussions/InvitationForm.js +0 -107
- package/lib/components/discussions/MessageHistory.js +0 -110
- package/lib/components/discussions/MessagesByDate.js +0 -40
- package/lib/components/discussions/MessagesList.js +0 -30
- package/lib/components/discussions/MoreMessagesBanner.js +0 -26
- package/lib/components/discussions/ScrollHelper.js +0 -84
- package/lib/components/discussions/SystemMessage.js +0 -88
- package/lib/components/discussions/SystemMessageGroup.js +0 -15
- package/lib/components/discussions/UserMessage.js +0 -163
- package/lib/components/discussions/UserMessageGroup.js +0 -34
- package/lib/components/discussions/redux.js +0 -178
- package/lib/components/discussions/sagas.js +0 -500
- package/lib/helpers/discussions/canManage.js +0 -30
- package/lib/helpers/discussions/canManage.test.js +0 -69
- package/lib/helpers/discussions/generateSystemMessageContent.js +0 -131
- package/lib/helpers/discussions/generateSystemMessageContent.test.js +0 -450
- package/lib/models/discussions.js +0 -76
- package/lib/models/index.js +0 -1
|
@@ -1,131 +0,0 @@
|
|
|
1
|
-
import _slicedToArray from "@babel/runtime/helpers/esm/slicedToArray";
|
|
2
|
-
import _toConsumableArray from "@babel/runtime/helpers/esm/toConsumableArray";
|
|
3
|
-
import _objectSpread from "@babel/runtime/helpers/esm/objectSpread2";
|
|
4
|
-
import _objectWithoutProperties from "@babel/runtime/helpers/esm/objectWithoutProperties";
|
|
5
|
-
import isarray from 'isarray';
|
|
6
|
-
|
|
7
|
-
var formatLabel = function formatLabel(label) {
|
|
8
|
-
return label === 'owningUsers' ? 'owning users' : label === 'owningTeams' ? 'owning teams' : label;
|
|
9
|
-
};
|
|
10
|
-
|
|
11
|
-
var formatValue = function formatValue(value) {
|
|
12
|
-
return value === null ? '' : isarray(value) ? value.map(formatValue).join(', ') : value.username || value.name || value;
|
|
13
|
-
};
|
|
14
|
-
|
|
15
|
-
var getToken = function getToken(tokens, name) {
|
|
16
|
-
var required = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : true;
|
|
17
|
-
var result = tokens // find the token by the name
|
|
18
|
-
.filter(function (token) {
|
|
19
|
-
return token.name === name;
|
|
20
|
-
}) // map to a copy of the token but omit the name property
|
|
21
|
-
.map(function (_ref) {
|
|
22
|
-
var name = _ref.name,
|
|
23
|
-
rest = _objectWithoutProperties(_ref, ["name"]);
|
|
24
|
-
|
|
25
|
-
return _objectSpread({}, rest);
|
|
26
|
-
})[0];
|
|
27
|
-
|
|
28
|
-
if (!result && required) {
|
|
29
|
-
throw new Error("Could not find token named ".concat(name));
|
|
30
|
-
} else {
|
|
31
|
-
return result;
|
|
32
|
-
}
|
|
33
|
-
};
|
|
34
|
-
|
|
35
|
-
var textToken = function textToken(value) {
|
|
36
|
-
return {
|
|
37
|
-
type: 'text',
|
|
38
|
-
value: value
|
|
39
|
-
};
|
|
40
|
-
};
|
|
41
|
-
|
|
42
|
-
export default (function (action, content) {
|
|
43
|
-
var error;
|
|
44
|
-
|
|
45
|
-
try {
|
|
46
|
-
switch (action) {
|
|
47
|
-
case 'Invitation Sent':
|
|
48
|
-
{
|
|
49
|
-
var invitationEmail = getToken(content, 'invitationEmail', false);
|
|
50
|
-
return [invitationEmail ? textToken(invitationEmail.value) : getToken(content, 'user'), textToken('was invited by'), getToken(content, 'invitedBy')];
|
|
51
|
-
}
|
|
52
|
-
|
|
53
|
-
case 'Invitation Resent':
|
|
54
|
-
{
|
|
55
|
-
var _invitationEmail = getToken(content, 'invitationEmail', false);
|
|
56
|
-
|
|
57
|
-
return [_invitationEmail ? textToken(_invitationEmail.value) : getToken(content, 'user'), textToken('had their invitation updated by'), getToken(content, 'invitedBy')];
|
|
58
|
-
}
|
|
59
|
-
|
|
60
|
-
case 'Invitation Removed':
|
|
61
|
-
{
|
|
62
|
-
var _invitationEmail2 = getToken(content, 'invitationEmail', false);
|
|
63
|
-
|
|
64
|
-
return [_invitationEmail2 ? textToken(_invitationEmail2.value) : getToken(content, 'user'), textToken('had their invitation removed by'), getToken(content, 'removedBy')];
|
|
65
|
-
}
|
|
66
|
-
|
|
67
|
-
case 'Participant Created':
|
|
68
|
-
return [getToken(content, 'user'), textToken('was added as a participant by'), getToken(content, 'createdBy')];
|
|
69
|
-
|
|
70
|
-
case 'Participant Joined':
|
|
71
|
-
{
|
|
72
|
-
var user = getToken(content, 'user');
|
|
73
|
-
var invitedBy = getToken(content, 'invitedBy', false);
|
|
74
|
-
|
|
75
|
-
var _invitationEmail3 = getToken(content, 'invitationEmail', false);
|
|
76
|
-
|
|
77
|
-
var joinedAsAdmin = getToken(content, 'joinedAsAdmin', false);
|
|
78
|
-
var joinedAsOwner = getToken(content, 'joinedAsOwner', false);
|
|
79
|
-
|
|
80
|
-
if (invitedBy && _invitationEmail3) {
|
|
81
|
-
return [user, textToken('joined the discussion after'), invitedBy, textToken("sent an invitation to ".concat(_invitationEmail3.value))];
|
|
82
|
-
} else if (invitedBy) {
|
|
83
|
-
return [user, textToken('joined the discussion after being invited by'), invitedBy];
|
|
84
|
-
} else if (joinedAsAdmin) {
|
|
85
|
-
return [user, textToken('joined the discussion after being authorized as a space admin')];
|
|
86
|
-
} else if (joinedAsOwner) {
|
|
87
|
-
return [user, textToken('joined the discussion after being authorized as an owner')];
|
|
88
|
-
} else {
|
|
89
|
-
return [user, textToken('joined the discussion after being authorized by the join policy')];
|
|
90
|
-
}
|
|
91
|
-
}
|
|
92
|
-
|
|
93
|
-
case 'Participant Left':
|
|
94
|
-
return [getToken(content, 'user'), textToken('has left')];
|
|
95
|
-
|
|
96
|
-
case 'Participant Removed':
|
|
97
|
-
return [getToken(content, 'user'), textToken('has been removed by'), getToken(content, 'removedBy')];
|
|
98
|
-
|
|
99
|
-
case 'Message Updated':
|
|
100
|
-
return [getToken(content, 'updatedBy'), textToken('changed a message from'), getToken(content, 'previousMessage'), textToken('to'), getToken(content, 'message')];
|
|
101
|
-
|
|
102
|
-
case 'Discussion Updated':
|
|
103
|
-
var previous = JSON.parse(getToken(content, 'previousValues').value);
|
|
104
|
-
var current = JSON.parse(getToken(content, 'values').value);
|
|
105
|
-
return [getToken(content, 'updatedBy'), textToken('updated the discussion')].concat(_toConsumableArray(Object.entries(previous).map(function (_ref2, i) {
|
|
106
|
-
var _ref3 = _slicedToArray(_ref2, 1),
|
|
107
|
-
name = _ref3[0];
|
|
108
|
-
|
|
109
|
-
var prefix = i > 0 ? ', and ' : '';
|
|
110
|
-
var l = formatLabel(name);
|
|
111
|
-
var p = formatValue(previous[name]);
|
|
112
|
-
var c = formatValue(current[name]);
|
|
113
|
-
return textToken("".concat(prefix).concat(l, " from [").concat(p, "] to [").concat(c, "]"));
|
|
114
|
-
})));
|
|
115
|
-
|
|
116
|
-
default:
|
|
117
|
-
console.warn("Invalid system message action '".concat(action, "' - unable to generate content."));
|
|
118
|
-
}
|
|
119
|
-
} catch (e) {
|
|
120
|
-
error = e;
|
|
121
|
-
}
|
|
122
|
-
|
|
123
|
-
console.error('Invalid system message', {
|
|
124
|
-
action: action,
|
|
125
|
-
content: content
|
|
126
|
-
}, error);
|
|
127
|
-
return [{
|
|
128
|
-
type: 'text',
|
|
129
|
-
value: 'Invalid system message'
|
|
130
|
-
}];
|
|
131
|
-
});
|
|
@@ -1,450 +0,0 @@
|
|
|
1
|
-
import generateContent from './generateSystemMessageContent';
|
|
2
|
-
var USER1 = {
|
|
3
|
-
username: 'User 1'
|
|
4
|
-
};
|
|
5
|
-
var USER2 = {
|
|
6
|
-
username: 'User 2'
|
|
7
|
-
};
|
|
8
|
-
var MESSAGE1 = {
|
|
9
|
-
content: [{
|
|
10
|
-
type: 'text',
|
|
11
|
-
value: 'Hello'
|
|
12
|
-
}]
|
|
13
|
-
};
|
|
14
|
-
var MESSAGE2 = {
|
|
15
|
-
content: [{
|
|
16
|
-
type: 'text',
|
|
17
|
-
value: 'World'
|
|
18
|
-
}]
|
|
19
|
-
};
|
|
20
|
-
describe('generateContent', function () {
|
|
21
|
-
it('returns a text token with "invalid" if action does not match ', function () {
|
|
22
|
-
expect(generateContent('Invalid', [])).toEqual([{
|
|
23
|
-
type: 'text',
|
|
24
|
-
value: 'Invalid system message'
|
|
25
|
-
}]);
|
|
26
|
-
});
|
|
27
|
-
describe('Invitation Sent', function () {
|
|
28
|
-
it('returns invitation user sent message', function () {
|
|
29
|
-
var content = [{
|
|
30
|
-
type: 'user',
|
|
31
|
-
name: 'user',
|
|
32
|
-
value: USER1
|
|
33
|
-
}, {
|
|
34
|
-
type: 'user',
|
|
35
|
-
name: 'invitedBy',
|
|
36
|
-
value: USER2
|
|
37
|
-
}];
|
|
38
|
-
var expected = [{
|
|
39
|
-
type: 'user',
|
|
40
|
-
value: USER1
|
|
41
|
-
}, {
|
|
42
|
-
type: 'text',
|
|
43
|
-
value: 'was invited by'
|
|
44
|
-
}, {
|
|
45
|
-
type: 'user',
|
|
46
|
-
value: USER2
|
|
47
|
-
}];
|
|
48
|
-
expect(generateContent('Invitation Sent', content)).toEqual(expected);
|
|
49
|
-
});
|
|
50
|
-
it('returns invitation email sent message', function () {
|
|
51
|
-
var content = [{
|
|
52
|
-
type: 'text',
|
|
53
|
-
name: 'invitationEmail',
|
|
54
|
-
value: 'test.user@kinops.io'
|
|
55
|
-
}, {
|
|
56
|
-
type: 'user',
|
|
57
|
-
name: 'invitedBy',
|
|
58
|
-
value: USER2
|
|
59
|
-
}];
|
|
60
|
-
var expected = [{
|
|
61
|
-
type: 'text',
|
|
62
|
-
value: 'test.user@kinops.io'
|
|
63
|
-
}, {
|
|
64
|
-
type: 'text',
|
|
65
|
-
value: 'was invited by'
|
|
66
|
-
}, {
|
|
67
|
-
type: 'user',
|
|
68
|
-
value: USER2
|
|
69
|
-
}];
|
|
70
|
-
expect(generateContent('Invitation Sent', content)).toEqual(expected);
|
|
71
|
-
});
|
|
72
|
-
});
|
|
73
|
-
describe('Invitation Removed', function () {
|
|
74
|
-
it('returns invitation user removed message', function () {
|
|
75
|
-
var content = [{
|
|
76
|
-
type: 'user',
|
|
77
|
-
name: 'user',
|
|
78
|
-
value: USER1
|
|
79
|
-
}, {
|
|
80
|
-
type: 'user',
|
|
81
|
-
name: 'removedBy',
|
|
82
|
-
value: USER2
|
|
83
|
-
}];
|
|
84
|
-
var expected = [{
|
|
85
|
-
type: 'user',
|
|
86
|
-
value: USER1
|
|
87
|
-
}, {
|
|
88
|
-
type: 'text',
|
|
89
|
-
value: 'had their invitation removed by'
|
|
90
|
-
}, {
|
|
91
|
-
type: 'user',
|
|
92
|
-
value: USER2
|
|
93
|
-
}];
|
|
94
|
-
expect(generateContent('Invitation Removed', content)).toEqual(expected);
|
|
95
|
-
});
|
|
96
|
-
it('returns invitation email removed message', function () {
|
|
97
|
-
var content = [{
|
|
98
|
-
type: 'text',
|
|
99
|
-
name: 'invitationEmail',
|
|
100
|
-
value: 'test.user@kinops.io'
|
|
101
|
-
}, {
|
|
102
|
-
type: 'user',
|
|
103
|
-
name: 'removedBy',
|
|
104
|
-
value: USER2
|
|
105
|
-
}];
|
|
106
|
-
var expected = [{
|
|
107
|
-
type: 'text',
|
|
108
|
-
value: 'test.user@kinops.io'
|
|
109
|
-
}, {
|
|
110
|
-
type: 'text',
|
|
111
|
-
value: 'had their invitation removed by'
|
|
112
|
-
}, {
|
|
113
|
-
type: 'user',
|
|
114
|
-
value: USER2
|
|
115
|
-
}];
|
|
116
|
-
expect(generateContent('Invitation Removed', content)).toEqual(expected);
|
|
117
|
-
});
|
|
118
|
-
});
|
|
119
|
-
describe('Participant Created', function () {
|
|
120
|
-
it('returns participant created message', function () {
|
|
121
|
-
var content = [{
|
|
122
|
-
type: 'user',
|
|
123
|
-
name: 'user',
|
|
124
|
-
value: USER1
|
|
125
|
-
}, {
|
|
126
|
-
type: 'user',
|
|
127
|
-
name: 'createdBy',
|
|
128
|
-
value: USER2
|
|
129
|
-
}]; // "USER1 joined the discussion after being invited by USER2"
|
|
130
|
-
|
|
131
|
-
var expected = [{
|
|
132
|
-
type: 'user',
|
|
133
|
-
value: USER1
|
|
134
|
-
}, {
|
|
135
|
-
type: 'text',
|
|
136
|
-
value: 'was added as a participant by'
|
|
137
|
-
}, {
|
|
138
|
-
type: 'user',
|
|
139
|
-
value: USER2
|
|
140
|
-
}];
|
|
141
|
-
expect(generateContent('Participant Created', content)).toEqual(expected);
|
|
142
|
-
});
|
|
143
|
-
});
|
|
144
|
-
describe('Participant Joined', function () {
|
|
145
|
-
it('returns joined as user message', function () {
|
|
146
|
-
var content = [{
|
|
147
|
-
type: 'user',
|
|
148
|
-
name: 'user',
|
|
149
|
-
value: USER1
|
|
150
|
-
}, {
|
|
151
|
-
type: 'user',
|
|
152
|
-
name: 'invitedBy',
|
|
153
|
-
value: USER2
|
|
154
|
-
}]; // "USER1 joined the discussion after being invited by USER2"
|
|
155
|
-
|
|
156
|
-
var expected = [{
|
|
157
|
-
type: 'user',
|
|
158
|
-
value: USER1
|
|
159
|
-
}, {
|
|
160
|
-
type: 'text',
|
|
161
|
-
value: 'joined the discussion after being invited by'
|
|
162
|
-
}, {
|
|
163
|
-
type: 'user',
|
|
164
|
-
value: USER2
|
|
165
|
-
}];
|
|
166
|
-
expect(generateContent('Participant Joined', content)).toEqual(expected);
|
|
167
|
-
});
|
|
168
|
-
it('returns joined via email message', function () {
|
|
169
|
-
var content = [{
|
|
170
|
-
type: 'user',
|
|
171
|
-
name: 'user',
|
|
172
|
-
value: USER1
|
|
173
|
-
}, {
|
|
174
|
-
type: 'text',
|
|
175
|
-
name: 'invitationEmail',
|
|
176
|
-
value: 'test.user@kinops.io'
|
|
177
|
-
}, {
|
|
178
|
-
type: 'user',
|
|
179
|
-
name: 'invitedBy',
|
|
180
|
-
value: USER2
|
|
181
|
-
}]; // USER1 joined the discussion after USER2 sent an invitation to EMAIL
|
|
182
|
-
|
|
183
|
-
var expected = [{
|
|
184
|
-
type: 'user',
|
|
185
|
-
value: USER1
|
|
186
|
-
}, {
|
|
187
|
-
type: 'text',
|
|
188
|
-
value: 'joined the discussion after'
|
|
189
|
-
}, {
|
|
190
|
-
type: 'user',
|
|
191
|
-
value: USER2
|
|
192
|
-
}, {
|
|
193
|
-
type: 'text',
|
|
194
|
-
value: 'sent an invitation to test.user@kinops.io'
|
|
195
|
-
}];
|
|
196
|
-
expect(generateContent('Participant Joined', content)).toEqual(expected);
|
|
197
|
-
});
|
|
198
|
-
it('returns joined as owner message', function () {
|
|
199
|
-
var content = [{
|
|
200
|
-
name: 'user',
|
|
201
|
-
type: 'user',
|
|
202
|
-
value: USER1
|
|
203
|
-
}, {
|
|
204
|
-
name: 'joinedAsOwner',
|
|
205
|
-
type: 'json',
|
|
206
|
-
value: 'true'
|
|
207
|
-
}]; // USER1 joined the discussion after being authorized as an owner
|
|
208
|
-
|
|
209
|
-
var expected = [{
|
|
210
|
-
type: 'user',
|
|
211
|
-
value: USER1
|
|
212
|
-
}, {
|
|
213
|
-
type: 'text',
|
|
214
|
-
value: 'joined the discussion after being authorized as an owner'
|
|
215
|
-
}];
|
|
216
|
-
expect(generateContent('Participant Joined', content)).toEqual(expected);
|
|
217
|
-
});
|
|
218
|
-
it('returns joined as space admin message', function () {
|
|
219
|
-
var content = [{
|
|
220
|
-
name: 'user',
|
|
221
|
-
type: 'user',
|
|
222
|
-
value: USER1
|
|
223
|
-
}, {
|
|
224
|
-
name: 'joinedAsAdmin',
|
|
225
|
-
type: 'json',
|
|
226
|
-
value: 'true'
|
|
227
|
-
}]; // USER1 joined the discussion after being authorized as a space admin
|
|
228
|
-
|
|
229
|
-
var expected = [{
|
|
230
|
-
type: 'user',
|
|
231
|
-
value: USER1
|
|
232
|
-
}, {
|
|
233
|
-
type: 'text',
|
|
234
|
-
value: 'joined the discussion after being authorized as a space admin'
|
|
235
|
-
}];
|
|
236
|
-
expect(generateContent('Participant Joined', content)).toEqual(expected);
|
|
237
|
-
});
|
|
238
|
-
it('returns joined by join policy message', function () {
|
|
239
|
-
var content = [{
|
|
240
|
-
name: 'user',
|
|
241
|
-
type: 'user',
|
|
242
|
-
value: USER1
|
|
243
|
-
}]; // USER1 joined the discussion after being authorized by the join policy
|
|
244
|
-
|
|
245
|
-
var expected = [{
|
|
246
|
-
type: 'user',
|
|
247
|
-
value: USER1
|
|
248
|
-
}, {
|
|
249
|
-
type: 'text',
|
|
250
|
-
value: 'joined the discussion after being authorized by the join policy'
|
|
251
|
-
}];
|
|
252
|
-
expect(generateContent('Participant Joined', content)).toEqual(expected);
|
|
253
|
-
});
|
|
254
|
-
});
|
|
255
|
-
describe('Participant Left', function () {
|
|
256
|
-
it('returns participant left message', function () {
|
|
257
|
-
var content = [{
|
|
258
|
-
type: 'user',
|
|
259
|
-
name: 'user',
|
|
260
|
-
value: USER1
|
|
261
|
-
}];
|
|
262
|
-
var expected = [{
|
|
263
|
-
type: 'user',
|
|
264
|
-
value: USER1
|
|
265
|
-
}, {
|
|
266
|
-
type: 'text',
|
|
267
|
-
value: 'has left'
|
|
268
|
-
}];
|
|
269
|
-
expect(generateContent('Participant Left', content)).toEqual(expected);
|
|
270
|
-
});
|
|
271
|
-
});
|
|
272
|
-
describe('Participant Removed', function () {
|
|
273
|
-
it('returns participant removed message', function () {
|
|
274
|
-
var content = [{
|
|
275
|
-
type: 'user',
|
|
276
|
-
name: 'user',
|
|
277
|
-
value: USER1
|
|
278
|
-
}, {
|
|
279
|
-
type: 'user',
|
|
280
|
-
name: 'removedBy',
|
|
281
|
-
value: USER2
|
|
282
|
-
}];
|
|
283
|
-
var expected = [{
|
|
284
|
-
type: 'user',
|
|
285
|
-
value: USER1
|
|
286
|
-
}, {
|
|
287
|
-
type: 'text',
|
|
288
|
-
value: 'has been removed by'
|
|
289
|
-
}, {
|
|
290
|
-
type: 'user',
|
|
291
|
-
value: USER2
|
|
292
|
-
}];
|
|
293
|
-
expect(generateContent('Participant Removed', content)).toEqual(expected);
|
|
294
|
-
});
|
|
295
|
-
});
|
|
296
|
-
describe('Discussion Updated', function () {
|
|
297
|
-
it('returns the discussion updated message', function () {
|
|
298
|
-
var previousValues = {
|
|
299
|
-
title: 'Previous Title'
|
|
300
|
-
};
|
|
301
|
-
var values = {
|
|
302
|
-
title: 'New Title'
|
|
303
|
-
};
|
|
304
|
-
var content = [{
|
|
305
|
-
type: 'user',
|
|
306
|
-
name: 'updatedBy',
|
|
307
|
-
value: USER1
|
|
308
|
-
}, {
|
|
309
|
-
type: 'json',
|
|
310
|
-
name: 'previousValues',
|
|
311
|
-
value: JSON.stringify(previousValues)
|
|
312
|
-
}, {
|
|
313
|
-
type: 'json',
|
|
314
|
-
name: 'values',
|
|
315
|
-
value: JSON.stringify(values)
|
|
316
|
-
}];
|
|
317
|
-
var expected = [{
|
|
318
|
-
type: 'user',
|
|
319
|
-
value: USER1
|
|
320
|
-
}, {
|
|
321
|
-
type: 'text',
|
|
322
|
-
value: 'updated the discussion'
|
|
323
|
-
}, {
|
|
324
|
-
type: 'text',
|
|
325
|
-
value: 'title from [Previous Title] to [New Title]'
|
|
326
|
-
}];
|
|
327
|
-
expect(generateContent('Discussion Updated', content)).toEqual(expected);
|
|
328
|
-
});
|
|
329
|
-
it('returns the discussion updated message with multiple changes', function () {
|
|
330
|
-
var previousValues = {
|
|
331
|
-
title: 'Previous Title',
|
|
332
|
-
description: '..'
|
|
333
|
-
};
|
|
334
|
-
var values = {
|
|
335
|
-
title: 'New Title',
|
|
336
|
-
description: 'Hello World'
|
|
337
|
-
};
|
|
338
|
-
var content = [{
|
|
339
|
-
type: 'user',
|
|
340
|
-
name: 'updatedBy',
|
|
341
|
-
value: USER1
|
|
342
|
-
}, {
|
|
343
|
-
type: 'json',
|
|
344
|
-
name: 'previousValues',
|
|
345
|
-
value: JSON.stringify(previousValues)
|
|
346
|
-
}, {
|
|
347
|
-
type: 'json',
|
|
348
|
-
name: 'values',
|
|
349
|
-
value: JSON.stringify(values)
|
|
350
|
-
}];
|
|
351
|
-
var expected = [{
|
|
352
|
-
type: 'user',
|
|
353
|
-
value: USER1
|
|
354
|
-
}, {
|
|
355
|
-
type: 'text',
|
|
356
|
-
value: 'updated the discussion'
|
|
357
|
-
}, {
|
|
358
|
-
type: 'text',
|
|
359
|
-
value: 'title from [Previous Title] to [New Title]'
|
|
360
|
-
}, {
|
|
361
|
-
type: 'text',
|
|
362
|
-
value: ', and description from [..] to [Hello World]'
|
|
363
|
-
}];
|
|
364
|
-
expect(generateContent('Discussion Updated', content)).toEqual(expected);
|
|
365
|
-
});
|
|
366
|
-
it('returns the discussion update message with changed owners', function () {
|
|
367
|
-
var previousValues = {
|
|
368
|
-
owningUsers: [{
|
|
369
|
-
username: 'alice@kinops.io'
|
|
370
|
-
}, {
|
|
371
|
-
username: 'bob@kinops.io'
|
|
372
|
-
}],
|
|
373
|
-
owningTeams: [{
|
|
374
|
-
name: 'IT'
|
|
375
|
-
}]
|
|
376
|
-
};
|
|
377
|
-
var values = {
|
|
378
|
-
owningUsers: [{
|
|
379
|
-
username: 'alice@kinops.io'
|
|
380
|
-
}],
|
|
381
|
-
owningTeams: [{
|
|
382
|
-
name: 'IT'
|
|
383
|
-
}, {
|
|
384
|
-
name: 'HR'
|
|
385
|
-
}]
|
|
386
|
-
};
|
|
387
|
-
var content = [{
|
|
388
|
-
type: 'user',
|
|
389
|
-
name: 'updatedBy',
|
|
390
|
-
value: USER1
|
|
391
|
-
}, {
|
|
392
|
-
type: 'json',
|
|
393
|
-
name: 'previousValues',
|
|
394
|
-
value: JSON.stringify(previousValues)
|
|
395
|
-
}, {
|
|
396
|
-
type: 'json',
|
|
397
|
-
name: 'values',
|
|
398
|
-
value: JSON.stringify(values)
|
|
399
|
-
}];
|
|
400
|
-
var expected = [{
|
|
401
|
-
type: 'user',
|
|
402
|
-
value: USER1
|
|
403
|
-
}, {
|
|
404
|
-
type: 'text',
|
|
405
|
-
value: 'updated the discussion'
|
|
406
|
-
}, {
|
|
407
|
-
type: 'text',
|
|
408
|
-
value: 'owning users from [alice@kinops.io, bob@kinops.io] to [alice@kinops.io]'
|
|
409
|
-
}, {
|
|
410
|
-
type: 'text',
|
|
411
|
-
value: ', and owning teams from [IT] to [IT, HR]'
|
|
412
|
-
}];
|
|
413
|
-
expect(generateContent('Discussion Updated', content)).toEqual(expected);
|
|
414
|
-
});
|
|
415
|
-
});
|
|
416
|
-
describe('Message Updated', function () {
|
|
417
|
-
it('returns the message updated message', function () {
|
|
418
|
-
var content = [{
|
|
419
|
-
type: 'user',
|
|
420
|
-
name: 'updatedBy',
|
|
421
|
-
value: USER1
|
|
422
|
-
}, {
|
|
423
|
-
type: 'message',
|
|
424
|
-
name: 'previousMessage',
|
|
425
|
-
value: MESSAGE1
|
|
426
|
-
}, {
|
|
427
|
-
type: 'message',
|
|
428
|
-
name: 'message',
|
|
429
|
-
value: MESSAGE2
|
|
430
|
-
}];
|
|
431
|
-
var expected = [{
|
|
432
|
-
type: 'user',
|
|
433
|
-
value: USER1
|
|
434
|
-
}, {
|
|
435
|
-
type: 'text',
|
|
436
|
-
value: 'changed a message from'
|
|
437
|
-
}, {
|
|
438
|
-
type: 'message',
|
|
439
|
-
value: MESSAGE1
|
|
440
|
-
}, {
|
|
441
|
-
type: 'text',
|
|
442
|
-
value: 'to'
|
|
443
|
-
}, {
|
|
444
|
-
type: 'message',
|
|
445
|
-
value: MESSAGE2
|
|
446
|
-
}];
|
|
447
|
-
expect(generateContent('Message Updated', content)).toEqual(expected);
|
|
448
|
-
});
|
|
449
|
-
});
|
|
450
|
-
});
|
|
@@ -1,76 +0,0 @@
|
|
|
1
|
-
import _objectSpread from "@babel/runtime/helpers/esm/objectSpread2";
|
|
2
|
-
import { List, Record, getIn } from 'immutable';
|
|
3
|
-
import moment from 'moment';
|
|
4
|
-
export var createDiscussion = function createDiscussion(discussion) {
|
|
5
|
-
return Discussion(_objectSpread(_objectSpread({}, discussion), {}, {
|
|
6
|
-
loading: false,
|
|
7
|
-
messages: List(discussion.messagesPage.messages),
|
|
8
|
-
nextPageToken: discussion.messagesPage.nextPageToken,
|
|
9
|
-
owningTeams: List(discussion.owningTeams),
|
|
10
|
-
owningUsers: List(discussion.owningUsers),
|
|
11
|
-
participants: List(discussion.participants),
|
|
12
|
-
invitations: List(discussion.invitations),
|
|
13
|
-
relatedItems: List(discussion.relatedItems),
|
|
14
|
-
lastSeenAt: getIn(discussion, ['participants[7].lastSeenAt'])
|
|
15
|
-
}));
|
|
16
|
-
};
|
|
17
|
-
export var createDiscussionList = function createDiscussionList(discussions) {
|
|
18
|
-
return List(discussions.map(createDiscussion));
|
|
19
|
-
};
|
|
20
|
-
export var Topic = Record({
|
|
21
|
-
topicId: null,
|
|
22
|
-
topicStatus: 'closed'
|
|
23
|
-
});
|
|
24
|
-
export var Discussion = Record({
|
|
25
|
-
// NEW STUFF
|
|
26
|
-
topic: Topic(),
|
|
27
|
-
presences: List(),
|
|
28
|
-
isArchived: false,
|
|
29
|
-
createdAt: new Date(),
|
|
30
|
-
createdBy: {},
|
|
31
|
-
description: '',
|
|
32
|
-
error: null,
|
|
33
|
-
id: '',
|
|
34
|
-
invitations: List(),
|
|
35
|
-
isPrivate: false,
|
|
36
|
-
joinPolicy: null,
|
|
37
|
-
messages: List(),
|
|
38
|
-
nextPageToken: null,
|
|
39
|
-
milestone: 0,
|
|
40
|
-
owningTeams: List(),
|
|
41
|
-
owningUsers: List(),
|
|
42
|
-
participants: List(),
|
|
43
|
-
relatedItems: List(),
|
|
44
|
-
title: '',
|
|
45
|
-
updatedAt: new Date(),
|
|
46
|
-
updateBy: {},
|
|
47
|
-
versionId: '',
|
|
48
|
-
loading: true,
|
|
49
|
-
loadingMoreMessages: false
|
|
50
|
-
});
|
|
51
|
-
export var getLastMessageAt = function getLastMessageAt(discussion) {
|
|
52
|
-
return discussion.messages && discussion.messages.first() ? discussion.messages.first().createdAt : discussion.createdAt;
|
|
53
|
-
};
|
|
54
|
-
export var sortByLastMessageAt = function sortByLastMessageAt(d1, d2) {
|
|
55
|
-
return moment.utc(getLastMessageAt(d2)).diff(moment.utc(getLastMessageAt(d1)));
|
|
56
|
-
};
|
|
57
|
-
export var getGroupedDiscussions = function getGroupedDiscussions(discussions) {
|
|
58
|
-
return discussions.groupBy(function (discussion) {
|
|
59
|
-
return moment(getLastMessageAt(discussion)).fromNow();
|
|
60
|
-
});
|
|
61
|
-
};
|
|
62
|
-
export var getLastSeenAt = function getLastSeenAt(discussion, username) {
|
|
63
|
-
return username && discussion.participants ? getIn(discussion.participants.find(function (participant) {
|
|
64
|
-
return getIn(participant, ['user', 'username']) === username;
|
|
65
|
-
}), ['lastSeenAt']) : null;
|
|
66
|
-
};
|
|
67
|
-
export var getDiscussionLastTimestamps = function getDiscussionLastTimestamps(discussion, username) {
|
|
68
|
-
return {
|
|
69
|
-
lastMessageAt: getLastMessageAt(discussion),
|
|
70
|
-
lastSeenAt: getLastSeenAt(discussion, username)
|
|
71
|
-
};
|
|
72
|
-
};
|
|
73
|
-
export var isLastMessageUnread = function isLastMessageUnread(discussion, username) {
|
|
74
|
-
var timestamps = getDiscussionLastTimestamps(discussion, username);
|
|
75
|
-
return !!timestamps.lastSeenAt && !!timestamps.lastMessageAt && timestamps.lastSeenAt < timestamps.lastMessageAt;
|
|
76
|
-
};
|
package/lib/models/index.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export { createDiscussionList, getDiscussionLastTimestamps, getGroupedDiscussions, isLastMessageUnread, sortByLastMessageAt } from './discussions';
|