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

[chore]: Show an error popup when a user enters an invalid info #4177

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,7 @@ export default function CreateNewTokenController(props: CreateNewTokenController
const { mutate: createNewTokenMutation, isLoading } = useCreateApiTokenMutation(
{},
{
onSuccess: data => {
data.accessToken;
onSuccess: () => {
apiTokensRefetch();
showSuccess(getString('tokenCreateSuccessMessage'));
}
Expand Down
1 change: 1 addition & 0 deletions chaoscenter/web/src/strings/strings.en.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ allExecutions: All Executions
allFaultsExecuted: All your faults executed without any issue
allRuns: All Runs
alreadyExists: '{{value}} already exists'
alreadyExistsID: Entered id '{{value}}' already exists
apiTokens: API Tokens
appKind: App Kind
appKindName: app_kind
Expand Down
1 change: 1 addition & 0 deletions chaoscenter/web/src/strings/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ export interface StringsMap {
'allFaultsExecuted': unknown
'allRuns': unknown
'alreadyExists': PrimitiveObject<'value'>
'alreadyExistsID': PrimitiveObject<'value'>
'apiTokens': unknown
'appKind': unknown
'appKindName': unknown
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { FontVariation } from '@harnessio/design-system';
import { Button, ButtonVariation, Container, FormInput, Layout, Text } from '@harnessio/uicore';
import { Button, ButtonVariation, Container, FormInput, Layout, Text, useToaster } from '@harnessio/uicore';
import React from 'react';
import { Icon } from '@harnessio/icons';
import { Form, Formik } from 'formik';
Expand Down Expand Up @@ -28,6 +28,7 @@ interface AccountPasswordChangeFormProps {
export default function AccountPasswordChangeView(props: AccountPasswordChangeViewProps): React.ReactElement {
const { handleClose, updatePasswordMutation, updatePasswordMutationLoading, username } = props;
const { getString } = useStrings();
const { showError } = useToaster();

function isSubmitButtonDisabled(values: AccountPasswordChangeFormProps): boolean {
if (values.oldPassword === '' || values.newPassword === '' || values.reEnterNewPassword === '') {
Expand Down Expand Up @@ -56,6 +57,7 @@ export default function AccountPasswordChangeView(props: AccountPasswordChangeVi
}
},
{
onError: () => showError(getString('passwordsDoNotMatch')),
onSuccess: () => handleClose()
}
);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Button, ButtonVariation, CardSelect, Container, FormInput, Layout, Text } from '@harnessio/uicore';
import { Button, ButtonVariation, CardSelect, Container, FormInput, Layout, Text, useToaster } from '@harnessio/uicore';
import { FontVariation, Color } from '@harnessio/design-system';
import { Form, Formik } from 'formik';
import React from 'react';
Expand Down Expand Up @@ -48,6 +48,7 @@ export default function CreateEnvironment({
}: CreateEnvironmentProps): React.ReactElement {
const { getString } = useStrings();
const scope = getScope();
const { showError } = useToaster();
const initialValues: CreateEnvironmentData = {
id: editable ? environmentID ?? '' : '',
name: editable ? existingEnvironment?.name ?? '' : '',
Expand Down Expand Up @@ -87,6 +88,7 @@ export default function CreateEnvironment({
}
}
})
.catch(() => showError(getString('alreadyExistsID', { value: data.id })))
.then(() => closeModal())
: mutation.updateEnvironment &&
environmentID &&
Expand Down
Loading