@truedat/bg 7.0.5 → 7.0.7
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 +6 -6
- package/src/concepts/components/DomainConcepts.js +1 -4
- package/src/concepts/components/__tests__/__snapshots__/ConceptForm.spec.js.snap +5 -5
- package/src/concepts/components/__tests__/__snapshots__/ConceptsBulkUpdate.spec.js.snap +5 -5
- package/src/concepts/components/__tests__/__snapshots__/SharedToForm.spec.js.snap +5 -5
- package/src/hooks/useDomains.js +77 -0
- package/src/messages/en.js +6 -0
- package/src/messages/es.js +5 -0
- package/src/reducers/index.js +0 -1
- package/src/taxonomy/components/AddDomainMember.js +1 -7
- package/src/taxonomy/components/Domain.js +80 -84
- package/src/taxonomy/components/DomainActions.js +57 -84
- package/src/taxonomy/components/DomainCrumbs.js +51 -43
- package/src/taxonomy/components/DomainDetail.js +88 -46
- package/src/taxonomy/components/DomainForm.js +34 -36
- package/src/taxonomy/components/DomainImplementations.js +1 -4
- package/src/taxonomy/components/DomainMembers.js +8 -1
- package/src/taxonomy/components/DomainRoutes.js +8 -55
- package/src/taxonomy/components/DomainStructures.js +1 -4
- package/src/taxonomy/components/DomainTabs.js +22 -29
- package/src/taxonomy/components/Domains.js +66 -27
- package/src/taxonomy/components/DomainsActions.js +5 -14
- package/src/taxonomy/components/EditDomain.js +35 -21
- package/src/taxonomy/components/NewDomain.js +47 -22
- package/src/taxonomy/components/__tests__/Domain.spec.js +17 -8
- package/src/taxonomy/components/__tests__/DomainActions.spec.js +62 -7
- package/src/taxonomy/components/__tests__/DomainCrumbs.spec.js +18 -5
- package/src/taxonomy/components/__tests__/DomainDetail.spec.js +87 -4
- package/src/taxonomy/components/__tests__/DomainForm.spec.js +189 -4
- package/src/taxonomy/components/__tests__/DomainMembers.spec.js +1 -3
- package/src/taxonomy/components/__tests__/DomainStructures.spec.js +3 -2
- package/src/taxonomy/components/__tests__/Domains.spec.js +103 -6
- package/src/taxonomy/components/__tests__/EditDomain.spec.js +56 -5
- package/src/taxonomy/components/__tests__/NewDomain.spec.js +65 -6
- package/src/taxonomy/components/__tests__/__snapshots__/AddDomainMember.spec.js.snap +0 -10
- package/src/taxonomy/components/__tests__/__snapshots__/Domain.spec.js.snap +35 -48
- package/src/taxonomy/components/__tests__/__snapshots__/DomainActions.spec.js.snap +56 -1
- package/src/taxonomy/components/__tests__/__snapshots__/DomainCrumbs.spec.js.snap +14 -2
- package/src/taxonomy/components/__tests__/__snapshots__/DomainDetail.spec.js.snap +93 -40
- package/src/taxonomy/components/__tests__/__snapshots__/DomainForm.spec.js.snap +7 -7
- package/src/taxonomy/components/__tests__/__snapshots__/Domains.spec.js.snap +75 -10
- package/src/taxonomy/components/__tests__/__snapshots__/DomainsActions.spec.js.snap +20 -1
- package/src/taxonomy/components/__tests__/__snapshots__/EditDomain.spec.js.snap +192 -30
- package/src/taxonomy/components/__tests__/__snapshots__/NewDomain.spec.js.snap +405 -28
- package/src/taxonomy/components/index.js +1 -2
- package/src/taxonomy/index.js +0 -1
- package/src/taxonomy/routines.js +0 -10
- package/src/taxonomy/sagas/index.js +2 -21
- package/src/taxonomy/selectors/getDomainsConcept.js +0 -13
- package/src/taxonomy/selectors/index.js +0 -16
- package/src/taxonomy/components/DomainCards.js +0 -97
- package/src/taxonomy/components/DomainLoader.js +0 -60
- package/src/taxonomy/components/DomainMembersLoader.js +0 -44
- package/src/taxonomy/components/DomainsLoader.js +0 -40
- package/src/taxonomy/components/__tests__/DomainCards.spec.js +0 -30
- package/src/taxonomy/components/__tests__/DomainsLoader.spec.js +0 -38
- package/src/taxonomy/components/__tests__/__snapshots__/DomainCards.spec.js.snap +0 -160
- package/src/taxonomy/reducers/__tests__/domain.spec.js +0 -58
- package/src/taxonomy/reducers/__tests__/domainConceptLoading.spec.js +0 -26
- package/src/taxonomy/reducers/__tests__/domainCreating.spec.js +0 -24
- package/src/taxonomy/reducers/__tests__/domainLoading.spec.js +0 -22
- package/src/taxonomy/reducers/__tests__/domainMembersActions.spec.js +0 -38
- package/src/taxonomy/reducers/__tests__/domainMembersLoading.spec.js +0 -26
- package/src/taxonomy/reducers/__tests__/domainRedirect.spec.js +0 -36
- package/src/taxonomy/reducers/__tests__/domainUpdating.spec.js +0 -24
- package/src/taxonomy/reducers/__tests__/domains.spec.js +0 -30
- package/src/taxonomy/reducers/__tests__/domainsActions.spec.js +0 -36
- package/src/taxonomy/reducers/__tests__/domainsConcept.spec.js +0 -30
- package/src/taxonomy/reducers/__tests__/domainsFilter.spec.js +0 -41
- package/src/taxonomy/reducers/__tests__/domainsLoading.spec.js +0 -22
- package/src/taxonomy/reducers/domain.js +0 -32
- package/src/taxonomy/reducers/domainActions.js +0 -19
- package/src/taxonomy/reducers/domainCreating.js +0 -14
- package/src/taxonomy/reducers/domainLoading.js +0 -14
- package/src/taxonomy/reducers/domainMembersActions.js +0 -22
- package/src/taxonomy/reducers/domainMembersLoading.js +0 -12
- package/src/taxonomy/reducers/domainRedirect.js +0 -25
- package/src/taxonomy/reducers/domainUpdating.js +0 -14
- package/src/taxonomy/reducers/domains.js +0 -19
- package/src/taxonomy/reducers/domainsActions.js +0 -20
- package/src/taxonomy/reducers/domainsConcept.js +0 -19
- package/src/taxonomy/reducers/domainsConceptLoading.js +0 -12
- package/src/taxonomy/reducers/domainsFilter.js +0 -24
- package/src/taxonomy/reducers/domainsLoading.js +0 -12
- package/src/taxonomy/reducers/index.js +0 -31
- package/src/taxonomy/sagas/__tests__/fetchDomain.spec.js +0 -69
- package/src/taxonomy/sagas/__tests__/fetchDomains.spec.js +0 -90
- package/src/taxonomy/sagas/createDomain.js +0 -27
- package/src/taxonomy/sagas/deleteDomain.js +0 -34
- package/src/taxonomy/sagas/fetchDomain.js +0 -30
- package/src/taxonomy/sagas/fetchDomains.js +0 -37
- package/src/taxonomy/sagas/updateDomain.js +0 -30
- package/src/taxonomy/selectors/__tests__/domainParentOptionsSelector.spec.js +0 -24
- package/src/taxonomy/selectors/__tests__/getDomainActions.spec.js +0 -46
- package/src/taxonomy/selectors/__tests__/getDomainGroups.spec.js +0 -17
- package/src/taxonomy/selectors/__tests__/getDomainTypes.spec.js +0 -14
- package/src/taxonomy/selectors/domainParentOptionsSelector.js +0 -12
- package/src/taxonomy/selectors/getDomainActions.js +0 -32
- package/src/taxonomy/selectors/getDomainGroups.js +0 -11
|
@@ -2,39 +2,14 @@ import _ from "lodash/fp";
|
|
|
2
2
|
import React from "react";
|
|
3
3
|
import PropTypes from "prop-types";
|
|
4
4
|
import { Link } from "react-router-dom";
|
|
5
|
-
import {
|
|
6
|
-
import { bindActionCreators } from "redux";
|
|
7
|
-
import { connect } from "react-redux";
|
|
5
|
+
import { Button } from "semantic-ui-react";
|
|
8
6
|
import { FormattedMessage, useIntl } from "react-intl";
|
|
9
7
|
import { ConfirmModal, GroupActions } from "@truedat/core/components";
|
|
10
|
-
import { deleteDomain, filterDomains } from "../routines";
|
|
11
|
-
import { getPrimaryActions, getSecondaryActions } from "../selectors";
|
|
12
|
-
|
|
13
|
-
const DomainAction = ({ action, icon, messageId, id, ...rest }) => {
|
|
14
|
-
const { formatMessage } = useIntl();
|
|
15
|
-
return (
|
|
16
|
-
<Dropdown.Item
|
|
17
|
-
text={formatMessage({ id: messageId })}
|
|
18
|
-
icon={icon}
|
|
19
|
-
as={Link}
|
|
20
|
-
to={action(id)}
|
|
21
|
-
{...rest}
|
|
22
|
-
/>
|
|
23
|
-
);
|
|
24
|
-
};
|
|
25
|
-
|
|
26
|
-
DomainAction.propTypes = {
|
|
27
|
-
action: PropTypes.func,
|
|
28
|
-
icon: PropTypes.string,
|
|
29
|
-
messageId: PropTypes.string,
|
|
30
|
-
id: PropTypes.number,
|
|
31
|
-
};
|
|
32
8
|
|
|
33
9
|
const DomainActionButton = ({ action, icon, messageId, id, ...rest }) => {
|
|
34
10
|
const { formatMessage } = useIntl();
|
|
35
11
|
return (
|
|
36
12
|
<Button
|
|
37
|
-
floated="right"
|
|
38
13
|
primary
|
|
39
14
|
content={formatMessage({ id: messageId })}
|
|
40
15
|
icon={icon}
|
|
@@ -56,12 +31,11 @@ const ModalDelete = ({ onConfirm }) => {
|
|
|
56
31
|
const { formatMessage } = useIntl();
|
|
57
32
|
return (
|
|
58
33
|
<ConfirmModal
|
|
59
|
-
header={formatMessage({ id: "domain" })}
|
|
60
|
-
content={formatMessage({ id: "actions.
|
|
34
|
+
header={formatMessage({ id: "domain.actions.delete" })}
|
|
35
|
+
content={formatMessage({ id: "domain.actions.delete.question" })}
|
|
61
36
|
onConfirm={onConfirm}
|
|
62
37
|
trigger={
|
|
63
38
|
<Button
|
|
64
|
-
floated="right"
|
|
65
39
|
negative
|
|
66
40
|
content={formatMessage({ id: "actions.delete" })}
|
|
67
41
|
icon="trash"
|
|
@@ -103,7 +77,10 @@ const ActionButtons = ({
|
|
|
103
77
|
}) => {
|
|
104
78
|
const availableActions = _.flow(
|
|
105
79
|
composeAvailableActions,
|
|
106
|
-
_.map(({ action, ...rest }) => ({
|
|
80
|
+
_.map(({ action, ...rest }) => ({
|
|
81
|
+
...rest,
|
|
82
|
+
to: action(id),
|
|
83
|
+
})),
|
|
107
84
|
(actions) => (deleteAction ? withDelete(actions, onConfirm) : actions)
|
|
108
85
|
)(secondaryActions);
|
|
109
86
|
|
|
@@ -121,61 +98,57 @@ const ActionButtons = ({
|
|
|
121
98
|
|
|
122
99
|
ActionButtons.propTypes = {
|
|
123
100
|
id: PropTypes.number,
|
|
101
|
+
primaryActions: PropTypes.array,
|
|
102
|
+
secondaryActions: PropTypes.array,
|
|
103
|
+
deleteAction: PropTypes.bool,
|
|
124
104
|
onConfirm: PropTypes.func,
|
|
125
105
|
};
|
|
126
106
|
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
domain: PropTypes.object,
|
|
130
|
-
deleteDomain: PropTypes.func,
|
|
131
|
-
domainActions: PropTypes.object,
|
|
132
|
-
};
|
|
133
|
-
|
|
134
|
-
handleConfirm = () => {
|
|
135
|
-
this.setState({ open: false });
|
|
136
|
-
this.props.deleteDomain(this.props.domain);
|
|
137
|
-
};
|
|
138
|
-
|
|
139
|
-
render = () => {
|
|
140
|
-
const {
|
|
141
|
-
domain,
|
|
142
|
-
domainActions,
|
|
143
|
-
primaryActions,
|
|
144
|
-
secondaryActions,
|
|
145
|
-
deleteAction,
|
|
146
|
-
} = this.props;
|
|
147
|
-
const { id } = domain;
|
|
148
|
-
return _.isEmpty(domainActions) ? null : (
|
|
149
|
-
<ActionButtons
|
|
150
|
-
domainActions={domainActions}
|
|
151
|
-
primaryActions={primaryActions}
|
|
152
|
-
secondaryActions={secondaryActions}
|
|
153
|
-
deleteAction={deleteAction}
|
|
154
|
-
show={this.show}
|
|
155
|
-
id={id}
|
|
156
|
-
onConfirm={this.handleConfirm}
|
|
157
|
-
/>
|
|
158
|
-
);
|
|
159
|
-
};
|
|
160
|
-
}
|
|
161
|
-
|
|
162
|
-
const hiddenActions = ["show", "index"];
|
|
163
|
-
|
|
164
|
-
const mapDispatchToProps = (dispatch) => ({
|
|
165
|
-
...bindActionCreators({ deleteDomain }, dispatch),
|
|
166
|
-
handleFilterDomains: (event) => {
|
|
167
|
-
const query = event.target.value;
|
|
168
|
-
return dispatch(filterDomains({ query }));
|
|
169
|
-
},
|
|
170
|
-
});
|
|
171
|
-
|
|
172
|
-
const mapStateToProps = ({ domain, domainActions }, { availableActions }) => ({
|
|
107
|
+
const DomainActions = ({
|
|
108
|
+
availableActions,
|
|
173
109
|
domain,
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
110
|
+
domainAllActions,
|
|
111
|
+
onDeleteDomain,
|
|
112
|
+
}) => {
|
|
113
|
+
const hiddenActions = ["show", "index"];
|
|
114
|
+
const secondaryActionsKeys = ["delete", "update"];
|
|
115
|
+
|
|
116
|
+
const notHiddenActions = _.flow(
|
|
117
|
+
_.omit(hiddenActions),
|
|
118
|
+
_.toPairs,
|
|
119
|
+
_.map(([key, actionProps]) => ({ key, ...actionProps })),
|
|
120
|
+
_.filter(({ key }) => _.has(key)(availableActions)),
|
|
121
|
+
_.map((a) => ({ ...a, ..._.prop(_.prop("key")(a))(availableActions) }))
|
|
122
|
+
)(domainAllActions);
|
|
123
|
+
|
|
124
|
+
const primaryActions = _.filter(
|
|
125
|
+
({ key }) => !_.includes(key)(secondaryActionsKeys)
|
|
126
|
+
)(notHiddenActions);
|
|
127
|
+
|
|
128
|
+
const secondaryActions = _.filter(({ key }) =>
|
|
129
|
+
_.includes(key)(secondaryActionsKeys)
|
|
130
|
+
)(notHiddenActions);
|
|
131
|
+
|
|
132
|
+
const deleteAction =
|
|
133
|
+
_.has("delete")(domainAllActions) &&
|
|
134
|
+
_.has("deleteOption")(availableActions);
|
|
135
|
+
|
|
136
|
+
return _.isEmpty(domainAllActions) ? null : (
|
|
137
|
+
<ActionButtons
|
|
138
|
+
primaryActions={primaryActions}
|
|
139
|
+
secondaryActions={secondaryActions}
|
|
140
|
+
deleteAction={deleteAction}
|
|
141
|
+
id={domain.id}
|
|
142
|
+
onConfirm={onDeleteDomain}
|
|
143
|
+
/>
|
|
144
|
+
);
|
|
145
|
+
};
|
|
146
|
+
|
|
147
|
+
DomainActions.propTypes = {
|
|
148
|
+
availableActions: PropTypes.object,
|
|
149
|
+
domain: PropTypes.object,
|
|
150
|
+
domainAllActions: PropTypes.object,
|
|
151
|
+
onDeleteDomain: PropTypes.func,
|
|
152
|
+
};
|
|
153
|
+
|
|
154
|
+
export default DomainActions;
|
|
@@ -1,57 +1,65 @@
|
|
|
1
1
|
import React, { Fragment } from "react";
|
|
2
2
|
import { Link } from "react-router-dom";
|
|
3
3
|
import PropTypes from "prop-types";
|
|
4
|
-
import { connect } from "react-redux";
|
|
5
4
|
import { Breadcrumb } from "semantic-ui-react";
|
|
6
5
|
import { FormattedMessage } from "react-intl";
|
|
7
6
|
import { DOMAINS, linkTo } from "@truedat/core/routes";
|
|
8
|
-
import {
|
|
7
|
+
import { ascendants } from "@truedat/core/services/tree";
|
|
9
8
|
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
9
|
+
import { useDomains } from "../../hooks/useDomains";
|
|
10
|
+
|
|
11
|
+
export const DomainCrumbs = ({ domain, actionCrumb }) => {
|
|
12
|
+
const { data: domains } = useDomains();
|
|
13
|
+
|
|
14
|
+
const ancestorsAndDomainIds = domain
|
|
15
|
+
? ascendants(domain?.id, domains)
|
|
16
|
+
: undefined;
|
|
17
|
+
return (
|
|
18
|
+
<Breadcrumb>
|
|
19
|
+
<Breadcrumb.Section as={Link} to={DOMAINS} active={!domain}>
|
|
20
|
+
<FormattedMessage id="navigation.glossary.taxonomy" />
|
|
21
|
+
</Breadcrumb.Section>
|
|
22
|
+
{ancestorsAndDomainIds
|
|
23
|
+
? ancestorsAndDomainIds.slice(0, -1).map((p, i) => (
|
|
24
|
+
<Fragment key={i}>
|
|
25
|
+
<Breadcrumb.Divider icon="right angle" />
|
|
26
|
+
<Breadcrumb.Section
|
|
27
|
+
key={i}
|
|
28
|
+
as={Link}
|
|
29
|
+
to={linkTo.DOMAIN({ id: parseInt(p) })}
|
|
30
|
+
>
|
|
31
|
+
{domains.find((d) => d.id === parseInt(p)).name}
|
|
32
|
+
</Breadcrumb.Section>
|
|
33
|
+
</Fragment>
|
|
34
|
+
))
|
|
35
|
+
: null}
|
|
36
|
+
{domain ? (
|
|
37
|
+
<>
|
|
38
|
+
<Breadcrumb.Divider icon="right angle" />
|
|
39
|
+
{actionCrumb ? (
|
|
40
|
+
<Breadcrumb.Section as={Link} to={linkTo.DOMAIN({ id: domain.id })}>
|
|
41
|
+
{domain.name}
|
|
42
|
+
</Breadcrumb.Section>
|
|
43
|
+
) : (
|
|
44
|
+
<Breadcrumb.Section active>{domain.name}</Breadcrumb.Section>
|
|
45
|
+
)}
|
|
46
|
+
</>
|
|
47
|
+
) : null}
|
|
48
|
+
{actionCrumb ? (
|
|
49
|
+
<>
|
|
50
|
+
<Breadcrumb.Divider icon="right angle" />
|
|
51
|
+
<Breadcrumb.Section active>
|
|
52
|
+
<FormattedMessage id={actionCrumb} />
|
|
29
53
|
</Breadcrumb.Section>
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
{actionCrumb && (
|
|
36
|
-
<>
|
|
37
|
-
<Breadcrumb.Divider icon="right angle" />
|
|
38
|
-
<Breadcrumb.Section active>
|
|
39
|
-
<FormattedMessage id={actionCrumb} />
|
|
40
|
-
</Breadcrumb.Section>
|
|
41
|
-
</>
|
|
42
|
-
)}
|
|
43
|
-
</Breadcrumb>
|
|
44
|
-
);
|
|
54
|
+
</>
|
|
55
|
+
) : null}
|
|
56
|
+
</Breadcrumb>
|
|
57
|
+
);
|
|
58
|
+
};
|
|
45
59
|
|
|
46
60
|
DomainCrumbs.propTypes = {
|
|
47
61
|
actionCrumb: PropTypes.string,
|
|
48
62
|
domain: PropTypes.object,
|
|
49
|
-
parents: PropTypes.array,
|
|
50
63
|
};
|
|
51
64
|
|
|
52
|
-
|
|
53
|
-
domain: state.domain,
|
|
54
|
-
parents: getAncestorDomains(state),
|
|
55
|
-
});
|
|
56
|
-
|
|
57
|
-
export default connect(mapStateToProps)(DomainCrumbs);
|
|
65
|
+
export default DomainCrumbs;
|
|
@@ -1,63 +1,105 @@
|
|
|
1
1
|
import _ from "lodash/fp";
|
|
2
2
|
import React from "react";
|
|
3
3
|
import PropTypes from "prop-types";
|
|
4
|
-
import { Icon,
|
|
5
|
-
import {
|
|
6
|
-
import { FormattedMessage } from "react-intl";
|
|
4
|
+
import { Icon, Header, Grid, GridRow } from "semantic-ui-react";
|
|
5
|
+
import { useHistory } from "react-router-dom";
|
|
6
|
+
import { FormattedMessage, useIntl } from "react-intl";
|
|
7
7
|
import { linkTo } from "@truedat/core/routes";
|
|
8
|
+
import { DOMAINS_QUERY } from "@truedat/core/api/queries";
|
|
9
|
+
import { useQuery } from "@apollo/client";
|
|
10
|
+
import { useDomain, useDomainDelete } from "../../hooks/useDomains";
|
|
8
11
|
|
|
9
12
|
import DomainActions from "./DomainActions";
|
|
10
13
|
|
|
11
|
-
export const DomainDetail = ({
|
|
12
|
-
const
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
14
|
+
export const DomainDetail = ({ id }) => {
|
|
15
|
+
const { data: domain, actions: domainAllActions, loading } = useDomain(id);
|
|
16
|
+
const { trigger: deleteDomain } = useDomainDelete(id);
|
|
17
|
+
const { client } = useQuery(DOMAINS_QUERY, {
|
|
18
|
+
variables: { action: "viewDomain", fetchPolicy: "no-cache" },
|
|
19
|
+
});
|
|
20
|
+
|
|
21
|
+
const history = useHistory();
|
|
22
|
+
const { formatMessage } = useIntl();
|
|
23
|
+
|
|
24
|
+
const available_actions = domain
|
|
25
|
+
? {
|
|
26
|
+
create: {
|
|
27
|
+
id: id,
|
|
28
|
+
order: 1,
|
|
29
|
+
icon: "cube",
|
|
30
|
+
messageId: "domain.actions.create",
|
|
31
|
+
action: () => linkTo.DOMAIN_NEW({ id }),
|
|
32
|
+
},
|
|
33
|
+
update: {
|
|
34
|
+
id: id,
|
|
35
|
+
order: 2,
|
|
36
|
+
icon: "edit",
|
|
37
|
+
messageId: "actions.edit",
|
|
38
|
+
action: () => linkTo.DOMAIN_EDIT({ id }),
|
|
39
|
+
},
|
|
40
|
+
deleteOption: true,
|
|
41
|
+
}
|
|
42
|
+
: null;
|
|
43
|
+
|
|
44
|
+
const handleDeleteDomain = async () => {
|
|
45
|
+
const { id, parent_id } = domain;
|
|
46
|
+
await deleteDomain(id);
|
|
47
|
+
if (parent_id) {
|
|
48
|
+
history.push(linkTo.DOMAIN_CONCEPTS({ id: parent_id }));
|
|
49
|
+
} else {
|
|
50
|
+
history.push(linkTo.DOMAINS());
|
|
51
|
+
}
|
|
52
|
+
client.resetStore();
|
|
20
53
|
};
|
|
21
|
-
|
|
54
|
+
|
|
55
|
+
return !loading ? (
|
|
22
56
|
<>
|
|
23
57
|
<Grid>
|
|
24
|
-
<
|
|
25
|
-
<
|
|
26
|
-
<
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
<
|
|
37
|
-
|
|
58
|
+
<GridRow>
|
|
59
|
+
<Grid.Column width={8}>
|
|
60
|
+
<Header as="h2">
|
|
61
|
+
<Icon name="cube" />
|
|
62
|
+
<Header.Content>
|
|
63
|
+
{domain.name}
|
|
64
|
+
<Header.Subheader>
|
|
65
|
+
{domain.type || <FormattedMessage id="domain" />}
|
|
66
|
+
</Header.Subheader>
|
|
67
|
+
</Header.Content>
|
|
68
|
+
</Header>
|
|
69
|
+
</Grid.Column>
|
|
70
|
+
<Grid.Column width={8} textAlign="right">
|
|
71
|
+
<DomainActions
|
|
72
|
+
availableActions={available_actions}
|
|
73
|
+
domain={domain}
|
|
74
|
+
domainAllActions={domainAllActions}
|
|
75
|
+
onDeleteDomain={handleDeleteDomain}
|
|
76
|
+
/>
|
|
77
|
+
</Grid.Column>
|
|
78
|
+
</GridRow>
|
|
79
|
+
{domain.description ? (
|
|
80
|
+
<GridRow>
|
|
81
|
+
<Grid.Column>{domain.description}</Grid.Column>
|
|
82
|
+
</GridRow>
|
|
83
|
+
) : null}
|
|
84
|
+
{domain.domain_group ? (
|
|
85
|
+
<GridRow>
|
|
86
|
+
<Grid.Column>
|
|
87
|
+
<Header sub>
|
|
88
|
+
{formatMessage({
|
|
89
|
+
id: "domain.props.domain_group",
|
|
90
|
+
})}
|
|
91
|
+
</Header>
|
|
92
|
+
<span>{_.get("name")(domain.domain_group)}</span>
|
|
93
|
+
</Grid.Column>
|
|
94
|
+
</GridRow>
|
|
95
|
+
) : null}
|
|
38
96
|
</Grid>
|
|
39
|
-
<p>{description}</p>
|
|
40
|
-
{domain_group && (
|
|
41
|
-
<Item>
|
|
42
|
-
<Item.Content>
|
|
43
|
-
<Item.Header as="h5">
|
|
44
|
-
<FormattedMessage id="domain.props.domain_group" />
|
|
45
|
-
</Item.Header>
|
|
46
|
-
<Item.Description>{_.get("name")(domain_group)}</Item.Description>
|
|
47
|
-
</Item.Content>
|
|
48
|
-
</Item>
|
|
49
|
-
)}
|
|
50
97
|
</>
|
|
51
|
-
);
|
|
98
|
+
) : null;
|
|
52
99
|
};
|
|
53
100
|
|
|
54
101
|
DomainDetail.propTypes = {
|
|
55
|
-
|
|
56
|
-
name: PropTypes.string,
|
|
57
|
-
description: PropTypes.string,
|
|
58
|
-
domain_group: PropTypes.object,
|
|
102
|
+
id: PropTypes.number,
|
|
59
103
|
};
|
|
60
104
|
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
export default connect(mapStateToProps)(DomainDetail);
|
|
105
|
+
export default DomainDetail;
|
|
@@ -2,16 +2,11 @@ import _ from "lodash/fp";
|
|
|
2
2
|
import React from "react";
|
|
3
3
|
import PropTypes from "prop-types";
|
|
4
4
|
import { Button, Form } from "semantic-ui-react";
|
|
5
|
-
import { connect } from "react-redux";
|
|
6
5
|
import { useIntl } from "react-intl";
|
|
7
6
|
import { useForm, Controller } from "react-hook-form";
|
|
8
7
|
import { HistoryBackButton } from "@truedat/core/components";
|
|
9
8
|
import { accentInsensitiveOrder } from "@truedat/core/services/sort";
|
|
10
|
-
import {
|
|
11
|
-
getDomainGroups,
|
|
12
|
-
getDomainTypes,
|
|
13
|
-
domainParentOptionsSelector,
|
|
14
|
-
} from "../selectors";
|
|
9
|
+
import { useDomains } from "../../hooks/useDomains";
|
|
15
10
|
|
|
16
11
|
const toOption = (t, i) => ({ key: i, text: t, value: t });
|
|
17
12
|
|
|
@@ -24,6 +19,25 @@ const buildOptions = (collection, value) =>
|
|
|
24
19
|
_.map.convert({ cap: false })(toOption)
|
|
25
20
|
)(collection);
|
|
26
21
|
|
|
22
|
+
const getDomainGroups = _.flow(
|
|
23
|
+
_.map(_.path("domain_group.name")),
|
|
24
|
+
_.filter(_.isString),
|
|
25
|
+
_.sortBy(_.toLower)
|
|
26
|
+
);
|
|
27
|
+
|
|
28
|
+
const getDomainTypes = _.flow(
|
|
29
|
+
_.map("type"),
|
|
30
|
+
_.filter(_.isString),
|
|
31
|
+
_.uniq,
|
|
32
|
+
_.sortBy(_.toLower)
|
|
33
|
+
);
|
|
34
|
+
|
|
35
|
+
const getDomainParentOptions = (parentableIds = []) =>
|
|
36
|
+
_.flow(
|
|
37
|
+
_.filter((d) => _.includes(d.id)(parentableIds)),
|
|
38
|
+
_.map(({ id, name }) => ({ key: id, text: name, value: id }))
|
|
39
|
+
);
|
|
40
|
+
|
|
27
41
|
const DEFAULTS = {
|
|
28
42
|
description: "",
|
|
29
43
|
external_id: "",
|
|
@@ -33,16 +47,10 @@ const DEFAULTS = {
|
|
|
33
47
|
domain_group: null,
|
|
34
48
|
};
|
|
35
49
|
|
|
36
|
-
export const DomainForm = ({
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
domainGroups,
|
|
40
|
-
domainParentOptions,
|
|
41
|
-
domainTypes,
|
|
42
|
-
onSubmit,
|
|
43
|
-
}) => {
|
|
50
|
+
export const DomainForm = ({ domain = {}, onSubmit }) => {
|
|
51
|
+
const { data: domains } = useDomains();
|
|
52
|
+
|
|
44
53
|
const { formatMessage } = useIntl();
|
|
45
|
-
// const domainGroup = domain?.domain_group;
|
|
46
54
|
const { handleSubmit, control, formState, watch } = useForm({
|
|
47
55
|
mode: "all",
|
|
48
56
|
defaultValues: {
|
|
@@ -52,12 +60,19 @@ export const DomainForm = ({
|
|
|
52
60
|
},
|
|
53
61
|
});
|
|
54
62
|
const [group, type] = watch(["domain_group", "type"]);
|
|
63
|
+
const domainTypes = getDomainTypes(domains);
|
|
64
|
+
const domainGroups = getDomainGroups(domains);
|
|
55
65
|
const domainGroupOptions = buildOptions(domainGroups, group);
|
|
56
66
|
const domainTypeOptions = buildOptions(domainTypes, type);
|
|
57
67
|
const groupClearable =
|
|
58
68
|
domain?.domain_group?.status === "root" || !domain?.domain_group;
|
|
59
69
|
|
|
60
70
|
const { errors, isDirty, isValid } = formState;
|
|
71
|
+
|
|
72
|
+
const parentableIds = domain.parentable_ids || [];
|
|
73
|
+
const domainParentOptions =
|
|
74
|
+
domain?.id && domains ? getDomainParentOptions(parentableIds)(domains) : [];
|
|
75
|
+
|
|
61
76
|
return (
|
|
62
77
|
<Form onSubmit={handleSubmit(onSubmit)}>
|
|
63
78
|
<Controller
|
|
@@ -199,7 +214,7 @@ export const DomainForm = ({
|
|
|
199
214
|
placeholder={formatMessage({
|
|
200
215
|
id: "domain.props.description.placeholder",
|
|
201
216
|
})}
|
|
202
|
-
value={value}
|
|
217
|
+
value={value || ""}
|
|
203
218
|
/>
|
|
204
219
|
)}
|
|
205
220
|
/>
|
|
@@ -208,14 +223,10 @@ export const DomainForm = ({
|
|
|
208
223
|
floated="right"
|
|
209
224
|
type="submit"
|
|
210
225
|
primary
|
|
211
|
-
|
|
212
|
-
disabled={isSubmitting || !isDirty || !isValid}
|
|
226
|
+
disabled={!isDirty || !isValid}
|
|
213
227
|
content={formatMessage({ id: "actions.save" })}
|
|
214
228
|
/>
|
|
215
|
-
<HistoryBackButton
|
|
216
|
-
content={formatMessage({ id: "actions.cancel" })}
|
|
217
|
-
disabled={isSubmitting}
|
|
218
|
-
/>
|
|
229
|
+
<HistoryBackButton content={formatMessage({ id: "actions.cancel" })} />
|
|
219
230
|
</div>
|
|
220
231
|
</Form>
|
|
221
232
|
);
|
|
@@ -223,20 +234,7 @@ export const DomainForm = ({
|
|
|
223
234
|
|
|
224
235
|
DomainForm.propTypes = {
|
|
225
236
|
domain: PropTypes.object,
|
|
226
|
-
isSubmitting: PropTypes.bool,
|
|
227
|
-
domainGroups: PropTypes.array,
|
|
228
|
-
domainParentOptions: PropTypes.array,
|
|
229
|
-
domainTypes: PropTypes.array,
|
|
230
237
|
onSubmit: PropTypes.func.isRequired,
|
|
231
238
|
};
|
|
232
239
|
|
|
233
|
-
|
|
234
|
-
domainTypes: getDomainTypes(state),
|
|
235
|
-
domainGroups: getDomainGroups(state),
|
|
236
|
-
domainParentOptions: ownProps.domain?.id
|
|
237
|
-
? domainParentOptionsSelector(state)
|
|
238
|
-
: [],
|
|
239
|
-
isSubmitting: state.domainCreating || state.domainUpdating,
|
|
240
|
-
});
|
|
241
|
-
|
|
242
|
-
export default connect(mapStateToProps)(DomainForm);
|
|
240
|
+
export default DomainForm;
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import React from "react";
|
|
2
2
|
import PropTypes from "prop-types";
|
|
3
|
-
import { connect } from "react-redux";
|
|
4
3
|
|
|
5
4
|
const ImplementationFiltersLoader = React.lazy(() =>
|
|
6
5
|
import("@truedat/dq/components/ImplementationFiltersLoader")
|
|
@@ -32,6 +31,4 @@ DomainImplementations.propTypes = {
|
|
|
32
31
|
domain: PropTypes.object.isRequired,
|
|
33
32
|
};
|
|
34
33
|
|
|
35
|
-
export
|
|
36
|
-
|
|
37
|
-
export default connect(mapStateToProps)(DomainImplementations);
|
|
34
|
+
export default DomainImplementations;
|
|
@@ -1,6 +1,13 @@
|
|
|
1
1
|
import React from "react";
|
|
2
2
|
import ResourceMembers from "@truedat/core/components/ResourceMembers";
|
|
3
|
+
import PropTypes from "prop-types";
|
|
3
4
|
|
|
4
|
-
export const DomainMembers = () =>
|
|
5
|
+
export const DomainMembers = ({ domainId }) => (
|
|
6
|
+
<ResourceMembers type="domain" id={domainId} />
|
|
7
|
+
);
|
|
8
|
+
|
|
9
|
+
DomainMembers.propTypes = {
|
|
10
|
+
domainId: PropTypes.number,
|
|
11
|
+
};
|
|
5
12
|
|
|
6
13
|
export default DomainMembers;
|
|
@@ -2,66 +2,19 @@ import React from "react";
|
|
|
2
2
|
import { Route, Switch } from "react-router-dom";
|
|
3
3
|
import { Unauthorized } from "@truedat/core/components";
|
|
4
4
|
import { useAuthorized } from "@truedat/core/hooks";
|
|
5
|
-
import {
|
|
6
|
-
DOMAIN,
|
|
7
|
-
DOMAIN_CONCEPTS,
|
|
8
|
-
DOMAINS,
|
|
9
|
-
DOMAINS_NEW,
|
|
10
|
-
DOMAINS_SEARCH,
|
|
11
|
-
DOMAIN_EDIT,
|
|
12
|
-
DOMAIN_IMPLEMENTATIONS,
|
|
13
|
-
DOMAIN_MEMBERS,
|
|
14
|
-
DOMAIN_MEMBERS_NEW,
|
|
15
|
-
DOMAIN_NEW,
|
|
16
|
-
DOMAIN_STRUCTURES,
|
|
17
|
-
} from "@truedat/core/routes";
|
|
18
|
-
import Domain from "./Domain";
|
|
19
|
-
import DomainLoader from "./DomainLoader";
|
|
20
|
-
import DomainMembersLoader from "./DomainMembersLoader";
|
|
21
|
-
import Domains from "./Domains";
|
|
22
|
-
import DomainsLoader from "./DomainsLoader";
|
|
23
|
-
import EditDomain from "./EditDomain";
|
|
5
|
+
import { DOMAINS, DOMAIN, DOMAINS_NEW } from "@truedat/core/routes";
|
|
24
6
|
import NewDomain from "./NewDomain";
|
|
25
|
-
import
|
|
26
|
-
|
|
27
|
-
const RolesLoader = React.lazy(() =>
|
|
28
|
-
import("@truedat/auth/roles/components/RolesLoader")
|
|
29
|
-
);
|
|
7
|
+
import Domains from "./Domains";
|
|
30
8
|
|
|
31
9
|
const DomainRoutes = () => (
|
|
32
|
-
|
|
33
|
-
<Route
|
|
34
|
-
<Route
|
|
35
|
-
<Route exact path={
|
|
36
|
-
|
|
37
|
-
<Route exact path={DOMAIN_IMPLEMENTATIONS} component={Domain} />
|
|
38
|
-
<Route exact path={DOMAIN_STRUCTURES} component={Domain} />
|
|
39
|
-
<Route exact path={DOMAIN_MEMBERS} component={Domain} />
|
|
40
|
-
<Route exact path={DOMAIN_EDIT} render={() => <EditDomain />} />
|
|
41
|
-
<Route exact path={DOMAIN_NEW} component={NewDomain} />
|
|
42
|
-
<Route
|
|
43
|
-
path={DOMAIN_MEMBERS_NEW}
|
|
44
|
-
render={({ match }) => (
|
|
45
|
-
<>
|
|
46
|
-
<RolesLoader />
|
|
47
|
-
<AddDomainMember id={parseInt(match?.params?.id)} />
|
|
48
|
-
</>
|
|
49
|
-
)}
|
|
50
|
-
/>
|
|
51
|
-
</>
|
|
10
|
+
<Switch>
|
|
11
|
+
<Route exact path={DOMAINS_NEW} render={() => <NewDomain />} />
|
|
12
|
+
<Route path={DOMAIN} render={() => <Domains />} />
|
|
13
|
+
<Route exact path={DOMAINS} render={() => <Domains />} />
|
|
14
|
+
</Switch>
|
|
52
15
|
);
|
|
53
16
|
|
|
54
|
-
const AuthorizedRoutes = () =>
|
|
55
|
-
<>
|
|
56
|
-
<Route component={DomainsLoader} />
|
|
57
|
-
<Route path={DOMAINS} component={Domains} exact />
|
|
58
|
-
<Switch>
|
|
59
|
-
<Route path={DOMAINS_SEARCH} component={Domains} exact />
|
|
60
|
-
<Route path={DOMAINS_NEW} component={NewDomain} exact />
|
|
61
|
-
<Route path={DOMAIN} render={() => <DomainRoutes />} />
|
|
62
|
-
</Switch>
|
|
63
|
-
</>
|
|
64
|
-
);
|
|
17
|
+
const AuthorizedRoutes = () => <DomainRoutes />;
|
|
65
18
|
|
|
66
19
|
const DomainsRoutes = () => {
|
|
67
20
|
const authorized = useAuthorized(["taxonomy", "taxonomy_membership"]);
|