Add custom YAML plan upload - #145
Open
nxlouie wants to merge 2 commits into
Open
Conversation
Allow users to upload their own training plan as a YAML file via a new "Upload Custom" option in the plan dropdown. The uploaded file is parsed client-side with js-yaml and cached in PlanRepo so that subsequent operations (date changes, week-starts-on changes) work seamlessly. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
The select now stays on the custom upload option after a plan is loaded, and the file chooser button remains visible for re-uploading. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Author
|
I manually validated the test plan checklist |
Owner
|
Thanks, it's a nice idea. I've been working on a version of this in this branch. Trying to convince myself it will be generally useful. I'd like to preserve the share-ability of the plans so coaches can set these up for their athletes and pass them along. But I need to think it through some more. This is also prompting me to think about the file format. It's kind of sloppy right now and I'd like it to be more flexible. More to come. |
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Summary
.yamlfilejs-yamland cached inPlanRepo, so all existing functionality (date changes, week-starts-on, undo, export) works seamlessly with custom plansChanges
src/components/PlanPicker.tsx— Added(Custom) Upload Customoption at the end of the dropdown with a sentinel value. Selecting it triggers a callback instead of the normal plan change flow.src/components/PlanAndDate.tsx— Added a hidden file input (.yaml,.yml) and a "Choose Plan File" button that appears when the upload option is selected. Reads the file withFileReader, parses withjs-yaml, validates required fields, and passes the plan up.src/App.tsx— AddedshowUploadButtonstate andonCustomPlanLoadedhandler that caches the parsed plan in the repo, builds the race plan, and updates all state. Selecting a different built-in plan hides the upload button.src/ch/planrepo.ts— AddedaddCustomPlan()method that stores the plan in the existing cache under the same URL-based key thatfetch()uses, so subsequent fetches (e.g., on date/settings changes) return the custom plan from cache.jest.config.ts— Addedtypes/*path alias to matchtsconfig.app.json.src/ch/customPlanUpload.test.ts— Tests for YAML parsing (valid, missing fields, invalid) andPlanRepo.addCustomPlan(caching, fetching, finding).Test plan
yarn testpasses (6 new tests for YAML parsing and plan caching)public/plans/yaml/) — verify the calendar renders🤖 Generated with Claude Code