mirror of
https://github.com/ansible/awx.git
synced 2026-05-08 09:57:35 -02:30
Removes the need to pass default search params to the select resource step
This commit is contained in:
@@ -147,7 +147,8 @@ describe('<SelectResourceStep />', () => {
|
|||||||
foo: 'bar'
|
foo: 'bar'
|
||||||
});
|
});
|
||||||
expect(readUsers).toHaveBeenCalledWith({
|
expect(readUsers).toHaveBeenCalledWith({
|
||||||
foo: 'bar'
|
foo: 'bar',
|
||||||
|
is_superuser: false
|
||||||
});
|
});
|
||||||
wrapper.instance().readTeams({
|
wrapper.instance().readTeams({
|
||||||
foo: 'bar'
|
foo: 'bar'
|
||||||
|
|||||||
@@ -15,9 +15,6 @@ describe('<SelectResourceStep />', () => {
|
|||||||
<I18nProvider>
|
<I18nProvider>
|
||||||
<SelectResourceStep
|
<SelectResourceStep
|
||||||
columns={columns}
|
columns={columns}
|
||||||
defaultSearchParams={{
|
|
||||||
is_superuser: false
|
|
||||||
}}
|
|
||||||
displayKey="username"
|
displayKey="username"
|
||||||
onRowClick={jest.fn()}
|
onRowClick={jest.fn()}
|
||||||
onSearch={jest.fn()}
|
onSearch={jest.fn()}
|
||||||
@@ -40,9 +37,6 @@ describe('<SelectResourceStep />', () => {
|
|||||||
<I18nProvider>
|
<I18nProvider>
|
||||||
<SelectResourceStep
|
<SelectResourceStep
|
||||||
columns={columns}
|
columns={columns}
|
||||||
defaultSearchParams={{
|
|
||||||
is_superuser: false
|
|
||||||
}}
|
|
||||||
displayKey="username"
|
displayKey="username"
|
||||||
onRowClick={jest.fn()}
|
onRowClick={jest.fn()}
|
||||||
onSearch={handleSearch}
|
onSearch={handleSearch}
|
||||||
@@ -51,7 +45,6 @@ describe('<SelectResourceStep />', () => {
|
|||||||
</I18nProvider>
|
</I18nProvider>
|
||||||
);
|
);
|
||||||
expect(handleSearch).toHaveBeenCalledWith({
|
expect(handleSearch).toHaveBeenCalledWith({
|
||||||
is_superuser: false,
|
|
||||||
order_by: 'username',
|
order_by: 'username',
|
||||||
page: 1,
|
page: 1,
|
||||||
page_size: 5
|
page_size: 5
|
||||||
@@ -77,9 +70,6 @@ describe('<SelectResourceStep />', () => {
|
|||||||
<I18nProvider>
|
<I18nProvider>
|
||||||
<SelectResourceStep
|
<SelectResourceStep
|
||||||
columns={columns}
|
columns={columns}
|
||||||
defaultSearchParams={{
|
|
||||||
is_superuser: false
|
|
||||||
}}
|
|
||||||
displayKey="username"
|
displayKey="username"
|
||||||
onRowClick={jest.fn()}
|
onRowClick={jest.fn()}
|
||||||
onSearch={handleSearch}
|
onSearch={handleSearch}
|
||||||
@@ -93,7 +83,6 @@ describe('<SelectResourceStep />', () => {
|
|||||||
order_by: '-username'
|
order_by: '-username'
|
||||||
});
|
});
|
||||||
expect(handleSearch).toHaveBeenCalledWith({
|
expect(handleSearch).toHaveBeenCalledWith({
|
||||||
is_superuser: false,
|
|
||||||
order_by: '-username',
|
order_by: '-username',
|
||||||
page: 1
|
page: 1
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -106,7 +106,7 @@ class AddResourceRole extends React.Component {
|
|||||||
|
|
||||||
async readUsers (queryParams) {
|
async readUsers (queryParams) {
|
||||||
const { api } = this.props;
|
const { api } = this.props;
|
||||||
return api.readUsers(queryParams);
|
return api.readUsers(Object.assign(queryParams, { is_superuser: false }));
|
||||||
}
|
}
|
||||||
|
|
||||||
async readTeams (queryParams) {
|
async readTeams (queryParams) {
|
||||||
@@ -174,9 +174,6 @@ class AddResourceRole extends React.Component {
|
|||||||
{selectedResource === 'users' && (
|
{selectedResource === 'users' && (
|
||||||
<SelectResourceStep
|
<SelectResourceStep
|
||||||
columns={userColumns}
|
columns={userColumns}
|
||||||
defaultSearchParams={{
|
|
||||||
is_superuser: false
|
|
||||||
}}
|
|
||||||
displayKey="username"
|
displayKey="username"
|
||||||
emptyListBody={i18n._(t`Please add users to populate this list`)}
|
emptyListBody={i18n._(t`Please add users to populate this list`)}
|
||||||
emptyListTitle={i18n._(t`No Users Found`)}
|
emptyListTitle={i18n._(t`No Users Found`)}
|
||||||
|
|||||||
@@ -70,7 +70,7 @@ class SelectResourceStep extends React.Component {
|
|||||||
}
|
}
|
||||||
|
|
||||||
async readResourceList (queryParams) {
|
async readResourceList (queryParams) {
|
||||||
const { onSearch, defaultSearchParams } = this.props;
|
const { onSearch } = this.props;
|
||||||
const { page, order_by } = queryParams;
|
const { page, order_by } = queryParams;
|
||||||
|
|
||||||
let sortOrder = 'ascending';
|
let sortOrder = 'ascending';
|
||||||
@@ -84,7 +84,7 @@ class SelectResourceStep extends React.Component {
|
|||||||
this.setState({ error: false });
|
this.setState({ error: false });
|
||||||
|
|
||||||
try {
|
try {
|
||||||
const { data } = await onSearch(Object.assign(queryParams, defaultSearchParams));
|
const { data } = await onSearch(queryParams);
|
||||||
const { count, results } = data;
|
const { count, results } = data;
|
||||||
|
|
||||||
const stateToUpdate = {
|
const stateToUpdate = {
|
||||||
@@ -189,7 +189,6 @@ class SelectResourceStep extends React.Component {
|
|||||||
|
|
||||||
SelectResourceStep.propTypes = {
|
SelectResourceStep.propTypes = {
|
||||||
columns: PropTypes.arrayOf(PropTypes.object).isRequired,
|
columns: PropTypes.arrayOf(PropTypes.object).isRequired,
|
||||||
defaultSearchParams: PropTypes.shape(),
|
|
||||||
displayKey: PropTypes.string,
|
displayKey: PropTypes.string,
|
||||||
emptyListBody: PropTypes.string,
|
emptyListBody: PropTypes.string,
|
||||||
emptyListTitle: PropTypes.string,
|
emptyListTitle: PropTypes.string,
|
||||||
@@ -202,7 +201,6 @@ SelectResourceStep.propTypes = {
|
|||||||
};
|
};
|
||||||
|
|
||||||
SelectResourceStep.defaultProps = {
|
SelectResourceStep.defaultProps = {
|
||||||
defaultSearchParams: {},
|
|
||||||
displayKey: 'name',
|
displayKey: 'name',
|
||||||
emptyListBody: i18nMark('Please add items to populate this list'),
|
emptyListBody: i18nMark('Please add items to populate this list'),
|
||||||
emptyListTitle: i18nMark('No Items Found'),
|
emptyListTitle: i18nMark('No Items Found'),
|
||||||
|
|||||||
Reference in New Issue
Block a user