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 e25dd98
Show file tree
Hide file tree
Showing 26 changed files with 3,480 additions and 5,679 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
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 })
}))
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"
}
}
}
59 changes: 22 additions & 37 deletions packages/ui/locales/en/views.json
Original file line number Diff line number Diff line change
Expand Up @@ -236,6 +236,22 @@
},
"projectSettings": {
"newLabels": "Create label",
"general": {
"mainTitle": "General settings",
"projectNamePlaceholder": "Enter project name",
"projectNameLabel": "Project name",
"projectDescriptionPlaceholder": "Enter description (optional)",
"projectDescriptionLabel": "Description",
"formSubmitButton": {
"savingState": "Saving...",
"defaultState": "Save changes",
"savedState": "Saved"
},
"formCancelButton": "Cancel",
"deleteProjectTitle": "Delete project",
"deleteProjectDescription": "This will permanently delete this project, and everything contained in it. All repositories in it will also be deleted.",
"deleteProjectButton": "Delete project"
},
"newMember": "New member",
"member": "Member",
"role": "Role",
Expand All @@ -247,7 +263,12 @@
},
"removeMember": "Remove member",
"inviteNewMember": "Invite new member",
"members": "Members"
"members": "Members",
"tabs": {
"general": "General",
"members": "Members",
"labels": "Labels"
}
},
"landingPage": {
"selectProject": "Select a project to get started",
Expand Down Expand Up @@ -378,42 +399,6 @@
"generalTab": "General",
"keysTab": "Keys and Tokens"
},
"projectSettings": {
"general": {
"mainTitle": "General settings",
"projectNamePlaceholder": "Enter project name",
"projectNameLabel": "Project name",
"projectDescriptionPlaceholder": "Enter description (optional)",
"projectDescriptionLabel": "Description",
"formSubmitButton": {
"savingState": "Saving...",
"defaultState": "Save changes",
"savedState": "Saved"
},
"formCancelButton": "Cancel",
"deleteProjectTitle": "Delete project",
"deleteProjectDescription": "This will permanently delete this project, and everything contained in it. All repositories in it will also be deleted.",
"deleteProjectButton": "Delete project"
},
"newLabels": "Create label",
"newMember": "New member",
"member": "Member",
"role": "Role",
"addMember": "Add member to this project",
"membersTable": {
"user": "User",
"email": "Email",
"role": "Role"
},
"removeMember": "Remove member",
"inviteNewMember": "Invite new member",
"members": "Members",
"tabs": {
"general": "General",
"members": "Members",
"labels": "Labels"
}
},
"forms": {
"selectMember": "Select member",
"selectRole": "Select role",
Expand Down
Loading

0 comments on commit e25dd98

Please sign in to comment.