Skip to content

Commit

Permalink
review comments fix
Browse files Browse the repository at this point in the history
  • Loading branch information
ankormoreankor committed Feb 3, 2025
1 parent 80e96b9 commit 6ce68b1
Show file tree
Hide file tree
Showing 28 changed files with 3,480 additions and 5,699 deletions.
12 changes: 4 additions & 8 deletions .eslintrc.json
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@
"ecmaVersion": "latest",
"sourceType": "module"
},
"plugins": ["@typescript-eslint", "tailwindcss", "react", "react-hooks", "import", "prettier", "unused-imports"],
"plugins": ["@typescript-eslint", "tailwindcss", "react", "react-hooks", "import", "prettier"],
"rules": {
"tailwindcss/no-contradicting-classname": "error",
"import/no-unresolved": "off",
Expand All @@ -47,15 +47,11 @@
"jsx-a11y/click-events-have-key-events": "warn",
"jsx-a11y/no-autofocus": "off",

"@typescript-eslint/no-unused-vars": "off",
"unused-imports/no-unused-imports": "error",
"unused-imports/no-unused-vars": [
"warn",
"@typescript-eslint/no-unused-vars": [
"error",
{
"vars": "all",
"args": "after-used",
"varsIgnorePattern": "^_",
"argsIgnorePattern": "^_",
"varsIgnorePattern": "^_",
"caughtErrorsIgnorePattern": "^_"
}
],
Expand Down
7 changes: 1 addition & 6 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,5 @@
"[ignore]": {
"editor.defaultFormatter": "foxundermoon.shell-format"
},
"prettier.trailingComma": "none",
"editor.codeActionsOnSave": {
"source.fixAll": "always",
"source.fixAll.eslint": "always"
},
"eslint.validate": ["javascript", "javascriptreact", "typescript", "typescriptreact"]
"prettier.trailingComma": "none"
}
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
import { FC, HTMLAttributes, PropsWithChildren } from 'react'
import { Route, Routes } from 'react-router-dom'

import { useTranslationsStore } from '@utils/viewUtils'
import { useTranslationStore } from '@utils/viewUtils'

import { ProfileSettingsLayout } from '@harnessio/ui/views'

export const ProfileSettingsViewWrapper: FC<PropsWithChildren<HTMLAttributes<HTMLElement>>> = ({ children }) => {
return (
<Routes>
<Route path="*" element={<ProfileSettingsLayout useTranslationStore={useTranslationsStore} />}>
<Route path="*" element={<ProfileSettingsLayout useTranslationStore={useTranslationStore} />}>
<Route path="*" element={children} />
</Route>
</Routes>
Expand Down
4 changes: 2 additions & 2 deletions apps/design-system/src/subjects/views/labels/labels-form.tsx
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
import { LabelsListStore } from '@subjects/stores/labels-store.tsx'
import { useTranslationsStore } from '@utils/viewUtils.ts'
import { useTranslationStore } from '@utils/viewUtils.ts'

import { LabelFormPage } from '@harnessio/ui/views'

export const LabelsForm = () => {
return (
<LabelFormPage
useLabelsStore={LabelsListStore.useLabelsStore}
useTranslationStore={useTranslationsStore}
useTranslationStore={useTranslationStore}
isLoading={false}
onSubmit={() => {}}
onFormCancel={() => {}}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { useState } from 'react'

import { noop, useTranslationsStore } from '@utils/viewUtils'
import { noop, useTranslationStore } from '@utils/viewUtils'

import { DeleteAlertDialog } from '@harnessio/ui/components'
import {
Expand All @@ -24,7 +24,7 @@ export const ProfileSettingsKeysView = () => {
openSshKeyDialog={() => setIsKeysDialogOpen(true)}
openAlertDeleteDialog={() => setIsDeleteDialogOpen(true)}
error={null}
useTranslationStore={useTranslationsStore}
useTranslationStore={useTranslationStore}
isLoadingTokenList={false}
isLoadingKeysList={false}
/>
Expand All @@ -34,23 +34,23 @@ export const ProfileSettingsKeysView = () => {
handleCreateToken={noop}
error={null}
isLoading={false}
useTranslationStore={useTranslationsStore}
useTranslationStore={useTranslationStore}
useProfileSettingsStore={mockProfileSettingsStore}
/>
<ProfileSettingsKeysCreateDialog
open={isKeysDialogOpen}
onClose={() => setIsKeysDialogOpen(false)}
handleCreateSshKey={noop}
error={null}
useTranslationStore={useTranslationsStore}
useTranslationStore={useTranslationStore}
/>
<DeleteAlertDialog
open={isDeleteDialogOpen}
onClose={() => setIsDeleteDialogOpen(false)}
deleteFn={noop}
error={null}
isLoading={false}
useTranslationStore={useTranslationsStore}
useTranslationStore={useTranslationStore}
/>
</>
)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { useEffect, useState } from 'react'

import { noop, useTranslationsStore } from '@utils/viewUtils'
import { noop, useTranslationStore } from '@utils/viewUtils'

import { SettingsAccountGeneralPage } from '@harnessio/ui/views'

Expand All @@ -16,7 +16,7 @@ export const ProfileSettingsView = () => {
return (
<SettingsAccountGeneralPage
useProfileSettingsStore={mockProfileSettingsStore}
useTranslationStore={useTranslationsStore}
useTranslationStore={useTranslationStore}
isLoadingUser={isLoadingUser}
isUpdatingUser={false}
isUpdatingPassword={false}
Expand Down
4 changes: 2 additions & 2 deletions apps/design-system/src/subjects/views/repo-create/index.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { noop, useTranslationsStore } from '@utils/viewUtils'
import { noop, useTranslationStore } from '@utils/viewUtils'

import { RepoCreatePage } from '@harnessio/ui/views'

Expand All @@ -15,7 +15,7 @@ export const CreateRepoView = () => {
isSuccess={false}
gitIgnoreOptions={gitIgnoreOptions}
licenseOptions={licenseOptions}
useTranslationStore={useTranslationsStore}
useTranslationStore={useTranslationStore}
/>
)
}
4 changes: 2 additions & 2 deletions apps/design-system/src/subjects/views/repo-import/index.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { noop, useTranslationsStore } from '@utils/viewUtils'
import { noop, useTranslationStore } from '@utils/viewUtils'

import { RepoImportPage } from '@harnessio/ui/views'

Expand All @@ -10,7 +10,7 @@ export const ImportRepoView = () => {
onFormCancel={noop}
isLoading={false}
apiErrorsValue={undefined}
useTranslationStore={useTranslationsStore}
useTranslationStore={useTranslationStore}
/>
</>
)
Expand Down
8 changes: 7 additions & 1 deletion apps/gitness/src/framework/context/AppContext.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ import usePageTitle from '../hooks/usePageTitle'

interface AppContextType {
spaces: TypesSpace[]
isSpacesLoading: boolean
setSpaces: (value: TypesSpace[]) => void
addSpaces: (newSpaces: TypesSpace[]) => void
currentUser?: TypesUser
Expand All @@ -34,6 +35,7 @@ interface AppContextType {

const AppContext = createContext<AppContextType>({
spaces: [],
isSpacesLoading: false,
setSpaces: noop,
addSpaces: noop,
currentUser: undefined,
Expand All @@ -48,6 +50,7 @@ const AppContext = createContext<AppContextType>({
export const AppProvider: FC<{ children: ReactNode }> = ({ children }) => {
usePageTitle()
const [spaces, setSpaces] = useState<TypesSpace[]>([])
const [isSpacesLoading, setSpacesIsLoading] = useState<boolean>(false)
const [currentUser, setCurrentUser] = useLocalStorage<TypesUser>('currentUser', {})
const [isLoadingUser, setIsLoadingUser] = useState(false)
const [isUpdatingUser, setIsUpdatingUser] = useState(false)
Expand Down Expand Up @@ -91,6 +94,7 @@ export const AppProvider: FC<{ children: ReactNode }> = ({ children }) => {
}

useEffect(() => {
setSpacesIsLoading(true)
Promise.allSettled([
membershipSpaces({
queryParams: { page: 1, limit: 100, sort: 'identifier', order: 'asc' }
Expand All @@ -102,6 +106,7 @@ export const AppProvider: FC<{ children: ReactNode }> = ({ children }) => {

if (membershipResult.status === 'fulfilled') {
setSpaces(membershipResult.value.body.filter(item => item?.space).map(item => item.space as TypesSpace))
setSpacesIsLoading(false)
}
})
.catch(() => {
Expand All @@ -125,7 +130,8 @@ export const AppProvider: FC<{ children: ReactNode }> = ({ children }) => {
updateUserProfile,
isLoadingUser,
isUpdatingUser,
updateUserError
updateUserError,
isSpacesLoading
}}
>
{children}
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -18,21 +18,15 @@ import { useSpaceStore } from './stores/spaces-store'

export const ProjectGeneralSettingsPageContainer = () => {
const spaceURL = useGetSpaceURLParam()
const { spaces } = useAppContext()
const { setSpace } = useSpaceStore()
const { spaces, isSpacesLoading } = useAppContext()
const { setSpace, setIsLoading } = useSpaceStore()
const space = spaces.find((space: TypesSpace) => space?.identifier === spaceURL)
const [openDeleteDialog, setOpenDeleteDialog] = useState(false)
const [updateError, setUpdateError] = useState<string | null>(null)
const [deleteError, setDeleteError] = useState<{ type: string; message: string } | null>(null)

useEffect(() => {
setSpace(space || null)
}, [space, setSpace])

const updateDescription = useUpdateSpaceMutation(
{
space_ref: space?.path
},
{ space_ref: space?.path },
{
onSuccess: ({ body: data }) => {
if (space) {
Expand All @@ -48,8 +42,8 @@ export const ProjectGeneralSettingsPageContainer = () => {
}
)

const handleFormSubmit = (body: ProjectSettingsGeneralFields) => {
updateDescription.mutate({ space_ref: space?.path, body })
const handleFormSubmit = (formdata: ProjectSettingsGeneralFields) => {
updateDescription.mutate({ space_ref: space?.path, body: { description: formdata?.description } })
}

// delete API call here
Expand All @@ -59,7 +53,7 @@ export const ProjectGeneralSettingsPageContainer = () => {
onSuccess: ({ body: data }) => {
if (data) {
setDeleteError(null)
window.location.href = '/'
redirect('/')
}
},
onError: (error: DeleteSpaceErrorResponse) => {
Expand All @@ -75,12 +69,20 @@ export const ProjectGeneralSettingsPageContainer = () => {
{
onSuccess: () => {
setDeleteError(null)
window.location.href = '/'
redirect('/')
}
}
)
}

useEffect(() => {
setIsLoading(isSpacesLoading)
}, [isSpacesLoading, setIsLoading])

useEffect(() => {
setSpace(space || null)
}, [space, setSpace])

return (
<>
<ProjectSettingsGeneralPage
Expand Down
4 changes: 3 additions & 1 deletion apps/gitness/src/pages-v2/project/stores/spaces-store.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,7 @@ import { ISpaceStore } from '@harnessio/ui/views'

export const useSpaceStore = create<ISpaceStore>(set => ({
space: null,
setSpace: space => set({ space })
isLoading: false,
setSpace: space => set({ space }),
setIsLoading: isLoading => set({ isLoading })
}))
1 change: 0 additions & 1 deletion apps/gitness/src/routes.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@ import PipelineEditPage from './pages-v2/pipeline/pipeline-edit/pipeline-edit'
import ProjectPipelineListPage from './pages-v2/pipeline/project-pipeline-list-page'
import { SettingsProfileGeneralPage } from './pages-v2/profile-settings/profile-settings-general-container'
import { SettingsProfileKeysPage } from './pages-v2/profile-settings/profile-settings-keys-container'
import { ProfileSettingsLayout } from './pages-v2/profile-settings/profile-settings-layout'
import { ProfileSettingsThemePage } from './pages-v2/profile-settings/profile-settings-theme-page'
import { ProjectLabelFormContainer } from './pages-v2/project/labels/project-label-form-container'
import { ProjectLabelsList } from './pages-v2/project/labels/project-labels-list-container'
Expand Down
3 changes: 1 addition & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -38,12 +38,11 @@
"eslint-plugin-react": "^7.37.2",
"eslint-plugin-react-hooks": "^5.0.0",
"eslint-plugin-tailwindcss": "^3.17.5",
"eslint-plugin-unused-imports": "3.2.0",
"husky": "^9.1.4",
"lint-staged": "^15.2.9",
"prettier": "^3.3.3",
"prettier-plugin-tailwindcss": "^0.6.8",
"rimraf": "^6.0.1",
"typescript-eslint": "^8.14.0"
}
}
}
Loading

0 comments on commit 6ce68b1

Please sign in to comment.