forked from Cloud-Pipelines/pipeline-editor
-
Notifications
You must be signed in to change notification settings - Fork 6
feat: Guided Tours Ephemeral Pipelines #2334
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
Open
camielvs
wants to merge
1
commit into
05-29-feat_guided_tours_navigation_dots_track_progress
Choose a base branch
from
05-27-fix_guided_tours_ephemeral_state
base: 05-29-feat_guided_tours_navigation_dots_track_progress
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
62 changes: 62 additions & 0 deletions
62
src/providers/TourProvider/tourPipelineStorage/SessionStoragePipelineDriver.ts
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,62 @@ | ||
| import type { | ||
| PipelineFileDescriptor, | ||
| PipelineStorageDriver, | ||
| } from "@/services/pipelineStorage/types"; | ||
|
|
||
| import { SESSION_KEY_PREFIX } from "./constants"; | ||
|
|
||
| export class SessionStoragePipelineDriver implements PipelineStorageDriver { | ||
| readonly type = "session-storage"; | ||
| readonly allowsMoveIn = false; | ||
| readonly allowsMoveOut = false; | ||
|
|
||
| private key(storageKey: string): string { | ||
| return `${SESSION_KEY_PREFIX}${storageKey}`; | ||
| } | ||
|
|
||
| async list(): Promise<PipelineFileDescriptor[]> { | ||
| const descriptors: PipelineFileDescriptor[] = []; | ||
| for (let i = 0; i < sessionStorage.length; i++) { | ||
| const fullKey = sessionStorage.key(i); | ||
| if (fullKey?.startsWith(SESSION_KEY_PREFIX)) { | ||
| descriptors.push({ | ||
| storageKey: fullKey.slice(SESSION_KEY_PREFIX.length), | ||
| }); | ||
| } | ||
| } | ||
| return descriptors; | ||
| } | ||
|
|
||
| async read(storageKey: string): Promise<string> { | ||
| const content = sessionStorage.getItem(this.key(storageKey)); | ||
| if (content === null) { | ||
| throw new Error( | ||
| `Tour pipeline "${storageKey}" not found in sessionStorage`, | ||
| ); | ||
| } | ||
| return content; | ||
| } | ||
|
|
||
| async write(storageKey: string, content: string): Promise<void> { | ||
| sessionStorage.setItem(this.key(storageKey), content); | ||
| } | ||
|
|
||
| async delete(storageKey: string): Promise<void> { | ||
| sessionStorage.removeItem(this.key(storageKey)); | ||
| } | ||
|
|
||
| async rename(oldStorageKey: string, newStorageKey: string): Promise<void> { | ||
| const content = sessionStorage.getItem(this.key(oldStorageKey)); | ||
| if (content === null) { | ||
| throw new Error( | ||
| `Tour pipeline "${oldStorageKey}" not found in sessionStorage`, | ||
| ); | ||
| } | ||
| sessionStorage.setItem(this.key(newStorageKey), content); | ||
| sessionStorage.removeItem(this.key(oldStorageKey)); | ||
| } | ||
|
|
||
| async hasKey(storageKey: string): Promise<boolean> { | ||
| return sessionStorage.getItem(this.key(storageKey)) !== null; | ||
| } | ||
| } |
57 changes: 57 additions & 0 deletions
57
src/providers/TourProvider/tourPipelineStorage/TourPipelineFolder.ts
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,57 @@ | ||
| import { PipelineFile } from "@/services/pipelineStorage/PipelineFile"; | ||
| import { PipelineFolder } from "@/services/pipelineStorage/PipelineFolder"; | ||
|
|
||
| /** | ||
| * Session-storage-backed folder for ephemeral tour pipelines. Files are built | ||
| * with `id: storageKey` and have no IndexedDB registry entry, so the inherited | ||
| * `PipelineFile.rename()` / `deleteFile()` — which call `updateEntry` / | ||
| * `deleteEntry` against that registry — are unsupported in tour mode and would | ||
| * no-op or error against the missing row. Latent today: the tour UI disables | ||
| * rename/delete, so these paths are never reached. | ||
| */ | ||
| export class TourPipelineFolder extends PipelineFolder { | ||
|
camielvs marked this conversation as resolved.
|
||
| override async listPipelines(): Promise<PipelineFile[]> { | ||
| const descriptors = await this.driver.list(); | ||
| return descriptors.map( | ||
| (d) => | ||
| new PipelineFile({ | ||
| id: d.storageKey, | ||
| storageKey: d.storageKey, | ||
| folder: this, | ||
| createdAt: d.createdAt, | ||
| modifiedAt: d.modifiedAt, | ||
| }), | ||
| ); | ||
| } | ||
|
|
||
| override async findFile( | ||
| storageKey: string, | ||
| ): Promise<PipelineFile | undefined> { | ||
| if (!(await this.driver.hasKey(storageKey))) return undefined; | ||
| return new PipelineFile({ | ||
| id: storageKey, | ||
| storageKey, | ||
| folder: this, | ||
| }); | ||
| } | ||
|
|
||
| override async assignFile(storageKey: string): Promise<PipelineFile> { | ||
| return new PipelineFile({ | ||
| id: storageKey, | ||
| storageKey, | ||
| folder: this, | ||
| }); | ||
| } | ||
|
|
||
| override async addFile( | ||
| storageKey: string, | ||
| content: string, | ||
| ): Promise<PipelineFile> { | ||
| await this.driver.write(storageKey, content); | ||
| return new PipelineFile({ | ||
| id: storageKey, | ||
| storageKey, | ||
| folder: this, | ||
| }); | ||
| } | ||
| } | ||
20 changes: 20 additions & 0 deletions
20
src/providers/TourProvider/tourPipelineStorage/TourPipelineStorageProvider.tsx
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,20 @@ | ||
| import type { ReactNode } from "react"; | ||
| import { useState } from "react"; | ||
|
|
||
| import { PipelineStorageCtx } from "@/services/pipelineStorage/PipelineStorageProvider"; | ||
|
|
||
| import { TourPipelineStorageService } from "./TourPipelineStorageService"; | ||
|
|
||
| export function TourPipelineStorageProvider({ | ||
| children, | ||
| }: { | ||
| children: ReactNode; | ||
| }) { | ||
| const [service] = useState(() => new TourPipelineStorageService()); | ||
|
|
||
| return ( | ||
| <PipelineStorageCtx.Provider value={service}> | ||
| {children} | ||
| </PipelineStorageCtx.Provider> | ||
| ); | ||
| } |
48 changes: 48 additions & 0 deletions
48
src/providers/TourProvider/tourPipelineStorage/TourPipelineStorageService.ts
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,48 @@ | ||
| import type { PipelineFile } from "@/services/pipelineStorage/PipelineFile"; | ||
| import { PipelineFolder } from "@/services/pipelineStorage/PipelineFolder"; | ||
| import { PipelineStorageService } from "@/services/pipelineStorage/PipelineStorageService"; | ||
|
|
||
| import { TOUR_FOLDER_ID } from "./constants"; | ||
| import { SessionStoragePipelineDriver } from "./SessionStoragePipelineDriver"; | ||
| import { TourPipelineFolder } from "./TourPipelineFolder"; | ||
|
|
||
| export class TourPipelineStorageService extends PipelineStorageService { | ||
| constructor() { | ||
| super(); | ||
| this.rootFolder = new TourPipelineFolder({ | ||
| id: TOUR_FOLDER_ID, | ||
| name: "Tour", | ||
| parentId: null, | ||
| driver: new SessionStoragePipelineDriver(), | ||
| }); | ||
| } | ||
|
|
||
| override async findPipelineById(id: string): Promise<PipelineFile> { | ||
| const file = await this.rootFolder.findFile(id); | ||
| if (!file) { | ||
| throw new Error(`Tour pipeline not found: ${id}`); | ||
| } | ||
| return file; | ||
| } | ||
|
|
||
| override async resolvePipelineByName( | ||
| name: string, | ||
| ): Promise<PipelineFile | undefined> { | ||
| return this.rootFolder.findFile(name); | ||
| } | ||
|
|
||
| override async findFolderById(id: string): Promise<PipelineFolder> { | ||
| if (id === TOUR_FOLDER_ID || id === this.rootFolder.id) { | ||
| return this.rootFolder; | ||
| } | ||
| throw new Error(`Folder not available in tour mode: ${id}`); | ||
| } | ||
|
|
||
| override async getAllFolders(): Promise<PipelineFolder[]> { | ||
| return [this.rootFolder]; | ||
| } | ||
|
|
||
| override async getFavoriteFolders(): Promise<PipelineFolder[]> { | ||
| return []; | ||
| } | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,2 @@ | ||
| export const SESSION_KEY_PREFIX = "tour-pipeline:"; | ||
| export const TOUR_FOLDER_ID = "__tour_folder__"; |
30 changes: 30 additions & 0 deletions
30
src/providers/TourProvider/tourPipelineStorage/resetAllTourPipelineState.ts
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,30 @@ | ||
| import type { QueryClient } from "@tanstack/react-query"; | ||
|
|
||
| import { TOUR_PIPELINE_PREFIX } from "@/providers/TourProvider/tourPipelineLifecycle"; | ||
| import { EDITOR_SPEC_QUERY_KEY } from "@/routes/v2/pages/Editor/hooks/useLoadSpec"; | ||
|
|
||
| import { SESSION_KEY_PREFIX } from "./constants"; | ||
|
|
||
| export function resetAllTourPipelineState(queryClient: QueryClient): void { | ||
| const sessionKeys: string[] = []; | ||
| for (let i = 0; i < sessionStorage.length; i++) { | ||
| const key = sessionStorage.key(i); | ||
| if (key?.startsWith(SESSION_KEY_PREFIX)) { | ||
| sessionKeys.push(key); | ||
| } | ||
| } | ||
| for (const key of sessionKeys) { | ||
| sessionStorage.removeItem(key); | ||
| } | ||
|
|
||
| queryClient.removeQueries({ | ||
| predicate: (query) => { | ||
| const [head, second] = query.queryKey; | ||
| return ( | ||
| head === EDITOR_SPEC_QUERY_KEY && | ||
| typeof second === "string" && | ||
| second.startsWith(TOUR_PIPELINE_PREFIX) | ||
| ); | ||
| }, | ||
| }); | ||
| } |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.