-
Notifications
You must be signed in to change notification settings - Fork 27
FIX: [DEV-10387] - Fix Widget delete issue #2039
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
base: dev
Are you sure you want to change the base?
Changes from 2 commits
7f51cf4
9c25287
a5c1666
d6fab2e
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 |
---|---|---|
|
@@ -34,6 +34,7 @@ const Widget = ({ | |
const { overlay } = useGlobalContext() | ||
const { config, data } = useContext(DashboardContext) | ||
const dispatch = useContext(DashboardDispatchContext) | ||
const updateConfig = config => dispatch({ type: 'UPDATE_CONFIG', payload: [config] }) | ||
|
||
const [isEditing, setIsEditing] = useState(false) | ||
const [toggleName, setToggleName] = useState( | ||
|
@@ -71,7 +72,24 @@ const Widget = ({ | |
|
||
const deleteWidget = () => { | ||
if (!widgetConfig) return | ||
// if last widget left in row remove whole row on delete | ||
if (widgetConfig.colIdx === 0) { | ||
let newVisualizations = { ...config.visualizations } | ||
const rows = config.rows | ||
const rowIdx = widgetConfig.rowIdx | ||
|
||
//delete the instantiated widgets | ||
if (rows[rowIdx] && rows[rowIdx].columns && rows[rowIdx].columns.length && config.visualizations) { | ||
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. can simplify this: rows[rowIdx]?.columns?.length |
||
rows[rowIdx].columns.forEach(column => { | ||
if (column.widget) { | ||
delete newVisualizations[column.widget] | ||
} | ||
}) | ||
} | ||
|
||
config.rows.splice(rowIdx, 1) // delete the row | ||
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 think the functionality should be that you delete the column but leave a placeholder there, a single column so that you can still add a widget there if you want. say for example you put a chart widget when you meant to put a table widget, it would be annoying if the row disappeared when you deleted the mistaken chart widget. you'd have to add a new row and if you have a lot of rows, move it all the way to the top. 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. @joshlacey i tryied to leave placeholder emty then the library that is being used thinks that widget is still there and cannot move new widget on top of it.and Cailin then asked to delete whole row |
||
updateConfig({ ...config, rows, visualizations: newVisualizations }) | ||
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. Can you match the pattern everywhere else here and call the dispatch function directly? |
||
} | ||
dispatch({ | ||
type: 'DELETE_WIDGET', | ||
payload: { uid: widgetConfig.uid as string } | ||
|
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.
what if it's the last column but it's at index 2?
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.
@joshlacey thats not issue. it will delete only last(one) widget.