Skip to content

Commit

Permalink
test toast
Browse files Browse the repository at this point in the history
  • Loading branch information
abe garcia committed Jun 29, 2023
1 parent f586f33 commit 5c9914b
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,16 @@ import { broadside } from '../../services/';
interface IRetriggerButtonProps {
executions: IExecution[];
refreshExecutions: () => void;
handleSuccess: (msg: string) => void;
handleError: (msg: string) => void;
}

export const RetriggerButton = ({ executions, refreshExecutions }: IRetriggerButtonProps) => {
export const RetriggerButton = ({
executions,
refreshExecutions,
handleSuccess,
handleError,
}: IRetriggerButtonProps) => {
const [retriggerInProgress, setRetriggerInProgress] = useState(false);
const [hover, setHover] = useState(false);

Expand All @@ -25,11 +32,13 @@ export const RetriggerButton = ({ executions, refreshExecutions }: IRetriggerBut
.then((res) => {
// eslint-disable-next-line no-console
console.log('retriggered: ', res.status);
handleSuccess('Pipelines Retriggered');
setRetriggerInProgress(false);
})
.catch((e) => {
//TODO: surface this error
console.error('error retriggering: ', e);
handleError(e);
})
.finally(() => {
setRetriggerInProgress(false);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -74,11 +74,19 @@ export const ExecutionsTable = ({ executions, parameters, refreshExecutions }: I
};

const isSelected = (name: string) => selectedExecutionIds.indexOf(name) !== -1;
const showToastMessage = () => {
toast.success('Success Notification !', {
position: toast.POSITION.TOP_RIGHT,

const handleError = (msg: string) => {
toast.error(msg, {
position: toast.POSITION.BOTTOM_RIGHT,
});
};

const handleSuccess = (msg: string) => {
toast(msg, {
position: toast.POSITION.BOTTOM_RIGHT,
});
};

return (
<TableContainer component={Paper} classes={{ root: styles.tableContainer }}>
<Table stickyHeader>
Expand Down Expand Up @@ -107,6 +115,8 @@ export const ExecutionsTable = ({ executions, parameters, refreshExecutions }: I
<RetriggerButton
executions={executions.filter((e) => selectedExecutionIds.includes(e.id))}
refreshExecutions={refreshExecutions}
handleSuccess={handleSuccess}
handleError={handleError}
/>
</ActionButtonsContainer>
</TableCell>
Expand Down Expand Up @@ -136,8 +146,7 @@ export const ExecutionsTable = ({ executions, parameters, refreshExecutions }: I
</TableFooter>
</Table>
<div>
<button onClick={showToastMessage}>Notify</button>
<ToastContainer />
<ToastContainer position="bottom-right" autoClose={false} newestOnTop={true} closeOnClick={false} />
</div>
</TableContainer>
);
Expand Down
4 changes: 1 addition & 3 deletions spin-observatory-plugin-deck/src/services/broadside.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import type { IExecution } from '@spinnaker/core';
import { SETTINGS } from '@spinnaker/core';
// http://broadside.cd:80
const BROADSIDE_URI = `${SETTINGS.gateUrl}/proxies/broadside/v1/broadsides`;
const BROADSIDE_URI = `${SETTINGS.gateUrl}/proxies/broadside/v1/broadside`;

// See https://github.com/one-thd/broadside/blob/main/api/swagger.yml#L206
const retriggerExecutions = ({ executions }: { executions: IExecution[] }) => {
Expand All @@ -13,8 +13,6 @@ const retriggerExecutions = ({ executions }: { executions: IExecution[] }) => {
* pipelineBaseParameters: '{ "parameterName": "custom data" }'
* pipelineMultiParameters: '[ { "multiParameterName": "custom data" } ]'
*/
// eslint-disable-next-line no-console
console.log({ executions });

const application = executions[0].application;
const pipelineNameOrId = executions[0].name;
Expand Down

0 comments on commit 5c9914b

Please sign in to comment.