-
Notifications
You must be signed in to change notification settings - Fork 977
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
Conversation
The latest updates on your projects. Learn more about Vercel for Git ↗︎
|
@@ -8,6 +8,8 @@ meta: | |||
api_name: dbt Semantic Layer APIs | |||
--- | |||
|
|||
### test <Lifecycle status="team,enterprise"/> |
There was a problem hiding this comment.
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
@@ -8,6 +8,8 @@ meta: | |||
api_name: dbt Semantic Layer APIs | |||
--- | |||
|
|||
### test <Lifecycle status="team,enterprise"/> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
### test <Lifecycle status="team,enterprise"/> |
There was a problem hiding this 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 😁
// 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]; |
There was a problem hiding this comment.
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!
There was a problem hiding this comment.
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:
There was a problem hiding this comment.
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!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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).