-
Notifications
You must be signed in to change notification settings - Fork 9
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
UIOR-1177 Add settings components for custom fields #1536
Merged
Changes from 2 commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
fae570f
Add CustomFieldsSettings, permissions and translations
alb3rtino 53b68d2
Update interface versions
alb3rtino 548ead4
Merge branch 'master' into UIOR-1177
alb3rtino 30b1c29
Merge branch 'master' into UIOR-1177
alb3rtino d705d3a
Merge branch 'master' into UIOR-1177
alb3rtino File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,64 @@ | ||
import React from 'react'; | ||
import { Switch, Route } from 'react-router-dom'; | ||
|
||
import { useStripes } from '@folio/stripes/core'; | ||
import { | ||
ViewCustomFieldsSettings, | ||
EditCustomFieldsSettings, | ||
} from '@folio/stripes/smart-components'; | ||
|
||
const CustomFieldsSettings = () => { | ||
const stripes = useStripes(); | ||
|
||
const basePO = '/settings/orders/custom-fields-po'; | ||
const basePOL = '/settings/orders/custom-fields-pol'; | ||
|
||
const permissions = { | ||
canView: stripes.hasPerm('ui-orders.settings.custom-fields.view'), | ||
canEdit: stripes.hasPerm('ui-orders.settings.custom-fields.edit'), | ||
canDelete: stripes.hasPerm('ui-orders.settings.custom-fields.delete'), | ||
}; | ||
|
||
const backendModuleName = 'Orders CRUD module'; | ||
const entityTypePO = 'purchase_order'; | ||
const entityTypePOL = 'po_line'; | ||
|
||
return ( | ||
<Switch> | ||
<Route exact path={basePO}> | ||
<ViewCustomFieldsSettings | ||
backendModuleName={backendModuleName} | ||
entityType={entityTypePO} | ||
editRoute={`${basePO}/edit`} | ||
permissions={permissions} | ||
/> | ||
</Route> | ||
<Route exact path={`${basePO}/edit`}> | ||
<EditCustomFieldsSettings | ||
backendModuleName={backendModuleName} | ||
entityType={entityTypePO} | ||
viewRoute={basePO} | ||
permissions={permissions} | ||
/> | ||
</Route> | ||
<Route exact path={basePOL}> | ||
<ViewCustomFieldsSettings | ||
backendModuleName={backendModuleName} | ||
entityType={entityTypePOL} | ||
editRoute={`${basePOL}/edit`} | ||
permissions={permissions} | ||
/> | ||
</Route> | ||
<Route exact path={`${basePOL}/edit`}> | ||
<EditCustomFieldsSettings | ||
backendModuleName={backendModuleName} | ||
entityType={entityTypePOL} | ||
viewRoute={basePOL} | ||
permissions={permissions} | ||
/> | ||
</Route> | ||
</Switch> | ||
); | ||
}; | ||
|
||
export default CustomFieldsSettings; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,79 @@ | ||
import React from 'react'; | ||
|
||
import { | ||
render, | ||
screen, | ||
} from '@folio/jest-config-stripes/testing-library/react'; | ||
import { MemoryRouter } from 'react-router-dom'; | ||
import CustomFieldsSettings from './CustomFieldsSettings'; | ||
|
||
jest.mock('@folio/stripes/smart-components', () => { | ||
const mockViewCustomFieldsSettings = ({ entityType }) => ( | ||
<div>ViewCustomFieldsSettings-{entityType}</div> | ||
); | ||
|
||
const mockEditCustomFieldsSettings = ({ entityType }) => ( | ||
<div>EditCustomFieldsSettings-{entityType}</div> | ||
); | ||
|
||
return { | ||
ViewCustomFieldsSettings: mockViewCustomFieldsSettings, | ||
EditCustomFieldsSettings: mockEditCustomFieldsSettings, | ||
}; | ||
}); | ||
|
||
const renderCustomFieldsSettings = ({ initialEntries }) => render( | ||
<MemoryRouter initialEntries={initialEntries}> | ||
<CustomFieldsSettings /> | ||
</MemoryRouter>, | ||
); | ||
|
||
describe('Custom fields settings page', () => { | ||
it('should render viewCustomFieldsSettings with entityType=purchase_order', async () => { | ||
renderCustomFieldsSettings({ | ||
initialEntries: ['/settings/orders/custom-fields-po'], | ||
}); | ||
|
||
const viewCustomFieldsSettingsText = await screen.findByText( | ||
/ViewCustomFieldsSettings-purchase_order/, | ||
); | ||
|
||
expect(viewCustomFieldsSettingsText).toBeVisible(); | ||
}); | ||
|
||
it('should render editCustomFieldsSettings with entityType=purchase_order', async () => { | ||
renderCustomFieldsSettings({ | ||
initialEntries: ['/settings/orders/custom-fields-po/edit'], | ||
}); | ||
|
||
const editCustomFieldsSettings = await screen.findByText( | ||
/EditCustomFieldsSettings-purchase_order/, | ||
); | ||
|
||
expect(editCustomFieldsSettings).toBeVisible(); | ||
}); | ||
|
||
it('should render viewCustomFieldsSettings with entityType=po_line', async () => { | ||
renderCustomFieldsSettings({ | ||
initialEntries: ['/settings/orders/custom-fields-pol'], | ||
}); | ||
|
||
const viewCustomFieldsSettingsText = await screen.findByText( | ||
/ViewCustomFieldsSettings-po_line/, | ||
); | ||
|
||
expect(viewCustomFieldsSettingsText).toBeVisible(); | ||
}); | ||
|
||
it('should render editCustomFieldsSettings with entityType=po_line', async () => { | ||
renderCustomFieldsSettings({ | ||
initialEntries: ['/settings/orders/custom-fields-pol/edit'], | ||
}); | ||
|
||
const editCustomFieldsSettings = await screen.findByText( | ||
/EditCustomFieldsSettings-po_line/, | ||
); | ||
|
||
expect(editCustomFieldsSettings).toBeVisible(); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
why do you think it's a breaking change?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We're discontinuing support for
orders <12.1
andorder-lines <3.3
. Interface requirements are a part of the public API. This change is backward incompatible, asui-orders
will no longer function in an environment that providesorders <12.1
ororder-lines <3.3
.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Guidelines for Contributing Code