@truedat/dd 6.1.2 → 6.1.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@truedat/dd",
3
- "version": "6.1.2",
3
+ "version": "6.1.4",
4
4
  "description": "Truedat Web Data Dictionary",
5
5
  "sideEffects": false,
6
6
  "jsnext:main": "src/index.js",
@@ -34,7 +34,7 @@
34
34
  "@testing-library/jest-dom": "^5.16.5",
35
35
  "@testing-library/react": "^12.0.0",
36
36
  "@testing-library/user-event": "^13.2.1",
37
- "@truedat/test": "6.1.2",
37
+ "@truedat/test": "6.1.4",
38
38
  "babel-jest": "^28.1.0",
39
39
  "babel-plugin-dynamic-import-node": "^2.3.3",
40
40
  "babel-plugin-lodash": "^3.3.4",
@@ -88,9 +88,9 @@
88
88
  },
89
89
  "dependencies": {
90
90
  "@apollo/client": "^3.7.1",
91
- "@truedat/auth": "6.1.2",
92
- "@truedat/core": "6.1.2",
93
- "@truedat/df": "6.1.2",
91
+ "@truedat/auth": "6.1.4",
92
+ "@truedat/core": "6.1.4",
93
+ "@truedat/df": "6.1.4",
94
94
  "lodash": "^4.17.21",
95
95
  "moment": "^2.29.4",
96
96
  "path-to-regexp": "^1.7.0",
@@ -115,5 +115,5 @@
115
115
  "react-dom": ">= 16.8.6 < 17",
116
116
  "semantic-ui-react": ">= 2.0.3 < 2.2"
117
117
  },
118
- "gitHead": "34f3dad97550142a4a23048fee3214ce04e957bf"
118
+ "gitHead": "c0ef00d553186b7601e136f3e38fa0d0d7287fd9"
119
119
  }
@@ -38,7 +38,23 @@ export const GrantHeader = ({ grant, title, actions, onStatusChange }) => {
38
38
  ...structure.data,
39
39
  ...structure.data.data_structure,
40
40
  };
41
+
41
42
  const { formatMessage } = useIntl();
