(ctx context.Context, tabId string, layout PortableLayout, recordTelemetry bool)
| 114 | } |
| 115 | |
| 116 | func ApplyPortableLayout(ctx context.Context, tabId string, layout PortableLayout, recordTelemetry bool) error { |
| 117 | actions := make([]waveobj.LayoutActionData, len(layout)+1) |
| 118 | actions[0] = waveobj.LayoutActionData{ActionType: LayoutActionDataType_ClearTree} |
| 119 | for i := 0; i < len(layout); i++ { |
| 120 | layoutAction := layout[i] |
| 121 | |
| 122 | blockData, err := CreateBlockWithTelemetry(ctx, tabId, layoutAction.BlockDef, &waveobj.RuntimeOpts{}, recordTelemetry) |
| 123 | if err != nil { |
| 124 | return fmt.Errorf("unable to create block to apply portable layout to tab %s: %w", tabId, err) |
| 125 | } |
| 126 | |
| 127 | actions[i+1] = waveobj.LayoutActionData{ |
| 128 | ActionType: LayoutActionDataType_InsertAtIndex, |
| 129 | BlockId: blockData.OID, |
| 130 | IndexArr: &layoutAction.IndexArr, |
| 131 | NodeSize: layoutAction.Size, |
| 132 | Focused: layoutAction.Focused, |
| 133 | } |
| 134 | } |
| 135 | |
| 136 | err := QueueLayoutActionForTab(ctx, tabId, actions...) |
| 137 | if err != nil { |
| 138 | return fmt.Errorf("unable to queue layout actions for portable layout: %w", err) |
| 139 | } |
| 140 | |
| 141 | return nil |
| 142 | } |
| 143 | |
| 144 | func BootstrapStarterLayout(ctx context.Context) error { |
| 145 | ctx, cancelFn := context.WithTimeout(ctx, 2*time.Second) |
no test coverage detected