Skip to content

Commit 0979f59

Browse files
committed
refactor: TabGroup - disabled css class update, useForm - error type changed from string | string | null to string[] | null
1 parent 7a72233 commit 0979f59

File tree

6 files changed

+10
-12
lines changed

6 files changed

+10
-12
lines changed

src/Pages/Applications/DevtronApps/Details/AppConfigurations/DeploymentTemplate/service.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ import {
1212
ResolvedDeploymentTemplateDTO,
1313
ValuesAndManifestFlagDTO,
1414
} from './types'
15+
import { GET_RESOLVED_DEPLOYMENT_TEMPLATE_EMPTY_RESPONSE } from './constants'
1516

1617
export const getDeploymentManifest = async (
1718
params: GetDeploymentManifestProps,
@@ -60,6 +61,6 @@ export const getResolvedDeploymentTemplate = async (
6061
showError(error)
6162
throw error
6263
}
63-
return null
64+
return GET_RESOLVED_DEPLOYMENT_TEMPLATE_EMPTY_RESPONSE
6465
}
6566
}

src/Shared/Components/CICDHistory/DeploymentHistoryDiff/DeploymentHistoryDiffView.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -87,6 +87,7 @@ const DeploymentHistoryDiffView = ({
8787

8888
const renderDeploymentDiffViaCodeEditor = () => (
8989
<CodeEditor
90+
// TODO: Add key from prop
9091
key={`${sortBy}-${sortOrder}`}
9192
value={editorValuesRHS}
9293
defaultValue={editorValuesLHS}

src/Shared/Components/TabGroup/TabGroup.component.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,7 @@ const Tab = ({
101101

102102
const renderTabContainer = () => (
103103
<li
104-
className={`tab-group__tab lh-20 ${active ? 'tab-group__tab--active cb-5 fw-6' : 'cn-9 fw-4'} ${alignActiveBorderWithContainer ? 'tab-group__tab--align-active-border' : ''} ${tabType === 'block' ? 'tab-group__tab--block' : ''} ${disabled ? 'cursor-not-allowed dc__opacity-0_5' : 'cursor'}`}
104+
className={`tab-group__tab lh-20 ${active ? 'tab-group__tab--active cb-5 fw-6' : 'cn-9 fw-4'} ${alignActiveBorderWithContainer ? 'tab-group__tab--align-active-border' : ''} ${tabType === 'block' ? 'tab-group__tab--block' : ''} ${disabled ? 'dc__disabled' : 'cursor'}`}
105105
>
106106
{getTabComponent()}
107107
</li>

src/Shared/Components/TabGroup/TabGroup.scss

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@
3333
bottom: -1px;
3434
}
3535

36-
&:hover:not(.tab-group__tab--block):not(.dc__opacity-0_5) {
36+
&:hover:not(.tab-group__tab--block):not(.dc__disabled) {
3737
color: var(--B500);
3838
@include svg-styles(var(--B500));
3939
}

src/Shared/Hooks/useForm/useForm.types.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -52,9 +52,9 @@ export interface UseFormValidation {
5252

5353
/**
5454
* Represents the structure for form validation errors.
55-
* Maps each field to an error message or an array of error messages.
55+
* Maps each field to an array of error messages.
5656
*/
57-
export type UseFormErrors<T> = Partial<Record<keyof T, string | string[]>>
57+
export type UseFormErrors<T> = Partial<Record<keyof T, string[]>>
5858

5959
/**
6060
* Represents the fields that have been modified ("dirty") in the form.

src/Shared/Hooks/useForm/useForm.utils.ts

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -11,13 +11,13 @@ import { UseFormValidation } from './useForm.types'
1111
export const checkValidation = <T extends Record<keyof T, any> = {}>(
1212
value: T[keyof T],
1313
validation: UseFormValidation,
14-
): string | string[] | null => {
14+
): string[] | null => {
1515
if (
1616
validation?.required &&
1717
(typeof validation.required === 'object' ? validation.required.value : validation.required) &&
1818
(value === null || value === undefined || value === '')
1919
) {
20-
return typeof validation.required === 'object' ? validation.required.message : 'This is a required field'
20+
return [typeof validation.required === 'object' ? validation.required.message : 'This is a required field']
2121
}
2222

2323
const errors = []
@@ -53,9 +53,5 @@ export const checkValidation = <T extends Record<keyof T, any> = {}>(
5353
errors.push(custom.message)
5454
}
5555

56-
if (!errors.length) {
57-
return null
58-
}
59-
60-
return errors.length === 1 ? errors[0] : errors
56+
return errors.length ? errors : null
6157
}

0 commit comments

Comments
 (0)