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

Make state badge prefer its state prop's type if present. #2210

Merged
merged 1 commit into from Mar 13, 2024

Conversation

collincchoy
Copy link
Collaborator

This PR contains a small change to have the StateBadge use its state type directly for styling if present else fallback to the current method of deriving the type from its name.

This enables custom flow run states to render in styled like their actual, inherent state type while maintaining the custom name.

@flow
def hello_world():
    return State(
        type=StateType.COMPLETED,
        name="My custom name",
        message="My custom message.",
    )
Before After
image image

@collincchoy collincchoy requested a review from a team as a code owner March 13, 2024 16:27
@@ -18,7 +18,7 @@
dismissible?: boolean,
}>()

const type = computed(() => mapStateNameToStateType(props.state?.name).type)
const type = computed(() => props.state?.type ?? mapStateNameToStateType(props.state?.name).type)
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

In the example flow in the PR description, props.state.type === 'completed' already but the state has a custom name so before, it wouldn't map to any type.

Copy link
Collaborator

@pleek91 pleek91 left a comment

Choose a reason for hiding this comment

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

Ah nice, yeah should have been this way to begin with. TY!

Copy link
Contributor

@znicholasbrown znicholasbrown left a comment

Choose a reason for hiding this comment

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

love this

@collincchoy collincchoy merged commit ee6012c into main Mar 13, 2024
3 checks passed
@collincchoy collincchoy deleted the custom-flow-run-state-badges-maintain-their-type branch March 13, 2024 16:44
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants