diff --git a/package.json b/package.json index 0416630e2c..ce7361955c 100644 --- a/package.json +++ b/package.json @@ -72,7 +72,7 @@ "@pmmmwh/react-refresh-webpack-plugin": "0.5.4", "@sentry/electron": "4.0.0", "@sentry/tracing": "7.10.0", - "@sentry/webpack-plugin": "1.18.8", + "@sentry/webpack-plugin": "1.20.0", "@storybook/addon-actions": "6.5.10", "@storybook/addon-essentials": "6.5.10", "@storybook/builder-webpack5": "6.5.10", diff --git a/packages/studio-base/src/providers/CurrentLayoutProvider/defaultLayout.ts b/packages/studio-base/src/providers/CurrentLayoutProvider/defaultLayout.ts index 0b00ec9690..de57fd17a1 100644 --- a/packages/studio-base/src/providers/CurrentLayoutProvider/defaultLayout.ts +++ b/packages/studio-base/src/providers/CurrentLayoutProvider/defaultLayout.ts @@ -3,48 +3,37 @@ // file, You can obtain one at http://mozilla.org/MPL/2.0/ import { PanelsState } from "@foxglove/studio-base/context/CurrentLayoutContext/actions"; -import { defaultPlaybackConfig } from "@foxglove/studio-base/providers/CurrentLayoutProvider/reducers"; /** * This is loaded when the user has no layout selected on application launch * to avoid presenting the user with a blank layout. */ export const defaultLayout: PanelsState = { - configById: { - "3D!18i6zy7": { - layers: { - "845139cb-26bc-40b3-8161-8ab60af4baf5": { - visible: true, - frameLocked: true, - label: "Grid", - instanceId: "845139cb-26bc-40b3-8161-8ab60af4baf5", - layerId: "foxglove.Grid", - size: 10, - divisions: 10, - lineWidth: 1, - color: "#248eff", - position: [0, 0, 0], - rotation: [0, 0, 0], - order: 1, - }, - }, - }, - "RawMessages!os6rgs": {}, - "ImageViewPanel!3mnp456": {}, + "configById": { + "Plot!3fa5k5u": { + "title": "Plot", + "paths": [ + { + "value": "/topic.data", + "enabled": true, + "timestampMethod": "receiveTime" + } + ], + "showXAxisLabels": true, + "showYAxisLabels": true, + "showLegend": true, + "legendDisplay": "floating", + "showPlotValuesInLegend": false, + "isSynced": true, + "xAxisVal": "timestamp", + "sidebarDimension": 240 + } }, - globalVariables: {}, - userNodes: {}, - linkedGlobalVariables: [], - playbackConfig: { ...defaultPlaybackConfig }, - layout: { - first: "3D!18i6zy7", - second: { - first: "ImageViewPanel!3mnp456", - second: "RawMessages!os6rgs", - direction: "column", - splitPercentage: 30, - }, - direction: "row", - splitPercentage: 70, + "globalVariables": {}, + "userNodes": {}, + "linkedGlobalVariables": [], + "playbackConfig": { + "speed": 1.0 }, + "layout": "Plot!3fa5k5u" } as const; diff --git a/packages/studio-base/src/providers/CurrentLayoutProvider/index.tsx b/packages/studio-base/src/providers/CurrentLayoutProvider/index.tsx index 8d1850b78f..0c7fd18806 100644 --- a/packages/studio-base/src/providers/CurrentLayoutProvider/index.tsx +++ b/packages/studio-base/src/providers/CurrentLayoutProvider/index.tsx @@ -35,13 +35,13 @@ import { import { useLayoutManager } from "@foxglove/studio-base/context/LayoutManagerContext"; import { useUserProfileStorage } from "@foxglove/studio-base/context/UserProfileStorageContext"; import { LinkedGlobalVariables } from "@foxglove/studio-base/panels/ThreeDimensionalViz/Interactions/useLinkedGlobalVariables"; -import { defaultLayout } from "@foxglove/studio-base/providers/CurrentLayoutProvider/defaultLayout"; +// import { defaultLayout } from "@foxglove/studio-base/providers/CurrentLayoutProvider/defaultLayout"; import panelsReducer from "@foxglove/studio-base/providers/CurrentLayoutProvider/reducers"; import { LayoutID } from "@foxglove/studio-base/services/ConsoleApi"; import { AppEvent } from "@foxglove/studio-base/services/IAnalytics"; import { LayoutManagerEventTypes } from "@foxglove/studio-base/services/ILayoutManager"; import { PanelConfig, UserNodes, PlaybackConfig } from "@foxglove/studio-base/types/panels"; -import { windowAppURLState } from "@foxglove/studio-base/util/appURLState"; +// import { windowAppURLState } from "@foxglove/studio-base/util/appURLState"; import { getPanelTypeFromId } from "@foxglove/studio-base/util/layout"; const log = Logger.getLogger(__filename); @@ -253,25 +253,28 @@ export default function CurrentLayoutProvider({ // Load initial state by re-selecting the last selected layout from the UserProfile. useAsync(async () => { - // Don't restore the layout if there's one specified in the app state url. - if (windowAppURLState()?.layoutId) { - return; + + async function loadLayout() { + const response = await fetch('layout.json'); + const layout = await response.json(); + return layout; } + const defaultLayout = await loadLayout(); // Retreive the selected layout id from the user's profile. If there's no layout specified // or we can't load it then save and select a default layout. const { currentLayoutId } = await getUserProfile(); - const layout = currentLayoutId ? await layoutManager.getLayout(currentLayoutId) : undefined; - if (layout) { - await setSelectedLayoutId(currentLayoutId, { saveToProfile: false }); - } else { - const newLayout = await layoutManager.saveNewLayout({ - name: "Default", - data: defaultLayout, - permission: "CREATOR_WRITE", - }); + + const newLayout = await layoutManager.saveNewLayout({ + name: "Default", + data: defaultLayout, + permission: "CREATOR_WRITE", + }); + + if(currentLayoutId != newLayout.id){ await setSelectedLayoutId(newLayout.id); } + }, [getUserProfile, layoutManager, setSelectedLayoutId]); const actions: ICurrentLayout["actions"] = useMemo( diff --git a/web/public/layout.json b/web/public/layout.json new file mode 100644 index 0000000000..fc8d7028cb --- /dev/null +++ b/web/public/layout.json @@ -0,0 +1,29 @@ +{ + "configById": { + "Plot!3fa5k5u": { + "title": "Plot", + "paths": [ + { + "value": "/topic.datasdfasdf", + "enabled": true, + "timestampMethod": "receiveTime" + } + ], + "showXAxisLabels": true, + "showYAxisLabels": true, + "showLegend": true, + "legendDisplay": "floating", + "showPlotValuesInLegend": false, + "isSynced": true, + "xAxisVal": "timestamp", + "sidebarDimension": 240 + } + }, + "globalVariables": {}, + "userNodes": {}, + "linkedGlobalVariables": [], + "playbackConfig": { + "speed": 1.0 + }, + "layout": "Plot!3fa5k5u" + } diff --git a/web/src/Root.tsx b/web/src/Root.tsx index cc568e31d1..8b5e4fb288 100644 --- a/web/src/Root.tsx +++ b/web/src/Root.tsx @@ -66,7 +66,7 @@ export function Root({ appConfiguration }: { appConfiguration: IAppConfiguration