@truedat/bg 4.48.9 → 4.48.12

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.
@@ -28,7 +28,7 @@ export const Domains = ({ domainsLoading, createDomain }) => (
28
28
  <Route
29
29
  exact
30
30
  path={DOMAINS_NEW}
31
- render={() => <DomainForm handleSubmit={createDomain} />}
31
+ render={() => <DomainForm onSubmit={createDomain} />}
32
32
  />
33
33
  </Switch>
34
34
  </Segment>
@@ -1,3 +1,4 @@
1
+ import _ from "lodash/fp";
1
2
  import React from "react";
2
3
  import PropTypes from "prop-types";
3
4
  import { connect } from "react-redux";
@@ -7,23 +8,24 @@ import { updateDomain } from "../routines";
7
8
  import DomainForm from "./DomainForm";
8
9
  import DomainCrumbs from "./DomainCrumbs";
9
10
 
10
- export const EditDomain = ({ domain, updateDomain }) => (
11
- <>
12
- <DomainCrumbs actionCrumb="domain.actions.edit.header" />
13
- <Container as={Segment} text>
14
- <Header as="h2">
15
- <Icon name="cube" />
16
- <Header.Content>
17
- <FormattedMessage id="domain.actions.edit.header" />
18
- </Header.Content>
19
- </Header>
20
- <DomainForm handleSubmit={updateDomain} domain={domain} />
21
- </Container>
22
- </>
23
- );
11
+ export const EditDomain = ({ domain, updateDomain }) =>
12
+ _.isEmpty(domain) ? null : (
13
+ <>
14
+ <DomainCrumbs actionCrumb="domain.actions.edit.header" />
15
+ <Container as={Segment} text>
16
+ <Header as="h2">
17
+ <Icon name="cube" />
18
+ <Header.Content>
19
+ <FormattedMessage id="domain.actions.edit.header" />
20
+ </Header.Content>
21
+ </Header>
22
+ <DomainForm onSubmit={updateDomain} domain={domain} />
23
+ </Container>
24
+ </>
25
+ );
24
26
 
25
27
  EditDomain.propTypes = {
26
- domain: PropTypes.object.isRequired,
28
+ domain: PropTypes.object,
27
29
  updateDomain: PropTypes.func.isRequired,
28
30
  };
29
31
 
@@ -15,18 +15,10 @@ export const NewDomain = ({ domain, createDomain }) => (
15
15
  <Header as="h2">
16
16
  <Icon name="cube" />
17
17
  <Header.Content>
18
- {!_.isEmpty(domain) && (
19
- <FormattedMessage id="domain.actions.create" />
20
- )}
21
- {_.isEmpty(domain) && (
22
- <FormattedMessage id="domains.actions.create" />
23
- )}
18
+ <FormattedMessage id="domain.actions.create" />
24
19
  </Header.Content>
25
20
  </Header>
26
- <DomainForm
27
- handleSubmit={createDomain}
28
- domain={{ parent_id: domain.id }}
29
- />
21
+ <DomainForm onSubmit={createDomain} domain={{ parent_id: domain.id }} />
30
22
  </Container>
31
23
  </>
32
24
  );
@@ -1,23 +1,26 @@
1
1
  import React from "react";
2
- import { shallowWithIntl } from "@truedat/test/intl-stub";
2
+ import userEvent from "@testing-library/user-event";
3
+ import { render } from "@truedat/test/render";
3
4
  import { DomainForm } from "../DomainForm";
4
5
 
5
6
  describe("<DomainForm />", () => {
6
- const handleSubmit = jest.fn();
7
+ const onSubmit = jest.fn();
7
8
  const domain = { id: 1, name: "nn", external_id: "foo", description: "dd" };
8
9
  const isSubmitting = false;
9
- const props = { domain, handleSubmit, isSubmitting };
10
+ const props = { domain, onSubmit, isSubmitting };
10
11
 
11
- it("matches the latest snapshot", () => {
12
- const wrapper = shallowWithIntl(<DomainForm {...props} />);
13
- expect(wrapper).toMatchSnapshot();
12
+ it("matches the latest snapshot", async () => {
13
+ const { container, findByRole } = render(<DomainForm {...props} />);
14
+ await findByRole("button", { name: "Save" });
15
+ expect(container).toMatchSnapshot();
14
16
  });
15
17
 
16
- it("disables submit button when there are uniformed mandatory fields", () => {
17
- const wrapper = shallowWithIntl(<DomainForm {...props} />);
18
- wrapper.setState({ touched: true });
19
- expect(wrapper.find({ type: "submit" }).prop("disabled")).toBeFalsy();
20
- wrapper.setState({ domain: { ...props, external_id: null } });
21
- expect(wrapper.find({ type: "submit" }).prop("disabled")).toBeTruthy();
18
+ it("enables submit when required fields have values", async () => {
19
+ const props = { domain: {}, onSubmit: jest.fn() };
20
+ const { findByRole } = render(<DomainForm {...props} />);
21
+ expect(await findByRole("button", { name: "Save" })).toBeDisabled();
22
+ userEvent.type(await findByRole("textbox", { name: "Name" }), "name");
23
+ userEvent.type(await findByRole("textbox", { name: "External Id" }), "id");
24
+ expect(await findByRole("button", { name: "Save" })).toBeEnabled();
22
25
  });
23
26
  });
@@ -0,0 +1,12 @@
1
+ import React from "react";
2
+ import { render } from "@truedat/test/render";
3
+ import DomainStructures from "../DomainStructures";
4
+
5
+ describe("<DomainStructures />", () => {
6
+ const renderOpts = { state: { domain: { id: 1, name: "domain" } } };
7
+
8
+ it("matches the latest snapshot", () => {
9
+ const { container } = render(<DomainStructures />, renderOpts);
10
+ expect(container).toMatchSnapshot();
11
+ });
12
+ });
@@ -25,6 +25,11 @@ exports[`<Domain /> matches the latest snapshot (no subdomains) 1`] = `
25
25
  path="/domains/:id/concepts"
26
26
  render={[Function]}
27
27
  />
28
+ <Route
29
+ exact={true}
30
+ path="/domains/:id/structures"
31
+ render={[Function]}
32
+ />
28
33
  </Switch>
29
34
  </Segment>
30
35
  </Segment>
@@ -56,6 +61,11 @@ exports[`<Domain /> matches the latest snapshot (with subdomains) 1`] = `
56
61
  path="/domains/:id/concepts"
57
62
  render={[Function]}
58
63
  />
64
+ <Route
65
+ exact={true}
66
+ path="/domains/:id/structures"
67
+ render={[Function]}
68
+ />
59
69
  </Switch>
60
70
  </Segment>
61
71
  </Segment>
@@ -1,142 +1,182 @@
1
1
  // Jest Snapshot v1, https://goo.gl/fbAQLP
2
2
 
3
3
  exports[`<DomainForm /> matches the latest snapshot 1`] = `
4
- <Form
5
- as="form"
6
- onSubmit={[Function]}
7
- >
8
- <FormInput
9
- as={[Function]}
10
- autoComplete="off"
11
- control={[Function]}
12
- label="domain.props.name"
13
- name="name"
14
- onChange={[Function]}
15
- placeholder="domain.props.name.placeholder"
16
- required={true}
17
- value="nn"
18
- />
19
- <FormInput
20
- as={[Function]}
21
- autoComplete="off"
22
- control={[Function]}
23
- label="domain.props.external_id"
24
- name="external_id"
25
- onChange={[Function]}
26
- placeholder="domain.props.external_id.placeholder"
27
- required={true}
28
- value="foo"
29
- />
30
- <Segment>
31
- <FormGroup
32
- inline={true}
4
+ <div>
5
+ <form
6
+ class="ui form"
7
+ >
8
+ <div
9
+ class="required field"
10
+ >
11
+ <label
12
+ for="name"
13
+ >
14
+ Name
15
+ </label>
16
+ <div
17
+ class="ui input"
18
+ >
19
+ <input
20
+ autocomplete="off"
21
+ id="name"
22
+ name="name"
23
+ placeholder="Domain Name"
24
+ required=""
25
+ type="text"
26
+ value="nn"
27
+ />
28
+ </div>
29
+ </div>
30
+ <div
31
+ class="required field"
32
+ >
33
+ <label
34
+ for="external_id"
35
+ >
36
+ External Id
37
+ </label>
38
+ <div
39
+ class="ui input"
40
+ >
41
+ <input
42
+ autocomplete="off"
43
+ id="external_id"
44
+ name="external_id"
45
+ placeholder="Domain's external reference"
46
+ required=""
47
+ type="text"
48
+ value="foo"
49
+ />
50
+ </div>
51
+ </div>
52
+ <div
53
+ class="field"
33
54
  >
34
55
  <label>
35
- domain.props.domain_group
56
+ Group
36
57
  </label>
37
- </FormGroup>
38
- <Accordion>
39
- <AccordionTitle
40
- onClick={[Function]}
58
+ <div
59
+ aria-expanded="false"
60
+ class="ui basic search selection dropdown"
61
+ name="domain_group"
62
+ role="combobox"
41
63
  >
42
- <Icon
43
- as="i"
44
- name="dropdown"
64
+ <input
65
+ aria-autocomplete="list"
66
+ autocomplete="off"
67
+ class="search"
68
+ tabindex="0"
69
+ type="text"
70
+ value=""
71
+ />
72
+ <div
73
+ aria-atomic="true"
74
+ aria-live="polite"
75
+ class="divider default text"
76
+ role="alert"
77
+ >
78
+ Domain Group
79
+ </div>
80
+ <i
81
+ aria-hidden="true"
82
+ class="dropdown icon"
45
83
  />
46
- domain.domain_group.select
47
-
48
- </AccordionTitle>
49
- <AccordionContent>
50
- <FormDropdown
51
- additionLabel={
52
- <i
53
- style={
54
- Object {
55
- "color": "red",
56
- }
57
- }
58
- >
59
- domain.label.domain_group
60
- </i>
61
- }
62
- allowAdditions={true}
63
- as={[Function]}
64
- basic={true}
65
- clearable={true}
66
- control={[Function]}
67
- label="domain.props.domain_group"
68
- name="domain_group"
69
- onChange={[Function]}
70
- options={Array []}
71
- placeholder="domain.props.domain_group.placeholder"
72
- search={true}
73
- selection={true}
84
+ <div
85
+ class="menu transition"
86
+ role="listbox"
87
+ >
88
+ <div
89
+ class="message"
90
+ >
91
+ No results found.
92
+ </div>
93
+ </div>
94
+ </div>
95
+ </div>
96
+ <div
97
+ class="field"
98
+ >
99
+ <label>
100
+ Type
101
+ </label>
102
+ <div
103
+ aria-expanded="false"
104
+ class="ui basic search selection dropdown"
105
+ name="type"
106
+ role="combobox"
107
+ >
108
+ <input
109
+ aria-autocomplete="list"
110
+ autocomplete="off"
111
+ class="search"
112
+ tabindex="0"
113
+ type="text"
74
114
  value=""
75
115
  />
76
- </AccordionContent>
77
- </Accordion>
78
- </Segment>
79
- <FormDropdown
80
- additionLabel={
81
- <i
82
- style={
83
- Object {
84
- "color": "red",
85
- }
86
- }
116
+ <div
117
+ aria-atomic="true"
118
+ aria-live="polite"
119
+ class="divider default text"
120
+ role="alert"
121
+ >
122
+ Domain Type
123
+ </div>
124
+ <i
125
+ aria-hidden="true"
126
+ class="dropdown icon"
127
+ />
128
+ <div
129
+ class="menu transition"
130
+ role="listbox"
131
+ >
132
+ <div
133
+ aria-checked="true"
134
+ aria-selected="true"
135
+ class="active selected item"
136
+ role="option"
137
+ style="pointer-events: all;"
138
+ >
139
+ <span
140
+ class="text"
141
+ />
142
+ </div>
143
+ </div>
144
+ </div>
145
+ </div>
146
+ <div
147
+ class="field"
148
+ >
149
+ <label>
150
+ Description
151
+ </label>
152
+ <textarea
153
+ autocomplete="off"
154
+ name="description"
155
+ placeholder="A description for this domain"
156
+ rows="3"
87
157
  >
88
- New Domain Type:
89
- </i>
90
- }
91
- allowAdditions={true}
92
- as={[Function]}
93
- basic={true}
94
- clearable={true}
95
- control={[Function]}
96
- label="domain.props.type"
97
- name="type"
98
- onChange={[Function]}
99
- options={
100
- Array [
101
- Object {
102
- "key": 0,
103
- "text": "",
104
- "value": "",
105
- },
106
- ]
107
- }
108
- placeholder="domain.props.type.placeholder"
109
- search={true}
110
- selection={true}
111
- value=""
112
- />
113
- <FormTextArea
114
- as={[Function]}
115
- autoComplete="off"
116
- control={[Function]}
117
- label="domain.props.description"
118
- maxLength={255}
119
- name="description"
120
- onChange={[Function]}
121
- placeholder="domain.props.description.placeholder"
122
- required={true}
123
- value="dd"
124
- />
125
- <div
126
- className="actions"
127
- >
128
- <HistoryBackButton
129
- content="actions.cancel"
130
- disabled={false}
131
- />
132
- <Button
133
- as="button"
134
- content="actions.save"
135
- disabled={true}
136
- loading={false}
137
- primary={true}
138
- type="submit"
139
- />
140
- </div>
141
- </Form>
158
+ dd
159
+ </textarea>
160
+ </div>
161
+ <div
162
+ class="actions"
163
+ >
164
+ <button
165
+ class="ui primary disabled right floated button"
166
+ disabled=""
167
+ tabindex="-1"
168
+ type="submit"
169
+ >
170
+ Save
171
+ </button>
172
+ <a
173
+ class="ui secondary button"
174
+ href="/"
175
+ role="button"
176
+ >
177
+ Cancel
178
+ </a>
179
+ </div>
180
+ </form>
181
+ </div>
142
182
  `;
@@ -0,0 +1,151 @@
1
+ // Jest Snapshot v1, https://goo.gl/fbAQLP
2
+
3
+ exports[`<DomainStructures /> matches the latest snapshot 1`] = `
4
+ <div>
5
+ <div
6
+ aria-expanded="false"
7
+ class="ui floating dropdown button icon group-actions button-update"
8
+ role="listbox"
9
+ tabindex="0"
10
+ >
11
+ <i
12
+ aria-hidden="true"
13
+ class="ellipsis vertical icon"
14
+ />
15
+ <div
16
+ class="menu transition left"
17
+ >
18
+ <div
19
+ class="divider"
20
+ />
21
+ <div
22
+ aria-disabled="true"
23
+ class="disabled item"
24
+ role="option"
25
+ >
26
+ <i
27
+ aria-hidden="true"
28
+ class="download icon"
29
+ />
30
+ <span>
31
+ Download structures metadata
32
+ </span>
33
+ <p
34
+ class="menu-item-description"
35
+ >
36
+ You must search or filter to download structures
37
+ </p>
38
+ </div>
39
+ <div
40
+ aria-disabled="true"
41
+ class="disabled item"
42
+ role="option"
43
+ >
44
+ <i
45
+ aria-hidden="true"
46
+ class="download icon"
47
+ />
48
+ <span>
49
+ Download editable structures metadata
50
+ </span>
51
+ <p
52
+ class="menu-item-description"
53
+ >
54
+ You must search or filter to download structures
55
+ </p>
56
+ </div>
57
+ <div
58
+ class="divider"
59
+ />
60
+ </div>
61
+ </div>
62
+ <div
63
+ class="ui action left icon input"
64
+ >
65
+ <i
66
+ aria-hidden="true"
67
+ class="search link icon"
68
+ />
69
+ <input
70
+ placeholder="Search structures..."
71
+ type="text"
72
+ value=""
73
+ />
74
+ <button
75
+ class="ui icon button"
76
+ >
77
+ <i
78
+ aria-hidden="true"
79
+ class="calendar alternate outline icon"
80
+ />
81
+ </button>
82
+ <div
83
+ aria-expanded="false"
84
+ class="ui button floating labeled scrolling dropdown icon"
85
+ role="listbox"
86
+ tabindex="0"
87
+ >
88
+ <div
89
+ aria-atomic="true"
90
+ aria-live="polite"
91
+ class="divider text"
92
+ role="alert"
93
+ >
94
+ Filters
95
+ </div>
96
+ <i
97
+ aria-hidden="true"
98
+ class="filter icon"
99
+ />
100
+ <div
101
+ class="menu transition"
102
+ >
103
+ <div
104
+ class="item"
105
+ role="option"
106
+ >
107
+ <em>
108
+ (reset all filters)
109
+ </em>
110
+ </div>
111
+ </div>
112
+ </div>
113
+ </div>
114
+ <div
115
+ class="selectedFilters"
116
+ />
117
+ <div
118
+ class="dimmable"
119
+ >
120
+ <div
121
+ class="ui inverted dimmer"
122
+ >
123
+ <div
124
+ class="content"
125
+ >
126
+ <div
127
+ class="ui large loader"
128
+ />
129
+ </div>
130
+ </div>
131
+ <div
132
+ class="ui icon info message"
133
+ >
134
+ <i
135
+ aria-hidden="true"
136
+ class="search icon"
137
+ />
138
+ <div
139
+ class="content"
140
+ >
141
+ <div
142
+ class="header"
143
+ >
144
+ Nothing found...
145
+ </div>
146
+ No structures have been found matching these filters.
147
+ </div>
148
+ </div>
149
+ </div>
150
+ </div>
151
+ `;
@@ -22,7 +22,7 @@ exports[`<EditDomain /> matches the latest snapshot 1`] = `
22
22
  />
23
23
  </HeaderContent>
24
24
  </Header>
25
- <injectIntl(Connect(DomainForm))
25
+ <Connect(DomainForm)
26
26
  domain={
27
27
  Object {
28
28
  "description": "dd",
@@ -30,7 +30,7 @@ exports[`<EditDomain /> matches the latest snapshot 1`] = `
30
30
  "name": "nn",
31
31
  }
32
32
  }
33
- handleSubmit={[MockFunction]}
33
+ onSubmit={[MockFunction]}
34
34
  />
35
35
  </Container>
36
36
  </Fragment>
@@ -22,13 +22,13 @@ exports[`<NewDomain /> matches the latest snapshot 1`] = `
22
22
  />
23
23
  </HeaderContent>
24
24
  </Header>
25
- <injectIntl(Connect(DomainForm))
25
+ <Connect(DomainForm)
26
26
  domain={
27
27
  Object {
28
28
  "parent_id": 1,
29
29
  }
30
30
  }
31
- handleSubmit={[MockFunction]}
31
+ onSubmit={[MockFunction]}
32
32
  />
33
33
  </Container>
34
34
  </Fragment>
@@ -1,11 +1,13 @@
1
- import DomainsLoader from "./DomainsLoader";
2
- import DomainRoutes from "./DomainRoutes";
3
1
  import DomainDropdownSelector from "./DomainDropdownSelector";
4
2
  import DomainMenuSelector from "./DomainMenuSelector";
3
+ import DomainRoutes from "./DomainRoutes";
4
+ import DomainsLoader from "./DomainsLoader";
5
+ import DomainStructures from "./DomainStructures";
5
6
 
6
7
  export {
7
8
  DomainDropdownSelector,
8
9
  DomainMenuSelector,
9
10
  DomainRoutes,
10
11
  DomainsLoader,
12
+ DomainStructures,
11
13
  };
@@ -11,7 +11,7 @@ const pickFields = _.pick([
11
11
  "description",
12
12
  "type",
13
13
  "parentable_ids",
14
- "domain_group"
14
+ "domain_group",
15
15
  ]);
16
16
 
17
17
  const domain = (state = initialState, { type, payload }) => {