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

create ui for the full embedding homepage, without any logic #40251

Merged
merged 6 commits into from
Mar 20, 2024

Conversation

npretto
Copy link
Member

@npretto npretto commented Mar 18, 2024

Part of [Epic] Initial homepage experience for embedding admins

Description

This only adds the "dumb" UI, all the logic and tests will come in separate PRs

Note that I'm currently importing List from mantine, I'll open a PR to re-export it from metabase/ui (see slack) and to also fix the numbers not showing up without the inline style.

How to verify

@npretto npretto changed the title wip ui for the full embedding homepage ui for the full embedding homepage Mar 19, 2024
@npretto npretto changed the title ui for the full embedding homepage create ui for the full embedding homepage, without any logic Mar 19, 2024
@@ -0,0 +1,47 @@
import type { Meta, StoryObj } from "@storybook/react";
Copy link
Member Author

Choose a reason for hiding this comment

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

This may or may not land in master (slack), but for now it's helpful to test all the variants of the UI.

Copy link
Member

Choose a reason for hiding this comment

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

I have no objection for having this in the repo if it helps with feature development.

@@ -0,0 +1,65 @@
// eslint-disable-next-line no-restricted-imports
import { List } from "@mantine/core";
Copy link
Member Author

@npretto npretto Mar 19, 2024

Choose a reason for hiding this comment

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

I'll move this to metabase/ui, see description of PR

type="ordered"
mb="lg"
size="sm"
// TODO: fix this in a better way
Copy link
Member Author

@npretto npretto Mar 19, 2024

Choose a reason for hiding this comment

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

I'll also fix this (I hope there's a easy way with the mantine overrides) when re-exporting List from metabase/ui

@npretto npretto requested a review from a team March 19, 2024 13:51
@npretto npretto marked this pull request as ready for review March 19, 2024 13:51
Copy link

github-actions bot commented Mar 19, 2024

Codenotify: Notifying subscribers in CODENOTIFY files for diff 6710930...25fb1b4.

Notify File(s)
@ranquild frontend/src/metabase/home/components/EmbedHomepage/EmbedHomepage.stories.tsx
frontend/src/metabase/home/components/EmbedHomepage/EmbedHomepage.tsx
frontend/src/metabase/home/components/EmbedHomepage/EmbedHomepageView.tsx
frontend/src/metabase/home/components/EmbedHomepage/InteractiveTabContent.tsx
frontend/src/metabase/home/components/EmbedHomepage/StaticTabContent.tsx
frontend/src/metabase/home/components/EmbedHomepage/index.ts

Copy link

replay-io bot commented Mar 19, 2024

Status Complete ↗︎
Commit 25fb1b4
Results
⚠️ 3 Flaky
2367 Passed

Copy link
Member

@WiNloSt WiNloSt 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 with some minor comments.


