refactor: priority messages duplication
This commit is contained in:
17
frontend/components/TestCasePriority.tsx
Normal file
17
frontend/components/TestCasePriority.tsx
Normal file
@@ -0,0 +1,17 @@
|
|||||||
|
import { Circle } from 'lucide-react';
|
||||||
|
import { priorities } from '@/config/selection';
|
||||||
|
import { PriorityMessages } from '@/types/priority';
|
||||||
|
|
||||||
|
type Props = {
|
||||||
|
priorityValue: number;
|
||||||
|
priorityMessages: PriorityMessages;
|
||||||
|
};
|
||||||
|
|
||||||
|
export default function TestCasePriority({ priorityValue, priorityMessages }: Props) {
|
||||||
|
return (
|
||||||
|
<div className="flex items-center">
|
||||||
|
<Circle size={8} color={priorities[priorityValue].color} fill={priorities[priorityValue].color} />
|
||||||
|
<div className="ms-3">{priorityMessages[priorities[priorityValue].uid]}</div>
|
||||||
|
</div>
|
||||||
|
);
|
||||||
|
}
|
||||||
@@ -1,4 +1,10 @@
|
|||||||
{
|
{
|
||||||
|
"Priority": {
|
||||||
|
"critical": "Critical",
|
||||||
|
"high": "High",
|
||||||
|
"medium": "Medium",
|
||||||
|
"low": "Low"
|
||||||
|
},
|
||||||
"Index": {
|
"Index": {
|
||||||
"get_started": "Get Started",
|
"get_started": "Get Started",
|
||||||
"demo": "Demo",
|
"demo": "Demo",
|
||||||
|
|||||||
@@ -1,4 +1,11 @@
|
|||||||
{
|
{
|
||||||
|
"Priority": {
|
||||||
|
"priority": "優先度",
|
||||||
|
"critical": "致",
|
||||||
|
"high": "高",
|
||||||
|
"medium": "中",
|
||||||
|
"low": "低"
|
||||||
|
},
|
||||||
"Index": {
|
"Index": {
|
||||||
"get_started": "テスト管理を始める",
|
"get_started": "テスト管理を始める",
|
||||||
"demo": "デモ",
|
"demo": "デモ",
|
||||||
|
|||||||
@@ -37,6 +37,7 @@ import { fetchFolders } from '../../folders/foldersControl';
|
|||||||
import { TokenContext } from '@/utils/TokenProvider';
|
import { TokenContext } from '@/utils/TokenProvider';
|
||||||
import { useTheme } from 'next-themes';
|
import { useTheme } from 'next-themes';
|
||||||
import { useFormGuard } from '@/utils/formGuard';
|
import { useFormGuard } from '@/utils/formGuard';
|
||||||
|
import { PriorityMessages } from '@/types/priority';
|
||||||
|
|
||||||
const defaultTestRun = {
|
const defaultTestRun = {
|
||||||
id: 0,
|
id: 0,
|
||||||
@@ -53,10 +54,11 @@ type Props = {
|
|||||||
projectId: string;
|
projectId: string;
|
||||||
runId: string;
|
runId: string;
|
||||||
messages: RunMessages;
|
messages: RunMessages;
|
||||||
|
priorityMessages: PriorityMessages;
|
||||||
locale: string;
|
locale: string;
|
||||||
};
|
};
|
||||||
|
|
||||||
export default function RunEditor({ projectId, runId, messages, locale }: Props) {
|
export default function RunEditor({ projectId, runId, messages, priorityMessages, locale }: Props) {
|
||||||
const context = useContext(TokenContext);
|
const context = useContext(TokenContext);
|
||||||
const { theme, setTheme } = useTheme();
|
const { theme, setTheme } = useTheme();
|
||||||
const [testRun, setTestRun] = useState<RunType>(defaultTestRun);
|
const [testRun, setTestRun] = useState<RunType>(defaultTestRun);
|
||||||
@@ -314,6 +316,7 @@ export default function RunEditor({ projectId, runId, messages, locale }: Props)
|
|||||||
onIncludeCase={(includeTestId) => handleIncludeExcludeCase(true, includeTestId)}
|
onIncludeCase={(includeTestId) => handleIncludeExcludeCase(true, includeTestId)}
|
||||||
onExcludeCase={(excludeCaseId) => handleIncludeExcludeCase(false, excludeCaseId)}
|
onExcludeCase={(excludeCaseId) => handleIncludeExcludeCase(false, excludeCaseId)}
|
||||||
messages={messages}
|
messages={messages}
|
||||||
|
priorityMessages={priorityMessages}
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@@ -1,8 +1,9 @@
|
|||||||
import { Button, Modal, ModalContent, ModalHeader, ModalBody, ModalFooter, Chip, Divider } from '@nextui-org/react';
|
import { Button, Modal, ModalContent, ModalHeader, ModalBody, ModalFooter } from '@nextui-org/react';
|
||||||
|
import { testTypes, templates } from '@/config/selection';
|
||||||
|
import TestCasePriority from '@/components/TestCasePriority';
|
||||||
import { RunMessages } from '@/types/run';
|
import { RunMessages } from '@/types/run';
|
||||||
import { CaseType } from '@/types/case';
|
import { CaseType } from '@/types/case';
|
||||||
import { Circle } from 'lucide-react';
|
import { PriorityMessages } from '@/types/priority';
|
||||||
import { priorities, testTypes, templates } from '@/config/selection';
|
|
||||||
|
|
||||||
type Props = {
|
type Props = {
|
||||||
isOpen: boolean;
|
isOpen: boolean;
|
||||||
@@ -10,9 +11,17 @@ type Props = {
|
|||||||
onCancel: () => void;
|
onCancel: () => void;
|
||||||
onChangeStatus: (changeCaseId: number, status: number) => {};
|
onChangeStatus: (changeCaseId: number, status: number) => {};
|
||||||
messages: RunMessages;
|
messages: RunMessages;
|
||||||
|
priorityMessages: PriorityMessages;
|
||||||
};
|
};
|
||||||
|
|
||||||
export default function showTestCaseDetailDialog({ isOpen, testCase, onCancel, onChangeStatus, messages }: Props) {
|
export default function showTestCaseDetailDialog({
|
||||||
|
isOpen,
|
||||||
|
testCase,
|
||||||
|
onCancel,
|
||||||
|
onChangeStatus,
|
||||||
|
messages,
|
||||||
|
priorityMessages,
|
||||||
|
}: Props) {
|
||||||
return (
|
return (
|
||||||
<Modal
|
<Modal
|
||||||
isOpen={isOpen}
|
isOpen={isOpen}
|
||||||
@@ -34,19 +43,7 @@ export default function showTestCaseDetailDialog({ isOpen, testCase, onCancel, o
|
|||||||
<div className="flex my-2">
|
<div className="flex my-2">
|
||||||
<div className="w-1/2">
|
<div className="w-1/2">
|
||||||
<p className={'font-bold'}>{messages.priority}</p>
|
<p className={'font-bold'}>{messages.priority}</p>
|
||||||
<Chip
|
<TestCasePriority priorityValue={testCase.priority} priorityMessages={priorityMessages} />
|
||||||
startContent={
|
|
||||||
<Circle
|
|
||||||
size={8}
|
|
||||||
className="me-2"
|
|
||||||
color={priorities[testCase.priority].color}
|
|
||||||
fill={priorities[testCase.priority].color}
|
|
||||||
/>
|
|
||||||
}
|
|
||||||
variant="light"
|
|
||||||
>
|
|
||||||
{messages[priorities[testCase.priority].uid]}
|
|
||||||
</Chip>
|
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div className="w-1/2">
|
<div className="w-1/2">
|
||||||
|
|||||||
@@ -30,6 +30,7 @@ import { priorities, testRunCaseStatus } from '@/config/selection';
|
|||||||
import { CaseType } from '@/types/case';
|
import { CaseType } from '@/types/case';
|
||||||
import { RunMessages } from '@/types/run';
|
import { RunMessages } from '@/types/run';
|
||||||
import TestCaseDetailDialog from './TestCaseDetailDialog';
|
import TestCaseDetailDialog from './TestCaseDetailDialog';
|
||||||
|
import { PriorityMessages } from '@/types/priority';
|
||||||
|
|
||||||
type Props = {
|
type Props = {
|
||||||
cases: CaseType[];
|
cases: CaseType[];
|
||||||
@@ -40,6 +41,7 @@ type Props = {
|
|||||||
onIncludeCase: (includeCaseId: number) => {};
|
onIncludeCase: (includeCaseId: number) => {};
|
||||||
onExcludeCase: (excludeCaseId: number) => {};
|
onExcludeCase: (excludeCaseId: number) => {};
|
||||||
messages: RunMessages;
|
messages: RunMessages;
|
||||||
|
priorityMessages: PriorityMessages;
|
||||||
};
|
};
|
||||||
|
|
||||||
export default function TestCaseSelector({
|
export default function TestCaseSelector({
|
||||||
@@ -51,6 +53,7 @@ export default function TestCaseSelector({
|
|||||||
onIncludeCase,
|
onIncludeCase,
|
||||||
onExcludeCase,
|
onExcludeCase,
|
||||||
messages,
|
messages,
|
||||||
|
priorityMessages,
|
||||||
}: Props) {
|
}: Props) {
|
||||||
const headerColumns = [
|
const headerColumns = [
|
||||||
{ name: messages.id, uid: 'id', sortable: true },
|
{ name: messages.id, uid: 'id', sortable: true },
|
||||||
@@ -303,6 +306,7 @@ export default function TestCaseSelector({
|
|||||||
onCancel={hideTestCaseDetailDialog}
|
onCancel={hideTestCaseDetailDialog}
|
||||||
onChangeStatus={(showingCaseId, newStatus) => onChangeStatus(showingCaseId, newStatus)}
|
onChangeStatus={(showingCaseId, newStatus) => onChangeStatus(showingCaseId, newStatus)}
|
||||||
messages={messages}
|
messages={messages}
|
||||||
|
priorityMessages={priorityMessages}
|
||||||
/>
|
/>
|
||||||
</>
|
</>
|
||||||
);
|
);
|
||||||
|
|||||||
@@ -1,9 +1,11 @@
|
|||||||
import RunEditor from './RunEditor';
|
import RunEditor from './RunEditor';
|
||||||
import { useTranslations } from 'next-intl';
|
import { useTranslations } from 'next-intl';
|
||||||
|
import { RunMessages } from '@/types/run';
|
||||||
|
import { PriorityMessages } from '@/types/priority';
|
||||||
|
|
||||||
export default function Page({ params }: { params: { projectId: string; runId: string; locale: string } }) {
|
export default function Page({ params }: { params: { projectId: string; runId: string; locale: string } }) {
|
||||||
const t = useTranslations('Run');
|
const t = useTranslations('Run');
|
||||||
const messages = {
|
const messages: RunMessages = {
|
||||||
backToRuns: t('back_to_runs'),
|
backToRuns: t('back_to_runs'),
|
||||||
updating: t('updating'),
|
updating: t('updating'),
|
||||||
update: t('update'),
|
update: t('update'),
|
||||||
@@ -22,10 +24,6 @@ export default function Page({ params }: { params: { projectId: string; runId: s
|
|||||||
priority: t('priority'),
|
priority: t('priority'),
|
||||||
actions: t('actions'),
|
actions: t('actions'),
|
||||||
status: t('status'),
|
status: t('status'),
|
||||||
critical: t('critical'),
|
|
||||||
high: t('high'),
|
|
||||||
medium: t('medium'),
|
|
||||||
low: t('low'),
|
|
||||||
untested: t('untested'),
|
untested: t('untested'),
|
||||||
passed: t('passed'),
|
passed: t('passed'),
|
||||||
failed: t('failed'),
|
failed: t('failed'),
|
||||||
@@ -57,5 +55,21 @@ export default function Page({ params }: { params: { projectId: string; runId: s
|
|||||||
close: t('close'),
|
close: t('close'),
|
||||||
};
|
};
|
||||||
|
|
||||||
return <RunEditor projectId={params.projectId} runId={params.runId} messages={messages} locale={params.locale} />;
|
const priorityTranslation = useTranslations('Priority');
|
||||||
|
const priorityMessages: PriorityMessages = {
|
||||||
|
critical: priorityTranslation('critical'),
|
||||||
|
high: priorityTranslation('high'),
|
||||||
|
medium: priorityTranslation('medium'),
|
||||||
|
low: priorityTranslation('low'),
|
||||||
|
};
|
||||||
|
|
||||||
|
return (
|
||||||
|
<RunEditor
|
||||||
|
projectId={params.projectId}
|
||||||
|
runId={params.runId}
|
||||||
|
messages={messages}
|
||||||
|
priorityMessages={priorityMessages}
|
||||||
|
locale={params.locale}
|
||||||
|
/>
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -101,11 +101,6 @@ type CaseMessages = {
|
|||||||
pleaseEnterTitle: string;
|
pleaseEnterTitle: string;
|
||||||
description: string;
|
description: string;
|
||||||
testCaseDescription: string;
|
testCaseDescription: string;
|
||||||
priority: string;
|
|
||||||
critical: string;
|
|
||||||
high: string;
|
|
||||||
medium: string;
|
|
||||||
low: string;
|
|
||||||
type: string;
|
type: string;
|
||||||
other: string;
|
other: string;
|
||||||
security: string;
|
security: string;
|
||||||
|
|||||||
7
frontend/types/priority.ts
Normal file
7
frontend/types/priority.ts
Normal file
@@ -0,0 +1,7 @@
|
|||||||
|
type PriorityMessages = {
|
||||||
|
critical: string;
|
||||||
|
high: string;
|
||||||
|
medium: string;
|
||||||
|
low: string;
|
||||||
|
};
|
||||||
|
export type { PriorityMessages };
|
||||||
Reference in New Issue
Block a user