-
Notifications
You must be signed in to change notification settings - Fork 916
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
[D&D] Fixes autosave with debounce #1965
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,5 @@ | ||
@import "@elastic/eui/src/global_styling/variables/header"; | ||
@import "@elastic/eui/src/global_styling/variables/form"; | ||
|
||
$osdHeaderOffset: $euiHeaderHeightCompensation * 2; | ||
$osdHeaderOffset: $euiHeaderHeightCompensation; | ||
$wizSideNavWidth: 470px; |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -5,6 +5,7 @@ | |
|
||
import React, { useCallback, useMemo, useState } from 'react'; | ||
import { cloneDeep } from 'lodash'; | ||
import { useDebounce } from 'react-use'; | ||
import { useTypedDispatch, useTypedSelector } from '../../utils/state_management'; | ||
import { DefaultEditorAggParams } from '../../../../../vis_default_editor/public'; | ||
import { Title } from './title'; | ||
|
@@ -13,13 +14,15 @@ import { useOpenSearchDashboards } from '../../../../../opensearch_dashboards_re | |
import { WizardServices } from '../../../types'; | ||
import { IAggType } from '../../../../../data/public'; | ||
import { saveDraftAgg, editDraftAgg } from '../../utils/state_management/visualization_slice'; | ||
import { setValid } from '../../utils/state_management/metadata_slice'; | ||
import { setValidity } from '../../utils/state_management/metadata_slice'; | ||
|
||
const EDITOR_KEY = 'CONFIG_PANEL'; | ||
|
||
export function SecondaryPanel() { | ||
const draftAgg = useTypedSelector((state) => state.visualization.activeVisualization!.draftAgg); | ||
const valid = useTypedSelector((state) => state.metadata.editorState.valid[EDITOR_KEY]); | ||
const isEditorValid = useTypedSelector( | ||
(state) => state.metadata.editorState.validity[EDITOR_KEY] | ||
); | ||
const [touched, setTouched] = useState(false); | ||
const dispatch = useTypedDispatch(); | ||
const vizType = useVisualizationType(); | ||
|
@@ -56,18 +59,27 @@ export function SecondaryPanel() { | |
(isValid: boolean) => { | ||
// Set validity state globally | ||
dispatch( | ||
setValid({ | ||
setValidity({ | ||
key: EDITOR_KEY, | ||
valid: isValid, | ||
}) | ||
); | ||
}, | ||
[dispatch] | ||
); | ||
|
||
// Autosave changes if valid | ||
if (valid) { | ||
// Autosave is agg value has changed and edits are valid | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. did you mean "Autosave if agg value..."? |
||
useDebounce( | ||
() => { | ||
if (isEditorValid) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Should we check if isTouched? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
I'm setting |
||
dispatch(saveDraftAgg()); | ||
} else { | ||
// To indicate that an invalid edit was made | ||
setTouched(true); | ||
} | ||
}, | ||
[dispatch, valid] | ||
200, | ||
[draftAgg, isEditorValid] | ||
); | ||
|
||
return ( | ||
|
@@ -81,7 +93,7 @@ export function SecondaryPanel() { | |
setValidity={handleSetValid} | ||
setTouched={setTouched} | ||
schemas={schemas} | ||
formIsTouched={false} | ||
formIsTouched={touched} | ||
groupName={selectedSchema?.group ?? 'none'} | ||
metricAggs={[]} | ||
state={{ | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -16,9 +16,9 @@ | |
} | ||
|
||
&__handFieldSvg { | ||
animation: wizDragAnimation 2s ease-in-out infinite alternate; | ||
animation: wizDragAnimation 6s ease-in-out infinite forwards; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. do we have the specs for this are we kind of eyeballing it? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. For now its eyeballing. Dont want it to be too distracting, which is why i changed it to include a pause and take longer to loop. |
||
position: absolute; | ||
top: 43%; | ||
top: 34.5%; | ||
} | ||
} | ||
|
||
|
@@ -27,7 +27,15 @@ | |
transform: none; | ||
} | ||
|
||
30% { | ||
transform: translate(116%, -80%); | ||
} | ||
|
||
60% { | ||
transform: none; | ||
} | ||
|
||
100% { | ||
transform: translate(65%, -30%); | ||
transform: none; | ||
} | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nice, thanks for fixing - beat me to it!