261119_01_ENH: 리스트 필터 다이얼로그에 필터 초기화 버튼 추가 #78

Merged
gitadmin merged 2 commits from develop into master 2026-11-20 15:50:09 +09:00
6 changed files with 54 additions and 8 deletions

View File

@@ -1,6 +1,7 @@
'use client'
import { useEffect, useMemo, useState } from 'react'
import { RotateCcw } from 'lucide-react'
import { KriDialog } from '@/components/common/KriDialog'
import { Button } from '@/components/ui/button'
import { Input } from '@/components/ui/input'
@@ -107,6 +108,18 @@ const ListFilterDialog = ({
[rows, headerOptions],
)
// 잠긴 헤더는 조회 조건에 쓰이지 않으므로 초기화 필요 여부 판단에서 제외한다.
const isResettable = rows.some((row) => {
if (isDisabledHeader(row.headerId)) return false
const defaultOperator = getHeaderOption(row.headerId)?.defaultOperator ?? 'eq'
return row.operator !== defaultOperator || row.textValue !== '' || row.multiValues.length > 0
})
// 다이얼로그 내 입력만 기본값으로 되돌린다. 실제 반영은 "적용"을 눌러야 이뤄진다.
const handleReset = () => {
setRows(headerOptions.map((option) => createFilterRow(option.id, headerOptions)))
}
const handleConfirm = async () => {
setSubmitting(true)
try {
@@ -138,7 +151,20 @@ const ListFilterDialog = ({
<div className="grid h-11 grid-cols-[1fr_140px_1.4fr] items-center border-b bg-muted px-4 text-sm font-semibold">
<span>헤더</span>
<span>비교 연산자</span>
<span>값</span>
<div className="flex items-center justify-between gap-2">
<span>값</span>
<Button
type="button"
variant="ghost"
size="sm"
className="h-7 text-muted-foreground"
onClick={handleReset}
disabled={submitting || !isResettable}
>
<RotateCcw className="size-3.5" />
초기화
</Button>
</div>
</div>
<div className="max-h-170 overflow-auto">

View File

@@ -2,11 +2,10 @@
import { useEffect } from 'react'
import { useAtom } from 'jotai'
import { HttpError } from '@kri/common/http'
import { Button } from '@/components/ui/button'
import { ListJobProgress } from '@/components/list/ListJobProgress'
import { useAuth } from '@/hooks/useAuth'
import { isAvailabilityUnsupported, useListJob, useListJobAvailability, useUploadResetActive } from '@/query/list-job'
import { isAvailabilityUnsupported, isListJobGone, useListJob, useListJobAvailability, useUploadResetActive } from '@/query/list-job'
import { findTrackedListJob, trackListJob, untrackListJob, useTrackedListJobs } from '@/store/list-job-tracker'
import { listJobLabel } from '@/const/listJobConst'
import { blockerJobLabel, blockerPhaseLabel, blockerUserLabel, describeListJobAvailability } from '@/utils/listJobAvailability'
@@ -45,7 +44,7 @@ export function useListJobGate({ prjctIdx, jobType, active, requestLabel, pollWh
const detail = useListJob(prjctIdx, jobKey, active)
const job = detail.data?.jobKey === jobKey ? detail.data : undefined
const finishedJob = job && !isActiveListJob(job.jobStatus) ? job : undefined
const detailNotFound = detail.error instanceof HttpError && detail.error.status === 404
const detailNotFound = isListJobGone(detail.error)
useEffect(() => {
if (!active && requestMatches && openRequest.opened) setOpenRequest(null)

View File

@@ -4,10 +4,9 @@ import { useEffect } from 'react'
import { usePathname, useRouter } from 'next/navigation'
import { useAtom } from 'jotai'
import { useQueries, useQueryClient } from '@tanstack/react-query'
import { HttpError } from '@kri/common/http'
import { toast } from 'sonner'
import { nextApi } from '@/lib/http-client'
import { listJobKeys, useMyActiveListJobs } from '@/query/list-job'
import { isListJobGone, listJobKeys, useMyActiveListJobs } from '@/query/list-job'
import { listJobOpenRequestAtom } from '@/store/jotai/list-job'
import { useSelectedProject } from '@/hooks/useSelectedProject'
import { useDialog } from '@/hooks/useDialog'
@@ -90,7 +89,7 @@ export function ListJobWatcher({ userId, prjctIdx }: { userId: string; prjctIdx:
details.forEach((result, index) => {
const tracked = trackedJobs[index]
if (!tracked) return
if (result.error instanceof HttpError && result.error.status === 404) {
if (isListJobGone(result.error)) {
untrackListJob(tracked.jobKey)
return
}

View File

@@ -1,9 +1,12 @@
"use client";
import { useMutation, useQueryClient } from "@tanstack/react-query";
import { useSetAtom } from "jotai";
import { nextApi } from "@/lib/http-client";
import { useAuth } from "@/hooks/useAuth";
import { useSelectedProject } from "@/hooks/useSelectedProject";
import { clearTrackedListJobs } from "@/store/list-job-tracker";
import { listJobOpenRequestAtom } from "@/store/jotai/list-job";
import type { LoginUser } from "@kri/common";
export const useLoginMutation = () => {
@@ -31,6 +34,7 @@ export const useLogoutMutation = () => {
const qc = useQueryClient();
const { auth, logout } = useAuth();
const { clearSelectedProject } = useSelectedProject();
const setListJobOpenRequest = useSetAtom(listJobOpenRequestAtom);
return useMutation({
mutationFn: async () => {
@@ -49,6 +53,8 @@ export const useLogoutMutation = () => {
},
onSettled: () => {
clearSelectedProject();
clearTrackedListJobs();
setListJobOpenRequest(null);
logout();
qc.clear(); // 다음 사용자/세션에 서버상태 남지 않게
},

View File

@@ -38,6 +38,14 @@ const fetchAvailability = async (prjctIdx: number, jobType: ListJobType) =>
/** 신규 API 미배포·롤백 상태. 반복 호출하지 않고 사전 안내만 중단한다. */
export const isAvailabilityUnsupported = (error: unknown) => error instanceof HttpError && error.status === 404
/**
* 작업을 더 이상 조회할 수 없는 경우. 기록을 지우고 반복 조회를 멈춘다.
* - 404: 작업이 만료됐거나 내 작업이 아니다.
* - 403 PROJECT_ACCESS_DENIED: 프로젝트가 삭제됐거나 접근 권한·배정·상태가 바뀌었다.
*/
export const isListJobGone = (error: unknown) => error instanceof HttpError
&& (error.status === 404 || (error.status === 403 && apiError(error).code === 'PROJECT_ACCESS_DENIED'))
export function useSubmitListJob(prjctIdx: number) {
const qc = useQueryClient()
const { auth } = useAuth()

View File

@@ -1,7 +1,7 @@
'use client'
import { useSyncExternalStore } from 'react'
import { getLocalStorage, setLocalStorage } from '@/store/storage/secure-storage'
import { getLocalStorage, removeLocalStorage, setLocalStorage } from '@/store/storage/secure-storage'
import { StorageKeys } from '@/store/storage/storage-keys'
import { isListJobType, type ListJobType } from '@/types/list-job'
@@ -77,6 +77,14 @@ export const untrackListJob = (jobKey: string) => {
write(jobs.filter((job) => job.jobKey !== jobKey))
}
/** 로그아웃 시 다음 사용자에게 기록이 남지 않게 모두 지운다. 진행 중인 작업은 재로그인 후 my-active 조회로 다시 채워진다. */
export const clearTrackedListJobs = () => {
if (typeof window === 'undefined') return
removeLocalStorage(StorageKeys.ListJobs)
cache = EMPTY
window.dispatchEvent(new Event(CHANGE_EVENT))
}
export const findTrackedListJob = (jobs: TrackedListJob[], userId: string, prjctIdx: number, jobType: ListJobType) =>
jobs.find((job) => job.userId === userId && job.prjctIdx === prjctIdx && job.jobType === jobType)