[DASHBOARDS] Widget duplication (#15979)

## Widget duplication

- Created a shared component for the option menu shared by the record
page, the dashboards and the workflows
- Fix arrow selection in the option menu in workflows, which wasn't
working
- Scroll to the new widget after creation and open the new widget
settings


https://github.com/user-attachments/assets/47b8dade-44bd-4ba2-a81c-01b09e8718d3
This commit is contained in:
Raphaël Bosi
2025-11-24 14:38:18 +01:00
committed by GitHub
parent 8923d2fa0a
commit 2b80d9e015
18 changed files with 526 additions and 217 deletions
@@ -16,6 +16,8 @@ import { pageLayoutCurrentLayoutsComponentState } from '../states/pageLayoutCurr
import { pageLayoutDraftComponentState } from '../states/pageLayoutDraftComponentState';
import { pageLayoutTabSettingsOpenTabIdComponentState } from '../states/pageLayoutTabSettingsOpenTabIdComponentState';
import { type PageLayoutTab } from '../types/PageLayoutTab';
import { generateDuplicatedTimestamps } from '../utils/generateDuplicatedTimestamps';
import { getDuplicatedTitle } from '../utils/getDuplicatedTitle';
export const useDuplicatePageLayoutTab = (pageLayoutIdFromProps?: string) => {
const pageLayoutId = useAvailableComponentInstanceIdOrThrow(
@@ -76,8 +78,7 @@ export const useDuplicatePageLayoutTab = (pageLayoutIdFromProps?: string) => {
...widget,
id: newWidgetId,
pageLayoutTabId: newTabId,
createdAt: new Date().toISOString(),
updatedAt: new Date().toISOString(),
...generateDuplicatedTimestamps(),
};
});
@@ -93,13 +94,10 @@ export const useDuplicatePageLayoutTab = (pageLayoutIdFromProps?: string) => {
const newTab: PageLayoutTab = {
...sourceTab,
id: newTabId,
title: sourceTab.title.endsWith('(Copy)')
? sourceTab.title
: `${sourceTab.title} (Copy)`,
title: getDuplicatedTitle(sourceTab.title),
position: newTabPosition,
widgets: clonedWidgets,
createdAt: new Date().toISOString(),
updatedAt: new Date().toISOString(),
...generateDuplicatedTimestamps(),
};
const sourceLayouts = allTabLayouts[tabId] ?? {