Skip to content

Commit

Permalink
Fixes #37112 - Remove query-string dependency (Katello#11025)
Browse files Browse the repository at this point in the history
* Fixes #37112 - Remove query-string dependency
* Refs #37112 - remove unsupported ouiaId
  • Loading branch information
jeremylenz authored Jun 25, 2024
1 parent bc07be6 commit 57167f3
Show file tree
Hide file tree
Showing 9 changed files with 37 additions and 97 deletions.
1 change: 0 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,6 @@
"angular": "1.8.2",
"bootstrap-select": "1.13.18",
"ngreact": "^0.5.0",
"query-string": "^6.1.0",
"react-bootstrap": "^0.32.1",
"use-deep-compare-effect": "^1.6.1"
}
Expand Down
1 change: 0 additions & 1 deletion webpack/components/Content/ContentTable.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@ const ContentTable = ({ content, tableSchema, onPaginationChange }) => {
loadingText={__('Loading')}
>
<Table
ouiaId="content-table-table"
columns={tableSchema}
rows={results}
pagination={pagination}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ exports[`Content Table should render and contain appropriate components 1`] = `
}
itemCount={2}
onPaginationChange={[Function]}
ouiaId="content-table-table"
pagination={Object {}}
rows={
Array [
Expand Down
72 changes: 33 additions & 39 deletions webpack/scenes/ModuleStreams/ModuleStreamsPage.js
Original file line number Diff line number Diff line change
@@ -1,59 +1,53 @@
import React, { Component } from 'react';
import React, { useState, useEffect } from 'react';
import PropTypes from 'prop-types';
import qs from 'query-string';
import { useUrlParams } from 'foremanReact/components/PF4/TableIndexPage/Table/TableHooks';
import { translate as __ } from 'foremanReact/common/I18n';
import { orgId } from '../../services/api';
import TableSchema from '../ModuleStreams/ModuleStreamsTableSchema';
import GenericContentPage from '../../components/Content/GenericContentPage';

class ModuleStreamsPage extends Component {
constructor(props) {
super(props);
const ModuleStreamsPage = (props) => {
const { searchParam } = useUrlParams();
const [searchQuery, setSearchQuery] = useState(searchParam || '');
const { getModuleStreams } = props;

const queryParams = qs.parse(this.props.location.search);
this.state = {
searchQuery: queryParams.search || '',
};
}

componentDidMount() {
this.props.getModuleStreams({
search: this.state.searchQuery,
useEffect(() => {
getModuleStreams({
search: searchQuery,
});
}
}, [getModuleStreams, searchQuery]);

onPaginationChange = (pagination) => {
this.props.getModuleStreams({
const onPaginationChange = (pagination) => {
props.getModuleStreams({
...pagination,
});
};

onSearch = (search) => {
this.props.getModuleStreams({ search });
const onSearch = (search) => {
props.getModuleStreams({ search });
};

updateSearchQuery = (searchQuery) => {
this.setState({ searchQuery });
const updateSearchQuery = (newSearchQuery) => {
setSearchQuery(newSearchQuery);
};

render() {
const { moduleStreams } = this.props;
return (
<GenericContentPage
header={__('Module Streams')}
content={moduleStreams}
tableSchema={TableSchema}
onSearch={this.onSearch}
autocompleteEndpoint="/katello/api/v2/module_streams"
autocompleteQueryParams={{ organization_id: orgId() }}
bookmarkController="katello_module_streams"
updateSearchQuery={this.updateSearchQuery}
initialInputValue={this.state.searchQuery}
onPaginationChange={this.onPaginationChange}
/>
);
}
}
const { moduleStreams } = props;
return (
<GenericContentPage
header={__('Module Streams')}
content={moduleStreams}
tableSchema={TableSchema}
onSearch={onSearch}
autocompleteEndpoint="/katello/api/v2/module_streams"
autocompleteQueryParams={{ organization_id: orgId() }}
bookmarkController="katello_module_streams"
updateSearchQuery={updateSearchQuery}
initialInputValue={searchQuery}
onPaginationChange={onPaginationChange}
/>
);
};


ModuleStreamsPage.propTypes = {
location: PropTypes.shape({
Expand Down
Original file line number Diff line number Diff line change
@@ -1,19 +1,21 @@
import React from 'react';
import { shallow } from 'enzyme';
import toJson from 'enzyme-to-json';
import * as hooks from 'foremanReact/components/PF4/TableIndexPage/Table/TableHooks';
import ModuleStreamsPage from '../ModuleStreamsPage';
import GenericContentPage from '../../../components/Content/GenericContentPage';

describe('Module streams page', () => {
it('should render and contain appropiate components', async () => {
const moduleStreams = {};
const mockLocation = { search: '' };
jest.spyOn(hooks, 'useUrlParams').mockImplementation(() => ({
searchParam: '',
}));
const getModuleStreams = () => {};

const wrapper = shallow(<ModuleStreamsPage
moduleStreams={moduleStreams}
getModuleStreams={getModuleStreams}
location={mockLocation}
/>);

expect(toJson(wrapper)).toMatchSnapshot();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,6 @@ exports[`Module streams table should render and contain appropiate components 1`
}
itemCount={0}
onPaginationChange={[Function]}
ouiaId="content-table-table"
pagination={Object {}}
rows={Array []}
/>
Expand Down
22 changes: 0 additions & 22 deletions webpack/utils/__tests__/useParamsWithHash.test.js

This file was deleted.

16 changes: 0 additions & 16 deletions webpack/utils/paramsFromHash.js

This file was deleted.

14 changes: 0 additions & 14 deletions webpack/utils/useUrlParams.js

This file was deleted.

0 comments on commit 57167f3

Please sign in to comment.