43
+
44
+ const getTodayDate = () => {
45
+ const today = new Date();
46
+ const year = today.getFullYear();
47
+ const month = today.getMonth() + 1;
48
+ const formatedMonth = month < 10 ? "0" + month : month;
49
+ const day = today.getDate();
50
+ const formatedDay = day < 10 ? "0" + day : day;
51
+
52
+ return `${year}-${formatedMonth}-${formatedDay}`;
53
+ };
54
+
55
+ const isGrantExpired = () =>
56
+ !_.isNil(grant.end_date) && _.lte(grant.end_date, getTodayDate());
57
+
42
58
  return (
43
59
  <Grid>
44
60
  <Grid.Row>
@@ -53,25 +69,29 @@ export const GrantHeader = ({ grant, title, actions, onStatusChange }) => {
53
69
  </Header>
54
70
  </Grid.Column>
55
71
  <Grid.Column width={4} textAlign="right">
56
- {actions?.update && !loading ? (
57
- <GrantChangeRequest
58
- structure={data_structure}
59
- grant={grant}
60
- key="requestChange"
61
- >
62
- <Button
63
- className="button icon group-actions"
64
- content={formatMessage({
65
- id: "structure.grant.request_grant_change",
66
- })}
72
+ {!isGrantExpired() ? (
73
+ <>
74
+ {actions?.update && !loading ? (
75
+ <GrantChangeRequest
76
+ structure={data_structure}
77
+ grant={grant}
78
+ key="requestChange"
79
+ >
80
+ <Button
81
+ className="button icon group-actions"
82
+ content={formatMessage({
83
+ id: "structure.grant.request_grant_change",
84
+ })}
85
+ />
86
+ </GrantChangeRequest>
87
+ ) : null}
88
+ <GrantRemoval
89
+ actions={actions}
90
+ grant={grant}
91
+ onConfirm={onStatusChange}
67
92
  />
68
- </GrantChangeRequest>
93
+ </>
69
94
  ) : null}
70
- <GrantRemoval
71
- actions={actions}
72
- grant={grant}
73
- onConfirm={onStatusChange}
74
- />
75
95
  </Grid.Column>
76
96
  </Grid.Row>
77
97
  </Grid>
@@ -190,11 +210,15 @@ export const Grant = ({ grant, actions, loading, onStatusChange }) => {
190
210
  {formatMessage({ id: "grant.header.end_date" })}
191
211
  </List.Header>
192
212
  <List.Description>
193
- <Moment
194
- locale="es"
195
- date={grant?.end_date}
196
- format="YYYY-MM-DD"
197
- />
213
+ {grant?.end_date ? (
214
+ <Moment
215
+ locale="es"
216
+ date={grant.end_date}
217
+ format="YYYY-MM-DD"
218
+ />
219
+ ) : (
220
+ formatMessage({ id: "grant.cell.end_date.null" })
221
+ )}
198
222
  </List.Description>
199
223
  </List.Item>
200
224
  {_.isEmpty(grant?.detail) ? null : (
@@ -46,7 +46,7 @@ export const GrantRequestRow = ({
46
46
  * inside an anchor, such as an icon) is clicked
47
47
  */
48
48
  !ev.target.closest("a") &&
49
- history.push(linkTo.GRANT_REQUEST(grantRequest))
49
+ history.push(linkTo.GRANT_REQUEST(grantRequest));
50
50
  }}
51
51
  content={columnDecoratorComponent(column)(grantRequest)}
52
52
  />
@@ -36,7 +36,7 @@ describe("<Grant />", () => {
36
36
  bar: "baz",
37
37
  },
38
38
  start_date: "2018-12-01",
39
- end_date: "2019-12-31",
39
+ end_date: "2029-12-31",
40
40
  inserted_at: "2022-12-12T12:49:09.789722Z",
41
41
  pending_removal: false,
42
42
  external_ref: "foo",
@@ -111,4 +111,20 @@ describe("<Grant />", () => {
111
111
  id: 1,
112
112
  });
113
113
  });
114
+
115
+ it("don't show buttons of edit and remove if the grant is expired", async () => {
116
+ const updatedGrant = {
117
+ ...defaultProps.grant,
118
+ end_date: "2024-01-01",
119
+ };
120
+
121
+ const updatedProps = {
122
+ ...defaultProps,
123
+ grant: updatedGrant,
124
+ };
125
+
126
+ const { queryByText } = render(<Grant {...updatedProps} />, renderOpts);
127
+ const buttonText = queryByText("request grant change");
128
+ expect(buttonText).toBeNull();
129
+ });
114
130
  });
@@ -190,9 +190,9 @@ exports[`<Grant /> matches the latest snapshot 1`] = `
190
190
  class="description"
191
191
  >
192
192
  <time
193
- datetime="1577750400000"
193
+ datetime="1893369600000"
194
194
  >
195
- 2019-12-31
195
+ 2029-12-31
196
196
  </time>
197
197
  </div>
198
198
  </div>
@@ -411,9 +411,9 @@ exports[`<Grant /> matches the latest snapshot with manage_grant_removal action
411
411
  class="description"
412
412
  >
413
413
  <time
414
- datetime="1577750400000"
414
+ datetime="1893369600000"
415
415
  >
416
- 2019-12-31
416
+ 2029-12-31
417
417
  </time>
418
418
  </div>
419
419
  </div>
@@ -685,9 +685,9 @@ exports[`<Grant /> matches the latest snapshot with update action 1`] = `
685
685
  class="description"
686
686
  >
687
687
  <time
688
- datetime="1577750400000"
688
+ datetime="1893369600000"
689
689
  >
690
- 2019-12-31
690
+ 2029-12-31
691
691
  </time>
692
692
  </div>
693
693
  </div>
@@ -55,7 +55,7 @@ export const StructureDecorator = ({
55
55
  content={formatMessage({ id: "request.grantRemoval" })}
56
56
  trigger={
57
57
  <Link to={linkTo.GRANT({ id: grant.id })}>
58
- <Icon name="key" />
58
+ <Icon name="user delete" style={{ color: "black" }} />{" "}
59
59
  </Link>
60
60
  }
61
61
  />
@@ -45,7 +45,7 @@ export const StructureDecorator = (grantRequest) => {
45
45
  content={formatMessage({ id: "request.grantRemoval" })}
46
46
  trigger={
47
47
  <Link to={linkTo.GRANT({ id: grantRequest.grant.id })}>
48
- <Icon name="key" />
48
+ <Icon name="user delete" style={{ color: "black" }} />{" "}
49
49
  </Link>
50
50
  }
51
51
  />
@@ -39,7 +39,7 @@ export const GrantRequestStructureDecorator = (grantRequest) => {
39
39
  }
40
40
  />
41
41
  ) : null}
42
- { grantRequest?.data_structure_version?.name ||
42
+ {grantRequest?.data_structure_version?.name ||
43
43
  grantRequest?.grant?.data_structure_version?.name}
44
44
  </>
45
45
  );
@@ -65,4 +65,4 @@ export const StatusDecorator = ({ status }) => {
65
65
 
66
66
  StatusDecorator.propTypes = {
67
67
  status: PropTypes.string,
68
- };
68
+ };