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

Add Saved Segments UI (variant D) #4891

Merged
merged 26 commits into from
Feb 26, 2025
Merged

Add Saved Segments UI (variant D) #4891

merged 26 commits into from
Feb 26, 2025

Conversation

apata
Copy link
Contributor

@apata apata commented Dec 10, 2024

Changes

Adds saved segments related menus and modals. Almost all of it is conditional on feature flag saved_segments: true.

Tests

  • Automated tests have been added

Changelog

  • This PR does not make a user-facing change (for those without the FF)

Documentation

  • This change does not need a documentation update

Dark mode

  • The UI has been tested both in dark and light mode

@apata apata added the preview label Dec 10, 2024
Copy link

Preview environment👷🏼‍♀️🏗️
PR-4891

@apata apata force-pushed the saved-segments/variant-d branch from e6af6e9 to c43f1c6 Compare January 28, 2025 10:55
@apata apata changed the base branch from saved-segments/variant-c to master January 28, 2025 10:56
@apata apata added preview and removed preview labels Jan 28, 2025
Copy link

Preview environment👷🏼‍♀️🏗️
PR-4891

@apata apata force-pushed the saved-segments/variant-d branch 3 times, most recently from fc60610 to ef8670a Compare February 17, 2025 11:50
@apata apata added preview and removed preview labels Feb 17, 2025
Copy link

Preview environment👷🏼‍♀️🏗️
PR-4891

@apata apata force-pushed the saved-segments/variant-d branch 2 times, most recently from 567faec to 5710785 Compare February 18, 2025 18:44
@apata apata force-pushed the saved-segments/variant-d branch from f5bde8e to 2c3e8e6 Compare February 20, 2025 13:41
@apata apata marked this pull request as ready for review February 20, 2025 14:03
@apata apata requested a review from a team February 20, 2025 14:04
@apata apata changed the title [WIP] Saved Segments variant D Add Saved Segments UI (variant D) Feb 20, 2025
Comment on lines +72 to +74
export function dateForSite(utcDateString, site) {
return dayjs.utc(utcDateString).utcOffset(site.offset / 60)
}
Copy link
Contributor Author

Choose a reason for hiding this comment

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

This is the new thing here, and it's a workaround. To follow the rest of the backend, I'd have to offset the dates there.

The other changes are related to formatting.

@@ -397,6 +411,30 @@ defmodule PlausibleWeb.StatsController do
end)
|> Map.new()

defp get_members(site_role, %Plausible.Site{} = site)
Copy link
Contributor Author

@apata apata Feb 20, 2025

Choose a reason for hiding this comment

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

This is a workaround to avoid resolving segment.owner_id to segment.owner_name in the backend. Instead, we forward users <id>:<name> map to the front-end.

Copy link
Contributor

Choose a reason for hiding this comment

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

Why not resolve it on the backend?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Mostly because this worked ok and the PR was getting too bloated already.

Copy link
Contributor

Choose a reason for hiding this comment

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

Got it. I think the logic would be more cohesive if the owners were resolved in the same query as segments themselves. But I agree with not making the PR any bigger than it is.

Copy link
Contributor

@ukutaht ukutaht left a comment

Choose a reason for hiding this comment

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

Looks good overall but the quality of my review is meh. Touches a bunch of code I haven't worked with in a long time, plus the PR is pretty big.

className={classNames(
'self-start button h-9 !px-3 !py-2 flex !bg-red-500 dark:!bg-red-500 hover:!bg-red-600 dark:hover:!bg-red-700 whitespace-nowrap'
'button flex self-start h-9 !px-3 !bg-red-500 dark:!bg-red-500 hover:!bg-red-600 dark:hover:!bg-red-700 whitespace-nowrap'
Copy link
Contributor

Choose a reason for hiding this comment

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

I think the .button class should be considered legacy and not used for any new stuff. This applies to pretty much everything in app.css. These were added due to missing features in tailwind that would not allow us to use tailwind directly. But tailwind has been developed a lot and pretty much everything is possible now by just using tailwind classes.

Copy link
Contributor Author

@apata apata Feb 25, 2025

Choose a reason for hiding this comment

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

True, I saw that it was sort of wonky, and I'd be ok with getting rid of it. At the moment, I think let's leave it to mark which components should ideally share style.

Separate topic, but I had a notion that these custom classes made using TW @apply in app.css could be used to share class combinations between server-rendered pages and React dashboard.

Now that we have the storybook as well, it's especially tempting to try to codify and share these basic styles, like texts, notices, button types, dropdown backgrounds.

Copy link
Contributor

Choose a reason for hiding this comment

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

Hmm yes they could be used for sharing...

For me though, one of the biggest things I like about tailwind is not having to come up with class names, and especially names for modifier classes :) I prefer the style where template and style code are combined and named together as a component (like <.button theme={"plain"} disabled="true"> over .button .button--plain .button--disabled).

return '(Removed User)'
}

// if (owner_id === user.id) {
Copy link
Contributor

Choose a reason for hiding this comment

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

Should this be uncommented? Deleted?

@@ -397,6 +411,30 @@ defmodule PlausibleWeb.StatsController do
end)
|> Map.new()

defp get_members(site_role, %Plausible.Site{} = site)
Copy link
Contributor

Choose a reason for hiding this comment

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

Why not resolve it on the backend?

@apata apata added this pull request to the merge queue Feb 26, 2025
Merged via the queue into master with commit 421e7d2 Feb 26, 2025
8 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants