Skip to content

Commit

Permalink
[UnifiedFieldList] Address PR comments
Browse files Browse the repository at this point in the history
  • Loading branch information
jughosta committed Oct 27, 2022
1 parent a27f79c commit cdbceeb
Show file tree
Hide file tree
Showing 7 changed files with 19 additions and 19 deletions.
2 changes: 1 addition & 1 deletion src/plugins/unified_field_list/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ const { fieldGroups } = useGroupedFields({
<FieldListGrouped
fieldGroups={fieldGroups}
fieldsExistenceStatus={fieldsExistenceReader.getFieldsExistenceStatus(currentDataViewId)}
existFieldsInIndex={!!allFields.length}
fieldsExistInIndex={!!allFields.length}
renderFieldItem={renderFieldItem}
screenReaderDescriptionForSearchInputId={fieldSearchDescriptionId}
/>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ describe('UnifiedFieldList <FieldListGrouped /> + useGroupedFields()', () => {
defaultProps = {
fieldGroups: {},
fieldsExistenceStatus: ExistenceFetchStatus.succeeded,
existFieldsInIndex: true,
fieldsExistInIndex: true,
screenReaderDescriptionForSearchInputId: 'testId',
renderFieldItem: jest.fn(({ field, itemIndex, groupIndex }) => (
<EuiText
Expand Down Expand Up @@ -181,7 +181,7 @@ describe('UnifiedFieldList <FieldListGrouped /> + useGroupedFields()', () => {
const wrapper = await mountGroupedList({
listProps: {
...defaultProps,
existFieldsInIndex: false,
fieldsExistInIndex: false,
fieldsExistenceStatus: ExistenceFetchStatus.failed,
},
hookParams: {
Expand All @@ -196,7 +196,7 @@ describe('UnifiedFieldList <FieldListGrouped /> + useGroupedFields()', () => {
expect(wrapper.find(FieldsAccordion)).toHaveLength(3);
expect(wrapper.find(EuiLoadingSpinner)).toHaveLength(0);
expect(
wrapper.find(NoFieldsCallout).map((callout) => callout.prop('existFieldsInIndex'))
wrapper.find(NoFieldsCallout).map((callout) => callout.prop('fieldsExistInIndex'))
).toStrictEqual([false, false, false]);
});

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,15 +31,15 @@ function getDisplayedFieldsLength<T extends FieldListItem>(
export interface FieldListGroupedProps<T extends FieldListItem> {
fieldGroups: FieldListGroups<T>;
fieldsExistenceStatus: ExistenceFetchStatus;
existFieldsInIndex: boolean;
fieldsExistInIndex: boolean;
renderFieldItem: FieldsAccordionProps<T>['renderFieldItem'];
screenReaderDescriptionForSearchInputId?: string;
}

function InnerFieldListGrouped<T extends FieldListItem = DataViewField>({
fieldGroups,
fieldsExistenceStatus,
existFieldsInIndex,
fieldsExistInIndex,
renderFieldItem,
screenReaderDescriptionForSearchInputId,
}: FieldListGroupedProps<T>) {
Expand Down Expand Up @@ -220,7 +220,7 @@ function InnerFieldListGrouped<T extends FieldListItem = DataViewField>({
isAffectedByGlobalFilter={fieldGroup.isAffectedByGlobalFilter}
isAffectedByTimerange={fieldGroup.isAffectedByTimeFilter}
isAffectedByFieldFilter={fieldGroup.fieldCount !== fieldGroup.fields.length}
existFieldsInIndex={!!existFieldsInIndex}
fieldsExistInIndex={!!fieldsExistInIndex}
defaultNoFieldsMessage={fieldGroup.defaultNoFieldsMessage}
/>
)}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import { NoFieldsCallout } from './no_fields_callout';

describe('UnifiedFieldList <NoFieldCallout />', () => {
it('renders correctly for index with no fields', () => {
const component = shallow(<NoFieldsCallout existFieldsInIndex={false} />);
const component = shallow(<NoFieldsCallout fieldsExistInIndex={false} />);
expect(component).toMatchInlineSnapshot(`
<EuiCallOut
color="warning"
Expand All @@ -22,7 +22,7 @@ describe('UnifiedFieldList <NoFieldCallout />', () => {
`);
});
it('renders correctly when empty with no filters/timerange reasons', () => {
const component = shallow(<NoFieldsCallout existFieldsInIndex={true} />);
const component = shallow(<NoFieldsCallout fieldsExistInIndex={true} />);
expect(component).toMatchInlineSnapshot(`
<EuiCallOut
color="warning"
Expand All @@ -33,7 +33,7 @@ describe('UnifiedFieldList <NoFieldCallout />', () => {
});
it('renders correctly with passed defaultNoFieldsMessage', () => {
const component = shallow(
<NoFieldsCallout existFieldsInIndex={true} defaultNoFieldsMessage="No empty fields" />
<NoFieldsCallout fieldsExistInIndex={true} defaultNoFieldsMessage="No empty fields" />
);
expect(component).toMatchInlineSnapshot(`
<EuiCallOut
Expand All @@ -46,7 +46,7 @@ describe('UnifiedFieldList <NoFieldCallout />', () => {

it('renders properly when affected by field filter', () => {
const component = shallow(
<NoFieldsCallout existFieldsInIndex={true} isAffectedByFieldFilter={true} />
<NoFieldsCallout fieldsExistInIndex={true} isAffectedByFieldFilter={true} />
);
expect(component).toMatchInlineSnapshot(`
<EuiCallOut
Expand All @@ -69,7 +69,7 @@ describe('UnifiedFieldList <NoFieldCallout />', () => {
it('renders correctly when affected by global filters and timerange', () => {
const component = shallow(
<NoFieldsCallout
existFieldsInIndex={true}
fieldsExistInIndex={true}
isAffectedByTimerange={true}
isAffectedByGlobalFilter={true}
defaultNoFieldsMessage="There are no available fields that contain data."
Expand Down Expand Up @@ -99,7 +99,7 @@ describe('UnifiedFieldList <NoFieldCallout />', () => {
it('renders correctly when affected by global filters and field filters', () => {
const component = shallow(
<NoFieldsCallout
existFieldsInIndex={true}
fieldsExistInIndex={true}
isAffectedByTimerange={true}
isAffectedByFieldFilter={true}
defaultNoFieldsMessage="There are no available fields that contain data."
Expand Down Expand Up @@ -129,7 +129,7 @@ describe('UnifiedFieldList <NoFieldCallout />', () => {
it('renders correctly when affected by field filters, global filter and timerange', () => {
const component = shallow(
<NoFieldsCallout
existFieldsInIndex={true}
fieldsExistInIndex={true}
isAffectedByFieldFilter={true}
isAffectedByTimerange={true}
isAffectedByGlobalFilter={true}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,19 +18,19 @@ const defaultNoFieldsMessageCopy = i18n.translate(
);

export const NoFieldsCallout = ({
existFieldsInIndex,
fieldsExistInIndex,
defaultNoFieldsMessage = defaultNoFieldsMessageCopy,
isAffectedByFieldFilter = false,
isAffectedByTimerange = false,
isAffectedByGlobalFilter = false,
}: {
existFieldsInIndex: boolean;
fieldsExistInIndex: boolean;
isAffectedByFieldFilter?: boolean;
defaultNoFieldsMessage?: string;
isAffectedByTimerange?: boolean;
isAffectedByGlobalFilter?: boolean;
}) => {
if (!existFieldsInIndex) {
if (!fieldsExistInIndex) {
return (
<EuiCallOut
size="s"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -618,7 +618,7 @@ export const InnerFormBasedDataPanel = function InnerFormBasedDataPanel({
<FieldListGrouped<IndexPatternField>
fieldGroups={fieldGroups}
fieldsExistenceStatus={fieldsExistenceStatus}
existFieldsInIndex={!!allFields.length}
fieldsExistInIndex={!!allFields.length}
renderFieldItem={renderFieldItem}
screenReaderDescriptionForSearchInputId={fieldSearchDescriptionId}
/>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -199,7 +199,7 @@ export function TextBasedDataPanel({
fieldsExistenceStatus={
dataHasLoaded ? ExistenceFetchStatus.succeeded : ExistenceFetchStatus.unknown
}
existFieldsInIndex={Boolean(fieldList.length)}
fieldsExistInIndex={Boolean(fieldList.length)}
renderFieldItem={renderFieldItem}
screenReaderDescriptionForSearchInputId={fieldSearchDescriptionId}
/>
Expand Down

0 comments on commit cdbceeb

Please sign in to comment.