@genesislcap/foundation-workspace 15.19.0 → 15.19.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,370 +0,0 @@
1
- import { sync, whenElse } from '@genesislcap/foundation-utils';
2
- import { ExecutionContext, html, ref, repeat, ViewTemplate, when } from '@genesislcap/web-core';
3
- import { SavedWorkspace, SharedWorkspace } from '../workspace/workspace-state.types';
4
- import type { WorkspaceManager } from './workspace-manager';
5
-
6
- export const WORKSPACE_DESCRIPTION_MAX = 200;
7
-
8
- export const workspaceHeaderPartial: ViewTemplate<WorkspaceManager> = html`
9
- <div class="workspace-manager">
10
- <rapid-button @click=${(x) => x.openSaveDialog()}>
11
- <rapid-icon name="download"></rapid-icon>
12
- Save Workspace
13
- </rapid-button>
14
- <rapid-button @click=${(x) => x.openLoadDialog()}>
15
- <rapid-icon name="upload"></rapid-icon>
16
- Load Workspace
17
- </rapid-button>
18
- </div>
19
- `;
20
-
21
- export const workspaceSaveModalPartial: ViewTemplate<WorkspaceManager> = html`
22
- <rapid-modal ${ref('saveModal')}>
23
- <h2 slot="top">Save Workspace</h2>
24
- <div class="dialog-content">
25
- <div class="save-mode-selector">
26
- <rapid-segmented-control value="${sync((x) => x.saveMode)}">
27
- <rapid-segmented-item value="create">Create</rapid-segmented-item>
28
- <rapid-segmented-item value="overwrite">Overwrite</rapid-segmented-item>
29
- ${when(
30
- () => false,
31
- html<WorkspaceManager>`
32
- <rapid-segmented-item value="shared">Share</rapid-segmented-item>
33
- `,
34
- )}
35
- </rapid-segmented-control>
36
- </div>
37
- ${when(
38
- (x) => x.saveMode === 'create',
39
- html<WorkspaceManager>`
40
- <rapid-label>Workspace Name:</rapid-label>
41
- <rapid-text-field
42
- class="save-field"
43
- :value=${(x) => x.workspaceName}
44
- @input=${(x, c) => (x.workspaceName = (c.event.target as HTMLInputElement).value)}
45
- placeholder="Enter workspace name"
46
- ></rapid-text-field>
47
- <rapid-label>
48
- Description (optional, max ${WORKSPACE_DESCRIPTION_MAX} characters):
49
- </rapid-label>
50
- <rapid-text-area
51
- class="save-field workspace-description-input"
52
- maxlength="${WORKSPACE_DESCRIPTION_MAX}"
53
- :value=${(x) => x.workspaceDescription}
54
- @input=${(x, c) =>
55
- x.updateWorkspaceDescription((c.event.target as HTMLTextAreaElement).value)}
56
- placeholder="Add a description for this workspace"
57
- rows="3"
58
- ></rapid-text-area>
59
- ${when(
60
- (x) => x.workspaceName && x.isWorkspaceExisting(x.workspaceName),
61
- html`
62
- <div class="warning-message">
63
- <rapid-icon name="triangle-exclamation"></rapid-icon>
64
- A workspace with this name already exists. Use "Overwrite Existing Workspace" to
65
- replace it.
66
- </div>
67
- `,
68
- )}
69
- `,
70
- )}
71
- ${when(
72
- (x) => x.saveMode === 'overwrite',
73
- html<WorkspaceManager>`
74
- ${when(
75
- (x) => x.savedWorkspaces.length === 0,
76
- html`
77
- <div class="empty-state">No saved workspaces to overwrite</div>
78
- `,
79
- )}
80
- <rapid-label>Select Workspace to Overwrite:</rapid-label>
81
- <rapid-radio-group
82
- class="workspace-list"
83
- value=${sync((x) => x.selectedWorkspaceToOverwrite)}
84
- orientation="vertical"
85
- >
86
- ${repeat(
87
- (x) => x.savedWorkspaces,
88
- html<SavedWorkspace>`
89
- <rapid-radio value=${(x) => x.name} class="workspace-item">
90
- <div class="workspace-info">
91
- <div class="workspace-name">${(x) => x.name}</div>
92
- <div class="workspace-date">
93
- Saved: ${(x) => new Date(x.savedAt).toLocaleString()}
94
- </div>
95
- ${when(
96
- (w) => w.description,
97
- html<SavedWorkspace>`
98
- <div class="workspace-description">${(w) => w.description}</div>
99
- `,
100
- )}
101
- </div>
102
- </rapid-radio>
103
- `,
104
- )}
105
- </rapid-radio-group>
106
- <rapid-label>Description (optional):</rapid-label>
107
- <rapid-text-area
108
- class="save-field"
109
- :value=${(x) => x.workspaceDescription}
110
- maxlength="${WORKSPACE_DESCRIPTION_MAX}"
111
- @input=${(x, c) =>
112
- x.updateWorkspaceDescription((c.event.target as HTMLTextAreaElement).value)}
113
- placeholder="Add a description for this workspace"
114
- rows="3"
115
- ></rapid-text-area>
116
- <div class="warning-message">
117
- <rapid-icon name="triangle-exclamation"></rapid-icon>
118
- This will permanently replace the selected workspace. This action cannot be undone.
119
- </div>
120
- `,
121
- )}
122
- ${when(
123
- () => false,
124
- html<WorkspaceManager>`
125
- <h3>Share existing workspace:</h3>
126
- ${whenElse(
127
- (x) => x.savedWorkspaces.length === 0,
128
- html`
129
- <div class="empty-state">No saved workspaces to share</div>
130
- `,
131
- html<WorkspaceManager>`
132
- <div class="workspace-list">
133
- ${repeat(
134
- (x) => x.savedWorkspaces,
135
- html<SavedWorkspace>`
136
- <div class="workspace-item">
137
- <div class="workspace-info">
138
- <div class="workspace-name">${(w) => w.name}</div>
139
- <div class="workspace-date">
140
- Saved: ${(w) => new Date(w.savedAt).toLocaleString()}
141
- </div>
142
- ${when(
143
- (w) => w.description,
144
- html<SavedWorkspace>`
145
- <div class="workspace-description">${(w) => w.description}</div>
146
- `,
147
- )}
148
- </div>
149
- <div class="button-group">
150
- <rapid-button
151
- appearance="primary"
152
- @click=${(w, c: ExecutionContext<WorkspaceManager>) =>
153
- c.parent.shareExistingWorkspace(w.name)}
154
- >
155
- Share
156
- </rapid-button>
157
- </div>
158
- </div>
159
- `,
160
- )}
161
- </div>
162
- `,
163
- )}
164
- <h3>My Shared Workspaces</h3>
165
- ${whenElse(
166
- (x) =>
167
- x.sharedWorkspaces.filter((w) => w.userName === x.auth?.loggedUserResult?.username)
168
- .length === 0,
169
- html`
170
- <div class="empty-state">You have not shared any workspaces</div>
171
- `,
172
- html<WorkspaceManager>`
173
- <div class="workspace-list">
174
- ${repeat(
175
- (x) =>
176
- x.sharedWorkspaces.filter(
177
- (w) => w.userName === x.auth?.loggedUserResult?.username,
178
- ),
179
- html<SharedWorkspace>`
180
- <div class="workspace-item">
181
- <div class="workspace-info">
182
- <div class="workspace-name">${(w) => w.name}</div>
183
- <div class="workspace-date">
184
- Shared on
185
- ${(w) => new Date((w.modifiedOn || w.createdOn) as any).toLocaleString()}
186
- </div>
187
- ${when(
188
- (w) => w.description,
189
- html<SharedWorkspace>`
190
- <div class="workspace-description">${(w) => w.description}</div>
191
- `,
192
- )}
193
- </div>
194
- <div class="button-group">
195
- <rapid-button
196
- appearance="primary"
197
- @click=${(w, c: ExecutionContext<WorkspaceManager>) =>
198
- c.parent.modifySharedWorkspace(w)}
199
- >
200
- Save
201
- </rapid-button>
202
- <rapid-button
203
- appearance="danger"
204
- @click=${(w, c: ExecutionContext<WorkspaceManager>) =>
205
- c.parent.confirmDeleteSharedWorkspace(w)}
206
- >
207
- Delete
208
- </rapid-button>
209
- </div>
210
- </div>
211
- `,
212
- )}
213
- </div>
214
- `,
215
- )}
216
- `,
217
- )}
218
- <div class="button-group">
219
- <rapid-button
220
- @click=${(x) => x.saveWorkspace()}
221
- appearance="primary"
222
- ?disabled=${(x) =>
223
- (x.saveMode === 'create' && !x.workspaceName.trim()) ||
224
- (x.saveMode === 'overwrite' && !x.selectedWorkspaceToOverwrite) ||
225
- x.saveMode === 'shared' ||
226
- (x.workspaceName && x.isWorkspaceExisting(x.workspaceName))}
227
- >
228
- ${(x) =>
229
- x.saveMode === 'create' ? 'Create' : x.saveMode === 'overwrite' ? 'Overwrite' : 'Save'}
230
- </rapid-button>
231
- <rapid-button appearance="outline" @click=${(x) => x.closeSaveDialog()}>
232
- Cancel
233
- </rapid-button>
234
- </div>
235
- <div class="workspace-dialog-boundary" ${ref('sharedWorkspaceDialogBoundary')}></div>
236
- </div>
237
- </rapid-modal>
238
- `;
239
-
240
- export const workspaceLoadModalPartial: ViewTemplate<WorkspaceManager> = html`
241
- <rapid-modal ${ref('loadModal')}>
242
- <h2 slot="top">Load Workspace</h2>
243
- <div class="dialog-content">
244
- ${when(
245
- (x) => x.applyingWorkspace || x.isLoading,
246
- html`
247
- <div class="loading-container">
248
- <div>Loading...</div>
249
- </div>
250
- `,
251
- )}
252
- ${when(
253
- (x) => !x.applyingWorkspace,
254
- html<WorkspaceManager>`
255
- ${when(
256
- () => false,
257
- html<WorkspaceManager>`
258
- <rapid-segmented-control value="${sync((x) => x.loadMode)}">
259
- <rapid-segmented-item value="MY">My Workspaces</rapid-segmented-item>
260
-
261
- <rapid-segmented-item value="SHARED">Shared Workspaces</rapid-segmented-item>
262
- </rapid-segmented-control>
263
- `,
264
- )}
265
- ${when(
266
- (x) => x.loadMode === 'MY',
267
- html`
268
- <div class="workspace-list">
269
- ${repeat(
270
- (x) => x.savedWorkspaces,
271
- html<SavedWorkspace>`
272
- <div class="workspace-item">
273
- <div class="workspace-info">
274
- <div class="workspace-name">${(w) => w.name}</div>
275
- <div class="workspace-date">
276
- Saved: ${(w) => new Date(w.savedAt).toLocaleString()}
277
- </div>
278
- ${when(
279
- (w) => w.description,
280
- html<SavedWorkspace>`
281
- <div class="workspace-description">${(w) => w.description}</div>
282
- `,
283
- )}
284
- </div>
285
- <div class="button-group">
286
- <rapid-button
287
- appearance="primary"
288
- @click=${(w, c: ExecutionContext<WorkspaceManager>) =>
289
- c.parent.loadWorkspace(w.name)}
290
- >
291
- Load
292
- </rapid-button>
293
- <rapid-button
294
- appearance="danger"
295
- @click=${(w, c: ExecutionContext<WorkspaceManager>) =>
296
- c.parent.confirmDeleteWorkspace(w.name)}
297
- >
298
- Delete
299
- </rapid-button>
300
- </div>
301
- </div>
302
- `,
303
- )}
304
- ${when(
305
- (x) => x.savedWorkspaces.length === 0,
306
- html`
307
- <div class="empty-state">No saved workspaces found</div>
308
- `,
309
- )}
310
- </div>
311
- `,
312
- )}
313
- ${when(
314
- () => false,
315
- html`
316
- <div class="workspace-section">
317
- <div class="workspace-list">
318
- ${repeat(
319
- (x) => x.sharedWorkspaces,
320
- html<SharedWorkspace>`
321
- <div class="workspace-item">
322
- <div class="workspace-info">
323
- <div class="workspace-name">${(w) => w.name}</div>
324
- <div class="workspace-date">
325
- Shared by ${(w) => w.userName} ·
326
- ${(w) =>
327
- new Date((w.modifiedOn || w.createdOn) as any).toLocaleString()}
328
- </div>
329
- ${when(
330
- (w) => w.description,
331
- html<SharedWorkspace>`
332
- <div class="workspace-description">${(w) => w.description}</div>
333
- `,
334
- )}
335
- </div>
336
- <div class="button-group">
337
- <rapid-button
338
- appearance="primary"
339
- @click=${(w, c: ExecutionContext<WorkspaceManager>) =>
340
- c.parent.loadSharedWorkspace(w)}
341
- >
342
- Load
343
- </rapid-button>
344
- </div>
345
- </div>
346
- `,
347
- )}
348
- </div>
349
- ${when(
350
- (x) => x.sharedWorkspaces.length === 0,
351
- html`
352
- <div class="empty-state">No shared workspaces available</div>
353
- `,
354
- )}
355
- </div>
356
- `,
357
- )}
358
- `,
359
- )}
360
- <div class="button-group">
361
- <rapid-button appearance="outline" @click=${(x) => x.closeLoadDialog()}>Close</rapid-button>
362
- </div>
363
- </div>
364
- <div class="workspace-dialog-boundary" ${ref('dialogBoundary')}></div>
365
- </rapid-modal>
366
- `;
367
-
368
- export const WorkspaceManagerTemplate = html<WorkspaceManager>`
369
- ${workspaceHeaderPartial} ${workspaceSaveModalPartial} ${workspaceLoadModalPartial}
370
- `;