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

update lifecycle component to accept strings + commas #4919

Merged
merged 7 commits into from
Feb 14, 2024
Merged

Conversation

mirnawong1
Copy link
Contributor

@mirnawong1 mirnawong1 commented Feb 14, 2024

this pr quickly updates the lifcycle pill so that we can use the lifecycle pill without the curly brackets (### test <Lifecycle status="team,enterprise"/>)

and updated the lifecycle code to check if the status is a string and accept strings separated by commands (without curly brackets).

@mirnawong1 mirnawong1 requested a review from a team as a code owner February 14, 2024 17:31
Copy link

vercel bot commented Feb 14, 2024

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

Name Status Preview Comments Updated (UTC)
docs-getdbt-com ✅ Ready (Inspect) Visit Preview 💬 Add feedback Feb 14, 2024 8:20pm

@github-actions github-actions bot added size: x-small This change will take under 3 hours to fix. Docs team Authored by the Docs team @dbt Labs labels Feb 14, 2024
@mirnawong1 mirnawong1 changed the title update to accept strings + commas update lifecycle component to accept strings + commas Feb 14, 2024
@@ -8,6 +8,8 @@ meta:
api_name: dbt Semantic Layer APIs
---

### test <Lifecycle status="team,enterprise"/>
Copy link
Contributor Author

Choose a reason for hiding this comment

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

tessting to see if build comes out right. will remove

@mirnawong1
Copy link
Contributor Author

@@ -8,6 +8,8 @@ meta:
api_name: dbt Semantic Layer APIs
---

### test <Lifecycle status="team,enterprise"/>
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Suggested change
### test <Lifecycle status="team,enterprise"/>

Copy link
Collaborator

@JKarlavige JKarlavige left a comment

Choose a reason for hiding this comment

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

This is close! Left one comment walking through a few adjustments 😁

Comment on lines 25 to 28
// Check if props.status is an array or a single value amd to handle strings separated by commas
const statuses = typeof props.status ==='string'
?props.status.split(',').map(s => s.trim())
: Array.isArray(props.status) ? props.status : [props.status];
Copy link
Collaborator

Choose a reason for hiding this comment

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

Now that we're always passing in a string, there's a couple adjustments we can make:

You're on the right track with using .split(',')! I recommend updating this section and simply setting const statuses = props?.status?.split(','). This will always create an array, even if one item is passed in without a comma.

For example, passing in status="enterprise" will set props?.status?.split(',') to ['enterprise']. If the status prop isn't set on a component, statuses will become undefined.

I then recommend moving this line above the if check on line 22. We can then update the if check to: if(!statuses?.length). This will check if statuses has a value and is an array. If not, return null. Otherwise apply the html.

Let me know if you have any questions!

Copy link
Contributor Author

@mirnawong1 mirnawong1 Feb 14, 2024

Choose a reason for hiding this comment

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

ok awesome! thank you so much @JKarlavige ! i made those changes. one thing i kept though was

  if (!props.status || (Array.isArray(props.status) && props.status.length === 0)) {
    return null;
  }

because if i didn't add a status, the header would display a dash:
Screenshot 2024-02-14 at 18 29 14

Copy link
Collaborator

Choose a reason for hiding this comment

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

Nice catch, was able to recreate when passing an empty string into the status prop: status="". I merged your if check into the updated one so we only have 1 if check. The !props.status is enough to verify if status is an empty string.

Added the component to a few headers to double-check the build one more time, if the build passes i'll get this merged!

@github-actions github-actions bot added size: small This change will take 1 to 2 days to address and removed size: x-small This change will take under 3 hours to fix. labels Feb 14, 2024
@JKarlavige
Copy link
Collaborator

Build completed successfully after the latest updates. Verified the following:

<Lifecycle status="team,enterprise" /> shows the pricing plans
image

<Lifecycle status="" /> does not render the component

<Lifecycle /> does not render the component

<Lifecycle status="custom" /> renders the component with default bg
image

Also verified the link copying works!

Copy link
Collaborator

@JKarlavige JKarlavige left a comment

Choose a reason for hiding this comment

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

:shipit:

@github-actions github-actions bot added size: x-small This change will take under 3 hours to fix. and removed size: small This change will take 1 to 2 days to address labels Feb 14, 2024
@JKarlavige JKarlavige enabled auto-merge February 14, 2024 20:13
@JKarlavige JKarlavige merged commit 35bd14c into current Feb 14, 2024
7 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Docs team Authored by the Docs team @dbt Labs February-2024 size: x-small This change will take under 3 hours to fix.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants