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

[ML] Transforms: Improves transform list reloading behavior. #164296

Merged
Merged
Changes from 1 commit
Commits
Show all changes
64 commits
Select commit Hold shift + click to select a range
3919a8b
migrate transform list to use react-query
walterra Aug 21, 2023
ec2bd1c
refactor inline useQuery to custom hook. cleanup useApi.
walterra Aug 21, 2023
04ae3c0
migrate wizard to use react-query
walterra Aug 22, 2023
2daa660
fix i18n
walterra Aug 22, 2023
c23dc68
migrate cloning to use react-query
walterra Aug 22, 2023
a8ee0ea
remove getTransformStats from useApi
walterra Aug 22, 2023
a2978b2
migrate update to use react-query
walterra Aug 22, 2023
1f55030
migrate preview to use react-query
walterra Aug 22, 2023
7d5107b
migrate reauthorize to use react-query
walterra Aug 22, 2023
e7d1c0e
migrate reset to use react-query
walterra Aug 22, 2023
9c47fe6
migrate stop to use react-query
walterra Aug 22, 2023
cb904c0
migrate schedule now to use react-query
walterra Aug 22, 2023
1526d62
migrate more to react-query
walterra Aug 22, 2023
8cade10
migrate rest of useApi to react-query
walterra Aug 22, 2023
0614d00
remove unnecessary type guards
walterra Aug 22, 2023
5f04ab7
remove unnecessary type guards
walterra Aug 22, 2023
c4b4d53
cleanup
walterra Aug 22, 2023
be3e0fc
cleanup
walterra Aug 22, 2023
3080150
refactor IndexService into custom hooks using react-query
walterra Aug 22, 2023
d302856
fix tests
walterra Aug 23, 2023
5fbaec2
remove success toasts
walterra Aug 23, 2023
b986a42
fix i18n
walterra Aug 23, 2023
32c12eb
refactor AuthorizationProvider into useAuthorization hook.
walterra Aug 24, 2023
27233be
fix react-query caching
walterra Aug 24, 2023
6a00eef
cleanup
walterra Aug 24, 2023
4802a9a
fix authorization hooks
walterra Aug 24, 2023
9acea75
cleanup
walterra Aug 24, 2023
c135c95
cleanup
walterra Aug 24, 2023
70a8d63
return mutate only instead of whole mutation from custom hooks
walterra Aug 24, 2023
61b300a
cleanup
walterra Aug 24, 2023
bfbb3dc
migrate enzyme-snapshots to react-testing-lib
walterra Aug 24, 2023
a6a7c70
client side code no longer relies on privileges
walterra Aug 25, 2023
9d44654
fix jest tests
walterra Aug 25, 2023
6beaef4
fix i18n
walterra Aug 25, 2023
b4da48b
error modal
walterra Aug 25, 2023
06042c7
migrate to updated toMountPoint
walterra Aug 25, 2023
c4d1811
linting
walterra Aug 25, 2023
ed56944
tweak react-query default settings
walterra Aug 25, 2023
cc7426d
move useRefreshTransformList to hooks folder
walterra Aug 25, 2023
95ff5c0
remove ununused code. tweak empty list state
walterra Aug 25, 2023
1c4c3c2
adds retry button to warning callout for no transform nodes.
walterra Aug 25, 2023
4ce9526
fix jest test
walterra Aug 25, 2023
9319b13
Merge branch 'main' into ml-transform-fix-transform-list-reload
walterra Aug 28, 2023
04aa299
Merge branch 'main' into ml-transform-fix-transform-list-reload
walterra Aug 28, 2023
07212e8
Merge branch 'main' into ml-transform-fix-transform-list-reload
walterra Aug 30, 2023
d7db6af
Merge branch 'main' into ml-transform-fix-transform-list-reload
walterra Aug 31, 2023
f25ea75
add null checks
walterra Aug 31, 2023
c6b72a6
cleanup types
walterra Aug 31, 2023
ee46ca2
fix passing on populated fields
walterra Aug 31, 2023
1fa7a2e
refactor useCreateTransform for consistency
walterra Aug 31, 2023
493f52d
move fetching transform nodes to its own hook
walterra Aug 31, 2023
9b02239
refactor EuiPageContent_Deprecated
walterra Aug 31, 2023
a47947c
revert space after preview text
walterra Aug 31, 2023
4efc4bd
tweak capabilities checks
walterra Aug 31, 2023
0a26daf
fix i18n
walterra Aug 31, 2023
279e526
fix handling options default
walterra Aug 31, 2023
534ac1f
Merge branch 'main' into ml-transform-fix-transform-list-reload
walterra Aug 31, 2023
28aeedd
Merge branch 'main' into ml-transform-fix-transform-list-reload
walterra Sep 1, 2023
f0e555f
fix populated fields cleanup
walterra Sep 1, 2023
0a73faa
Merge branch 'main' into ml-transform-fix-transform-list-reload
walterra Sep 1, 2023
6144781
Merge branch 'main' into ml-transform-fix-transform-list-reload
walterra Sep 1, 2023
2091a57
Merge branch 'main' into ml-transform-fix-transform-list-reload
walterra Sep 1, 2023
d10bdb9
Merge branch 'main' into ml-transform-fix-transform-list-reload
walterra Sep 1, 2023
ecedbad
Merge branch 'main' into ml-transform-fix-transform-list-reload
walterra Sep 1, 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
Prev Previous commit
Next Next commit
fix jest tests
walterra committed Aug 25, 2023
commit 9d44654919c4a1bed668100237fdec6edc948445
9 changes: 9 additions & 0 deletions x-pack/plugins/transform/common/types/capabilities.ts
Original file line number Diff line number Diff line change
@@ -5,6 +5,8 @@
* 2.0.
*/

import { isPopulatedObject } from '@kbn/ml-is-populated-object';

export const getInitialTransformCapabilities = (initialSetting = false) => ({
canCreateTransform: initialSetting,
canCreateTransformAlerts: initialSetting,
@@ -19,6 +21,13 @@ export const getInitialTransformCapabilities = (initialSetting = false) => ({
canUseTransformAlerts: initialSetting,
});

export const isTransformCapabilities = (arg: unknown): arg is TransformCapabilities => {
return (
isPopulatedObject(arg, Object.keys(getInitialTransformCapabilities())) &&
Object.values(arg).every((d) => typeof d === 'boolean')
);
};

export type TransformCapabilities = ReturnType<typeof getInitialTransformCapabilities>;
export type TransformCapability = keyof TransformCapabilities;

Original file line number Diff line number Diff line change
@@ -5,12 +5,20 @@
* 2.0.
*/

import type { PrivilegesAndCapabilities } from '../../../common/types/capabilities';
import {
getInitialTransformCapabilities,
isTransformCapabilities,
type TransformCapabilities,
} from '../../../common/types/capabilities';

import { useAppDependencies } from '../app_dependencies';

export const useTransformCapabilities = () => {
const { application } = useAppDependencies();

return application.capabilities.transform as PrivilegesAndCapabilities['capabilities'];
if (isTransformCapabilities(application?.capabilities?.transform)) {
return application.capabilities.transform as TransformCapabilities;
qn895 marked this conversation as resolved.
Show resolved Hide resolved
}

return getInitialTransformCapabilities();
};
Original file line number Diff line number Diff line change
@@ -46,7 +46,7 @@ describe('Transform: Transform List <TransformList />', () => {
);

await waitFor(() => {
expect(useQueryMock).toHaveBeenCalledTimes(22);
expect(useQueryMock).toHaveBeenCalledTimes(4);
expect(container.textContent).toContain('Reload');
});
});
Original file line number Diff line number Diff line change
@@ -24,6 +24,6 @@ describe('Transform: <TransformManagementSection />', () => {
</QueryClientProvider>
);

expect(container.textContent).toBe('Checking privileges…');
expect(container.textContent).toContain('Missing permission');
});
});
Original file line number Diff line number Diff line change
@@ -5,6 +5,8 @@
* 2.0.
*/

import { type TransformCapabilities } from '../common/types/capabilities';

import { extractMissingPrivileges, getPrivilegesAndCapabilities } from './capabilities';

describe('has_privilege_factory', () => {
@@ -65,9 +67,10 @@ describe('has_privilege_factory', () => {

describe('getPrivilegesAndCapabilities', () => {
it('returns full capabilities if provided both monitor and admin cluster privileges', () => {
const fullCapabilities = {
const fullCapabilities: TransformCapabilities = {
canCreateTransform: true,
canCreateTransformAlerts: true,
canDeleteIndex: true,
canDeleteTransform: true,
canGetTransform: true,
canPreviewTransform: true,
@@ -91,9 +94,10 @@ describe('has_privilege_factory', () => {
});
});
it('returns view only capabilities if provided only monitor cluster privileges', () => {
const viewOnlyCapabilities = {
const viewOnlyCapabilities: TransformCapabilities = {
canCreateTransform: false,
canCreateTransformAlerts: false,
canDeleteIndex: false,
canDeleteTransform: false,
canGetTransform: true,
canPreviewTransform: false,
@@ -119,9 +123,10 @@ describe('has_privilege_factory', () => {
});
});
it('returns no capabilities and all the missing privileges if no cluster privileges', () => {
const noCapabilities = {
const noCapabilities: TransformCapabilities = {
canCreateTransform: false,
canCreateTransformAlerts: false,
canDeleteIndex: false,
canDeleteTransform: false,
canGetTransform: false,
canPreviewTransform: false,