Skip to content

Commit

Permalink
STSMACOM-794 Allow sending requests to a different tenant from <Contr…
Browse files Browse the repository at this point in the history
…olledVocab>
  • Loading branch information
BogdanDenis committed Dec 29, 2023
1 parent 194a1b3 commit 64b3d91
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 1 deletion.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
* Extend `Tags` component to accept `mutateEntity` prop. Refs STSMACOM-792.
* Refactor CSS away from postcss-color-function. Refs STSMACOM-791.
* `<EditCustomFieldsSettings>` now passes the `entityType` when making PUT requests to `/custom-fields`. Refs FCFIELDS-44.
* Added `tenant` prop to `<ControlledVocab>`. Refs STSMACOM-794.

## [9.0.0](https://github.com/folio-org/stripes-smart-components/tree/v9.0.0) (2023-10-11)
[Full Changelog](https://github.com/folio-org/stripes-smart-components/compare/v8.0.0...v9.0.0)
Expand Down
22 changes: 21 additions & 1 deletion lib/ControlledVocab/ControlledVocab.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ class ControlledVocab extends React.Component {
path: '!{baseUrl}',
records: '!{records}',
throwErrors: false,
tenant: '%{tenant}',
clientGeneratePk: '!{clientGeneratePk}',
PUT: {
path: '!{baseUrl}/%{activeRecord.id}',
Expand All @@ -54,6 +55,7 @@ class ControlledVocab extends React.Component {
type: 'okapi',
records: 'users',
path: 'users',
tenant: '%{tenant}',
GET: {
params: {
query: (queryParams, pathComponents, resourceValues) => {
Expand All @@ -66,6 +68,7 @@ class ControlledVocab extends React.Component {
}
},
updaterIds: {},
tenant: {},
});

static propTypes = {
Expand Down Expand Up @@ -103,6 +106,9 @@ class ControlledVocab extends React.Component {
GET: PropTypes.func,
reset: PropTypes.func,
}),
tenant: PropTypes.shape({
replace: PropTypes.func,
}),
values: PropTypes.shape({
DELETE: PropTypes.func,
GET: PropTypes.func,
Expand Down Expand Up @@ -134,7 +140,10 @@ class ControlledVocab extends React.Component {
sortby: PropTypes.string,
stripes: PropTypes.shape({
connect: PropTypes.func.isRequired,
hasPerm: PropTypes.func.isRequired
hasPerm: PropTypes.func.isRequired,
okapi: PropTypes.shape({
tenant: PropTypes.string.isRequired,
}).isRequired,
}).isRequired,
/*
sample translation prop
Expand All @@ -146,6 +155,7 @@ class ControlledVocab extends React.Component {
termWillBeDeleted: "The patron group <b>{term}</b> will be <b>deleted.</b>"
}
*/
tenant: PropTypes.string,
translations: PropTypes.shape({
cannotDeleteTermHeader: PropTypes.string,
cannotDeleteTermMessage: PropTypes.string,
Expand Down Expand Up @@ -235,6 +245,16 @@ class ControlledVocab extends React.Component {
return null;
}

componentDidMount() {
const {
mutator,
tenant,
stripes,
} = this.props;

mutator.tenant.replace(tenant || stripes.okapi.tenant);
}

componentDidUpdate() {
// build a list of the ids of users who have updated CV items so
// we can look them up all at once
Expand Down

0 comments on commit 64b3d91

Please sign in to comment.