Skip to content
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

[Test] Add field list cache busting for functional tests #173447

Closed
wants to merge 168 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
168 commits
Select commit Hold shift + click to select a range
ed19554
add stale while revalidate
mattkime Oct 15, 2023
da2dddc
add cache busting
mattkime Oct 15, 2023
a3ae0de
Merge branch 'main' into fields_for_wildcard_stale_while_revalidate
mattkime Oct 16, 2023
2b1f7f6
Merge branch 'main' into fields_for_wildcard_stale_while_revalidate
mattkime Oct 16, 2023
fdcbfb6
garbage test code mostly to be removed later
mattkime Oct 17, 2023
7f06095
Update src/plugins/data_views/server/rest_api_routes/internal/fields_…
mattkime Oct 30, 2023
671461f
Update src/plugins/data_views/public/data_views/data_views_api_client.ts
mattkime Nov 1, 2023
2c61688
Update src/plugins/data_views/public/data_views/data_views_api_client.ts
mattkime Nov 1, 2023
5dc9eee
Merge branch 'fields_for_wildcard_stale_while_revalidate' of github.c…
mattkime Nov 1, 2023
797263d
Merge branch 'main' into fields_for_wildcard_stale_while_revalidate
mattkime Nov 1, 2023
691df4f
caching fields requests mostly working
mattkime Nov 2, 2023
609a962
implement advanced setting for cache length AND etag headers
mattkime Nov 2, 2023
2aec419
add mock
mattkime Nov 2, 2023
2abf10e
attempt to fix discover alerting functional test
mattkime Nov 2, 2023
4de45b5
304 sohuldn't accept body
mattkime Nov 2, 2023
8d8fbb4
try setting cache to zero to see if fewer tests fail
mattkime Nov 3, 2023
146ba0b
remove some comments
mattkime Nov 4, 2023
567e250
Merge branch 'main' into fields_for_wildcard_stale_while_revalidate
mattkime Nov 4, 2023
830b959
fix tests
mattkime Nov 5, 2023
9638c36
restore default cache max-age
mattkime Nov 5, 2023
442c048
fix 304 responses, implement refresh button, hopefully fix a test
mattkime Nov 7, 2023
c0e4e26
Merge branch 'main' into fields_for_wildcard_stale_while_revalidate
mattkime Nov 7, 2023
3f533ab
fix tests
mattkime Nov 7, 2023
ffde29e
revert fields_for_wildcard changes
mattkime Nov 7, 2023
40704e7
revert fields_for_wildcard changes
mattkime Nov 7, 2023
4b02f2d
functional test fixes
mattkime Nov 7, 2023
f294f75
Merge branch 'main' into fields_for_wildcard_stale_while_revalidate
mattkime Nov 7, 2023
78bd537
disable cache for sanity check
mattkime Nov 7, 2023
86681be
cleanup
mattkime Nov 7, 2023
4099571
fix test
mattkime Nov 7, 2023
97e7689
restore default cache time length
mattkime Nov 7, 2023
7b7189d
functional test fix
mattkime Nov 8, 2023
7d93e2b
Merge branch 'main' into fields_for_wildcard_stale_while_revalidate
mattkime Nov 9, 2023
5de584f
Merge branch 'main' of github.com:elastic/kibana into fields_for_wild…
mattkime Nov 9, 2023
5313afb
Merge branch 'main' of github.com:elastic/kibana into fields_for_wild…
mattkime Nov 10, 2023
521e028
hopefully fix some functional tests
mattkime Nov 10, 2023
d93f86b
[CI] Auto-commit changed files from 'node scripts/lint_ts_projects --…
kibanamachine Nov 10, 2023
4845511
add vary header which should clear cache on user change
mattkime Nov 10, 2023
9dd5d15
Merge branch 'fields_for_wildcard_stale_while_revalidate' of github.c…
mattkime Nov 10, 2023
7f52130
test fixes
mattkime Nov 10, 2023
1566350
Merge branch 'main' of github.com:elastic/kibana into fields_for_wild…
mattkime Nov 10, 2023
abcf7d6
I think I implemented the Vary header
mattkime Nov 11, 2023
5f123ae
[CI] Auto-commit changed files from 'node scripts/lint_ts_projects --…
kibanamachine Nov 11, 2023
ebc5c67
remove unused type
mattkime Nov 11, 2023
62e3d79
t Merge branch 'fields_for_wildcard_stale_while_revalidate' of github…
mattkime Nov 11, 2023
efdc60a
[CI] Auto-commit changed files from 'node scripts/lint_ts_projects --…
kibanamachine Nov 11, 2023
0b90af3
remove unused type
mattkime Nov 11, 2023
6cc3ba4
Merge branch 'fields_for_wildcard_stale_while_revalidate' of github.c…
mattkime Nov 11, 2023
cbfc4de
fix jest test
mattkime Nov 11, 2023
cde6207
add console.log debugging for functional tests
mattkime Nov 12, 2023
2c0e5d5
add console.log debugging for functional tests
mattkime Nov 12, 2023
e2b2ba7
add refresh button in data view picker, attempt to fix field formatte…
mattkime Nov 12, 2023
c929e5f
functional test fixes
mattkime Nov 12, 2023
8f59cf5
fix transform functional test
mattkime Nov 12, 2023
7e7da4a
fix data view mgmt type filter on refresh
mattkime Nov 12, 2023
fd083a1
try to fix another test
mattkime Nov 12, 2023
b1e3357
Merge branch 'main' into fields_for_wildcard_stale_while_revalidate
mattkime Nov 12, 2023
4e5d94d
script field functional test fixes
mattkime Nov 13, 2023
651a792
I hope I fixed the maps functional test
mattkime Nov 13, 2023
8685243
fix some functional tests
mattkime Nov 13, 2023
7319b18
cleanup and functional test fix
mattkime Nov 13, 2023
45b3dca
don't cache empty responses
mattkime Nov 13, 2023
4b4266f
fix functional tests by removing unneeded code
mattkime Nov 13, 2023
2f11c36
cleanup
mattkime Nov 13, 2023
5e94706
Merge branch 'main' of github.com:elastic/kibana into fields_for_wild…
mattkime Nov 13, 2023
b0f930e
remove console.log statements
mattkime Nov 13, 2023
208f643
use hash instead of userid
mattkime Nov 14, 2023
e101dba
fix browser bundle size
mattkime Nov 14, 2023
6e9e871
Merge branch 'main' of github.com:elastic/kibana into fields_for_wild…
mattkime Nov 14, 2023
eb2e989
add integration tests
mattkime Nov 14, 2023
121c2e8
update refresh button text
mattkime Nov 14, 2023
aa3503b
increase bundle limit
mattkime Nov 14, 2023
7734118
skip flakey test
mattkime Nov 14, 2023
b12cade
Merge branch 'main' of github.com:elastic/kibana into fields_for_wild…
mattkime Nov 14, 2023
247bcaa
skip flakey test
mattkime Nov 14, 2023
66836bd
skip flaky test
mattkime Nov 14, 2023
294dfd1
Merge branch 'main' into fields_for_wildcard_stale_while_revalidate
mattkime Nov 14, 2023
c2d5595
Merge branch 'main' of github.com:elastic/kibana into fields_for_wild…
mattkime Nov 14, 2023
8736f54
Merge branch 'fields_for_wildcard_stale_while_revalidate' of github.c…
mattkime Nov 14, 2023
387b203
update snapshot
mattkime Nov 14, 2023
99b03af
skip scripted field test, its being flaky
mattkime Nov 15, 2023
4246c60
skip scripted field test, its being flaky
mattkime Nov 15, 2023
42bd2f4
refactor security / data view plugin dependency
mattkime Nov 15, 2023
fef8a55
Merge branch 'main' of github.com:elastic/kibana into fields_for_wild…
mattkime Nov 15, 2023
6693cf6
[CI] Auto-commit changed files from 'node scripts/lint_ts_projects --…
kibanamachine Nov 15, 2023
7b384d4
Revert "refactor security / data view plugin dependency"
mattkime Nov 15, 2023
486308a
Merge branch 'fields_for_wildcard_stale_while_revalidate' of github.c…
mattkime Nov 15, 2023
b009721
[CI] Auto-commit changed files from 'node scripts/lint_ts_projects --…
kibanamachine Nov 15, 2023
5c58232
remove circ dependency
mattkime Nov 15, 2023
7445428
Merge branch 'fields_for_wildcard_stale_while_revalidate' of github.c…
mattkime Nov 15, 2023
6ea9098
disable flaky test
mattkime Nov 15, 2023
864d9ef
remove discover refresh button and turn off cache
mattkime Nov 15, 2023
2d7ab2f
fix api integration test
mattkime Nov 15, 2023
dbee901
cleanup
mattkime Nov 15, 2023
80249e5
remove skips
mattkime Nov 16, 2023
f26a084
Merge branch 'main' into fields_for_wildcard_stale_while_revalidate
mattkime Nov 16, 2023
cd4049b
[CI] Auto-commit changed files from 'node scripts/eslint --no-cache -…
kibanamachine Nov 17, 2023
544aa05
Merge branch 'main' into fields_for_wildcard_stale_while_revalidate
mattkime Nov 19, 2023
df2307e
Merge branch 'main' into fields_for_wildcard_stale_while_revalidate
mattkime Nov 21, 2023
0fc9422
Merge branch 'fields_for_wildcard_stale_while_revalidate' of github.c…
mattkime Nov 21, 2023
efa3195
Merge branch 'main' into fields_for_wildcard_stale_while_revalidate
mattkime Nov 21, 2023
e03a3ec
reenable cache but only for classic environment
mattkime Nov 21, 2023
7bae56d
Merge branch 'main' into fields_for_wildcard_stale_while_revalidate
mattkime Nov 22, 2023
5c69712
type cleanup
mattkime Nov 22, 2023
377a5a6
remove user hash from server response
mattkime Nov 22, 2023
7dc380f
Merge branch 'fields_for_wildcard_stale_while_revalidate' of github.c…
mattkime Nov 22, 2023
1a9a450
remove server side user hash header
mattkime Nov 22, 2023
5971b41
typefix
mattkime Nov 22, 2023
fd7adb2
remove unneeded functional test changes
mattkime Nov 22, 2023
278d005
Merge branch 'main' into fields_for_wildcard_stale_while_revalidate
mattkime Nov 23, 2023
55b8191
implement versioned router on fields endpoint
mattkime Nov 27, 2023
1b8704d
Merge branch 'fields_for_wildcard_stale_while_revalidate' of github.c…
mattkime Nov 27, 2023
89c4ff2
fix fields route
mattkime Nov 27, 2023
c0fb816
Merge branch 'main' into fields_for_wildcard_stale_while_revalidate
mattkime Nov 27, 2023
6efa5f1
fix test
mattkime Nov 27, 2023
9723dc3
Merge branch 'fields_for_wildcard_stale_while_revalidate' of github.c…
mattkime Nov 27, 2023
c5c993e
add performance journey
mattkime Nov 27, 2023
6d7212a
remove one serialization
mattkime Nov 27, 2023
ed73b7b
fix api integration test
mattkime Nov 27, 2023
cdeec68
add performance journeys
mattkime Nov 30, 2023
72bbeb7
Merge branch 'main' into fields_for_wildcard_stale_while_revalidate
mattkime Nov 30, 2023
179105b
Merge branch 'main' into fields_for_wildcard_stale_while_revalidate
mattkime Dec 2, 2023
3fa1369
update setting text
mattkime Dec 2, 2023
f40eb1d
use new method for security dependency
mattkime Dec 2, 2023
cf7c893
[CI] Auto-commit changed files from 'node scripts/lint_ts_projects --…
kibanamachine Dec 2, 2023
781a580
Merge branch 'main' into fields_for_wildcard_stale_while_revalidate
mattkime Dec 2, 2023
9b719cc
Revert "use new method for security dependency"
mattkime Dec 2, 2023
780fc78
Merge branch 'fields_for_wildcard_stale_while_revalidate' of github.c…
mattkime Dec 2, 2023
ccd243a
[CI] Auto-commit changed files from 'node scripts/lint_ts_projects --…
kibanamachine Dec 2, 2023
9ec2773
Revert "Revert "use new method for security dependency""
mattkime Dec 2, 2023
e412172
Merge branch 'fields_for_wildcard_stale_while_revalidate' of github.c…
mattkime Dec 2, 2023
c51b7d2
[CI] Auto-commit changed files from 'node scripts/lint_ts_projects --…
kibanamachine Dec 2, 2023
6d5df9d
add loading text for button, better button push test logic
mattkime Dec 2, 2023
7f7be97
Merge branch 'fields_for_wildcard_stale_while_revalidate' of github.c…
mattkime Dec 2, 2023
3f7fb79
fix i18n name
mattkime Dec 2, 2023
3c1ab44
wait on field list refresh
mattkime Dec 3, 2023
fdcd16c
add refresh button push to serverless index filter test
mattkime Dec 3, 2023
53f1f19
fix ml alert test
mattkime Dec 3, 2023
ebd04c7
fix discover security functional test
mattkime Dec 3, 2023
46c9ee7
functional test fix attempts
mattkime Dec 3, 2023
60b0675
another attempt at fixing the discover security test
mattkime Dec 3, 2023
b563acd
add some debugging to hopefully help with remaining errors
mattkime Dec 3, 2023
b145375
a little more debugging
mattkime Dec 3, 2023
eb0604d
a little more debugging
mattkime Dec 4, 2023
6216b37
attempt to fix lens functional test with additional data view refresh
mattkime Dec 4, 2023
c386791
Merge branch 'main' of github.com:elastic/kibana into fields_for_wild…
mattkime Dec 4, 2023
2bce926
Merge branch 'main' of github.com:elastic/kibana into fields_for_wild…
mattkime Dec 5, 2023
af83362
fix discover alert functional test
mattkime Dec 5, 2023
1d0dcd5
get fresh field list vith data view swapping.
mattkime Dec 6, 2023
797f6ce
fix discover alert functional test
mattkime Dec 6, 2023
913bedb
fix discover alert functional test
mattkime Dec 6, 2023
e6e1e3e
Merge branch 'main' into fields_for_wildcard_stale_while_revalidate
kibanamachine Dec 6, 2023
b3349b1
Merge branch 'main' of github.com:elastic/kibana into fields_for_wild…
mattkime Dec 6, 2023
3f58ecd
fix functional test
mattkime Dec 6, 2023
152d016
Merge branch 'fields_for_wildcard_stale_while_revalidate' of github.c…
mattkime Dec 6, 2023
08a3ea8
cleanup
mattkime Dec 6, 2023
836452a
Merge branch 'main' into fields_for_wildcard_stale_while_revalidate
mattkime Dec 7, 2023
b73f727
Update docs/concepts/data-views.asciidoc
mattkime Dec 7, 2023
c7fbf1e
Merge branch 'main' into fields_for_wildcard_stale_while_revalidate
mattkime Dec 7, 2023
9c4e416
better rendering of refresh button
mattkime Dec 8, 2023
17d4b59
Merge branch 'fields_for_wildcard_stale_while_revalidate' of github.c…
mattkime Dec 8, 2023
44dded0
Merge branch 'main' into fields_for_wildcard_stale_while_revalidate
mattkime Dec 8, 2023
dc9fa0e
cleanup
mattkime Dec 11, 2023
4b17356
Merge branch 'main' of github.com:elastic/kibana into fields_for_wild…
mattkime Dec 11, 2023
082430d
Merge branch 'fields_for_wildcard_stale_while_revalidate' of github.c…
mattkime Dec 11, 2023
985ed11
better caching, add tests
mattkime Dec 11, 2023
d7701c7
Merge branch 'main' into fields_for_wildcard_stale_while_revalidate
mattkime Dec 11, 2023
17c535f
Add field list cache busting for functional tests
davismcphee Dec 15, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 11 additions & 0 deletions docs/concepts/data-views.asciidoc
Original file line number Diff line number Diff line change
Expand Up @@ -172,3 +172,14 @@ WARNING: Deleting a {data-source} breaks all visualizations, saved searches, and

