Skip to content

Commit

Permalink
Merge pull request #916 from porter-dev/0.6.0-911-webhook-generation
Browse files Browse the repository at this point in the history
[0.6.0] Fixes #911: it should be possible to regenerate webhooks
  • Loading branch information
abelanger5 authored Jul 23, 2021
2 parents c04ea42 + 61a1a97 commit 16b9e28
Show file tree
Hide file tree
Showing 5 changed files with 381 additions and 164 deletions.
71 changes: 55 additions & 16 deletions dashboard/src/components/SaveButton.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@ type PropsType = {

// Makes flush with corner if not within a modal
makeFlush?: boolean;
clearPosition?: boolean;
statusPosition?: "right" | "left";
};

type StateType = {};
Expand All @@ -21,51 +23,70 @@ export default class SaveButton extends Component<PropsType, StateType> {
if (this.props.status) {
if (this.props.status === "successful") {
return (
<StatusWrapper successful={true}>
<StatusWrapper position={this.props.statusPosition} successful={true}>
<i className="material-icons">done</i>
<StatusTextWrapper>Successfully updated</StatusTextWrapper>
</StatusWrapper>
);
} else if (this.props.status === "loading") {
return (
<StatusWrapper successful={false}>
<StatusWrapper
position={this.props.statusPosition}
successful={false}
>
<LoadingGif src={loading} />
<StatusTextWrapper>Updating . . .</StatusTextWrapper>
</StatusWrapper>
);
} else if (this.props.status === "error") {
return (
<StatusWrapper successful={false}>
<StatusWrapper
position={this.props.statusPosition}
successful={false}
>
<i className="material-icons">error_outline</i>
<StatusTextWrapper>Could not update</StatusTextWrapper>
</StatusWrapper>
);
} else {
return (
<StatusWrapper successful={false}>
<StatusWrapper
position={this.props.statusPosition}
successful={false}
>
<i className="material-icons">error_outline</i>
<StatusTextWrapper>{this.props.status}</StatusTextWrapper>
</StatusWrapper>
);
}
} else if (this.props.helper) {
return (
<StatusWrapper successful={true}>{this.props.helper}</StatusWrapper>
<StatusWrapper position={this.props.statusPosition} successful={true}>
{this.props.helper}
</StatusWrapper>
);
}
};

render() {
return (
<ButtonWrapper makeFlush={this.props.makeFlush}>
<div>{this.renderStatus()}</div>
<ButtonWrapper
makeFlush={this.props.makeFlush}
clearPosition={this.props.clearPosition}
>
{this.props.statusPosition !== "right" && (
<div>{this.renderStatus()}</div>
)}
<Button
disabled={this.props.disabled}
onClick={this.props.onClick}
color={this.props.color || "#616FEEcc"}
>
{this.props.text}
</Button>
{this.props.statusPosition === "right" && (
<div>{this.renderStatus()}</div>
)}
</ButtonWrapper>
);
}
Expand All @@ -87,13 +108,21 @@ const StatusTextWrapper = styled.p`
margin: 0;
`;

const StatusWrapper = styled.div`
const StatusWrapper = styled.div<{
successful: boolean;
position: "right" | "left";
}>`
display: flex;
align-items: center;
font-family: "Work Sans", sans-serif;
font-size: 13px;
color: #ffffff55;
margin-right: 25px;
${(props) => {
if (props.position !== "right") {
return "margin-right: 25px;";
}
return "margin-left: 25px;";
}}
max-width: 500px;
overflow: hidden;
text-overflow: ellipsis;
Expand All @@ -102,8 +131,7 @@ const StatusWrapper = styled.div`
font-size: 18px;
margin-right: 10px;
float: left;
color: ${(props: { successful: boolean }) =>
props.successful ? "#4797ff" : "#fcba03"};
color: ${(props) => (props.successful ? "#4797ff" : "#fcba03")};
}
animation: statusFloatIn 0.5s;
Expand All @@ -122,19 +150,30 @@ const StatusWrapper = styled.div`
`;

const ButtonWrapper = styled.div`
display: flex;
align-items: center;
position: absolute;
justify-content: flex-end;
${(props: { makeFlush: boolean }) => {
${(props: { makeFlush: boolean; clearPosition?: boolean }) => {
const baseStyles = `
display: flex;
align-items: center;
`;
if (props.clearPosition) {
return baseStyles;
}
if (!props.makeFlush) {
return `
${baseStyles}
position: absolute;
justify-content: flex-end;
bottom: 25px;
right: 27px;
left: 27px;
`;
}
return `
${baseStyles}
position: absolute;
justify-content: flex-end;
bottom: 5px;
right: 0;
`;
Expand Down
Loading

0 comments on commit 16b9e28

Please sign in to comment.