mirror of
https://github.com/ansible/awx.git
synced 2026-05-08 18:07:36 -02:30
revert MultiCredentialLookup loading jank fix
This commit is contained in:
@@ -37,14 +37,14 @@ function MultiCredentialsLookup(props) {
|
|||||||
const [selectedType, setSelectedType] = useState(null);
|
const [selectedType, setSelectedType] = useState(null);
|
||||||
const [credentials, setCredentials] = useState([]);
|
const [credentials, setCredentials] = useState([]);
|
||||||
const [credentialsCount, setCredentialsCount] = useState(0);
|
const [credentialsCount, setCredentialsCount] = useState(0);
|
||||||
const [isLoading, setIsLoading] = useState(false);
|
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
(async () => {
|
(async () => {
|
||||||
try {
|
try {
|
||||||
const types = await loadCredentialTypes();
|
const types = await loadCredentialTypes();
|
||||||
setCredentialTypes(types);
|
setCredentialTypes(types);
|
||||||
setSelectedType(types.find(type => type.kind === 'ssh') || types[0]);
|
const match = types.find(type => type.kind === 'ssh') || types[0];
|
||||||
|
setSelectedType(match);
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
onError(err);
|
onError(err);
|
||||||
}
|
}
|
||||||
@@ -57,7 +57,6 @@ function MultiCredentialsLookup(props) {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
try {
|
try {
|
||||||
setIsLoading(true);
|
|
||||||
const params = parseQueryString(QS_CONFIG, history.location.search);
|
const params = parseQueryString(QS_CONFIG, history.location.search);
|
||||||
const { results, count } = await loadCredentials(
|
const { results, count } = await loadCredentials(
|
||||||
params,
|
params,
|
||||||
@@ -65,14 +64,12 @@ function MultiCredentialsLookup(props) {
|
|||||||
);
|
);
|
||||||
setCredentials(results);
|
setCredentials(results);
|
||||||
setCredentialsCount(count);
|
setCredentialsCount(count);
|
||||||
setIsLoading(false);
|
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
onError(err);
|
onError(err);
|
||||||
}
|
}
|
||||||
})();
|
})();
|
||||||
}, [selectedType, history.location.search, onError]);
|
}, [selectedType, history.location.search, onError]);
|
||||||
|
|
||||||
const isMultiple = selectedType && selectedType.kind === 'vault';
|
|
||||||
const renderChip = ({ item, removeItem, canDelete }) => (
|
const renderChip = ({ item, removeItem, canDelete }) => (
|
||||||
<CredentialChip
|
<CredentialChip
|
||||||
key={item.id}
|
key={item.id}
|
||||||
@@ -82,6 +79,8 @@ function MultiCredentialsLookup(props) {
|
|||||||
/>
|
/>
|
||||||
);
|
);
|
||||||
|
|
||||||
|
const isMultiple = selectedType && selectedType.kind === 'vault';
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<FormGroup label={i18n._(t`Credentials`)} fieldId="multiCredential">
|
<FormGroup label={i18n._(t`Credentials`)} fieldId="multiCredential">
|
||||||
{tooltip && <FieldTooltip content={tooltip} />}
|
{tooltip && <FieldTooltip content={tooltip} />}
|
||||||
@@ -136,7 +135,6 @@ function MultiCredentialsLookup(props) {
|
|||||||
name="credentials"
|
name="credentials"
|
||||||
qsConfig={QS_CONFIG}
|
qsConfig={QS_CONFIG}
|
||||||
readOnly={!canDelete}
|
readOnly={!canDelete}
|
||||||
isLoading={isLoading}
|
|
||||||
selectItem={item => {
|
selectItem={item => {
|
||||||
if (isMultiple) {
|
if (isMultiple) {
|
||||||
return dispatch({ type: 'SELECT_ITEM', item });
|
return dispatch({ type: 'SELECT_ITEM', item });
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
import React from 'react';
|
import React, { Fragment } from 'react';
|
||||||
import PropTypes, { arrayOf, shape, string, bool } from 'prop-types';
|
import PropTypes, { arrayOf, shape, string, bool } from 'prop-types';
|
||||||
import { DataList } from '@patternfly/react-core';
|
import { DataList } from '@patternfly/react-core';
|
||||||
import { withI18n } from '@lingui/react';
|
import { withI18n } from '@lingui/react';
|
||||||
@@ -25,34 +25,10 @@ import PaginatedDataListItem from './PaginatedDataListItem';
|
|||||||
class PaginatedDataList extends React.Component {
|
class PaginatedDataList extends React.Component {
|
||||||
constructor(props) {
|
constructor(props) {
|
||||||
super(props);
|
super(props);
|
||||||
this.state = {
|
|
||||||
height: 0,
|
|
||||||
};
|
|
||||||
this.ref = React.createRef();
|
|
||||||
this.handleSetPage = this.handleSetPage.bind(this);
|
this.handleSetPage = this.handleSetPage.bind(this);
|
||||||
this.handleSetPageSize = this.handleSetPageSize.bind(this);
|
this.handleSetPageSize = this.handleSetPageSize.bind(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
componentDidUpdate(prevProps) {
|
|
||||||
const { items } = this.props;
|
|
||||||
if (prevProps.items !== items) {
|
|
||||||
this.findHeight();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
findHeight() {
|
|
||||||
if (!this.ref || !this.ref.current) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
const { state } = this;
|
|
||||||
const height = this.ref.current.scrollHeight;
|
|
||||||
if (height && height !== state.height) {
|
|
||||||
this.setState({
|
|
||||||
height: this.ref.current.scrollHeight,
|
|
||||||
});
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
handleSetPage(event, pageNumber) {
|
handleSetPage(event, pageNumber) {
|
||||||
const { history, qsConfig } = this.props;
|
const { history, qsConfig } = this.props;
|
||||||
const { search } = history.location;
|
const { search } = history.location;
|
||||||
@@ -90,7 +66,6 @@ class PaginatedDataList extends React.Component {
|
|||||||
i18n,
|
i18n,
|
||||||
renderToolbar,
|
renderToolbar,
|
||||||
} = this.props;
|
} = this.props;
|
||||||
const { height } = this.state;
|
|
||||||
const columns = toolbarColumns.length
|
const columns = toolbarColumns.length
|
||||||
? toolbarColumns
|
? toolbarColumns
|
||||||
: [
|
: [
|
||||||
@@ -110,14 +85,8 @@ class PaginatedDataList extends React.Component {
|
|||||||
const emptyContentTitle = i18n._(t`No ${pluralizedItemName} Found `);
|
const emptyContentTitle = i18n._(t`No ${pluralizedItemName} Found `);
|
||||||
|
|
||||||
let Content;
|
let Content;
|
||||||
if (hasContentLoading) {
|
if (hasContentLoading && items.length <= 0) {
|
||||||
Content = (
|
Content = <ContentLoading />;
|
||||||
<ContentLoading
|
|
||||||
css={`
|
|
||||||
min-height: ${height}px;
|
|
||||||
`}
|
|
||||||
/>
|
|
||||||
);
|
|
||||||
} else if (contentError) {
|
} else if (contentError) {
|
||||||
Content = <ContentError error={contentError} />;
|
Content = <ContentError error={contentError} />;
|
||||||
} else if (items.length <= 0) {
|
} else if (items.length <= 0) {
|
||||||
@@ -131,7 +100,7 @@ class PaginatedDataList extends React.Component {
|
|||||||
}
|
}
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div ref={this.ref}>
|
<Fragment>
|
||||||
<ListHeader
|
<ListHeader
|
||||||
itemCount={itemCount}
|
itemCount={itemCount}
|
||||||
renderToolbar={renderToolbar}
|
renderToolbar={renderToolbar}
|
||||||
@@ -160,7 +129,7 @@ class PaginatedDataList extends React.Component {
|
|||||||
onPerPageSelect={this.handleSetPageSize}
|
onPerPageSelect={this.handleSetPageSize}
|
||||||
/>
|
/>
|
||||||
) : null}
|
) : null}
|
||||||
</div>
|
</Fragment>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user