Skip to content

Commit

Permalink
Display MySQL user defined error of piped, command, and application (#…
Browse files Browse the repository at this point in the history
…4597)

Signed-off-by: Kenta Kozuka <[email protected]>
  • Loading branch information
kentakozuka authored Sep 8, 2023
1 parent c3ce6f4 commit 06b38f3
Show file tree
Hide file tree
Showing 5 changed files with 24 additions and 16 deletions.
2 changes: 1 addition & 1 deletion pkg/app/server/grpcapi/grpcapi.go
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ func getCommand(ctx context.Context, store commandstore.Store, id string, logger
func addCommand(ctx context.Context, store commandstore.Store, cmd *model.Command, logger *zap.Logger) error {
if err := store.AddCommand(ctx, cmd); err != nil {
logger.Error("failed to create command", zap.Error(err))
return status.Error(codes.Internal, "Failed to create command")
return gRPCStoreError(err, "create command")
}
return nil
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ import { SplitButton } from "~/components/split-button";
import { APPLICATION_KIND_TEXT } from "~/constants/application-kind";
import { PAGE_PATH_DEPLOYMENTS } from "~/constants/path";
import { UI_TEXT_REFRESH } from "~/constants/ui-text";
import { useAppDispatch, useAppSelector } from "~/hooks/redux";
import { unwrapResult, useAppDispatch, useAppSelector } from "~/hooks/redux";
import {
Application,
ApplicationDeploymentReference,
Expand Down Expand Up @@ -238,7 +238,9 @@ export const ApplicationDetail: FC<ApplicationDetailProps> = memo(
applicationId: app.id,
syncStrategy: syncStrategyByIndex[index],
})
);
)
.then(unwrapResult)
.catch(() => undefined);
}
};

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import {
import { useFormik } from "formik";
import { FC, memo, useCallback, useState } from "react";
import { UI_TEXT_CANCEL, UI_TEXT_DISCARD } from "~/constants/ui-text";
import { useAppDispatch, useAppSelector } from "~/hooks/redux";
import { unwrapResult, useAppDispatch, useAppSelector } from "~/hooks/redux";
import { addApplication } from "~/modules/applications";
import { selectProjectName } from "~/modules/me";
import {
Expand Down Expand Up @@ -42,10 +42,14 @@ export const AddApplicationDrawer: FC<AddApplicationDrawerProps> = memo(
validationSchema,
enableReinitialize: true,
async onSubmit(values) {
await dispatch(addApplication(values));
onAdded();
onClose();
formik.resetForm();
await dispatch(addApplication(values))
.then(unwrapResult)
.then(() => {
onAdded();
onClose();
formik.resetForm();
})
.catch(() => undefined);
},
});

Expand Down
1 change: 0 additions & 1 deletion web/src/components/settings-page/api-key/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,6 @@ export const APIKeyPage: FC = memo(function APIKeyPage() {
dispatch(generateAPIKey(values))
.then(unwrapResult)
.then(() => {
console.log("handleSubmit.then");
dispatch(fetchAPIKeys({ enabled: true }));
dispatch(
addToast({ message: GENERATE_API_KEY_SUCCESS, severity: "success" })
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { Dialog } from "@material-ui/core";
import { useFormik } from "formik";
import { FC, memo, useCallback } from "react";
import { ADD_PIPED_SUCCESS } from "~/constants/toast-text";
import { useAppDispatch, useAppSelector } from "~/hooks/redux";
import { unwrapResult, useAppDispatch, useAppSelector } from "~/hooks/redux";
import { selectProjectName } from "~/modules/me";
import { addPiped } from "~/modules/pipeds";
import { addToast } from "~/modules/toasts";
Expand All @@ -23,12 +23,15 @@ export const AddPipedDialog: FC<AddPipedDrawerProps> = memo(
validationSchema,
validateOnMount: true,
async onSubmit(values) {
await dispatch(addPiped(values)).then(() => {
dispatch(
addToast({ message: ADD_PIPED_SUCCESS, severity: "success" })
);
onClose();
});
await dispatch(addPiped(values))
.then(unwrapResult)
.then(() => {
dispatch(
addToast({ message: ADD_PIPED_SUCCESS, severity: "success" })
);
onClose();
})
.catch(() => undefined);
},
});

Expand Down

0 comments on commit 06b38f3

Please sign in to comment.