Skip to content
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

feat: add "edit" link to playground strategies #4027

Merged
merged 15 commits into from
Jun 22, 2023

Conversation

thomasheartman
Copy link
Contributor

@thomasheartman thomasheartman commented Jun 21, 2023

This change adds an "edit" link to all playground strategies when they
are returned from the API, allowing the user to jump directly to the
evaluated strategy edit screen.

This change applies to both old and new strategies, so it should even
work in the old playground.

This does not use this information in the frontend yet.

Discussion points:

Should "links" be an object or a singular string? I know the
notifications service uses just "link", but using an object will make
it easier to potentially add more actions in the future (such as
"enable"/"disable", maybe?)

Do we need to supply basePath? I noticed that the notifications links
only ever use an empty string for base path, so it might not be
necessary and can potentially be left out.

Changes

I've implemented the link building in a new view model file. Inspecting the output after the result is fully ready requires some gnarly introspection and mapping, but it's tested.

Further, I've done a little bit of work to stop the playground service using the schema types directly as the schema types now contain extra information.

This PR also updates the urlFriendlyString arbitrary to not produce strings that contain only periods. This causes issues when parsing URLs (and is also something we struggle with in the UI).

This change adds an "edit" link to all playground strategies when they
are returned from the API, allowing the user to jump directly to the
evaluated strategy edit screen.

This change applies to both old and new strategies, so it should even
work in the old playground.

## Discussion points:

Should "links" be an object or a singular string? I know the
notifications service uses just "link", but using an object will make
it easier to potentially add more actions in the future (such as
"enable"/"disable", maybe?)

Do we need to supply basePath? I noticed that the notifications links
only ever use an empty string for base path, so it might not be
necessary and can potentially be left out.

## Changes

I've implemented the link building in the playground service, as that
is where we have all the information we need.
@vercel
Copy link

vercel bot commented Jun 21, 2023

The latest updates on your projects. Learn more about Vercel for Git ↗︎

2 Ignored Deployments
Name Status Preview Comments Updated (UTC)
unleash-docs ⬜️ Ignored (Inspect) Visit Preview Jun 22, 2023 7:10am
unleash-monorepo-frontend ⬜️ Ignored (Inspect) Visit Preview Jun 22, 2023 7:10am

This causes breakage when parsing URLs because they are interpreted as
being directory navigation.

Interestingly enough, we also have this issue in Unleash itself.
Copy link
Contributor

@kwasniew kwasniew left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Very nice! I'd only move HTTP links building to controller handling HTTP logic.

src/lib/features/playground/playground-service.ts Outdated Show resolved Hide resolved
src/lib/features/playground/playground-service.ts Outdated Show resolved Hide resolved
@thomasheartman thomasheartman enabled auto-merge (squash) June 22, 2023 06:53
@thomasheartman thomasheartman merged commit 24e9cf7 into main Jun 22, 2023
10 checks passed
@thomasheartman thomasheartman deleted the feat/playground-link-to-strategies branch June 22, 2023 07:19
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Archived in project
Development

Successfully merging this pull request may close these issues.

None yet

2 participants