. Find the {data-source} that you want to delete, and then
click image:management/index-patterns/images/delete.png[Delete icon] in the *Actions* column.

[float]
[[data-view-field-cache]]
=== {data-source} field cache

The browser caches {data-source} field lists for increased performance. This is particularly impactful
for {data-sources} with a high field count that span a large number of indices and clusters. The field
list is updated every couple of minutes in typical {kib} usage. Alternatively, use the refresh button on the {data-source}
management detail page to get an updated field list. A force reload of {kib} has the same effect.

The field list may be impacted by changes in indices and user permissions.
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ import type {
ErrorHttpResponseOptions,
KibanaErrorResponseFactory,
KibanaRedirectionResponseFactory,
KibanaNotModifiedResponseFactory,
KibanaSuccessResponseFactory,
KibanaResponseFactory,
LifecycleResponseFactory,
Expand Down Expand Up @@ -51,6 +52,10 @@ const redirectionResponseFactory: KibanaRedirectionResponseFactory = {
redirected: (options: RedirectResponseOptions) => new KibanaResponse(302, options.body, options),
};

const notModifiedResponseFactory: KibanaNotModifiedResponseFactory = {
notModified: (options: HttpResponseOptions = {}) => new KibanaResponse(304, undefined, options),
};

const errorResponseFactory: KibanaErrorResponseFactory = {
badRequest: (options: ErrorHttpResponseOptions = {}) =>
new KibanaResponse(400, options.body || 'Bad Request', options),
Expand Down Expand Up @@ -120,6 +125,7 @@ export const fileResponseFactory = {
export const kibanaResponseFactory: KibanaResponseFactory = {
...successResponseFactory,
...redirectionResponseFactory,
...notModifiedResponseFactory,
...errorResponseFactory,
...fileResponseFactory,
custom: <T extends HttpResponsePayload | ResponseError>(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,8 @@ function setHeaders(response: HapiResponseObject, headers: Record<string, string

const statusHelpers = {
isSuccess: (code: number) => code >= 100 && code < 300,
isRedirect: (code: number) => code >= 300 && code < 400,
isNotModified: (code: number) => code === 304,
isRedirect: (code: number) => code >= 300 && code < 400 && code !== 304,
isError: (code: number) => code >= 400 && code < 600,
};

Expand Down Expand Up @@ -76,7 +77,10 @@ export class HapiResponseAdapter {
if (statusHelpers.isError(kibanaResponse.status)) {
return this.toError(kibanaResponse);
}
if (statusHelpers.isSuccess(kibanaResponse.status)) {
if (
statusHelpers.isSuccess(kibanaResponse.status) ||
statusHelpers.isNotModified(kibanaResponse.status)
) {
return this.toSuccess(kibanaResponse);
}
if (statusHelpers.isRedirect(kibanaResponse.status)) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,7 @@ const createResponseFactoryMock = (): jest.Mocked<KibanaResponseFactory> => ({
ok: jest.fn(),
accepted: jest.fn(),
noContent: jest.fn(),
notModified: jest.fn(),
custom: jest.fn(),
redirected: jest.fn(),
badRequest: jest.fn(),
Expand Down
1 change: 1 addition & 0 deletions packages/core/http/core-http-server/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,7 @@ export type {
IKibanaSocket,
KibanaErrorResponseFactory,
KibanaRedirectionResponseFactory,
KibanaNotModifiedResponseFactory,
KibanaSuccessResponseFactory,
KibanaResponseFactory,
LifecycleResponseFactory,
Expand Down
1 change: 1 addition & 0 deletions packages/core/http/core-http-server/src/router/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,7 @@ export type { IKibanaSocket } from './socket';
export type {
KibanaErrorResponseFactory,
KibanaRedirectionResponseFactory,
KibanaNotModifiedResponseFactory,
KibanaSuccessResponseFactory,
KibanaResponseFactory,
LifecycleResponseFactory,
Expand Down
4 changes: 1 addition & 3 deletions packages/core/http/core-http-server/src/router/response.ts
Original file line number Diff line number Diff line change
Expand Up @@ -95,9 +95,7 @@ export interface FileHttpResponseOptions<T extends HttpResponsePayload | Respons
* @public
*/
export type RedirectResponseOptions = HttpResponseOptions & {
headers: {
location: string;
};
headers?: ResponseHeaders;
};

/**
Expand Down
13 changes: 13 additions & 0 deletions packages/core/http/core-http-server/src/router/response_factory.ts
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,18 @@ export interface KibanaRedirectionResponseFactory {
redirected(options: RedirectResponseOptions): IKibanaResponse;
}

/**
* @public
*/
export interface KibanaNotModifiedResponseFactory {
/**
* Content not modified.
* Status code: `304`.
* @param options - {@link HttpResponseOptions} configures HTTP response body & headers.
*/
notModified(options: HttpResponseOptions): IKibanaResponse;
}

/**
* @public
*/
Expand Down Expand Up @@ -200,6 +212,7 @@ export interface KibanaErrorResponseFactory {
*/
export type KibanaResponseFactory = KibanaSuccessResponseFactory &
KibanaRedirectionResponseFactory &
KibanaNotModifiedResponseFactory &
KibanaErrorResponseFactory & {
/**
* Creates a response with defined status code and payload.
Expand Down
2 changes: 1 addition & 1 deletion packages/kbn-optimizer/limits.yml
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ pageLoadAssetSize:
dataViewEditor: 28082
dataViewFieldEditor: 27000
dataViewManagement: 5100
dataViews: 48300
dataViews: 50000
dataVisualizer: 27530
devTools: 38637
discover: 99999
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,9 @@ export const EditIndexPattern = withRouter(
const [showEditDialog, setShowEditDialog] = useState<boolean>(false);
const [relationships, setRelationships] = useState<SavedObjectRelationWithTitle[]>([]);
const [allowedTypes, setAllowedTypes] = useState<SavedObjectManagementTypeInfo[]>([]);
const [refreshCount, setRefreshCount] = useState<number>(0); // used for forcing rerender of field list
const [isRefreshing, setIsRefreshing] = React.useState(false);

const conflictFieldsUrl = useMemo(() => {
return setStateToKbnUrl(
APP_STATE_STORAGE_KEY,
Expand Down Expand Up @@ -144,7 +147,7 @@ export const EditIndexPattern = withRouter(
setConflictedFields(
indexPattern.fields.getAll().filter((field) => field.type === 'conflict')
);
}, [indexPattern]);
}, [indexPattern, refreshCount]);

useEffect(() => {
setTags(
Expand Down Expand Up @@ -246,8 +249,15 @@ export const EditIndexPattern = withRouter(
deleteIndexPatternClick={() =>
removeHandler([indexPattern as RemoveDataViewProps], <div>{warning}</div>)
}
refreshIndexPatternClick={async () => {
setIsRefreshing(true);
await dataViews.refreshFields(indexPattern, false, true);
setRefreshCount(refreshCount + 1); // rerender field list
setIsRefreshing(false);
}}
defaultIndex={defaultIndex}
canSave={userEditPermission}
isRefreshing={isRefreshing}
>
<EuiHorizontalRule margin="none" />
<EuiSpacer size="l" />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

import React from 'react';
import { i18n } from '@kbn/i18n';
import { EuiButton, EuiButtonEmpty, EuiPageHeader } from '@elastic/eui';
import { EuiButton, EuiButtonEmpty, EuiPageHeader, EuiToolTip } from '@elastic/eui';
import { DataView } from '@kbn/data-views-plugin/public';

interface IndexHeaderProps {
Expand All @@ -17,7 +17,9 @@ interface IndexHeaderProps {
setDefault?: () => void;
editIndexPatternClick?: () => void;
deleteIndexPatternClick?: () => void;
refreshIndexPatternClick?: () => void;
canSave: boolean;
isRefreshing?: boolean;
}

const setDefaultAriaLabel = i18n.translate('indexPatternManagement.editDataView.setDefaultAria', {
Expand All @@ -44,14 +46,32 @@ const removeTooltip = i18n.translate('indexPatternManagement.editDataView.remove
defaultMessage: 'Delete',
});

const refreshAriaLabel = i18n.translate('indexPatternManagement.editDataView.refreshAria', {
defaultMessage: 'Refresh',
});

const refreshTooltip = i18n.translate('indexPatternManagement.editDataView.refreshTooltip', {
defaultMessage: 'Refresh local copy of data view field list',
});

const refreshLabel = i18n.translate('indexPatternManagement.editDataView.refreshLabel', {
defaultMessage: 'Refresh',
});

const isLoadingLabel = i18n.translate('indexPatternManagement.editDataView.refreshLoading', {
defaultMessage: 'Loading...',
});

export const IndexHeader: React.FC<IndexHeaderProps> = ({
defaultIndex,
indexPattern,
setDefault,
editIndexPatternClick,
deleteIndexPatternClick,
refreshIndexPatternClick,
children,
canSave,
isRefreshing,
}) => {
return (
<EuiPageHeader
Expand All @@ -63,10 +83,23 @@ export const IndexHeader: React.FC<IndexHeaderProps> = ({
iconType="pencil"
aria-label={editAriaLabel}
data-test-subj="editIndexPatternButton"
color="primary"
>
{editTooltip}
</EuiButton>
),
<EuiToolTip content={<p>{refreshTooltip}</p>}>
<EuiButtonEmpty
onClick={refreshIndexPatternClick}
iconType="refresh"
aria-label={refreshAriaLabel}
data-test-subj="refreshDataViewButton"
isLoading={isRefreshing}
isDisabled={isRefreshing}
>
{isRefreshing ? isLoadingLabel : refreshLabel}
</EuiButtonEmpty>
</EuiToolTip>,
defaultIndex !== indexPattern.id && setDefault && canSave && indexPattern.isPersisted() && (
<EuiButton
onClick={setDefault}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -284,7 +284,9 @@ export const Tabs: React.FC<TabsProps> = ({

setIndexedFieldTypes(convertToEuiFilterOptions(tempIndexedFieldTypes));
setScriptedFieldLanguages(convertToEuiFilterOptions(tempScriptedFieldLanguages));
}, [indexPattern]);
// need to reset based on changes to fields but indexPattern is the same
// eslint-disable-next-line react-hooks/exhaustive-deps
}, [indexPattern, fields]);

const closeFieldEditor = useCallback(() => {
if (closeEditorHandler.current) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -217,7 +217,7 @@ export const IndexPatternTable = ({
<div>
<EuiLink
{...reactRouterNavigate(history, `patterns/${dataView.id}`)}
data-test-subj={`detail-link-${dataView.name}`}
data-test-subj={`detail-link-${dataView.getName()}`}
>
{dataView.getName()}
{dataView.name ? (
Expand Down
6 changes: 6 additions & 0 deletions src/plugins/data_views/common/constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,12 @@ export const PLUGIN_NAME = 'DataViews';
*/
export const FIELDS_FOR_WILDCARD_PATH = '/internal/data_views/_fields_for_wildcard';

/**
* Fields path. Like fields for wildcard but GET only
* @public
*/
export const FIELDS_PATH = '/internal/data_views/fields';

/**
* Existing indices path
* @public
Expand Down
6 changes: 6 additions & 0 deletions src/plugins/data_views/common/data_views/data_view.ts
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,8 @@ export class DataView extends AbstractDataView implements DataViewBase {
*/
public flattenHit: (hit: Record<string, unknown[]>, deep?: boolean) => Record<string, unknown>;

private etag: string | undefined;

/**
* constructor
* @param config - config data and dependencies
Expand All @@ -77,6 +79,10 @@ export class DataView extends AbstractDataView implements DataViewBase {
this.fields.replaceAll(Object.values(spec.fields || {}));
}

getEtag = () => this.etag;

setEtag = (etag: string | undefined) => (this.etag = etag);

/**
* Returns scripted fields
*/
Expand Down
13 changes: 13 additions & 0 deletions src/plugins/data_views/common/data_views/data_views.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -158,10 +158,23 @@ describe('IndexPatterns', () => {

test('force field refresh', async () => {
const id = '1';
// make sure initial load and subsequent reloads use same params
const args = {
allowHidden: undefined,
allowNoIndex: true,
indexFilter: undefined,
metaFields: false,
pattern: 'something',
rollupIndex: undefined,
type: undefined,
};

await indexPatterns.get(id);
expect(apiClient.getFieldsForWildcard).toBeCalledTimes(1);
expect(apiClient.getFieldsForWildcard).toBeCalledWith(args);
await indexPatterns.get(id, undefined, true);
expect(apiClient.getFieldsForWildcard).toBeCalledTimes(2);
expect(apiClient.getFieldsForWildcard).toBeCalledWith(args);
});

test('getFieldsForWildcard called with allowNoIndex set to true as default ', async () => {
Expand Down
Loading