export const EmbedHomepage = () => {
const interactiveEmbeddingQuickStartUrl = useSelector(state =>
// eslint-disable-next-line no-unconditional-metabase-links-render -- only visible to admins
Copy link
Member

Choose a reason for hiding this comment

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

How do you feel about having to apply this everywhere? I feel like I erred on the side of being more cautious than being more relaxed since this is only inconvenient for us, but failing to hide user-facing links could make Metabase looks less polished.

If we allow things like disabling the rule for the whole file, it could be possible there are both links that are visible to end users and admins in the same file, though it might never happen.

And I think we only have to do this a handful of times per feature. There are less than 10 inline comments if I count this correctly.

Any feedback would be welcome.

Copy link
Member Author

@npretto npretto Mar 20, 2024

Choose a reason for hiding this comment

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

it could be possible there are both links that are visible to end users and admins in the same file, though it might never happen.

Yeah that was my thought to, it may happen, maybe not, but it could. Adding the disable-next-line is a relatively low effort as the editor will do it for me so I'm fine with it

interactiveEmbeddingQuickstartUrl={interactiveEmbeddingQuickStartUrl}
embeddingDocsUrl={embeddingDocsUrl}
// eslint-disable-next-line no-unconditional-metabase-links-render -- only visible to admins
customerFacingAnalyticsDocsUrl="https://www.metabase.com/learn/customer-facing-analytics/"
Copy link
Member

Choose a reason for hiding this comment

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

The name feels a bit off. The comment suggests this link is only for admin, but the name suggests it's a user-facing string which, in theory, should be rendered conditionally.

Copy link
Member Author

Choose a reason for hiding this comment

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

Uhm interesting, I haven't thought of that prop as possibly being read like that, would it be better as analyticsDocsUrl?

Copy link
Member

Choose a reason for hiding this comment

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

sounds good to me.

Copy link
Member Author

Choose a reason for hiding this comment

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

25fb1b4

Comment on lines +30 to +33
exampleDashboardId={1}
embeddingAutoEnabled={false}
licenseActiveAtSetup={true}
plan="oss-starter"
Copy link
Member

Choose a reason for hiding this comment

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

Should we add comments that these values should be from, if I'm not mistaken, settings?

Copy link
Member Author

Choose a reason for hiding this comment

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

That prop will be calculated in this component the same way as the urls, so it's kind of a "private prop".
It should make more sense in the following PRs, I should have left a comment that the values were temporarily hardcoded though


<Text fw="bold" mb="md">{t`The TL;DR:`}</Text>

<List
Copy link
Member

Choose a reason for hiding this comment

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

What are the reasons/benefits for using List here? I mean I understand Mantine has it, but this doesn't look anything different from using simple ol and li tags. If we need to use icons then maybe I could understand we might need List but that doesn't seem to be the case here.

Copy link
Member Author

Choose a reason for hiding this comment

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

Yeah itt felt overkill to me too but right now we have a reset that removes the list type, so we'd have to make a styled(ol)/css class with

  list-style-type: decimal;
  list-style-position: inside;

I did it for the minimal embedding card but it felt like it should have been a re-usable component.

It should also help with making sure spacing, font sizes etc are consistent

exampleDashboardId,
licenseActiveAtSetup,
learnMoreInteractiveEmbedUrl,
} = props;
Copy link
Member

Choose a reason for hiding this comment

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

If we don't need to spread props like in frontend/src/metabase/home/components/EmbedHomepage/EmbedHomepageView.tsx what do you think about destructuring these props in the function arguments instead for consistency?

Copy link
Member Author

Choose a reason for hiding this comment

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

19d2486

// TODO: fix this in a better way
style={{ listStyleType: "decimal" }}
>
{licenseActiveAtSetup === false && (
Copy link
Member

Choose a reason for hiding this comment

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

I feel like booleans that could be undefined would be a bit awkward when the default value should be true. I'm not sure if that's the case, but the structure suggests so.

The reason sometimes we have someBoolean === false is to ensure undefined doesn't satisfy this clause. I feel like making the boolean that would have the default value as false would feel more natural. Since you can just do

Suggested change
{licenseActiveAtSetup === false && (
{!licenseActiveAtSetup && (

That being said, I guess from the name, this value should be false unless users activate their license, so I don't see the reason why we need to use xxx === false

Copy link
Member Author

Choose a reason for hiding this comment

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

I agree that's more readable, I think it may still make sense to set the default to undefined/null to make it explicit that the instance was setup after we introduced this, meaning that those flag have no value at all

Copy link
Member

Choose a reason for hiding this comment

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

to elaborate on what I meant by the default value as false. That covers the case for null and undefined too. I should have said falsy value by default.

It would feel more natural if you pass undefined, null, or false and gets the same result. Because It gets awkward sometimes if you pass undefined and false and get different results.

Copy link
Member Author

Choose a reason for hiding this comment

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

Ah I see, yeah that makes sense, I'll make sure not to render this when the any of the flags are undefined/null as it means they did the setup before this was introduced

@npretto npretto merged commit c961b4d into embed-homepage Mar 20, 2024
77 of 78 checks passed
@npretto npretto deleted the embed-homepage-ui branch March 20, 2024 14:31
npretto added a commit that referenced this pull request Mar 20, 2024
* wip ui for the full embedding homepage

* adds missing link + fix keys

* remove done TODO

* Update frontend/src/metabase/home/components/EmbedHomepage/InteractiveTabContent.tsx

Co-authored-by: Mahatthana (Kelvin) Nomsawadi <me@bboykelvin.dev>

* destructure props in the function arguments

* rename customerFacingAnalyticsDocsUrl to analyticsDocsUrl

---------

Co-authored-by: Mahatthana (Kelvin) Nomsawadi <me@bboykelvin.dev>
npretto added a commit that referenced this pull request Mar 26, 2024
* wip ui for the full embedding homepage

* adds missing link + fix keys

* remove done TODO

* Update frontend/src/metabase/home/components/EmbedHomepage/InteractiveTabContent.tsx

Co-authored-by: Mahatthana (Kelvin) Nomsawadi <me@bboykelvin.dev>

* destructure props in the function arguments

* rename customerFacingAnalyticsDocsUrl to analyticsDocsUrl

---------

Co-authored-by: Mahatthana (Kelvin) Nomsawadi <me@bboykelvin.dev>
deniskaber pushed a commit that referenced this pull request Apr 5, 2024
* create ui for the full embedding homepage, without any logic (#40251)

* wip ui for the full embedding homepage

* adds missing link + fix keys

* remove done TODO

* Update frontend/src/metabase/home/components/EmbedHomepage/InteractiveTabContent.tsx

Co-authored-by: Mahatthana (Kelvin) Nomsawadi <me@bboykelvin.dev>

* destructure props in the function arguments

* rename customerFacingAnalyticsDocsUrl to analyticsDocsUrl

---------

Co-authored-by: Mahatthana (Kelvin) Nomsawadi <me@bboykelvin.dev>

* add new settings for embedding homepage (#40455)

* remove old minimal version

* adds new embedding homepage settings and sets them at the end of the setup

* comment e2e test

* add tests for embedding homepage flags

* more tests

* remove unit tests related to old minimal version

* fixes flags descriptions

* :keyword for embedding-homepage

Co-authored-by: Mahatthana (Kelvin) Nomsawadi <me@bboykelvin.dev>

* replace reloadSettings and refreshSettingsList with initializeSettings

* `value => value === true` -> `Boolean`

* toMatchObject -> toEqual for more strict tests

* remove useless undefined check for settings, the component is conditionally rendered based on a setting so it means they're loaded anyway

* fix: use :hidden as we changed the type to :keyword

* specifically check for the `embedding` feature in the tokenFeatures object instead of checking if any feature is active

* remove double \n

Co-authored-by: Noah Moss <32746338+noahmoss@users.noreply.github.com>

---------

Co-authored-by: Mahatthana (Kelvin) Nomsawadi <me@bboykelvin.dev>
Co-authored-by: Noah Moss <32746338+noahmoss@users.noreply.github.com>

* connect settings to the embed homepage and show it (#40528)

* fix nested a warnings in browser console

* connect settings to the embed homepage and show it

* fix stories

* remove localStorage.clear() as we're not using it in the logic anymore

* dismiss without feedback for the embedding homepage (#40587)

* feat: add dismiss functionality to the embed homepage

* update setup e2e to check for the dismissal of embedding homepage

* use List from metabase/ui (#40638)

* set embedding-secret-key when embedding is enabled (#40813)

* set embedding-secret-key when embedding is enabled

* use "named" setters and getters as suggested by Noah

* Fix tests for ms1 after updating on master (#41069)

---------

Co-authored-by: Mahatthana (Kelvin) Nomsawadi <me@bboykelvin.dev>
Co-authored-by: Noah Moss <32746338+noahmoss@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants