= ({ targetPatternsCount, rulesAppliedCount, bypassAllowed }) => {
+ const { t } = useTranslation()
return (
{targetPatternsCount} {t('views:repos.targetPatterns', 'target patterns')}
@@ -53,7 +52,6 @@ export interface RepoSettingsGeneralRulesProps {
apiError: { type: ErrorTypes; message: string } | null
handleRuleClick: (identifier: string) => void
openRulesAlertDeleteDialog: (identifier: string) => void
- useTranslationStore: () => TranslationStore
isLoading: boolean
rulesSearchQuery?: string
setRulesSearchQuery?: (query: string) => void
@@ -65,14 +63,13 @@ export const RepoSettingsGeneralRules: FC = ({
apiError,
handleRuleClick,
openRulesAlertDeleteDialog,
- useTranslationStore,
isLoading,
rulesSearchQuery,
setRulesSearchQuery,
projectScope = false
}) => {
const { Link, NavLink } = useRouterContext()
- const { t } = useTranslationStore()
+ const { t } = useTranslation()
const handleSearchChange = useCallback(
(val: string) => {
@@ -166,7 +163,6 @@ export const RepoSettingsGeneralRules: FC = ({
targetPatternsCount={rule.targetPatternsCount ?? 0}
rulesAppliedCount={rule.rulesAppliedCount ?? 0}
bypassAllowed={rule.bypassAllowed ?? false}
- t={t}
/>
}
/>
diff --git a/packages/ui/src/views/repo/repo-settings/components/repo-settings-general-security.tsx b/packages/ui/src/views/repo/repo-settings/components/repo-settings-general-security.tsx
index bdb0665d89..5669569fe0 100644
--- a/packages/ui/src/views/repo/repo-settings/components/repo-settings-general-security.tsx
+++ b/packages/ui/src/views/repo/repo-settings/components/repo-settings-general-security.tsx
@@ -2,8 +2,8 @@ import { FC, useEffect } from 'react'
import { useForm } from 'react-hook-form'
import { Checkbox, ControlGroup, Fieldset, Message, MessageTheme, SkeletonForm, Spacer, Text } from '@/components'
+import { useTranslation } from '@/context'
import { zodResolver } from '@hookform/resolvers/zod'
-import { TranslationStore } from '@views/repo/repo-list/types'
import { z } from 'zod'
import { ErrorTypes } from '../types'
@@ -20,7 +20,6 @@ interface RepoSettingsSecurityFormProps {
handleUpdateSecuritySettings: (data: RepoSettingsSecurityFormFields) => void
isUpdatingSecuritySettings: boolean
isLoadingSecuritySettings: boolean
- useTranslationStore: () => TranslationStore
}
export const RepoSettingsSecurityForm: FC = ({
@@ -28,10 +27,9 @@ export const RepoSettingsSecurityForm: FC = ({
handleUpdateSecuritySettings,
apiError,
isUpdatingSecuritySettings,
- isLoadingSecuritySettings,
- useTranslationStore
+ isLoadingSecuritySettings
}) => {
- const { t } = useTranslationStore()
+ const { t } = useTranslation()
const {
handleSubmit,
setValue,
diff --git a/packages/ui/src/views/repo/repo-settings/repo-settings-general-page.tsx b/packages/ui/src/views/repo/repo-settings/repo-settings-general-page.tsx
index a3668966dc..fabe01e11d 100644
--- a/packages/ui/src/views/repo/repo-settings/repo-settings-general-page.tsx
+++ b/packages/ui/src/views/repo/repo-settings/repo-settings-general-page.tsx
@@ -1,8 +1,8 @@
import { FC, useEffect, useRef } from 'react'
import { Fieldset, FormSeparator } from '@/components'
-import { useRouterContext } from '@/context'
-import { SandboxLayout, TranslationStore } from '@/views'
+import { useRouterContext, useTranslation } from '@/context'
+import { SandboxLayout } from '@/views'
import { BranchSelectorContainerProps } from '@/views/repo/components'
import { RepoSettingsGeneralDelete } from './components/repo-settings-general-delete'
@@ -29,7 +29,6 @@ interface RepoSettingsGeneralPageProps {
openRulesAlertDeleteDialog: (identifier: string) => void
openRepoAlertDeleteDialog: () => void
useRepoRulesStore: () => IRepoStore
- useTranslationStore: () => TranslationStore
rulesSearchQuery: string
setRulesSearchQuery: (query: string) => void
branchSelectorRenderer: React.ComponentType
@@ -45,13 +44,12 @@ export const RepoSettingsGeneralPage: FC = ({
openRulesAlertDeleteDialog,
openRepoAlertDeleteDialog,
useRepoRulesStore,
- useTranslationStore,
rulesSearchQuery,
setRulesSearchQuery,
branchSelectorRenderer
}) => {
const { location } = useRouterContext()
- const { t } = useTranslationStore()
+ const { t } = useTranslation()
const rulesRef = useRef(null)
useEffect(() => {
@@ -78,7 +76,6 @@ export const RepoSettingsGeneralPage: FC = ({
isLoadingRepoData={loadingStates.isLoadingRepoData}
isUpdatingRepoData={loadingStates.isUpdatingRepoData}
isRepoUpdateSuccess={isRepoUpdateSuccess}
- useTranslationStore={useTranslationStore}
branchSelectorRenderer={branchSelectorRenderer}
/>
@@ -89,7 +86,6 @@ export const RepoSettingsGeneralPage: FC = ({
apiError={apiError}
handleRuleClick={handleRuleClick}
openRulesAlertDeleteDialog={openRulesAlertDeleteDialog}
- useTranslationStore={useTranslationStore}
rulesSearchQuery={rulesSearchQuery}
setRulesSearchQuery={setRulesSearchQuery}
/>
@@ -101,14 +97,9 @@ export const RepoSettingsGeneralPage: FC = ({
apiError={apiError}
isUpdatingSecuritySettings={loadingStates.isUpdatingSecuritySettings}
isLoadingSecuritySettings={loadingStates.isLoadingSecuritySettings}
- useTranslationStore={useTranslationStore}
/>
-
+
)
diff --git a/packages/ui/src/views/repo/repo-settings/repo-settings-layout.tsx b/packages/ui/src/views/repo/repo-settings/repo-settings-layout.tsx
index 8cf6ebbc7e..631f30ed18 100644
--- a/packages/ui/src/views/repo/repo-settings/repo-settings-layout.tsx
+++ b/packages/ui/src/views/repo/repo-settings/repo-settings-layout.tsx
@@ -1,8 +1,7 @@
-import { useRouterContext } from '@/context'
-import { ContentLayoutWithSidebar, TranslationStore } from '@/views'
-import { TFunction } from 'i18next'
+import { TFunctionWithFallback, useRouterContext, useTranslation } from '@/context'
+import { ContentLayoutWithSidebar } from '@/views'
-const getNavItems = (t: TFunction) => [
+const getNavItems = (t: TFunctionWithFallback) => [
{
groupId: 0,
title: t('views:repos.general', 'General'),
@@ -47,9 +46,9 @@ const getNavItems = (t: TFunction) => [
// }
]
-export function RepoSettingsLayout({ useTranslationStore }: { useTranslationStore: () => TranslationStore }) {
+export function RepoSettingsLayout() {
const { Outlet } = useRouterContext()
- const { t } = useTranslationStore()
+ const { t } = useTranslation()
return (
diff --git a/packages/ui/src/views/repo/repo-sidebar/index.tsx b/packages/ui/src/views/repo/repo-sidebar/index.tsx
index 6dbe5191dd..35ec4f798a 100644
--- a/packages/ui/src/views/repo/repo-sidebar/index.tsx
+++ b/packages/ui/src/views/repo/repo-sidebar/index.tsx
@@ -1,14 +1,13 @@
import { ReactNode } from 'react'
import { Button, Icon, ScrollArea, SearchFiles, Spacer } from '@/components'
-import { SandboxLayout, TranslationStore } from '@/views'
+import { SandboxLayout } from '@/views'
interface RepoSidebarProps {
navigateToNewFile: () => void
navigateToFile: (file: string) => void
filesList?: string[]
children: ReactNode
- useTranslationStore: () => TranslationStore
branchSelectorRenderer: ReactNode
}
@@ -17,8 +16,7 @@ export const RepoSidebar = ({
branchSelectorRenderer,
navigateToFile,
filesList,
- children,
- useTranslationStore
+ children
}: RepoSidebarProps) => {
return (
<>
@@ -33,11 +31,7 @@ export const RepoSidebar = ({
-
+
{children}
diff --git a/packages/ui/src/views/repo/repo-summary/components/clone-repo-dialog.tsx b/packages/ui/src/views/repo/repo-summary/components/clone-repo-dialog.tsx
index 73e834df2d..f4a12ee535 100644
--- a/packages/ui/src/views/repo/repo-summary/components/clone-repo-dialog.tsx
+++ b/packages/ui/src/views/repo/repo-summary/components/clone-repo-dialog.tsx
@@ -1,13 +1,12 @@
import { FC, useState } from 'react'
import { Alert, Button, CopyButton, DropdownMenu, Icon, Tabs, TextInput } from '@/components'
-import { TranslationStore } from '@/views'
+import { useTranslation } from '@/context'
export interface CloneRepoDialogProps {
sshUrl?: string
httpsUrl: string
handleCreateToken: () => void
- useTranslationStore: () => TranslationStore
tokenGenerationError?: string | null
}
@@ -20,11 +19,10 @@ export const CloneRepoDialog: FC = ({
httpsUrl,
sshUrl,
handleCreateToken,
- useTranslationStore,
tokenGenerationError
}) => {
const [currentTab, setCurrentTab] = useState(CloneRepoTabs.HTTPS)
- const { t } = useTranslationStore()
+ const { t } = useTranslation()
const isSSHAvailable = !!sshUrl
diff --git a/packages/ui/src/views/repo/repo-summary/components/summary-panel.tsx b/packages/ui/src/views/repo/repo-summary/components/summary-panel.tsx
index 2065225016..eafa084883 100644
--- a/packages/ui/src/views/repo/repo-summary/components/summary-panel.tsx
+++ b/packages/ui/src/views/repo/repo-summary/components/summary-panel.tsx
@@ -1,8 +1,7 @@
import { FC } from 'react'
import { Button, CounterBadge, DropdownMenu, Icon, IconProps, Spacer, Tag, Text } from '@/components'
-import { useRouterContext } from '@/context'
-import { TranslationStore } from '@views/repo/repo-list/types'
+import { useRouterContext, useTranslation } from '@/context'
import { EditRepoDetails } from './edit-repo-details-dialog'
@@ -24,7 +23,6 @@ interface SummaryPanelProps {
updateRepoError?: string
isEditDialogOpen: boolean
setEditDialogOpen: (value: boolean) => void
- useTranslationStore: () => TranslationStore
}
const SummaryPanel: FC = ({
@@ -36,10 +34,9 @@ const SummaryPanel: FC = ({
saveDescription,
updateRepoError,
isEditDialogOpen,
- setEditDialogOpen,
- useTranslationStore
+ setEditDialogOpen
}) => {
- const { t } = useTranslationStore()
+ const { t } = useTranslation()
const onClose = () => {
setEditDialogOpen(false)
}
diff --git a/packages/ui/src/views/repo/repo-summary/repo-summary.tsx b/packages/ui/src/views/repo/repo-summary/repo-summary.tsx
index ad618c160a..2f88d6bf08 100644
--- a/packages/ui/src/views/repo/repo-summary/repo-summary.tsx
+++ b/packages/ui/src/views/repo/repo-summary/repo-summary.tsx
@@ -10,9 +10,9 @@ import {
StackedList,
Text
} from '@/components'
-import { useRouterContext } from '@/context'
+import { useRouterContext, useTranslation } from '@/context'
import { formatDate } from '@/utils'
-import { BranchSelectorListItem, CommitDivergenceType, RepoFile, SandboxLayout, TranslationStore } from '@/views'
+import { BranchSelectorListItem, CommitDivergenceType, RepoFile, SandboxLayout } from '@/views'
import { BranchInfoBar, BranchSelectorTab, Summary } from '@/views/repo/components'
import { CloneRepoDialog } from './components/clone-repo-dialog'
@@ -68,7 +68,6 @@ export interface RepoSummaryViewProps extends Partial {
}
saveDescription: (description: string) => void
updateRepoError?: string
- useTranslationStore: () => TranslationStore
isEditDialogOpen: boolean
setEditDialogOpen: (value: boolean) => void
currentBranchDivergence: CommitDivergenceType
@@ -99,7 +98,6 @@ export function RepoSummaryView({
updateRepoError,
isEditDialogOpen,
setEditDialogOpen,
- useTranslationStore,
currentBranchDivergence,
handleCreateToken,
toRepoFiles,
@@ -114,7 +112,7 @@ export function RepoSummaryView({
...props
}: RepoSummaryViewProps) {
const { Link } = useRouterContext()
- const { t } = useTranslationStore()
+ const { t } = useTranslation()
if (loading) {
return (
@@ -183,11 +181,7 @@ export function RepoSummaryView({
{branchSelectorRenderer}
-
+
@@ -207,7 +201,6 @@ export function RepoSummaryView({
sshUrl={repository?.git_ssh_url}
httpsUrl={repository?.git_url ?? 'could not fetch url'}
handleCreateToken={handleCreateToken}
- useTranslationStore={useTranslationStore}
tokenGenerationError={tokenGenerationError}
/>
@@ -240,7 +233,6 @@ export function RepoSummaryView({
sha: latestCommitInfo?.sha || ''
}}
files={files}
- useTranslationStore={useTranslationStore}
toRepoFileDetails={toRepoFileDetails}
hideHeader
/>
@@ -307,7 +299,6 @@ export function RepoSummaryView({
isEditDialogOpen={isEditDialogOpen}
setEditDialogOpen={setEditDialogOpen}
is_public={repository?.is_public}
- useTranslationStore={useTranslationStore}
/>
{renderSidebarComponent}
diff --git a/packages/ui/src/views/repo/repo-tags/components/create-tag/create-tag-dialog.tsx b/packages/ui/src/views/repo/repo-tags/components/create-tag/create-tag-dialog.tsx
index a8d60f3edd..d1f1673b57 100644
--- a/packages/ui/src/views/repo/repo-tags/components/create-tag/create-tag-dialog.tsx
+++ b/packages/ui/src/views/repo/repo-tags/components/create-tag/create-tag-dialog.tsx
@@ -2,7 +2,8 @@ import { FC, useCallback, useEffect } from 'react'
import { useForm } from 'react-hook-form'
import { Alert, Button, ControlGroup, Dialog, FormInput, FormWrapper, Label } from '@/components'
-import { BranchSelectorListItem, TranslationStore } from '@/views/repo'
+import { useTranslation } from '@/context'
+import { BranchSelectorListItem } from '@/views/repo'
import { CreateTagFormFields, makeCreateTagFormSchema } from '@/views/repo/repo-tags/components/create-tag/schema'
import { zodResolver } from '@hookform/resolvers/zod'
@@ -17,7 +18,6 @@ interface CreateTagDialogProps {
onClose: () => void
onSubmit: (data: CreateTagFormFields) => void
error?: string
- useTranslationStore: () => TranslationStore
isLoading?: boolean
selectedBranchOrTag: BranchSelectorListItem | null
branchSelectorRenderer: () => JSX.Element | null
@@ -28,12 +28,11 @@ export const CreateTagDialog: FC = ({
onClose,
onSubmit,
error,
- useTranslationStore,
isLoading = false,
selectedBranchOrTag,
branchSelectorRenderer: BranchSelectorContainer
}) => {
- const { t } = useTranslationStore()
+ const { t } = useTranslation()
const formMethods = useForm({
resolver: zodResolver(makeCreateTagFormSchema(t)),
diff --git a/packages/ui/src/views/repo/repo-tags/components/create-tag/schema.ts b/packages/ui/src/views/repo/repo-tags/components/create-tag/schema.ts
index 90c0689bd2..38dd6813c5 100644
--- a/packages/ui/src/views/repo/repo-tags/components/create-tag/schema.ts
+++ b/packages/ui/src/views/repo/repo-tags/components/create-tag/schema.ts
@@ -1,7 +1,7 @@
-import { TranslationStore } from '@views/repo'
+import { TFunctionWithFallback } from '@/context'
import { z } from 'zod'
-export const makeCreateTagFormSchema = (t: TranslationStore['t']) =>
+export const makeCreateTagFormSchema = (t: TFunctionWithFallback) =>
z.object({
name: z
.string()
diff --git a/packages/ui/src/views/repo/repo-tags/components/repo-tags-list.tsx b/packages/ui/src/views/repo/repo-tags/components/repo-tags-list.tsx
index 6abf9f6a21..3aeaa5a2d3 100644
--- a/packages/ui/src/views/repo/repo-tags/components/repo-tags-list.tsx
+++ b/packages/ui/src/views/repo/repo-tags/components/repo-tags-list.tsx
@@ -1,11 +1,11 @@
import { FC } from 'react'
import { Avatar, CommitCopyActions, MoreActionsTooltip, NoData, SkeletonTable, Table, Text } from '@/components'
+import { useTranslation } from '@/context'
import { timeAgo } from '@/utils'
-import { BranchSelectorListItem, CommitTagType, RepoTagsStore, TranslationStore } from '@/views'
+import { BranchSelectorListItem, CommitTagType, RepoTagsStore } from '@/views'
interface RepoTagsListProps {
- useTranslationStore: () => TranslationStore
onDeleteTag: (tagName: string) => void
useRepoTagsStore: () => RepoTagsStore
toCommitDetails?: ({ sha }: { sha: string }) => string
@@ -17,7 +17,6 @@ interface RepoTagsListProps {
}
export const RepoTagsList: FC = ({
- useTranslationStore,
useRepoTagsStore,
toCommitDetails,
isLoading,
@@ -27,7 +26,7 @@ export const RepoTagsList: FC = ({
onDeleteTag,
onOpenCreateBranchDialog
}) => {
- const { t } = useTranslationStore()
+ const { t } = useTranslation()
const { tags: tagsList } = useRepoTagsStore()
const getTableActions = (tag: CommitTagType) => [
diff --git a/packages/ui/src/views/repo/repo-tags/repo-tags-list-page.tsx b/packages/ui/src/views/repo/repo-tags/repo-tags-list-page.tsx
index ff410e3e69..4e4ddb93bf 100644
--- a/packages/ui/src/views/repo/repo-tags/repo-tags-list-page.tsx
+++ b/packages/ui/src/views/repo/repo-tags/repo-tags-list-page.tsx
@@ -1,6 +1,7 @@
import { FC, useCallback, useMemo } from 'react'
import { Button, ListActions, Pagination, SearchBox, Spacer } from '@/components'
+import { useTranslation } from '@/context'
import { RepoTagsListViewProps, SandboxLayout } from '@/views'
import { useDebounceSearch } from '@hooks/use-debounce-search'
import { cn } from '@utils/cn'
@@ -8,7 +9,6 @@ import { cn } from '@utils/cn'
import { RepoTagsList } from './components/repo-tags-list'
export const RepoTagsListView: FC = ({
- useTranslationStore,
isLoading,
openCreateBranchDialog,
openCreateTagDialog,
@@ -18,7 +18,7 @@ export const RepoTagsListView: FC = ({
useRepoTagsStore,
toCommitDetails
}) => {
- const { t } = useTranslationStore()
+ const { t } = useTranslation()
const { tags: tagsList, page, xNextPage, xPrevPage, setPage } = useRepoTagsStore()
const { search, handleSearchChange } = useDebounceSearch({
@@ -78,7 +78,6 @@ export const RepoTagsListView: FC = ({
= ({
hasPrevious={xPrevPage > 0}
getNextPageLink={getNextPageLink}
getPrevPageLink={getPrevPageLink}
- t={t}
/>
)}
diff --git a/packages/ui/src/views/repo/repo-tags/types.tsx b/packages/ui/src/views/repo/repo-tags/types.tsx
index e3c4d45bb1..5225ce56ca 100644
--- a/packages/ui/src/views/repo/repo-tags/types.tsx
+++ b/packages/ui/src/views/repo/repo-tags/types.tsx
@@ -1,5 +1,3 @@
-import { TranslationStore } from '@views/index'
-
import { BranchSelectorListItem, TypesCommit } from '../repo.types'
export interface TypeTagger {
@@ -30,7 +28,6 @@ export interface RepoTagsStore {
}
export interface RepoTagsListViewProps {
- useTranslationStore: () => TranslationStore
isLoading: boolean
openCreateBranchDialog: (selectedTagInList: BranchSelectorListItem) => void
openCreateTagDialog: () => void
diff --git a/packages/ui/src/views/repo/webhooks/webhook-create/components/create-webhook-form-data.ts b/packages/ui/src/views/repo/webhooks/webhook-create/components/create-webhook-form-data.ts
index 7ba83f3476..d694ab8a7f 100644
--- a/packages/ui/src/views/repo/webhooks/webhook-create/components/create-webhook-form-data.ts
+++ b/packages/ui/src/views/repo/webhooks/webhook-create/components/create-webhook-form-data.ts
@@ -1,20 +1,20 @@
-import { TFunction } from 'i18next'
+import { TFunctionWithFallback } from '@/context'
import { WebhookTriggerEnum } from '../types'
-export const getBranchEvents = (t: TFunction) => [
+export const getBranchEvents = (t: TFunctionWithFallback) => [
{ id: WebhookTriggerEnum.BRANCH_CREATED, event: t('views:webhookData.branchCreated', 'Branch created') },
{ id: WebhookTriggerEnum.BRANCH_UPDATED, event: t('views:webhookData.branchUpdated', 'Branch updated') },
{ id: WebhookTriggerEnum.BRANCH_DELETED, event: t('views:webhookData.branchDeleted', 'Branch deleted') }
]
-export const getTagEvents = (t: TFunction) => [
+export const getTagEvents = (t: TFunctionWithFallback) => [
{ id: WebhookTriggerEnum.TAG_CREATED, event: t('views:webhookData.tagCreated', 'Tag created') },
{ id: WebhookTriggerEnum.TAG_UPDATED, event: t('views:webhookData.tagUpdated', 'Tag updated') },
{ id: WebhookTriggerEnum.TAG_DELETED, event: t('views:webhookData.tagDeleted', 'Tag deleted') }
]
-export const getPrEvents = (t: TFunction) => [
+export const getPrEvents = (t: TFunctionWithFallback) => [
{ id: WebhookTriggerEnum.PR_CREATED, event: t('views:webhookData.prCreated', 'PR created') },
{ id: WebhookTriggerEnum.PR_UPDATED, event: t('views:webhookData.prUpdated', 'PR updated') },
{ id: WebhookTriggerEnum.PR_REOPENED, event: t('views:webhookData.prReopened', 'PR reopened') },
diff --git a/packages/ui/src/views/repo/webhooks/webhook-create/components/create-webhooks-form-fields.tsx b/packages/ui/src/views/repo/webhooks/webhook-create/components/create-webhooks-form-fields.tsx
index 2bb2c0848a..dec4163092 100644
--- a/packages/ui/src/views/repo/webhooks/webhook-create/components/create-webhooks-form-fields.tsx
+++ b/packages/ui/src/views/repo/webhooks/webhook-create/components/create-webhooks-form-fields.tsx
@@ -1,73 +1,90 @@
import { FC } from 'react'
import { Checkbox, ControlGroup, FormInput, Label, Radio, StackedList, Switch } from '@/components'
+import { useTranslation } from '@/context'
import { TriggerEventsEnum, WebhookEvent, WebhookFormFieldProps, WebhookTriggerEnum } from '@/views'
-export const WebhookToggleField: FC = ({ register, watch, setValue, t }) => (
-
- setValue!('enabled', !watch!('enabled'))}
+export const WebhookToggleField: FC = ({ register, watch, setValue }) => {
+ const { t } = useTranslation()
+ return (
+
+ setValue!('enabled', !watch!('enabled'))}
+ />
+ }
+ >
+
- }
- >
-
-
-
-)
+
+
+ )
+}
-export const WebhookNameField: FC = ({ register, disabled, t }) => (
-
-)
+export const WebhookNameField: FC = ({ register, disabled }) => {
+ const { t } = useTranslation()
+ return (
+
+ )
+}
-export const WebhookDescriptionField: FC = ({ register, t }) => (
-
-)
+export const WebhookDescriptionField: FC = ({ register }) => {
+ const { t } = useTranslation()
+ return (
+
+ )
+}
-export const WebhookPayloadUrlField: FC = ({ register, t }) => (
-
-)
+export const WebhookPayloadUrlField: FC = ({ register }) => {
+ const { t } = useTranslation()
+ return (
+
+ )
+}
-export const WebhookSecretField: FC = ({ register, t }) => (
-
-)
+export const WebhookSecretField: FC = ({ register }) => {
+ const { t } = useTranslation()
+ return (
+
+ )
+}
-export const WebhookSSLVerificationField: FC = ({ watch, setValue, t }) => {
+export const WebhookSSLVerificationField: FC = ({ watch, setValue }) => {
+ const { t } = useTranslation()
const sslVerificationValue = watch!('insecure')
const handleAccessChange = (value: string) => {
setValue!('insecure', value)
@@ -95,7 +112,8 @@ export const WebhookSSLVerificationField: FC = ({ watch,
)
}
-export const WebhookTriggerField: FC = ({ watch, setValue, t }) => {
+export const WebhookTriggerField: FC = ({ watch, setValue }) => {
+ const { t } = useTranslation()
const sslVerificationValue = watch!('trigger')
const handleTriggerChange = (value: string) => {
setValue!('trigger', value)
diff --git a/packages/ui/src/views/repo/webhooks/webhook-create/repo-webhook-create-page.tsx b/packages/ui/src/views/repo/webhooks/webhook-create/repo-webhook-create-page.tsx
index 381c6f4d4f..da619ae7ec 100644
--- a/packages/ui/src/views/repo/webhooks/webhook-create/repo-webhook-create-page.tsx
+++ b/packages/ui/src/views/repo/webhooks/webhook-create/repo-webhook-create-page.tsx
@@ -2,7 +2,8 @@ import { FC, useEffect } from 'react'
import { SubmitHandler, useForm } from 'react-hook-form'
import { Button, ButtonGroup, Fieldset, FormWrapper } from '@/components'
-import { SandboxLayout, TranslationStore, WebhookStore } from '@/views'
+import { useTranslation } from '@/context'
+import { SandboxLayout, WebhookStore } from '@/views'
import { zodResolver } from '@hookform/resolvers/zod'
import { createWebhookFormSchema } from '@views/repo/webhooks/webhook-create/components/create-webhooks-form-schema'
@@ -26,7 +27,6 @@ interface RepoWebhooksCreatePageProps {
isLoading: boolean
// preSetWebHookData: CreateWebhookFormFields | null
useWebhookStore: () => WebhookStore
- useTranslationStore: () => TranslationStore
}
export const RepoWebhooksCreatePage: FC = ({
@@ -34,9 +34,10 @@ export const RepoWebhooksCreatePage: FC = ({
apiError,
isLoading,
onFormCancel,
- useTranslationStore,
useWebhookStore
}) => {
+ const { t } = useTranslation()
+
const formMethods = useForm({
resolver: zodResolver(createWebhookFormSchema),
mode: 'onChange',
@@ -61,8 +62,6 @@ export const RepoWebhooksCreatePage: FC = ({
formState: { errors }
} = formMethods
- const { t } = useTranslationStore()
-
const { preSetWebhookData } = useWebhookStore()
useEffect(() => {
@@ -101,30 +100,30 @@ export const RepoWebhooksCreatePage: FC = ({
-
+
-
+
)
diff --git a/packages/ui/src/views/secrets/secrets-list/secrets-list.tsx b/packages/ui/src/views/secrets/secrets-list/secrets-list.tsx
index e97762f80f..701767e8cd 100644
--- a/packages/ui/src/views/secrets/secrets-list/secrets-list.tsx
+++ b/packages/ui/src/views/secrets/secrets-list/secrets-list.tsx
@@ -1,5 +1,5 @@
import { Icon, MoreActionsTooltip, NoData, SkeletonList, SkeletonTable, Table } from '@/components'
-import { useRouterContext } from '@/context'
+import { useRouterContext, useTranslation } from '@/context'
import { timeAgo } from '@/utils'
import { SecretListProps } from './types'
@@ -8,15 +8,9 @@ const Title = ({ title }: { title: string }): JSX.Element => (
{title}
)
-export function SecretList({
- secrets,
- useTranslationStore,
- isLoading,
- toSecretDetails,
- onDeleteSecret
-}: SecretListProps): JSX.Element {
+export function SecretList({ secrets, isLoading, toSecretDetails, onDeleteSecret }: SecretListProps): JSX.Element {
const { navigate } = useRouterContext()
- const { t } = useTranslationStore()
+ const { t } = useTranslation()
if (isLoading) {
return
diff --git a/packages/ui/src/views/secrets/secrets-list/types.ts b/packages/ui/src/views/secrets/secrets-list/types.ts
index 332431662c..3abafac825 100644
--- a/packages/ui/src/views/secrets/secrets-list/types.ts
+++ b/packages/ui/src/views/secrets/secrets-list/types.ts
@@ -1,5 +1,3 @@
-import { TranslationStore } from '@views/repo'
-
interface RoutingProps {
toSecretDetails: (secret: SecretListItem) => string
}
@@ -16,7 +14,6 @@ export interface SecretListItem {
export interface SecretListProps extends Partial {
secrets: SecretListItem[]
- useTranslationStore: () => TranslationStore
isLoading: boolean
onEditSecret: (secret: SecretListItem) => void
onDeleteSecret: (secretId: string) => void
diff --git a/packages/ui/src/views/sidebar-view/sidebar-view.tsx b/packages/ui/src/views/sidebar-view/sidebar-view.tsx
index 4ae2ace778..a5078cc29a 100644
--- a/packages/ui/src/views/sidebar-view/sidebar-view.tsx
+++ b/packages/ui/src/views/sidebar-view/sidebar-view.tsx
@@ -17,9 +17,8 @@ import {
User,
useSidebar
} from '@/components'
-import { useRouterContext, useTheme } from '@/context'
+import { useRouterContext, useTheme, useTranslation } from '@/context'
import { TypesUser } from '@/types'
-import { TranslationStore } from '@/views'
interface SidebarProps {
recentMenuItems: NavbarItemType[]
@@ -33,13 +32,13 @@ interface SidebarProps {
handleLogOut: () => void
handleChangePinnedMenuItem: (item: NavbarItemType, pin: boolean) => void
handleRemoveRecentMenuItem: (item: NavbarItemType) => void
- useTranslationStore: () => TranslationStore
showNewSearch?: boolean
hasToggle?: boolean
+ changeLanguage: (language: string) => void
+ lang: string
}
export const SidebarView = ({
- useTranslationStore,
handleChangePinnedMenuItem,
handleRemoveRecentMenuItem,
pinnedMenuItems,
@@ -50,9 +49,11 @@ export const SidebarView = ({
handleCustomNav,
handleLogOut,
hasToggle = true,
- showNewSearch
+ showNewSearch,
+ changeLanguage,
+ lang
}: SidebarProps) => {
- const { t, i18n, changeLanguage } = useTranslationStore()
+ const { t } = useTranslation()
const { theme, setTheme } = useTheme()
const { navigate } = useRouterContext()
const { collapsed, toggleSidebar } = useSidebar()
@@ -84,10 +85,9 @@ export const SidebarView = ({
{showNewSearch ? (
-
+
@@ -96,7 +96,7 @@ export const SidebarView = ({
/>
) : (
- } />
+ } />
)}
@@ -110,7 +110,6 @@ export const SidebarView = ({
handleChangePinnedMenuItem={handleChangePinnedMenuItem}
handleRemoveRecentMenuItem={handleRemoveRecentMenuItem}
handleCustomNav={handleCustomNav}
- t={t}
/>
))}
@@ -140,7 +139,6 @@ export const SidebarView = ({
handleChangePinnedMenuItem={handleChangePinnedMenuItem}
handleRemoveRecentMenuItem={handleRemoveRecentMenuItem}
handleCustomNav={handleCustomNav}
- t={t}
/>
))}
@@ -203,7 +201,6 @@ export const SidebarView = ({
openThemeDialog={() => setOpenThemeDialog(true)}
openLanguageDialog={() => setOpenLanguageDialog(true)}
handleLogOut={handleLogOut}
- t={t}
/>
@@ -216,7 +213,7 @@ export const SidebarView = ({
/>
setOpenLanguageDialog(false)}
onChange={handleLanguageChange}
diff --git a/packages/ui/src/views/unified-pipeline-studio/components/form-inputs/ArrayInput.tsx b/packages/ui/src/views/unified-pipeline-studio/components/form-inputs/ArrayInput.tsx
deleted file mode 100644
index f91e8bac86..0000000000
--- a/packages/ui/src/views/unified-pipeline-studio/components/form-inputs/ArrayInput.tsx
+++ /dev/null
@@ -1,106 +0,0 @@
-import { useCallback } from 'react'
-
-import { Button } from '@components/button'
-import { Icon } from '@components/icon'
-
-import {
- AnyFormikValue,
- Controller,
- IInputDefinition,
- InputComponent,
- InputProps,
- RenderInputs,
- useFieldArray
-} from '@harnessio/forms'
-
-import { InputError } from './common/InputError'
-import { InputLabel } from './common/InputLabel'
-import { InputTooltip } from './common/InputTooltip'
-import { InputWrapper } from './common/InputWrapper'
-import { RuntimeInputConfig } from './types/types'
-
-export type UIInputWithConfigsForArray = Omit
-
-export interface ArrayInputConfig {
- inputType: 'array'
- inputConfig: {
- input: IInputDefinition
- tooltip?: string
- } & RuntimeInputConfig
-}
-
-type ArrayInputInternalProps = InputProps
-
-function ArrayInputInternal(props: ArrayInputInternalProps): JSX.Element {
- const { readonly, path, input, factory } = props
- const { label, required, inputConfig, description } = input
-
- const { fields, append, remove } = useFieldArray({
- name: path
- })
-
- const getChildInputs = useCallback(
- (rowInput: UIInputWithConfigsForArray, parentPath: string, idx: number): IInputDefinition[] => {
- const retInput = {
- ...rowInput,
- // NOTE: create absolute path using parent path and index
- path: `${parentPath}[${idx}]`
- } as IInputDefinition
-
- return [retInput]
- },
- []
- )
-
- return (
-
- <>
-
- {/* TODO: do we need Controller ? */}
- (
-
-
- {fields.map((item, idx) => (
-
- {inputConfig?.input && (
-
- )}
-
- {/* TODO: Design system: Find alternate */}
-
-
-
- ))}
-
-
-
-
-
- )}
- />
-
- {inputConfig?.tooltip && }
- >
-
- )
-}
-
-export class ArrayInput extends InputComponent {
- public internalType = 'array'
-
- renderComponent(props: ArrayInputInternalProps): JSX.Element {
- return
- }
-}
diff --git a/packages/ui/src/views/unified-pipeline-studio/components/form-inputs/BooleanInput.tsx b/packages/ui/src/views/unified-pipeline-studio/components/form-inputs/BooleanInput.tsx
deleted file mode 100644
index f66e1c3814..0000000000
--- a/packages/ui/src/views/unified-pipeline-studio/components/form-inputs/BooleanInput.tsx
+++ /dev/null
@@ -1,54 +0,0 @@
-import { Switch } from '@components/switch'
-
-import { InputComponent, InputProps, useController, type AnyFormikValue, type UseFormReturn } from '@harnessio/forms'
-
-import { InputError } from './common/InputError'
-import { InputTooltip } from './common/InputTooltip'
-import { InputWrapper } from './common/InputWrapper'
-import { RuntimeInputConfig } from './types/types'
-
-export interface BooleanInputConfig {
- inputType: 'boolean'
- inputConfig?: {
- onChange: (value: AnyFormikValue, formik: UseFormReturn) => void
- tooltip?: string
- } & RuntimeInputConfig
-}
-
-type BooleanInputInternalProps = InputProps
-
-function BooleanInputInternal(props: BooleanInputInternalProps): JSX.Element {
- const { readonly, path, input } = props
- const { label = '', required, description, inputConfig } = input
-
- const { field } = useController({
- name: path
- })
-
- return (
-
- <>
- {
- field.onChange(value)
- }}
- label={label}
- caption={description}
- showOptionalLabel={!required}
- />
-
- {inputConfig?.tooltip && }
- >
-
- )
-}
-
-export class BooleanInput extends InputComponent {
- public internalType = 'boolean'
-
- renderComponent(props: BooleanInputInternalProps): JSX.Element {
- return
- }
-}
diff --git a/packages/ui/src/views/unified-pipeline-studio/components/form-inputs/NumberInput.tsx b/packages/ui/src/views/unified-pipeline-studio/components/form-inputs/NumberInput.tsx
deleted file mode 100644
index 9b97988594..0000000000
--- a/packages/ui/src/views/unified-pipeline-studio/components/form-inputs/NumberInput.tsx
+++ /dev/null
@@ -1,55 +0,0 @@
-import { Input } from '@components/input'
-
-import { InputComponent, InputProps, useController, type AnyFormikValue } from '@harnessio/forms'
-
-import { InputError } from './common/InputError'
-import { InputLabel } from './common/InputLabel'
-import { InputTooltip } from './common/InputTooltip'
-import { InputWrapper } from './common/InputWrapper'
-import { RuntimeInputConfig } from './types/types'
-
-export interface NumberInputConfig {
- inputType: 'number'
- inputConfig?: {
- tooltip?: string
- } & RuntimeInputConfig
-}
-
-type NumberInputProps = InputProps
-
-// TODO: Design system: Replace it with new NumberInput component. Check with Srdjan.
-function NumberInputInternal(props: NumberInputProps): JSX.Element {
- const { readonly, path, input } = props
- const { label = '', required, placeholder, description, inputConfig } = input
-
- const { field } = useController({
- name: path
- })
-
- return (
-
- <>
-
- {
- field.onChange(parseFloat(evt.currentTarget.value))
- }}
- />
-
- {inputConfig?.tooltip && }
- >
-
- )
-}
-
-export class NumberInput extends InputComponent {
- public internalType = 'number'
-
- renderComponent(props: NumberInputProps): JSX.Element {
- return
- }
-}
diff --git a/packages/ui/src/views/unified-pipeline-studio/components/form-inputs/RadialInput.tsx b/packages/ui/src/views/unified-pipeline-studio/components/form-inputs/RadialInput.tsx
deleted file mode 100644
index 8ad93b227c..0000000000
--- a/packages/ui/src/views/unified-pipeline-studio/components/form-inputs/RadialInput.tsx
+++ /dev/null
@@ -1,60 +0,0 @@
-import { FormControl, FormField, FormItem } from '@components/form'
-import { RadioSelect } from '@views/components/RadioSelect'
-
-import { InputComponent, InputProps, type AnyFormikValue } from '@harnessio/forms'
-
-import { InputLabel, InputWrapper } from './common'
-import { InputError } from './common/InputError'
-import { InputTooltip } from './common/InputTooltip'
-import { RuntimeInputConfig } from './types/types'
-
-export interface RadioOption {
- label: string
- description: string
- value: string | boolean
- id: string
- title: string
-}
-
-export interface RadialInputConfig {
- inputConfig: {
- inputType: 'radio'
- options: RadioOption[]
- tooltip?: string
- } & RuntimeInputConfig
-}
-
-type RadialInputProps = InputProps
-
-function RadialInputInternal(props: RadialInputProps): JSX.Element {
- const { path, input } = props
- const { label = '', required, description, inputConfig } = input
- const options = inputConfig?.options ?? []
-
- return (
-
- (
-
-
-
-
-
-
-
- {inputConfig?.tooltip && }
-
- )}
- />
-
- )
-}
-
-export class RadialInput extends InputComponent {
- public internalType = 'radio'
-
- renderComponent(props: RadialInputProps): JSX.Element {
- return
- }
-}
diff --git a/packages/ui/src/views/unified-pipeline-studio/components/form-inputs/SelectInput.tsx b/packages/ui/src/views/unified-pipeline-studio/components/form-inputs/SelectInput.tsx
deleted file mode 100644
index 690d3a1c56..0000000000
--- a/packages/ui/src/views/unified-pipeline-studio/components/form-inputs/SelectInput.tsx
+++ /dev/null
@@ -1,86 +0,0 @@
-import { useEffect, useMemo } from 'react'
-
-import { Select } from '@components/select'
-
-import { InputComponent, InputProps, useController, useFormContext, type AnyFormikValue } from '@harnessio/forms'
-
-import { InputError } from './common/InputError'
-import { InputLabel } from './common/InputLabel'
-import { InputTooltip } from './common/InputTooltip'
-import { InputWrapper } from './common/InputWrapper'
-import { RuntimeInputConfig } from './types/types'
-
-export interface SelectOption {
- label: string
- value: string
-}
-
-export interface SelectInputConfig {
- inputType: 'select'
- inputConfig: {
- options: SelectOption[]
- tooltip?: string
- isDisabled?: (values: AnyFormikValue) => boolean
- disabledValue?: string
- } & RuntimeInputConfig
-}
-
-type SelectInputProps = InputProps
-
-function SelectInputInternal(props: SelectInputProps): JSX.Element {
- const { path, input } = props
- const { label = '', required, description, inputConfig, readonly, placeholder } = input
-
- const methods = useFormContext()
- const values = methods.watch()
-
- const disabled = useMemo(() => {
- return readonly || !!inputConfig?.isDisabled?.(values)
- }, [readonly, inputConfig?.isDisabled, values])
-
- const { field } = useController({
- name: path
- })
-
- useEffect(() => {
- if (disabled) {
- field.onChange(inputConfig?.disabledValue ?? '')
- }
- }, [disabled])
-
- return (
-
- <>
-
- {
- field.onChange(value)
- }}
- >
-
- {inputConfig?.options.map(item => {
- return (
-
- {item.label}
-
- )
- })}
-
-
-
- {inputConfig?.tooltip && }
- >
-
- )
-}
-
-export class SelectInput extends InputComponent {
- public internalType = 'select'
-
- renderComponent(props: SelectInputProps): JSX.Element {
- return
- }
-}
diff --git a/packages/ui/src/views/unified-pipeline-studio/components/form-inputs/TextAreaInput.tsx b/packages/ui/src/views/unified-pipeline-studio/components/form-inputs/TextAreaInput.tsx
deleted file mode 100644
index 82566af22d..0000000000
--- a/packages/ui/src/views/unified-pipeline-studio/components/form-inputs/TextAreaInput.tsx
+++ /dev/null
@@ -1,46 +0,0 @@
-import { Textarea } from '@components/index'
-
-import { InputComponent, InputProps, useController, type AnyFormikValue } from '@harnessio/forms'
-
-import { InputError } from './common/InputError'
-import { InputLabel } from './common/InputLabel'
-import { InputTooltip } from './common/InputTooltip'
-import { InputWrapper } from './common/InputWrapper'
-import { RuntimeInputConfig } from './types/types'
-
-export interface TextAreaInputConfig {
- inputType: 'textarea'
- inputConfig?: {
- tooltip?: string
- } & RuntimeInputConfig
-}
-
-type TextAreaInputProps = InputProps
-
-function TextAreaInputInternal(props: TextAreaInputProps): JSX.Element {
- const { readonly, path, input } = props
- const { label = '', required, placeholder, description, inputConfig } = input
-
- const { field } = useController({
- name: path
- })
-
- return (
-
- <>
-
-
-
- {inputConfig?.tooltip && }
- >
-
- )
-}
-
-export class TextAreaInput extends InputComponent {
- public internalType = 'textarea'
-
- renderComponent(props: TextAreaInputProps): JSX.Element {
- return
- }
-}
diff --git a/packages/ui/src/views/unified-pipeline-studio/components/form-inputs/TextInput.tsx b/packages/ui/src/views/unified-pipeline-studio/components/form-inputs/TextInput.tsx
deleted file mode 100644
index 31d0cf17ac..0000000000
--- a/packages/ui/src/views/unified-pipeline-studio/components/form-inputs/TextInput.tsx
+++ /dev/null
@@ -1,46 +0,0 @@
-import { Input } from '@components/input'
-
-import { InputComponent, InputProps, useController, type AnyFormikValue } from '@harnessio/forms'
-
-import { InputError } from './common/InputError'
-import { InputLabel } from './common/InputLabel'
-import { InputTooltip } from './common/InputTooltip'
-import { InputWrapper } from './common/InputWrapper'
-import { RuntimeInputConfig } from './types/types'
-
-export interface TextInputConfig {
- inputType: 'text'
- inputConfig?: {
- tooltip?: string
- } & RuntimeInputConfig
-}
-
-type TextInputProps = InputProps
-// TODO: Design system: Replace it with new TextInput component. Check with Srdjan.
-function TextInputInternal(props: TextInputProps): JSX.Element {
- const { readonly, path, input } = props
- const { label = '', required, placeholder, description, inputConfig } = input
-
- const { field } = useController({
- name: path
- })
-
- return (
-
- <>
-
-
-
- {inputConfig?.tooltip && }
- >
-
- )
-}
-
-export class TextInput extends InputComponent {
- public internalType = 'text'
-
- renderComponent(props: TextInputProps): JSX.Element {
- return
- }
-}
diff --git a/packages/ui/src/views/unified-pipeline-studio/components/form-inputs/array-input.tsx b/packages/ui/src/views/unified-pipeline-studio/components/form-inputs/array-input.tsx
new file mode 100644
index 0000000000..0978363ce5
--- /dev/null
+++ b/packages/ui/src/views/unified-pipeline-studio/components/form-inputs/array-input.tsx
@@ -0,0 +1,107 @@
+import { useCallback } from 'react'
+
+import { Button } from '@components/button'
+import { Icon } from '@components/icon'
+
+import {
+ AnyFormikValue,
+ Controller,
+ IInputDefinition,
+ InputComponent,
+ InputProps,
+ RenderInputs,
+ useFieldArray,
+ useFormContext
+} from '@harnessio/forms'
+
+import { InputCaption } from './common/InputCaption'
+import { InputLabel } from './common/InputLabel'
+import { InputWrapper } from './common/InputWrapper'
+import { RuntimeInputConfig } from './types/types'
+
+export type UIInputWithConfigsForArray = Omit
+
+export interface ArrayFormInputConfig {
+ inputType: 'array'
+ inputConfig: {
+ input: IInputDefinition
+ tooltip?: string
+ } & RuntimeInputConfig
+}
+
+type ArrayFormInputProps = InputProps
+
+function ArrayFormInputInternal(props: ArrayFormInputProps): JSX.Element {
+ const { readonly, path, input, factory } = props
+ const { label, required, inputConfig, description } = input
+
+ const { fields, append, remove } = useFieldArray({
+ name: path
+ })
+
+ const { getFieldState, formState } = useFormContext()
+ const fieldState = getFieldState(path, formState)
+ const { error } = fieldState
+
+ const getChildInputs = useCallback(
+ (rowInput: UIInputWithConfigsForArray, parentPath: string, idx: number): IInputDefinition[] => {
+ const retInput = {
+ ...rowInput,
+ // NOTE: create absolute path using parent path and index
+ path: `${parentPath}[${idx}]`
+ } as IInputDefinition
+
+ return [retInput]
+ },
+ []
+ )
+
+ return (
+
+
+ {/* TODO: do we need Controller ? */}
+ (
+
+
+ {fields.map((item, idx) => (
+
+ {inputConfig?.input && (
+
+ )}
+
+
+
+
+ ))}
+
+
+
+
+
+ )}
+ />
+
+
+ )
+}
+
+export class ArrayFormInput extends InputComponent {
+ public internalType = 'array'
+
+ renderComponent(props: ArrayFormInputProps): JSX.Element {
+ return
+ }
+}
diff --git a/packages/ui/src/views/unified-pipeline-studio/components/form-inputs/boolean-form-input.tsx b/packages/ui/src/views/unified-pipeline-studio/components/form-inputs/boolean-form-input.tsx
new file mode 100644
index 0000000000..7858e79123
--- /dev/null
+++ b/packages/ui/src/views/unified-pipeline-studio/components/form-inputs/boolean-form-input.tsx
@@ -0,0 +1,49 @@
+import { Switch } from '@components/switch'
+
+import { InputComponent, InputProps, useController, type AnyFormikValue } from '@harnessio/forms'
+
+import { InputCaption } from './common/InputCaption'
+import { InputWrapper } from './common/InputWrapper'
+import { RuntimeInputConfig } from './types/types'
+
+export interface BooleanFormInputConfig {
+ inputType: 'boolean'
+ inputConfig?: {
+ tooltip?: string
+ } & RuntimeInputConfig
+}
+
+type BooleanFormInputProps = InputProps
+
+function BooleanFormInputInternal(props: BooleanFormInputProps): JSX.Element {
+ const { readonly, path, input } = props
+ const { label = '', required, description } = input
+
+ const { field, fieldState } = useController({
+ name: path
+ })
+
+ return (
+
+ {
+ field.onChange(value)
+ }}
+ label={label}
+ caption={description}
+ showOptionalLabel={!required}
+ />
+
+
+ )
+}
+
+export class BooleanFormInput extends InputComponent {
+ public internalType = 'boolean'
+
+ renderComponent(props: BooleanFormInputProps): JSX.Element {
+ return
+ }
+}
diff --git a/packages/ui/src/views/unified-pipeline-studio/components/form-inputs/calendar-form-input.tsx b/packages/ui/src/views/unified-pipeline-studio/components/form-inputs/calendar-form-input.tsx
index c8ed2b63ae..2e624115c6 100644
--- a/packages/ui/src/views/unified-pipeline-studio/components/form-inputs/calendar-form-input.tsx
+++ b/packages/ui/src/views/unified-pipeline-studio/components/form-inputs/calendar-form-input.tsx
@@ -1,15 +1,15 @@
import { JSX } from 'react'
-import { CalendarInputView, InputError, InputLabel, InputWrapper } from '@/views'
+import { CalendarInputView, InputCaption, InputLabel, InputWrapper } from '@/views'
import { InputComponent, InputProps, useController, type AnyFormikValue } from '@harnessio/forms'
import { RuntimeInputConfig } from './types/types'
-export type CalendarInputType = 'calendar'
+export type CalendarFormInputType = 'calendar'
export interface CalendarInputConfig {
- inputType: CalendarInputType
+ inputType: 'calendar'
tooltip?: string
inputConfig?: {
/* placeholder for more config */
@@ -20,10 +20,11 @@ type CalendarFormInputProps = InputProps
function CalendarFormInputInternal(props: CalendarFormInputProps): JSX.Element {
const { path, input } = props
- const { label = '', required, description } = input
+ const { label, required, description, readonly } = input
- const { field } = useController({
- name: path
+ const { field, fieldState } = useController({
+ name: path,
+ disabled: readonly
})
// Convert ISO date string to timestamp for the form value
@@ -39,15 +40,15 @@ function CalendarFormInputInternal(props: CalendarFormInputProps): JSX.Element {
return (
-
+
-
+
)
}
export class CalendarInput extends InputComponent {
- public internalType: CalendarInputType = 'calendar'
+ public internalType: CalendarFormInputType = 'calendar'
renderComponent(props: CalendarFormInputProps): JSX.Element {
return
diff --git a/packages/ui/src/views/unified-pipeline-studio/components/form-inputs/cards-form-input.tsx b/packages/ui/src/views/unified-pipeline-studio/components/form-inputs/cards-form-input.tsx
new file mode 100644
index 0000000000..2f793a767d
--- /dev/null
+++ b/packages/ui/src/views/unified-pipeline-studio/components/form-inputs/cards-form-input.tsx
@@ -0,0 +1,59 @@
+import { CardSelect } from '@components/index'
+
+import { InputComponent, InputProps, useController, type AnyFormikValue } from '@harnessio/forms'
+
+import { InputLabel, InputWrapper } from './common'
+import { InputCaption } from './common/InputCaption'
+import { RuntimeInputConfig } from './types/types'
+
+export interface CardOption {
+ label: string
+ description: string
+ value: string | boolean
+ id: string
+ title: string
+}
+
+export interface CardsFormInputConfig {
+ inputType: 'cards'
+ inputConfig: {
+ options: CardOption[]
+ tooltip?: string
+ } & RuntimeInputConfig
+}
+
+type CardsFormInputProps = InputProps
+
+function CardsFormInputInternal(props: CardsFormInputProps): JSX.Element {
+ const { path, input } = props
+ const { label, required, description, inputConfig, readonly } = input
+ const options = inputConfig?.options ?? []
+
+ const { field, fieldState } = useController({
+ name: path,
+ disabled: readonly
+ })
+
+ return (
+
+
+
+ {options.map(option => (
+
+ {option.label}
+ {option.description}
+
+ ))}
+
+
+
+ )
+}
+
+export class CardsFormInput extends InputComponent {
+ public internalType = 'cards'
+
+ renderComponent(props: CardsFormInputProps): JSX.Element {
+ return
+ }
+}
diff --git a/packages/ui/src/views/unified-pipeline-studio/components/form-inputs/common/InputCaption.tsx b/packages/ui/src/views/unified-pipeline-studio/components/form-inputs/common/InputCaption.tsx
new file mode 100644
index 0000000000..9543ac753b
--- /dev/null
+++ b/packages/ui/src/views/unified-pipeline-studio/components/form-inputs/common/InputCaption.tsx
@@ -0,0 +1,17 @@
+import { FormCaption } from '@components/index'
+
+export interface InputCaptionProps {
+ error?: string
+ caption?: string
+}
+
+const InputCaption = ({ error, caption }: InputCaptionProps) => {
+ if (error) {
+ return {error}
+ }
+
+ return caption ? {caption} : null
+}
+InputCaption.displayName = 'InputCaption'
+
+export { InputCaption }
diff --git a/packages/ui/src/views/unified-pipeline-studio/components/form-inputs/common/InputError.tsx b/packages/ui/src/views/unified-pipeline-studio/components/form-inputs/common/InputError.tsx
deleted file mode 100644
index 698fb8d0fa..0000000000
--- a/packages/ui/src/views/unified-pipeline-studio/components/form-inputs/common/InputError.tsx
+++ /dev/null
@@ -1,26 +0,0 @@
-import { forwardRef } from 'react'
-import { useFormContext } from 'react-hook-form'
-
-import { cn } from '@utils/cn'
-
-const InputError = forwardRef>(
- ({ path, className, ...props }, ref) => {
- const { getFieldState, formState } = useFormContext()
-
- const fieldState = getFieldState(path, formState)
- const { error } = fieldState
-
- if (!error?.message) {
- return null
- }
-
- return (
-
- {error.message}
-
- )
- }
-)
-InputError.displayName = 'InputError'
-
-export { InputError }
diff --git a/packages/ui/src/views/unified-pipeline-studio/components/form-inputs/common/InputLabel.tsx b/packages/ui/src/views/unified-pipeline-studio/components/form-inputs/common/InputLabel.tsx
index 77e05ace6d..ad2febd21b 100644
--- a/packages/ui/src/views/unified-pipeline-studio/components/form-inputs/common/InputLabel.tsx
+++ b/packages/ui/src/views/unified-pipeline-studio/components/form-inputs/common/InputLabel.tsx
@@ -2,19 +2,21 @@ import { Label } from '@components/form-primitives/label'
export interface InputLabelProps {
label?: string
- description?: string
required?: boolean
+ disabled?: boolean
className?: string
}
function InputLabel(props: InputLabelProps): JSX.Element | null {
- const { label, required, className } = props
+ const { label, required, disabled, className } = props
if (!label) return null
- const labelText = required && label ? `${label} *` : label
-
- return
+ return (
+
+ )
}
export { InputLabel }
diff --git a/packages/ui/src/views/unified-pipeline-studio/components/form-inputs/common/InputTooltip.tsx b/packages/ui/src/views/unified-pipeline-studio/components/form-inputs/common/InputTooltip.tsx
index fe12093e31..0e57aad052 100644
--- a/packages/ui/src/views/unified-pipeline-studio/components/form-inputs/common/InputTooltip.tsx
+++ b/packages/ui/src/views/unified-pipeline-studio/components/form-inputs/common/InputTooltip.tsx
@@ -4,6 +4,7 @@ interface InputTooltipProps {
tooltip: string
}
+// TODO: not in use, delete after tooltip implementation is done
function InputTooltip(props: InputTooltipProps): JSX.Element | null {
const { tooltip } = props
return (
diff --git a/packages/ui/src/views/unified-pipeline-studio/components/form-inputs/common/InputWrapper.tsx b/packages/ui/src/views/unified-pipeline-studio/components/form-inputs/common/InputWrapper.tsx
index 9d1444a245..034c6d9c89 100644
--- a/packages/ui/src/views/unified-pipeline-studio/components/form-inputs/common/InputWrapper.tsx
+++ b/packages/ui/src/views/unified-pipeline-studio/components/form-inputs/common/InputWrapper.tsx
@@ -4,7 +4,7 @@ import { Input } from '@components/index'
import { AnyFormikValue, InputProps, useController } from '@harnessio/forms'
-import { InputError, InputLabel } from '.'
+import { InputCaption, InputLabel } from '.'
import { InputValueType, RuntimeInputConfig } from '../types/types'
import { constructRuntimeInputValue, extractRuntimeInputName, getInputValueType } from '../utils/input-value-utils'
import InputValueTypeSelection from './InputValueTypeSelector'
@@ -32,7 +32,7 @@ export function InputWrapper({
const { label, placeholder, required, inputConfig } = input
const isOnlyFixed = isOnlyFixedValueAllowed(inputConfig?.allowedValueTypes)
- const { field } = useController({
+ const { field, fieldState } = useController({
name: path
})
@@ -76,7 +76,7 @@ export function InputWrapper({
/>
{'>'}