@truedat/dd 4.35.8 → 4.36.0

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/CHANGELOG.md CHANGED
@@ -1,5 +1,11 @@
1
1
  # Changelog
2
2
 
3
+ ## [4.36.0] 2022-01-13
4
+
5
+ ### Fixed
6
+
7
+ - [TD-4308] Grant request actions should be hidden unless request is pending
8
+
3
9
  ## [4.35.8] 2022-01-07
4
10
 
5
11
  ### Added
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@truedat/dd",
3
- "version": "4.35.8",
3
+ "version": "4.36.0",
4
4
  "description": "Truedat Web Data Dictionary",
5
5
  "sideEffects": false,
6
6
  "jsnext:main": "src/index.js",
@@ -84,9 +84,9 @@
84
84
  ]
85
85
  },
86
86
  "dependencies": {
87
- "@truedat/auth": "4.35.8",
88
- "@truedat/core": "4.35.8",
89
- "@truedat/df": "4.35.8",
87
+ "@truedat/auth": "4.36.0",
88
+ "@truedat/core": "4.36.0",
89
+ "@truedat/df": "4.36.0",
90
90
  "lodash": "^4.17.21",
91
91
  "path-to-regexp": "^1.7.0",
92
92
  "prop-types": "^15.7.2",
@@ -107,5 +107,5 @@
107
107
  "react-dom": ">= 16.8.6 < 17",
108
108
  "semantic-ui-react": ">= 0.88.2 < 2.1"
109
109
  },
110
- "gitHead": "35a51ffb36f357fe814258d51420d5ace5b3cd63"
110
+ "gitHead": "6bf7c33362c73f97c8e5ff61f19c694ef28a0c3d"
111
111
  }
@@ -8,10 +8,9 @@ import GrantRequestApprovalPopup from "./GrantRequestApprovalPopup";
8
8
 
9
9
  export const GrantRequestHeader = ({ grantRequest }) => {
10
10
  const { formatMessage } = useIntl();
11
- const canApprove = _.flow([
12
- _.getOr([], "pending_roles"),
13
- _.negate(_.isEmpty),
14
- ])(grantRequest);
11
+ const canApprove =
12
+ grantRequest?.status === "pending" &&
13
+ !_.isEmpty(grantRequest?.pending_roles);
15
14
  return (
16
15
  <Grid>
17
16
  <Grid.Column width={12}>
@@ -22,7 +21,7 @@ export const GrantRequestHeader = ({ grantRequest }) => {
22
21
  </Header.Content>
23
22
  </Header>
24
23
  </Grid.Column>
25
- {canApprove && (
24
+ {canApprove ? (
26
25
  <Grid.Column width={4} textAlign="right">
27
26
  <GrantRequestApprovalPopup
28
27
  content={formatMessage({ id: "grantRequest.actions.approve" })}
@@ -36,7 +35,7 @@ export const GrantRequestHeader = ({ grantRequest }) => {
36
35
  grantRequest={grantRequest}
37
36
  />
38
37
  </Grid.Column>
39
- )}
38
+ ) : null}
40
39
  </Grid>
41
40
  );
42
41
  };
@@ -3,16 +3,29 @@ import { render } from "@truedat/test/render";
3
3
  import { GrantRequestHeader } from "../GrantRequestHeader";
4
4
 
5
5
  describe("<GrantRequestHeader />", () => {
6
- const grantRequest = {};
7
6
  const renderOpts = {
8
7
  messages: {
9
8
  en: {
10
9
  "grantRequest.header": "header",
10
+ "grantRequest.actions.approve": "approve",
11
+ "grantRequest.actions.reject": "reject",
11
12
  },
12
13
  },
13
14
  };
14
15
 
15
16
  it("matches the latest snapshot", () => {
17
+ const grantRequest = {};
18
+ const { container } = render(
19
+ <Suspense fallback={null}>
20
+ <GrantRequestHeader grantRequest={grantRequest} />
21
+ </Suspense>,
22
+ renderOpts
23
+ );
24
+ expect(container).toMatchSnapshot();
25
+ });
26
+
27
+ it("matches the latest snapshot (pending)", () => {
28
+ const grantRequest = { status: "pending", pending_roles: ["foo", "bar"] };
16
29
  const { container } = render(
17
30
  <Suspense fallback={null}>
18
31
  <GrantRequestHeader grantRequest={grantRequest} />
@@ -1,5 +1,45 @@
1
1
  // Jest Snapshot v1, https://goo.gl/fbAQLP
2
2
 
3
+ exports[`<GrantRequestHeader /> matches the latest snapshot (pending) 1`] = `
4
+ <div>
5
+ <div
6
+ class="ui grid"
7
+ >
8
+ <div
9
+ class="twelve wide column"
10
+ >
11
+ <h2
12
+ class="ui header"
13
+ >
14
+ <i
15
+ aria-hidden="true"
16
+ class="key circular icon"
17
+ />
18
+ <div
19
+ class="content"
20
+ >
21
+ header
22
+ </div>
23
+ </h2>
24
+ </div>
25
+ <div
26
+ class="right aligned four wide column"
27
+ >
28
+ <button
29
+ class="ui primary button button icon group-actions"
30
+ >
31
+ approve
32
+ </button>
33
+ <button
34
+ class="ui secondary button button icon group-actions"
35
+ >
36
+ reject
37
+ </button>
38
+ </div>
39
+ </div>
40
+ </div>
41
+ `;
42
+
3
43
  exports[`<GrantRequestHeader /> matches the latest snapshot 1`] = `
4
44
  <div>
5
45
  <div