fix: Typescript check (#21)
* fix: typescript check error * fix: typescript check error * fix: typescript check error * fix: typescript check error * fix: typescript check error
This commit is contained in:
@@ -12,17 +12,17 @@ import {
|
|||||||
ModalBody,
|
ModalBody,
|
||||||
ModalFooter,
|
ModalFooter,
|
||||||
} from '@nextui-org/react';
|
} from '@nextui-org/react';
|
||||||
import { ProjectType, ProjectsMessages } from '@/types/project';
|
import { ProjectType, ProjectDialogMessages } from '@/types/project';
|
||||||
|
|
||||||
type Props = {
|
type Props = {
|
||||||
isOpen: boolean;
|
isOpen: boolean;
|
||||||
editingProject: ProjectType | null;
|
editingProject: ProjectType | null;
|
||||||
onCancel: () => void;
|
onCancel: () => void;
|
||||||
onSubmit: (name: string, detail: string, isPublic: boolean) => void;
|
onSubmit: (name: string, detail: string, isPublic: boolean) => void;
|
||||||
messages: ProjectsMessages;
|
projectDialogMessages: ProjectDialogMessages;
|
||||||
};
|
};
|
||||||
|
|
||||||
export default function ProjectDialog({ isOpen, editingProject, onCancel, onSubmit, messages }: Props) {
|
export default function ProjectDialog({ isOpen, editingProject, onCancel, onSubmit, projectDialogMessages }: Props) {
|
||||||
const [projectName, setProjectName] = useState({
|
const [projectName, setProjectName] = useState({
|
||||||
text: editingProject ? editingProject.name : '',
|
text: editingProject ? editingProject.name : '',
|
||||||
isInvalid: false,
|
isInvalid: false,
|
||||||
@@ -83,7 +83,7 @@ export default function ProjectDialog({ isOpen, editingProject, onCancel, onSubm
|
|||||||
setProjectName({
|
setProjectName({
|
||||||
text: '',
|
text: '',
|
||||||
isInvalid: true,
|
isInvalid: true,
|
||||||
errorMessage: messages.pleaseEnter,
|
errorMessage: projectDialogMessages.pleaseEnter,
|
||||||
});
|
});
|
||||||
|
|
||||||
return;
|
return;
|
||||||
@@ -101,11 +101,11 @@ export default function ProjectDialog({ isOpen, editingProject, onCancel, onSubm
|
|||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
<ModalContent>
|
<ModalContent>
|
||||||
<ModalHeader className="flex flex-col gap-1">{messages.project}</ModalHeader>
|
<ModalHeader className="flex flex-col gap-1">{projectDialogMessages.project}</ModalHeader>
|
||||||
<ModalBody>
|
<ModalBody>
|
||||||
<Input
|
<Input
|
||||||
type="text"
|
type="text"
|
||||||
label={messages.projectName}
|
label={projectDialogMessages.projectName}
|
||||||
value={projectName.text}
|
value={projectName.text}
|
||||||
isInvalid={projectName.isInvalid}
|
isInvalid={projectName.isInvalid}
|
||||||
errorMessage={projectName.errorMessage}
|
errorMessage={projectName.errorMessage}
|
||||||
@@ -117,7 +117,7 @@ export default function ProjectDialog({ isOpen, editingProject, onCancel, onSubm
|
|||||||
}}
|
}}
|
||||||
/>
|
/>
|
||||||
<Textarea
|
<Textarea
|
||||||
label={messages.projectDetail}
|
label={projectDialogMessages.projectDetail}
|
||||||
value={projectDetail.text}
|
value={projectDetail.text}
|
||||||
isInvalid={projectDetail.isInvalid}
|
isInvalid={projectDetail.isInvalid}
|
||||||
errorMessage={projectDetail.errorMessage}
|
errorMessage={projectDetail.errorMessage}
|
||||||
@@ -129,16 +129,16 @@ export default function ProjectDialog({ isOpen, editingProject, onCancel, onSubm
|
|||||||
}}
|
}}
|
||||||
/>
|
/>
|
||||||
<Checkbox isSelected={isProjectPublic} onValueChange={setIsProjectPublic}>
|
<Checkbox isSelected={isProjectPublic} onValueChange={setIsProjectPublic}>
|
||||||
{messages.public}
|
{projectDialogMessages.public}
|
||||||
</Checkbox>
|
</Checkbox>
|
||||||
<div className="text-small text-default-500">{messages.ifYouMakePublic}</div>
|
<div className="text-small text-default-500">{projectDialogMessages.ifYouMakePublic}</div>
|
||||||
</ModalBody>
|
</ModalBody>
|
||||||
<ModalFooter>
|
<ModalFooter>
|
||||||
<Button variant="light" onPress={onCancel}>
|
<Button variant="light" onPress={onCancel}>
|
||||||
{messages.close}
|
{projectDialogMessages.close}
|
||||||
</Button>
|
</Button>
|
||||||
<Button color="primary" onPress={validate}>
|
<Button color="primary" onPress={validate}>
|
||||||
{editingProject ? messages.update : messages.create}
|
{editingProject ? projectDialogMessages.update : projectDialogMessages.create}
|
||||||
</Button>
|
</Button>
|
||||||
</ModalFooter>
|
</ModalFooter>
|
||||||
</ModalContent>
|
</ModalContent>
|
||||||
|
|||||||
@@ -10,7 +10,7 @@ export default function PublicityChip({ context }: Props) {
|
|||||||
return context.isSignedIn() ? (
|
return context.isSignedIn() ? (
|
||||||
<Avatar
|
<Avatar
|
||||||
size={16}
|
size={16}
|
||||||
name={context.token.user.username}
|
name={context.token!.user!.username}
|
||||||
variant="beam"
|
variant="beam"
|
||||||
colors={['#0A0310', '#49007E', '#FF005B', '#FF7D10', '#FFB238']}
|
colors={['#0A0310', '#49007E', '#FF005B', '#FF7D10', '#FFB238']}
|
||||||
/>
|
/>
|
||||||
|
|||||||
@@ -1,14 +1,15 @@
|
|||||||
|
import { AutomationStatusType, GlobalRoleType, MemberRoleType, TemplateType } from '@/types/base';
|
||||||
import { RunStatusType, TestRunCaseStatusType } from '@/types/status';
|
import { RunStatusType, TestRunCaseStatusType } from '@/types/status';
|
||||||
import { TestTypeType } from '@/types/testType';
|
import { TestTypeType } from '@/types/testType';
|
||||||
import { PriorityType } from '@/types/priority';
|
import { PriorityType } from '@/types/priority';
|
||||||
|
import { LocaleType } from '@/types/locale';
|
||||||
|
|
||||||
const roles = [{ uid: 'administrator' }, { uid: 'user' }];
|
const roles: GlobalRoleType[] = [{ uid: 'administrator' }, { uid: 'user' }];
|
||||||
|
const memberRoles: MemberRoleType[] = [{ uid: 'manager' }, { uid: 'developer' }, { uid: 'reporter' }];
|
||||||
const memberRoles = [{ uid: 'manager' }, { uid: 'developer' }, { uid: 'reporter' }];
|
|
||||||
|
|
||||||
const categoricalPalette = ['#fba91e', '#6ea56c', '#3ac6e1', '#feda2f', '#f15f47', '#244470', '#9c80bb', '#f595a6'];
|
const categoricalPalette = ['#fba91e', '#6ea56c', '#3ac6e1', '#feda2f', '#f15f47', '#244470', '#9c80bb', '#f595a6'];
|
||||||
|
|
||||||
const locales = [
|
const locales: LocaleType[] = [
|
||||||
{ code: 'en', name: 'English' },
|
{ code: 'en', name: 'English' },
|
||||||
{ code: 'ja', name: '日本語' },
|
{ code: 'ja', name: '日本語' },
|
||||||
];
|
];
|
||||||
@@ -59,14 +60,14 @@ const testTypes: TestTypeType[] = [
|
|||||||
{ uid: 'manual', chartColor: categoricalPalette[4] },
|
{ uid: 'manual', chartColor: categoricalPalette[4] },
|
||||||
];
|
];
|
||||||
|
|
||||||
const automationStatus = [
|
const automationStatus: AutomationStatusType[] = [
|
||||||
{ name: 'Automated', uid: 'automated' },
|
{ uid: 'automated' },
|
||||||
{ name: 'Automation Not Required', uid: 'automation-not-required' },
|
{ uid: 'automation-not-required' },
|
||||||
{ name: 'Cannot Be Automated', uid: 'cannot-be-automated' },
|
{ uid: 'cannot-be-automated' },
|
||||||
{ name: 'Obsolete', uid: 'obsolete' },
|
{ uid: 'obsolete' },
|
||||||
];
|
];
|
||||||
|
|
||||||
const templates = [{ uid: 'text' }, { uid: 'step' }];
|
const templates: TemplateType[] = [{ uid: 'text' }, { uid: 'step' }];
|
||||||
|
|
||||||
export {
|
export {
|
||||||
roles,
|
roles,
|
||||||
|
|||||||
@@ -35,6 +35,18 @@
|
|||||||
"automated": "Automated",
|
"automated": "Automated",
|
||||||
"manual": "Manual"
|
"manual": "Manual"
|
||||||
},
|
},
|
||||||
|
"ProjectDialog": {
|
||||||
|
"project": "Project",
|
||||||
|
"project_name": "Project Name",
|
||||||
|
"project_detail": "Project Detail",
|
||||||
|
"public": "Public",
|
||||||
|
"private": "Private",
|
||||||
|
"if_you_make_public": "Making a project public makes it visible to users who are not project members.",
|
||||||
|
"close": "Close",
|
||||||
|
"create": "Create",
|
||||||
|
"update": "Update",
|
||||||
|
"please_enter": "Please enter project name"
|
||||||
|
},
|
||||||
"Index": {
|
"Index": {
|
||||||
"get_started": "Get Started",
|
"get_started": "Get Started",
|
||||||
"demo": "Demo",
|
"demo": "Demo",
|
||||||
@@ -114,21 +126,14 @@
|
|||||||
},
|
},
|
||||||
"Projects": {
|
"Projects": {
|
||||||
"projectList": "Project List",
|
"projectList": "Project List",
|
||||||
"project": "Project",
|
|
||||||
"new_project": "New Project",
|
"new_project": "New Project",
|
||||||
"id": "ID",
|
"id": "ID",
|
||||||
"publicity": "Publicity",
|
"publicity": "Publicity",
|
||||||
|
"public": "Public",
|
||||||
|
"private": "Private",
|
||||||
"name": "Name",
|
"name": "Name",
|
||||||
"detail": "Detail",
|
"detail": "Detail",
|
||||||
"last_update": "Last update",
|
"last_update": "Last update",
|
||||||
"project_name": "Project Name",
|
|
||||||
"project_detail": "Project Detail",
|
|
||||||
"public": "Public",
|
|
||||||
"private": "Private",
|
|
||||||
"if_you_make_public": "Making a project public makes it visible to users who are not project members.",
|
|
||||||
"close": "Close",
|
|
||||||
"create": "Create",
|
|
||||||
"please_enter": "Please enter project name",
|
|
||||||
"no_projects_found": "No projects found"
|
"no_projects_found": "No projects found"
|
||||||
},
|
},
|
||||||
"Project": {
|
"Project": {
|
||||||
@@ -283,11 +288,8 @@
|
|||||||
"project_detail": "Project Detail",
|
"project_detail": "Project Detail",
|
||||||
"project_owner": "Project Owner",
|
"project_owner": "Project Owner",
|
||||||
"edit_project": "Edit Project",
|
"edit_project": "Edit Project",
|
||||||
"project": "Project",
|
|
||||||
"publicity": "Publicity",
|
"publicity": "Publicity",
|
||||||
"public": "Public",
|
"public": "Public",
|
||||||
"private": "Private",
|
|
||||||
"if_you_make_public": "Making a project public makes it visible to users who are not project members.",
|
|
||||||
"update": "Update",
|
"update": "Update",
|
||||||
"delete_project": "Delete Project",
|
"delete_project": "Delete Project",
|
||||||
"delete": "Delete",
|
"delete": "Delete",
|
||||||
|
|||||||
@@ -36,6 +36,18 @@
|
|||||||
"automated": "自動",
|
"automated": "自動",
|
||||||
"manual": "手動"
|
"manual": "手動"
|
||||||
},
|
},
|
||||||
|
"ProjectDialog": {
|
||||||
|
"project": "プロジェクト",
|
||||||
|
"project_name": "プロジェクト名",
|
||||||
|
"project_detail": "プロジェクト詳細",
|
||||||
|
"public": "パブリック",
|
||||||
|
"private": "プライベート",
|
||||||
|
"if_you_make_public": "プロジェクトをパブリックにすると、プロジェクトメンバーではないユーザーからも見えるようになります。",
|
||||||
|
"close": "閉じる",
|
||||||
|
"create": "作成",
|
||||||
|
"update": "更新",
|
||||||
|
"please_enter": "プロジェクト名を入力してください"
|
||||||
|
},
|
||||||
"Index": {
|
"Index": {
|
||||||
"get_started": "テスト管理を始める",
|
"get_started": "テスト管理を始める",
|
||||||
"demo": "デモ",
|
"demo": "デモ",
|
||||||
@@ -115,21 +127,14 @@
|
|||||||
},
|
},
|
||||||
"Projects": {
|
"Projects": {
|
||||||
"projectList": "プロジェクト一覧",
|
"projectList": "プロジェクト一覧",
|
||||||
"project": "プロジェクト",
|
|
||||||
"new_project": "新規プロジェクト",
|
"new_project": "新規プロジェクト",
|
||||||
"id": "ID",
|
"id": "ID",
|
||||||
"publicity": "公開",
|
"publicity": "公開",
|
||||||
|
"public": "パブリック",
|
||||||
|
"private": "プライベート",
|
||||||
"name": "名前",
|
"name": "名前",
|
||||||
"detail": "詳細",
|
"detail": "詳細",
|
||||||
"last_update": "最終更新",
|
"last_update": "最終更新",
|
||||||
"project_name": "プロジェクト名",
|
|
||||||
"project_detail": "プロジェクト詳細",
|
|
||||||
"public": "パブリック",
|
|
||||||
"private": "プライベート",
|
|
||||||
"if_you_make_public": "プロジェクトをパブリックにすると、プロジェクトメンバーではないユーザーからも見えるようになります。",
|
|
||||||
"close": "閉じる",
|
|
||||||
"create": "作成",
|
|
||||||
"please_enter": "プロジェクト名を入力してください",
|
|
||||||
"no_projects_found": "プロジェクトがありません"
|
"no_projects_found": "プロジェクトがありません"
|
||||||
},
|
},
|
||||||
"Project": {
|
"Project": {
|
||||||
@@ -284,12 +289,9 @@
|
|||||||
"project_detail": "プロジェクト詳細",
|
"project_detail": "プロジェクト詳細",
|
||||||
"project_owner": "所有者",
|
"project_owner": "所有者",
|
||||||
"edit_project": "プロジェクトの編集",
|
"edit_project": "プロジェクトの編集",
|
||||||
"project": "プロジェクト",
|
|
||||||
"publicity": "公開",
|
"publicity": "公開",
|
||||||
"public": "パブリック",
|
"public": "パブリック",
|
||||||
"private": "プライベート",
|
"private": "プライベート",
|
||||||
"if_you_make_public": "プロジェクトをパブリックにすると、プロジェクトメンバーではないユーザーからも見えるようになります。",
|
|
||||||
"update": "更新",
|
|
||||||
"delete_project": "プロジェクトの削除",
|
"delete_project": "プロジェクトの削除",
|
||||||
"delete": "削除",
|
"delete": "削除",
|
||||||
"close": "閉じる",
|
"close": "閉じる",
|
||||||
|
|||||||
@@ -3,13 +3,6 @@ const withNextIntl = createNextIntlPlugin();
|
|||||||
|
|
||||||
/** @type {import('next').NextConfig} */
|
/** @type {import('next').NextConfig} */
|
||||||
const nextConfig = {
|
const nextConfig = {
|
||||||
typescript: {
|
|
||||||
// !! WARN !!
|
|
||||||
// Dangerously allow production builds to successfully complete even if
|
|
||||||
// your project has type errors.
|
|
||||||
// !! WARN !!
|
|
||||||
ignoreBuildErrors: true,
|
|
||||||
},
|
|
||||||
output: 'standalone',
|
output: 'standalone',
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@@ -18,7 +18,11 @@ export default function DropdownAccount({ messages, locale, onItemPress }: Props
|
|||||||
const context = useContext(TokenContext);
|
const context = useContext(TokenContext);
|
||||||
|
|
||||||
const signOut = () => {
|
const signOut = () => {
|
||||||
context.setToken(null);
|
context.setToken({
|
||||||
|
access_token: '',
|
||||||
|
expires_at: 0,
|
||||||
|
user: null,
|
||||||
|
});
|
||||||
context.removeTokenFromLocalStorage();
|
context.removeTokenFromLocalStorage();
|
||||||
router.push(`/`, { locale: locale });
|
router.push(`/`, { locale: locale });
|
||||||
};
|
};
|
||||||
@@ -74,7 +78,7 @@ export default function DropdownAccount({ messages, locale, onItemPress }: Props
|
|||||||
startContent={<UserAvatar context={context} />}
|
startContent={<UserAvatar context={context} />}
|
||||||
endContent={<ChevronDown size={16} />}
|
endContent={<ChevronDown size={16} />}
|
||||||
>
|
>
|
||||||
{context.isSignedIn() ? context.token.user.username : messages.signIn}
|
{context.isSignedIn() ? context.token!.user!.username : messages.signIn}
|
||||||
</Button>
|
</Button>
|
||||||
</DropdownTrigger>
|
</DropdownTrigger>
|
||||||
{context.isSignedIn() ? (
|
{context.isSignedIn() ? (
|
||||||
|
|||||||
@@ -1,7 +1,8 @@
|
|||||||
import { useTranslations } from 'next-intl';
|
import { useTranslations } from 'next-intl';
|
||||||
import HeaderNavbarMenu from './HeaderNavbarMenu';
|
import HeaderNavbarMenu from './HeaderNavbarMenu';
|
||||||
|
import { LocaleCodeType } from '@/types/locale';
|
||||||
|
|
||||||
export default function Header(params: { locale: string }) {
|
export default function Header(params: { locale: LocaleCodeType }) {
|
||||||
const t = useTranslations('Header');
|
const t = useTranslations('Header');
|
||||||
const messages = {
|
const messages = {
|
||||||
projects: t('projects'),
|
projects: t('projects'),
|
||||||
|
|||||||
@@ -23,6 +23,7 @@ import { locales } from '@/config/selection';
|
|||||||
import DropdownAccount from './DropdownAccount';
|
import DropdownAccount from './DropdownAccount';
|
||||||
import DropdownLanguage from './DropdownLanguage';
|
import DropdownLanguage from './DropdownLanguage';
|
||||||
import UserAvatar from '@/components/UserAvatar';
|
import UserAvatar from '@/components/UserAvatar';
|
||||||
|
import { LocaleCodeType } from '@/types/locale';
|
||||||
|
|
||||||
type NabbarMenuMessages = {
|
type NabbarMenuMessages = {
|
||||||
projects: string;
|
projects: string;
|
||||||
@@ -39,7 +40,7 @@ type NabbarMenuMessages = {
|
|||||||
|
|
||||||
type Props = {
|
type Props = {
|
||||||
messages: NabbarMenuMessages;
|
messages: NabbarMenuMessages;
|
||||||
locale: string;
|
locale: LocaleCodeType;
|
||||||
};
|
};
|
||||||
|
|
||||||
export default function HeaderNavbarMenu({ messages, locale }: Props) {
|
export default function HeaderNavbarMenu({ messages, locale }: Props) {
|
||||||
@@ -202,7 +203,11 @@ export default function HeaderNavbarMenu({ messages, locale }: Props) {
|
|||||||
title={messages.signOut}
|
title={messages.signOut}
|
||||||
startContent={<ArrowRightFromLine size={16} />}
|
startContent={<ArrowRightFromLine size={16} />}
|
||||||
onPress={() => {
|
onPress={() => {
|
||||||
context.setToken(null);
|
context.setToken({
|
||||||
|
access_token: '',
|
||||||
|
expires_at: 0,
|
||||||
|
user: null,
|
||||||
|
});
|
||||||
context.removeTokenFromLocalStorage();
|
context.removeTokenFromLocalStorage();
|
||||||
router.push(`/`, { locale: locale });
|
router.push(`/`, { locale: locale });
|
||||||
setIsMenuOpen(false);
|
setIsMenuOpen(false);
|
||||||
|
|||||||
@@ -3,9 +3,10 @@ import { Button, Link as NextUiLink } from '@nextui-org/react';
|
|||||||
import { MoveUpRight } from 'lucide-react';
|
import { MoveUpRight } from 'lucide-react';
|
||||||
import { Link } from '@/src/navigation';
|
import { Link } from '@/src/navigation';
|
||||||
import { useTranslations } from 'next-intl';
|
import { useTranslations } from 'next-intl';
|
||||||
|
import { LocaleCodeType } from '@/types/locale';
|
||||||
|
|
||||||
type Props = {
|
type Props = {
|
||||||
locale: string;
|
locale: LocaleCodeType;
|
||||||
};
|
};
|
||||||
|
|
||||||
export default function MainTitle({ locale }: Props) {
|
export default function MainTitle({ locale }: Props) {
|
||||||
|
|||||||
@@ -7,6 +7,7 @@ import Avatar from 'boring-avatars';
|
|||||||
import { fetchMyProjects } from '@/utils/projectsControl';
|
import { fetchMyProjects } from '@/utils/projectsControl';
|
||||||
import { ProjectType } from '@/types/project';
|
import { ProjectType } from '@/types/project';
|
||||||
import PublicityChip from '@/components/PublicityChip';
|
import PublicityChip from '@/components/PublicityChip';
|
||||||
|
import { LocaleCodeType } from '@/types/locale';
|
||||||
|
|
||||||
type AccountPageMessages = {
|
type AccountPageMessages = {
|
||||||
yourProjects: string;
|
yourProjects: string;
|
||||||
@@ -17,7 +18,7 @@ type AccountPageMessages = {
|
|||||||
|
|
||||||
type Props = {
|
type Props = {
|
||||||
messages: AccountPageMessages;
|
messages: AccountPageMessages;
|
||||||
locale: string;
|
locale: LocaleCodeType;
|
||||||
};
|
};
|
||||||
|
|
||||||
export default function AccountPage({ messages, locale }: Props) {
|
export default function AccountPage({ messages, locale }: Props) {
|
||||||
@@ -50,13 +51,13 @@ export default function AccountPage({ messages, locale }: Props) {
|
|||||||
<CardHeader className="flex gap-6">
|
<CardHeader className="flex gap-6">
|
||||||
<Avatar
|
<Avatar
|
||||||
size={48}
|
size={48}
|
||||||
name={context.token.user.username}
|
name={context.token!.user!.username}
|
||||||
variant="beam"
|
variant="beam"
|
||||||
colors={['#0A0310', '#49007E', '#FF005B', '#FF7D10', '#FFB238']}
|
colors={['#0A0310', '#49007E', '#FF005B', '#FF7D10', '#FFB238']}
|
||||||
/>
|
/>
|
||||||
<div className="flex flex-col">
|
<div className="flex flex-col">
|
||||||
<p className="text-xl font-bold">{context.token.user.username}</p>
|
<p className="text-xl font-bold">{context.token!.user!.username}</p>
|
||||||
<p className="text-lg text-default-500">{context.token.user.email}</p>
|
<p className="text-lg text-default-500">{context.token!.user!.email}</p>
|
||||||
</div>
|
</div>
|
||||||
</CardHeader>
|
</CardHeader>
|
||||||
</Card>
|
</Card>
|
||||||
|
|||||||
@@ -77,9 +77,4 @@ function generateRandomEmail() {
|
|||||||
return `${randomString}@example.com`;
|
return `${randomString}@example.com`;
|
||||||
}
|
}
|
||||||
|
|
||||||
function getRandomAvatarPath() {
|
export { signUp, signIn, signInAsGuest };
|
||||||
const randomIndex = Math.floor(Math.random() * avatars.length);
|
|
||||||
return avatars[randomIndex];
|
|
||||||
}
|
|
||||||
|
|
||||||
export { signUp, signIn, signInAsGuest, getRandomAvatarPath };
|
|
||||||
|
|||||||
@@ -11,12 +11,13 @@ import { isValidEmail, isValidPassword } from './validate';
|
|||||||
import { TokenContext } from '@/utils/TokenProvider';
|
import { TokenContext } from '@/utils/TokenProvider';
|
||||||
import { useRouter } from '@/src/navigation';
|
import { useRouter } from '@/src/navigation';
|
||||||
import Config from '@/config/config';
|
import Config from '@/config/config';
|
||||||
|
import { LocaleCodeType } from '@/types/locale';
|
||||||
const isDemoSite = Config.isDemoSite;
|
const isDemoSite = Config.isDemoSite;
|
||||||
|
|
||||||
type Props = {
|
type Props = {
|
||||||
isSignup: Boolean;
|
isSignup: boolean;
|
||||||
messages: AuthMessages;
|
messages: AuthMessages;
|
||||||
locale: string;
|
locale: LocaleCodeType;
|
||||||
};
|
};
|
||||||
|
|
||||||
export default function AuthPage({ isSignup, messages, locale }: Props) {
|
export default function AuthPage({ isSignup, messages, locale }: Props) {
|
||||||
|
|||||||
@@ -1,6 +1,9 @@
|
|||||||
import { useTranslations } from 'next-intl';
|
import { useTranslations } from 'next-intl';
|
||||||
import AccountPage from './AccountPage';
|
import AccountPage from './AccountPage';
|
||||||
export default function Page(params: { locale: string }) {
|
import { PageType } from '@/types/base';
|
||||||
|
import { LocaleCodeType } from '@/types/locale';
|
||||||
|
|
||||||
|
export default function Page({ params }: PageType) {
|
||||||
const t = useTranslations('Auth');
|
const t = useTranslations('Auth');
|
||||||
const messages = {
|
const messages = {
|
||||||
yourProjects: t('your_projects'),
|
yourProjects: t('your_projects'),
|
||||||
@@ -9,5 +12,5 @@ export default function Page(params: { locale: string }) {
|
|||||||
noProjectsFound: t('no_projects_found'),
|
noProjectsFound: t('no_projects_found'),
|
||||||
};
|
};
|
||||||
|
|
||||||
return <AccountPage messages={messages} locale={params.locale} />;
|
return <AccountPage messages={messages} locale={params.locale as LocaleCodeType} />;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,7 +1,9 @@
|
|||||||
|
import { PageType } from '@/types/base';
|
||||||
import AuthPage from '../authPage';
|
import AuthPage from '../authPage';
|
||||||
import { useTranslations } from 'next-intl';
|
import { useTranslations } from 'next-intl';
|
||||||
|
import { LocaleCodeType } from '@/types/locale';
|
||||||
|
|
||||||
export default function Page(params: { locale: string }) {
|
export default function Page({ params }: PageType) {
|
||||||
const t = useTranslations('Auth');
|
const t = useTranslations('Auth');
|
||||||
const messages = {
|
const messages = {
|
||||||
title: t('signin'),
|
title: t('signin'),
|
||||||
@@ -24,7 +26,7 @@ export default function Page(params: { locale: string }) {
|
|||||||
};
|
};
|
||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
<AuthPage isSignup={false} messages={messages} locale={params.locale} />
|
<AuthPage isSignup={false} messages={messages} locale={params.locale as LocaleCodeType} />
|
||||||
</>
|
</>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,7 +1,9 @@
|
|||||||
|
import { PageType } from '@/types/base';
|
||||||
import AuthPage from '../authPage';
|
import AuthPage from '../authPage';
|
||||||
import { useTranslations } from 'next-intl';
|
import { useTranslations } from 'next-intl';
|
||||||
|
import { LocaleCodeType } from '@/types/locale';
|
||||||
|
|
||||||
export default function Page(params: { locale: string }) {
|
export default function Page({ params }: PageType) {
|
||||||
const t = useTranslations('Auth');
|
const t = useTranslations('Auth');
|
||||||
const messages = {
|
const messages = {
|
||||||
title: t('signup'),
|
title: t('signup'),
|
||||||
@@ -24,7 +26,7 @@ export default function Page(params: { locale: string }) {
|
|||||||
};
|
};
|
||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
<AuthPage isSignup={true} messages={messages} locale={params.locale} />
|
<AuthPage isSignup={true} messages={messages} locale={params.locale as LocaleCodeType} />
|
||||||
</>
|
</>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -5,11 +5,12 @@ import { UserType, AdminMessages } from '@/types/user';
|
|||||||
import { TokenContext } from '@/utils/TokenProvider';
|
import { TokenContext } from '@/utils/TokenProvider';
|
||||||
import UsersTable from './UsersTable';
|
import UsersTable from './UsersTable';
|
||||||
import Config from '@/config/config';
|
import Config from '@/config/config';
|
||||||
|
import { LocaleCodeType } from '@/types/locale';
|
||||||
const apiServer = Config.apiServer;
|
const apiServer = Config.apiServer;
|
||||||
|
|
||||||
type Props = {
|
type Props = {
|
||||||
messages: AdminMessages;
|
messages: AdminMessages;
|
||||||
locale: string;
|
locale: LocaleCodeType;
|
||||||
};
|
};
|
||||||
|
|
||||||
async function fetchUsers(jwt: string) {
|
async function fetchUsers(jwt: string) {
|
||||||
@@ -62,7 +63,7 @@ export default function AdminPage({ messages, locale }: Props) {
|
|||||||
<h3 className="font-bold">{messages.userManagement}</h3>
|
<h3 className="font-bold">{messages.userManagement}</h3>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<UsersTable users={users} messages={messages} locale={locale} />
|
<UsersTable users={users} messages={messages} />
|
||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -7,10 +7,9 @@ import Avatar from 'boring-avatars';
|
|||||||
type Props = {
|
type Props = {
|
||||||
users: UserType[];
|
users: UserType[];
|
||||||
messages: AdminMessages;
|
messages: AdminMessages;
|
||||||
locale: string;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
export default function UsersTable({ users, messages, locale }: Props) {
|
export default function UsersTable({ users, messages }: Props) {
|
||||||
const headerColumns = [
|
const headerColumns = [
|
||||||
{ name: messages.avatar, uid: 'avatar', sortable: false },
|
{ name: messages.avatar, uid: 'avatar', sortable: false },
|
||||||
{ name: messages.id, uid: 'id', sortable: true },
|
{ name: messages.id, uid: 'id', sortable: true },
|
||||||
@@ -34,7 +33,7 @@ export default function UsersTable({ users, messages, locale }: Props) {
|
|||||||
});
|
});
|
||||||
}, [sortDescriptor, users]);
|
}, [sortDescriptor, users]);
|
||||||
|
|
||||||
const renderCell = useCallback((user: UserType, columnKey: Key) => {
|
const renderCell = useCallback((user: UserType, columnKey: string) => {
|
||||||
const cellValue = user[columnKey as keyof UserType];
|
const cellValue = user[columnKey as keyof UserType];
|
||||||
|
|
||||||
switch (columnKey) {
|
switch (columnKey) {
|
||||||
@@ -54,7 +53,8 @@ export default function UsersTable({ users, messages, locale }: Props) {
|
|||||||
case 'name':
|
case 'name':
|
||||||
return cellValue;
|
return cellValue;
|
||||||
case 'role':
|
case 'role':
|
||||||
return <span>{messages[roles[cellValue].uid]}</span>;
|
return <span>{messages[roles[cellValue as number].uid]}</span>;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
return cellValue;
|
return cellValue;
|
||||||
}
|
}
|
||||||
@@ -101,7 +101,9 @@ export default function UsersTable({ users, messages, locale }: Props) {
|
|||||||
</TableHeader>
|
</TableHeader>
|
||||||
<TableBody emptyContent={messages.noUsersFound} items={sortedItems}>
|
<TableBody emptyContent={messages.noUsersFound} items={sortedItems}>
|
||||||
{(item) => (
|
{(item) => (
|
||||||
<TableRow key={item.id}>{(columnKey) => <TableCell>{renderCell(item, columnKey)}</TableCell>}</TableRow>
|
<TableRow key={item.id}>
|
||||||
|
{(columnKey) => <TableCell>{renderCell(item, columnKey as string)}</TableCell>}
|
||||||
|
</TableRow>
|
||||||
)}
|
)}
|
||||||
</TableBody>
|
</TableBody>
|
||||||
</Table>
|
</Table>
|
||||||
|
|||||||
@@ -1,7 +1,9 @@
|
|||||||
import { useTranslations } from 'next-intl';
|
import { useTranslations } from 'next-intl';
|
||||||
import AdminPage from './AdminPage';
|
import AdminPage from './AdminPage';
|
||||||
|
import { PageType } from '@/types/base';
|
||||||
|
import { LocaleCodeType } from '@/types/locale';
|
||||||
|
|
||||||
export default function Page(params: { locale: string }) {
|
export default function Page({ params }: PageType) {
|
||||||
const t = useTranslations('Admin');
|
const t = useTranslations('Admin');
|
||||||
const messages = {
|
const messages = {
|
||||||
admin: t('admin'),
|
admin: t('admin'),
|
||||||
@@ -18,7 +20,7 @@ export default function Page(params: { locale: string }) {
|
|||||||
|
|
||||||
return (
|
return (
|
||||||
<div className="w-full flex items-center justify-center">
|
<div className="w-full flex items-center justify-center">
|
||||||
<AdminPage messages={messages} locale={params.locale} />
|
<AdminPage messages={messages} locale={params.locale as LocaleCodeType} />
|
||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -5,8 +5,9 @@ import Header from './Header';
|
|||||||
import clsx from 'clsx';
|
import clsx from 'clsx';
|
||||||
import { getTranslations } from 'next-intl/server';
|
import { getTranslations } from 'next-intl/server';
|
||||||
import { useTranslations } from 'next-intl';
|
import { useTranslations } from 'next-intl';
|
||||||
|
import { LocaleCodeType } from '@/types/locale';
|
||||||
|
|
||||||
export async function generateMetadata({ params: { locale } }) {
|
export async function generateMetadata({ params: { locale } }: { params: { locale: LocaleCodeType } }) {
|
||||||
const t = await getTranslations({ locale, namespace: 'Header' });
|
const t = await getTranslations({ locale, namespace: 'Header' });
|
||||||
return {
|
return {
|
||||||
title: t('title'),
|
title: t('title'),
|
||||||
@@ -24,7 +25,7 @@ export default function RootLayout({
|
|||||||
params: { locale },
|
params: { locale },
|
||||||
}: {
|
}: {
|
||||||
children: React.ReactNode;
|
children: React.ReactNode;
|
||||||
params: { locale: string };
|
params: { locale: LocaleCodeType };
|
||||||
}) {
|
}) {
|
||||||
const t = useTranslations('Toast');
|
const t = useTranslations('Toast');
|
||||||
const toastMessages = {
|
const toastMessages = {
|
||||||
|
|||||||
@@ -4,8 +4,10 @@ import { title, subtitle } from '@/components/primitives';
|
|||||||
import PaneMainTitle from './PaneMainTitle';
|
import PaneMainTitle from './PaneMainTitle';
|
||||||
import PaneMainFeatures from './PaneMainFeatures';
|
import PaneMainFeatures from './PaneMainFeatures';
|
||||||
import DemoImage from './DemoImage';
|
import DemoImage from './DemoImage';
|
||||||
|
import { PageType } from '@/types/base';
|
||||||
|
import { LocaleCodeType } from '@/types/locale';
|
||||||
|
|
||||||
export default function Home(params: { locale: string }) {
|
export default function Home({ params }: PageType) {
|
||||||
const t = useTranslations('Index');
|
const t = useTranslations('Index');
|
||||||
|
|
||||||
const demoImages = [
|
const demoImages = [
|
||||||
@@ -35,7 +37,7 @@ export default function Home(params: { locale: string }) {
|
|||||||
<section className="mx-auto max-w-screen-xl my-12">
|
<section className="mx-auto max-w-screen-xl my-12">
|
||||||
<div className="flex flex-wrap">
|
<div className="flex flex-wrap">
|
||||||
<div className="w-full md:w-7/12 order-last md:order-first p-4">
|
<div className="w-full md:w-7/12 order-last md:order-first p-4">
|
||||||
<PaneMainTitle locale={params.locale} />
|
<PaneMainTitle locale={params.locale as LocaleCodeType} />
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div className="w-full md:w-5/12 p-4">
|
<div className="w-full md:w-5/12 p-4">
|
||||||
|
|||||||
@@ -3,17 +3,19 @@ import { useEffect, useState, useContext } from 'react';
|
|||||||
import { Button } from '@nextui-org/react';
|
import { Button } from '@nextui-org/react';
|
||||||
import { Plus } from 'lucide-react';
|
import { Plus } from 'lucide-react';
|
||||||
import { TokenContext } from '@/utils/TokenProvider';
|
import { TokenContext } from '@/utils/TokenProvider';
|
||||||
import { ProjectType, ProjectsMessages } from '@/types/project';
|
import { ProjectDialogMessages, ProjectType, ProjectsMessages } from '@/types/project';
|
||||||
import ProjectsTable from './ProjectsTable';
|
import ProjectsTable from './ProjectsTable';
|
||||||
import ProjectDialog from '@/components/ProjectDialog';
|
import ProjectDialog from '@/components/ProjectDialog';
|
||||||
import { fetchProjects, createProject } from '@/utils/projectsControl';
|
import { fetchProjects, createProject } from '@/utils/projectsControl';
|
||||||
|
import { LocaleCodeType } from '@/types/locale';
|
||||||
|
|
||||||
export type Props = {
|
export type Props = {
|
||||||
messages: ProjectsMessages;
|
messages: ProjectsMessages;
|
||||||
locale: string;
|
projectDialogMessages: ProjectDialogMessages;
|
||||||
|
locale: LocaleCodeType;
|
||||||
};
|
};
|
||||||
|
|
||||||
export default function ProjectsPage({ messages, locale }: Props) {
|
export default function ProjectsPage({ messages, projectDialogMessages, locale }: Props) {
|
||||||
const context = useContext(TokenContext);
|
const context = useContext(TokenContext);
|
||||||
const [projects, setProjects] = useState<ProjectType[]>([]);
|
const [projects, setProjects] = useState<ProjectType[]>([]);
|
||||||
|
|
||||||
@@ -73,7 +75,7 @@ export default function ProjectsPage({ messages, locale }: Props) {
|
|||||||
editingProject={editingProject}
|
editingProject={editingProject}
|
||||||
onCancel={closeDialog}
|
onCancel={closeDialog}
|
||||||
onSubmit={onSubmit}
|
onSubmit={onSubmit}
|
||||||
messages={messages}
|
projectDialogMessages={projectDialogMessages}
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
|
|||||||
@@ -1,14 +1,15 @@
|
|||||||
import { useState, useMemo, useCallback } from 'react';
|
import { useState, useMemo, useCallback, ReactNode } from 'react';
|
||||||
import { Table, TableHeader, TableColumn, TableBody, TableRow, TableCell, SortDescriptor } from '@nextui-org/react';
|
import { Table, TableHeader, TableColumn, TableBody, TableRow, TableCell, SortDescriptor } from '@nextui-org/react';
|
||||||
import { Link, NextUiLinkClasses } from '@/src/navigation';
|
import { Link, NextUiLinkClasses } from '@/src/navigation';
|
||||||
import { ProjectType, ProjectsMessages } from '@/types/project';
|
import { ProjectType, ProjectsMessages } from '@/types/project';
|
||||||
import dayjs from 'dayjs';
|
import dayjs from 'dayjs';
|
||||||
import PublicityChip from '@/components/PublicityChip';
|
import PublicityChip from '@/components/PublicityChip';
|
||||||
|
import { LocaleCodeType } from '@/types/locale';
|
||||||
|
|
||||||
type Props = {
|
type Props = {
|
||||||
projects: ProjectType[];
|
projects: ProjectType[];
|
||||||
messages: ProjectsMessages;
|
messages: ProjectsMessages;
|
||||||
locale: string;
|
locale: LocaleCodeType;
|
||||||
};
|
};
|
||||||
|
|
||||||
export default function ProjectsTable({ projects, messages, locale }: Props) {
|
export default function ProjectsTable({ projects, messages, locale }: Props) {
|
||||||
@@ -38,21 +39,23 @@ export default function ProjectsTable({ projects, messages, locale }: Props) {
|
|||||||
return text.length > maxLength ? text.slice(0, maxLength) + '...' : text;
|
return text.length > maxLength ? text.slice(0, maxLength) + '...' : text;
|
||||||
};
|
};
|
||||||
|
|
||||||
const renderCell = useCallback((project: ProjectType, columnKey: Key) => {
|
const renderCell = useCallback((project: ProjectType, columnKey: string): ReactNode => {
|
||||||
const cellValue = project[columnKey as keyof ProjectType];
|
const cellValue = project[columnKey as keyof ProjectType];
|
||||||
|
|
||||||
switch (columnKey) {
|
switch (columnKey) {
|
||||||
case 'id':
|
case 'id':
|
||||||
return <span>{cellValue}</span>;
|
return <span>{cellValue as number}</span>;
|
||||||
case 'isPublic':
|
case 'isPublic':
|
||||||
return <PublicityChip isPublic={cellValue} publicText={messages.public} privateText={messages.private} />;
|
return (
|
||||||
|
<PublicityChip isPublic={cellValue as boolean} publicText={messages.public} privateText={messages.private} />
|
||||||
|
);
|
||||||
case 'name':
|
case 'name':
|
||||||
const maxLength = 30;
|
const maxLength = 30;
|
||||||
const truncatedDetail = truncateText(project.detail, maxLength);
|
const truncatedDetail = truncateText(project.detail, maxLength);
|
||||||
return (
|
return (
|
||||||
<div>
|
<div>
|
||||||
<Link href={`/projects/${project.id}/home`} locale={locale} className={NextUiLinkClasses}>
|
<Link href={`/projects/${project.id}/home`} locale={locale} className={NextUiLinkClasses}>
|
||||||
{cellValue}
|
{cellValue as string}
|
||||||
</Link>
|
</Link>
|
||||||
<div className="text-xs text-default-500">
|
<div className="text-xs text-default-500">
|
||||||
<div>{truncatedDetail}</div>
|
<div>{truncatedDetail}</div>
|
||||||
@@ -60,9 +63,9 @@ export default function ProjectsTable({ projects, messages, locale }: Props) {
|
|||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
case 'updatedAt':
|
case 'updatedAt':
|
||||||
return <span>{dayjs(cellValue).format('YYYY/MM/DD HH:mm')}</span>;
|
return <span>{dayjs(cellValue as number).format('YYYY/MM/DD HH:mm')}</span>;
|
||||||
default:
|
default:
|
||||||
return cellValue;
|
return cellValue as string;
|
||||||
}
|
}
|
||||||
}, []);
|
}, []);
|
||||||
|
|
||||||
@@ -107,7 +110,9 @@ export default function ProjectsTable({ projects, messages, locale }: Props) {
|
|||||||
</TableHeader>
|
</TableHeader>
|
||||||
<TableBody emptyContent={messages.noProjectsFound} items={sortedItems}>
|
<TableBody emptyContent={messages.noProjectsFound} items={sortedItems}>
|
||||||
{(item) => (
|
{(item) => (
|
||||||
<TableRow key={item.id}>{(columnKey) => <TableCell>{renderCell(item, columnKey)}</TableCell>}</TableRow>
|
<TableRow key={item.id}>
|
||||||
|
{(columnKey) => <TableCell>{renderCell(item, columnKey as string)}</TableCell>}
|
||||||
|
</TableRow>
|
||||||
)}
|
)}
|
||||||
</TableBody>
|
</TableBody>
|
||||||
</Table>
|
</Table>
|
||||||
|
|||||||
@@ -33,7 +33,7 @@ export default function FoldersPane({ projectId, messages, locale }: Props) {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
try {
|
try {
|
||||||
const folders: FolderType[] = await fetchFolders(context.token.access_token, projectId);
|
const folders: FolderType[] = await fetchFolders(context.token.access_token, Number(projectId));
|
||||||
setFolders(folders);
|
setFolders(folders);
|
||||||
|
|
||||||
// no folder on project
|
// no folder on project
|
||||||
|
|||||||
@@ -7,13 +7,14 @@ import { CaseType, CasesMessages } from '@/types/case';
|
|||||||
import DeleteConfirmDialog from '@/components/DeleteConfirmDialog';
|
import DeleteConfirmDialog from '@/components/DeleteConfirmDialog';
|
||||||
import CaseDialog from './CaseDialog';
|
import CaseDialog from './CaseDialog';
|
||||||
import { PriorityMessages } from '@/types/priority';
|
import { PriorityMessages } from '@/types/priority';
|
||||||
|
import { LocaleCodeType } from '@/types/locale';
|
||||||
|
|
||||||
type Props = {
|
type Props = {
|
||||||
projectId: string;
|
projectId: string;
|
||||||
folderId: string;
|
folderId: string;
|
||||||
messages: CasesMessages;
|
messages: CasesMessages;
|
||||||
priorityMessages: PriorityMessages;
|
priorityMessages: PriorityMessages;
|
||||||
locale: string;
|
locale: LocaleCodeType;
|
||||||
};
|
};
|
||||||
|
|
||||||
export default function CasesPane({ projectId, folderId, messages, priorityMessages, locale }: Props) {
|
export default function CasesPane({ projectId, folderId, messages, priorityMessages, locale }: Props) {
|
||||||
@@ -67,7 +68,7 @@ export default function CasesPane({ projectId, folderId, messages, priorityMessa
|
|||||||
|
|
||||||
const onConfirm = async () => {
|
const onConfirm = async () => {
|
||||||
if (deleteCaseIds.length > 0) {
|
if (deleteCaseIds.length > 0) {
|
||||||
await deleteCases(context.token.access_token, deleteCaseIds, projectId);
|
await deleteCases(context.token.access_token, deleteCaseIds, Number(projectId));
|
||||||
setCases(cases.filter((entry) => !deleteCaseIds.includes(entry.id)));
|
setCases(cases.filter((entry) => !deleteCaseIds.includes(entry.id)));
|
||||||
closeDeleteConfirmDialog();
|
closeDeleteConfirmDialog();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
import { useState, useMemo, useCallback } from 'react';
|
import { useState, useMemo, useCallback, ReactNode } from 'react';
|
||||||
import {
|
import {
|
||||||
Table,
|
Table,
|
||||||
TableHeader,
|
TableHeader,
|
||||||
@@ -15,10 +15,11 @@ import {
|
|||||||
SortDescriptor,
|
SortDescriptor,
|
||||||
} from '@nextui-org/react';
|
} from '@nextui-org/react';
|
||||||
import { Link, NextUiLinkClasses } from '@/src/navigation';
|
import { Link, NextUiLinkClasses } from '@/src/navigation';
|
||||||
import { Plus, MoreVertical, Trash, Circle } from 'lucide-react';
|
import { Plus, MoreVertical, Trash } from 'lucide-react';
|
||||||
import { CaseType, CasesMessages } from '@/types/case';
|
import { CaseType, CasesMessages } from '@/types/case';
|
||||||
import { PriorityMessages } from '@/types/priority';
|
import { PriorityMessages } from '@/types/priority';
|
||||||
import TestCasePriority from '@/components/TestCasePriority';
|
import TestCasePriority from '@/components/TestCasePriority';
|
||||||
|
import { LocaleCodeType } from '@/types/locale';
|
||||||
|
|
||||||
type Props = {
|
type Props = {
|
||||||
projectId: string;
|
projectId: string;
|
||||||
@@ -29,7 +30,7 @@ type Props = {
|
|||||||
onDeleteCases: (caseIds: number[]) => void;
|
onDeleteCases: (caseIds: number[]) => void;
|
||||||
messages: CasesMessages;
|
messages: CasesMessages;
|
||||||
priorityMessages: PriorityMessages;
|
priorityMessages: PriorityMessages;
|
||||||
locale: string;
|
locale: LocaleCodeType;
|
||||||
};
|
};
|
||||||
|
|
||||||
export default function TestCaseTable({
|
export default function TestCaseTable({
|
||||||
@@ -73,12 +74,12 @@ export default function TestCaseTable({
|
|||||||
onDeleteCase(deleteCaseId);
|
onDeleteCase(deleteCaseId);
|
||||||
};
|
};
|
||||||
|
|
||||||
const renderCell = useCallback((testCase: CaseType, columnKey: Key) => {
|
const renderCell = useCallback((testCase: CaseType, columnKey: string): ReactNode => {
|
||||||
const cellValue = testCase[columnKey as keyof CaseType];
|
const cellValue = testCase[columnKey as keyof CaseType];
|
||||||
|
|
||||||
switch (columnKey) {
|
switch (columnKey) {
|
||||||
case 'id':
|
case 'id':
|
||||||
return <span>{cellValue}</span>;
|
return <span>{cellValue as number}</span>;
|
||||||
case 'title':
|
case 'title':
|
||||||
return (
|
return (
|
||||||
<Button size="sm" variant="light" className="data-[hover=true]:bg-transparent">
|
<Button size="sm" variant="light" className="data-[hover=true]:bg-transparent">
|
||||||
@@ -87,12 +88,12 @@ export default function TestCaseTable({
|
|||||||
locale={locale}
|
locale={locale}
|
||||||
className={NextUiLinkClasses}
|
className={NextUiLinkClasses}
|
||||||
>
|
>
|
||||||
{cellValue}
|
{cellValue as string}
|
||||||
</Link>
|
</Link>
|
||||||
</Button>
|
</Button>
|
||||||
);
|
);
|
||||||
case 'priority':
|
case 'priority':
|
||||||
return <TestCasePriority priorityValue={cellValue} priorityMessages={priorityMessages} />;
|
return <TestCasePriority priorityValue={cellValue as number} priorityMessages={priorityMessages} />;
|
||||||
case 'actions':
|
case 'actions':
|
||||||
return (
|
return (
|
||||||
<Dropdown>
|
<Dropdown>
|
||||||
@@ -113,7 +114,7 @@ export default function TestCaseTable({
|
|||||||
</Dropdown>
|
</Dropdown>
|
||||||
);
|
);
|
||||||
default:
|
default:
|
||||||
return cellValue;
|
return cellValue as string;
|
||||||
}
|
}
|
||||||
}, []);
|
}, []);
|
||||||
|
|
||||||
@@ -152,7 +153,7 @@ export default function TestCaseTable({
|
|||||||
<div className="border-b-1 dark:border-neutral-700 w-full p-3 flex items-center justify-between">
|
<div className="border-b-1 dark:border-neutral-700 w-full p-3 flex items-center justify-between">
|
||||||
<h3 className="font-bold">{messages.testCaseList}</h3>
|
<h3 className="font-bold">{messages.testCaseList}</h3>
|
||||||
<div>
|
<div>
|
||||||
{(selectedKeys.size > 0 || selectedKeys === 'all') && (
|
{((selectedKeys !== 'all' && selectedKeys.size > 0) || selectedKeys === 'all') && (
|
||||||
<Button
|
<Button
|
||||||
startContent={<Trash size={16} />}
|
startContent={<Trash size={16} />}
|
||||||
size="sm"
|
size="sm"
|
||||||
@@ -200,7 +201,9 @@ export default function TestCaseTable({
|
|||||||
</TableHeader>
|
</TableHeader>
|
||||||
<TableBody emptyContent={messages.noCasesFound} items={sortedItems}>
|
<TableBody emptyContent={messages.noCasesFound} items={sortedItems}>
|
||||||
{(item) => (
|
{(item) => (
|
||||||
<TableRow key={item.id}>{(columnKey) => <TableCell>{renderCell(item, columnKey)}</TableCell>}</TableRow>
|
<TableRow key={item.id}>
|
||||||
|
{(columnKey) => <TableCell>{renderCell(item, columnKey as string)}</TableCell>}
|
||||||
|
</TableRow>
|
||||||
)}
|
)}
|
||||||
</TableBody>
|
</TableBody>
|
||||||
</Table>
|
</Table>
|
||||||
|
|||||||
@@ -9,7 +9,7 @@ type Props = {
|
|||||||
attachments: AttachmentType[];
|
attachments: AttachmentType[];
|
||||||
onAttachmentDownload: (attachmentId: number, downloadFileName: string) => void;
|
onAttachmentDownload: (attachmentId: number, downloadFileName: string) => void;
|
||||||
onAttachmentDelete: (attachmentId: number) => void;
|
onAttachmentDelete: (attachmentId: number) => void;
|
||||||
onFilesDrop: (event: DragEvent) => void;
|
onFilesDrop: (event: DragEvent<HTMLElement>) => void;
|
||||||
onFilesInput: (event: ChangeEvent) => void;
|
onFilesInput: (event: ChangeEvent) => void;
|
||||||
messages: CaseMessages;
|
messages: CaseMessages;
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
'use client';
|
'use client';
|
||||||
import { useState, useEffect, useContext } from 'react';
|
import { useState, useEffect, useContext, ChangeEvent, DragEvent } from 'react';
|
||||||
import { Input, Textarea, Select, SelectItem, Button, Divider, Tooltip } from '@nextui-org/react';
|
import { Input, Textarea, Select, SelectItem, Button, Divider, Tooltip } from '@nextui-org/react';
|
||||||
import { useRouter } from '@/src/navigation';
|
import { useRouter } from '@/src/navigation';
|
||||||
import { Save, Plus, ArrowLeft, Circle } from 'lucide-react';
|
import { Save, Plus, ArrowLeft, Circle } from 'lucide-react';
|
||||||
@@ -134,13 +134,22 @@ export default function CaseEditor({
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
const handleDrop = async (event: DragEvent) => {
|
const handleDrop = (event: DragEvent<HTMLElement>) => {
|
||||||
event.preventDefault();
|
event.preventDefault();
|
||||||
handleFetchCreateAttachments(Number(caseId), event.dataTransfer.files);
|
if (event.dataTransfer) {
|
||||||
|
const filesArray = Array.from(event.dataTransfer.files);
|
||||||
|
handleFetchCreateAttachments(Number(caseId), filesArray);
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
const handleInput = (event: DragEvent) => {
|
const handleInput = (event: ChangeEvent) => {
|
||||||
handleFetchCreateAttachments(Number(caseId), event.target.files);
|
if (event.target) {
|
||||||
|
const input = event.target as HTMLInputElement;
|
||||||
|
if (input.files) {
|
||||||
|
const filesArray = Array.from(input.files);
|
||||||
|
handleFetchCreateAttachments(Number(caseId), filesArray);
|
||||||
|
}
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
const handleFetchCreateAttachments = async (caseId: number, files: File[]) => {
|
const handleFetchCreateAttachments = async (caseId: number, files: File[]) => {
|
||||||
@@ -149,28 +158,36 @@ export default function CaseEditor({
|
|||||||
if (newAttachments) {
|
if (newAttachments) {
|
||||||
const newAttachmentsWithJoinTable = [];
|
const newAttachmentsWithJoinTable = [];
|
||||||
newAttachments.forEach((attachment: AttachmentType) => {
|
newAttachments.forEach((attachment: AttachmentType) => {
|
||||||
attachment.caseAttachments = { AttachmentId: attachment.id };
|
attachment.caseAttachments = {
|
||||||
|
createdAt: new Date(),
|
||||||
|
updatedAt: new Date(),
|
||||||
|
caseId: 0,
|
||||||
|
attachmentId: attachment.id,
|
||||||
|
};
|
||||||
newAttachmentsWithJoinTable.push(attachment);
|
newAttachmentsWithJoinTable.push(attachment);
|
||||||
});
|
});
|
||||||
const updatedAttachments = testCase.Attachments;
|
const updatedAttachments = testCase.Attachments;
|
||||||
updatedAttachments.push(...newAttachments);
|
if (updatedAttachments) {
|
||||||
|
updatedAttachments.push(...newAttachments);
|
||||||
|
|
||||||
setTestCase({
|
setTestCase({
|
||||||
...testCase,
|
...testCase,
|
||||||
Attachments: updatedAttachments,
|
Attachments: updatedAttachments,
|
||||||
});
|
});
|
||||||
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
const onAttachmentDelete = async (attachmentId: number) => {
|
const onAttachmentDelete = async (attachmentId: number) => {
|
||||||
await fetchDeleteAttachment(attachmentId);
|
await fetchDeleteAttachment(attachmentId);
|
||||||
|
if (testCase.Attachments) {
|
||||||
|
const filteredAttachments = testCase.Attachments.filter((attachment) => attachment.id !== attachmentId);
|
||||||
|
|
||||||
const filteredAttachments = testCase.Attachments.filter((attachment) => attachment.id !== attachmentId);
|
setTestCase({
|
||||||
|
...testCase,
|
||||||
setTestCase({
|
Attachments: filteredAttachments,
|
||||||
...testCase,
|
});
|
||||||
Attachments: filteredAttachments,
|
}
|
||||||
});
|
|
||||||
};
|
};
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
@@ -261,10 +278,12 @@ export default function CaseEditor({
|
|||||||
size="sm"
|
size="sm"
|
||||||
variant="bordered"
|
variant="bordered"
|
||||||
selectedKeys={[priorities[testCase.priority].uid]}
|
selectedKeys={[priorities[testCase.priority].uid]}
|
||||||
onSelectionChange={(e) => {
|
onSelectionChange={(newSelection) => {
|
||||||
const selectedUid = e.anchorKey;
|
if (newSelection !== 'all' && newSelection.size !== 0) {
|
||||||
const index = priorities.findIndex((priority) => priority.uid === selectedUid);
|
const selectedUid = Array.from(newSelection)[0];
|
||||||
setTestCase({ ...testCase, priority: index });
|
const index = priorities.findIndex((priority) => priority.uid === selectedUid);
|
||||||
|
setTestCase({ ...testCase, priority: index });
|
||||||
|
}
|
||||||
}}
|
}}
|
||||||
startContent={
|
startContent={
|
||||||
<Circle size={8} color={priorities[testCase.priority].color} fill={priorities[testCase.priority].color} />
|
<Circle size={8} color={priorities[testCase.priority].color} fill={priorities[testCase.priority].color} />
|
||||||
@@ -285,10 +304,12 @@ export default function CaseEditor({
|
|||||||
size="sm"
|
size="sm"
|
||||||
variant="bordered"
|
variant="bordered"
|
||||||
selectedKeys={[testTypes[testCase.type].uid]}
|
selectedKeys={[testTypes[testCase.type].uid]}
|
||||||
onSelectionChange={(e) => {
|
onSelectionChange={(newSelection) => {
|
||||||
const selectedUid = e.anchorKey;
|
if (newSelection !== 'all' && newSelection.size !== 0) {
|
||||||
const index = testTypes.findIndex((type) => type.uid === selectedUid);
|
const selectedUid = Array.from(newSelection)[0];
|
||||||
setTestCase({ ...testCase, type: index });
|
const index = testTypes.findIndex((type) => type.uid === selectedUid);
|
||||||
|
setTestCase({ ...testCase, type: index });
|
||||||
|
}
|
||||||
}}
|
}}
|
||||||
label={messages.type}
|
label={messages.type}
|
||||||
className="mt-3 max-w-xs"
|
className="mt-3 max-w-xs"
|
||||||
@@ -306,10 +327,12 @@ export default function CaseEditor({
|
|||||||
size="sm"
|
size="sm"
|
||||||
variant="bordered"
|
variant="bordered"
|
||||||
selectedKeys={[templates[testCase.template].uid]}
|
selectedKeys={[templates[testCase.template].uid]}
|
||||||
onSelectionChange={(e) => {
|
onSelectionChange={(newSelection) => {
|
||||||
const selectedUid = e.anchorKey;
|
if (newSelection !== 'all' && newSelection.size !== 0) {
|
||||||
const index = templates.findIndex((template) => template.uid === selectedUid);
|
const selectedUid = Array.from(newSelection)[0];
|
||||||
setTestCase({ ...testCase, template: index });
|
const index = templates.findIndex((template) => template.uid === selectedUid);
|
||||||
|
setTestCase({ ...testCase, template: index });
|
||||||
|
}
|
||||||
}}
|
}}
|
||||||
label={messages.template}
|
label={messages.template}
|
||||||
className="mt-3 max-w-xs"
|
className="mt-3 max-w-xs"
|
||||||
@@ -365,41 +388,47 @@ export default function CaseEditor({
|
|||||||
{messages.newStep}
|
{messages.newStep}
|
||||||
</Button>
|
</Button>
|
||||||
</div>
|
</div>
|
||||||
<CaseStepsEditor
|
{testCase.Steps && (
|
||||||
isDisabled={!context.isProjectDeveloper(Number(projectId))}
|
<CaseStepsEditor
|
||||||
steps={testCase.Steps}
|
isDisabled={!context.isProjectDeveloper(Number(projectId))}
|
||||||
onStepUpdate={(stepId, changeStep) => {
|
steps={testCase.Steps}
|
||||||
setTestCase({
|
onStepUpdate={(stepId, changeStep) => {
|
||||||
...testCase,
|
if (testCase.Steps) {
|
||||||
Steps: testCase.Steps.map((step) => {
|
setTestCase({
|
||||||
if (step.id === stepId) {
|
...testCase,
|
||||||
return changeStep;
|
Steps: testCase.Steps.map((step) => {
|
||||||
} else {
|
if (step.id === stepId) {
|
||||||
return step;
|
return changeStep;
|
||||||
}
|
} else {
|
||||||
}),
|
return step;
|
||||||
});
|
}
|
||||||
}}
|
}),
|
||||||
onStepPlus={onPlusClick}
|
});
|
||||||
onStepDelete={onDeleteClick}
|
}
|
||||||
messages={messages}
|
}}
|
||||||
/>
|
onStepPlus={onPlusClick}
|
||||||
|
onStepDelete={onDeleteClick}
|
||||||
|
messages={messages}
|
||||||
|
/>
|
||||||
|
)}
|
||||||
</div>
|
</div>
|
||||||
)}
|
)}
|
||||||
|
|
||||||
<Divider className="my-6" />
|
<Divider className="my-6" />
|
||||||
<h6 className="font-bold">{messages.attachments}</h6>
|
<h6 className="font-bold">{messages.attachments}</h6>
|
||||||
<CaseAttachmentsEditor
|
{testCase.Attachments && (
|
||||||
isDisabled={!context.isProjectDeveloper(Number(projectId))}
|
<CaseAttachmentsEditor
|
||||||
attachments={testCase.Attachments}
|
isDisabled={!context.isProjectDeveloper(Number(projectId))}
|
||||||
onAttachmentDownload={(attachmentId: number, downloadFileName: string) =>
|
attachments={testCase.Attachments}
|
||||||
fetchDownloadAttachment(attachmentId, downloadFileName)
|
onAttachmentDownload={(attachmentId: number, downloadFileName: string) =>
|
||||||
}
|
fetchDownloadAttachment(attachmentId, downloadFileName)
|
||||||
onAttachmentDelete={onAttachmentDelete}
|
}
|
||||||
onFilesDrop={handleDrop}
|
onAttachmentDelete={onAttachmentDelete}
|
||||||
onFilesInput={handleInput}
|
onFilesDrop={handleDrop}
|
||||||
messages={messages}
|
onFilesInput={handleInput}
|
||||||
/>
|
messages={messages}
|
||||||
|
/>
|
||||||
|
)}
|
||||||
</div>
|
</div>
|
||||||
</>
|
</>
|
||||||
);
|
);
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
import { PriorityMessages } from '@/types/priority';
|
import { PriorityMessages } from '@/types/priority';
|
||||||
import CasesPane from './CasesPane';
|
import CasesPane from './CasesPane';
|
||||||
import { useTranslations } from 'next-intl';
|
import { useTranslations } from 'next-intl';
|
||||||
|
import { LocaleCodeType } from '@/types/locale';
|
||||||
|
|
||||||
export default function Page({ params }: { params: { projectId: string; folderId: string; locale: string } }) {
|
export default function Page({ params }: { params: { projectId: string; folderId: string; locale: string } }) {
|
||||||
const t = useTranslations('Cases');
|
const t = useTranslations('Cases');
|
||||||
@@ -36,7 +37,7 @@ export default function Page({ params }: { params: { projectId: string; folderId
|
|||||||
<CasesPane
|
<CasesPane
|
||||||
projectId={params.projectId}
|
projectId={params.projectId}
|
||||||
folderId={params.folderId}
|
folderId={params.folderId}
|
||||||
locale={params.locale}
|
locale={params.locale as LocaleCodeType}
|
||||||
messages={messages}
|
messages={messages}
|
||||||
priorityMessages={priorityMessages}
|
priorityMessages={priorityMessages}
|
||||||
/>
|
/>
|
||||||
|
|||||||
@@ -3,7 +3,6 @@ import { useState, useEffect, useContext } from 'react';
|
|||||||
import { title, subtitle } from '@/components/primitives';
|
import { title, subtitle } from '@/components/primitives';
|
||||||
import { Card, CardBody, Chip, Divider } from '@nextui-org/react';
|
import { Card, CardBody, Chip, Divider } from '@nextui-org/react';
|
||||||
import { Folder, Clipboard, FlaskConical } from 'lucide-react';
|
import { Folder, Clipboard, FlaskConical } from 'lucide-react';
|
||||||
import { CaseTypeCountType, CasePriorityCountType } from '@/types/case';
|
|
||||||
import { ProgressSeriesType } from '@/types/run';
|
import { ProgressSeriesType } from '@/types/run';
|
||||||
import { HomeMessages } from './page';
|
import { HomeMessages } from './page';
|
||||||
import { TokenContext } from '@/utils/TokenProvider';
|
import { TokenContext } from '@/utils/TokenProvider';
|
||||||
@@ -16,6 +15,8 @@ import TestProgressBarChart from './TestProgressColumnChart';
|
|||||||
import { TestRunCaseStatusMessages } from '@/types/status';
|
import { TestRunCaseStatusMessages } from '@/types/status';
|
||||||
import { TestTypeMessages } from '@/types/testType';
|
import { TestTypeMessages } from '@/types/testType';
|
||||||
import { PriorityMessages } from '@/types/priority';
|
import { PriorityMessages } from '@/types/priority';
|
||||||
|
import { ProjectType } from '@/types/project';
|
||||||
|
import { CasePriorityCountType, CaseTypeCountType } from '@/types/chart';
|
||||||
|
|
||||||
const apiServer = Config.apiServer;
|
const apiServer = Config.apiServer;
|
||||||
|
|
||||||
@@ -59,19 +60,24 @@ export function ProjectHome({
|
|||||||
}: Props) {
|
}: Props) {
|
||||||
const context = useContext(TokenContext);
|
const context = useContext(TokenContext);
|
||||||
const { theme, setTheme } = useTheme();
|
const { theme, setTheme } = useTheme();
|
||||||
const [project, setProject] = useState({
|
const [project, setProject] = useState<ProjectType>({
|
||||||
|
id: 0,
|
||||||
name: '',
|
name: '',
|
||||||
detail: '',
|
detail: '',
|
||||||
Folders: [{ Cases: [] }],
|
isPublic: false,
|
||||||
Runs: [{ RunCases: [] }],
|
userId: 0,
|
||||||
|
createdAt: '',
|
||||||
|
updatedAt: '',
|
||||||
|
Folders: [],
|
||||||
|
Runs: [],
|
||||||
});
|
});
|
||||||
const [folderNum, setFolderNum] = useState(0);
|
const [folderNum, setFolderNum] = useState(0);
|
||||||
const [caseNum, setCaseNum] = useState(0);
|
const [caseNum, setCaseNum] = useState(0);
|
||||||
const [runNum, setRunNum] = useState(0);
|
const [runNum, setRunNum] = useState(0);
|
||||||
const [typesCounts, setTypesCounts] = useState<CaseTypeCountType[]>();
|
const [typesCounts, setTypesCounts] = useState<CaseTypeCountType[]>([]);
|
||||||
const [priorityCounts, setPriorityCounts] = useState<CasePriorityCountType[]>();
|
const [priorityCounts, setPriorityCounts] = useState<CasePriorityCountType[]>([]);
|
||||||
const [progressCategories, setProgressCategories] = useState<string[]>();
|
const [progressCategories, setProgressCategories] = useState<string[]>([]);
|
||||||
const [progressSeries, setProgressSeries] = useState<ProgressSeriesType[]>();
|
const [progressSeries, setProgressSeries] = useState<ProgressSeriesType[]>([]);
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
async function fetchDataEffect() {
|
async function fetchDataEffect() {
|
||||||
@@ -92,6 +98,9 @@ export function ProjectHome({
|
|||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
async function aggregate() {
|
async function aggregate() {
|
||||||
|
if (!project) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
const { folderNum, runNum, caseNum } = aggregateBasicInfo(project);
|
const { folderNum, runNum, caseNum } = aggregateBasicInfo(project);
|
||||||
setFolderNum(folderNum);
|
setFolderNum(folderNum);
|
||||||
setRunNum(runNum);
|
setRunNum(runNum);
|
||||||
|
|||||||
@@ -2,18 +2,19 @@ import React from 'react';
|
|||||||
import { useState, useEffect } from 'react';
|
import { useState, useEffect } from 'react';
|
||||||
import dynamic from 'next/dynamic';
|
import dynamic from 'next/dynamic';
|
||||||
import { priorities } from '@/config/selection';
|
import { priorities } from '@/config/selection';
|
||||||
import { CasePriorityCountType } from '@/types/case';
|
import { CasePriorityCountType } from '@/types/chart';
|
||||||
import { PriorityMessages } from '@/types/priority';
|
import { PriorityMessages } from '@/types/priority';
|
||||||
|
import { ChartDataType } from '@/types/chart';
|
||||||
const Chart = dynamic(() => import('react-apexcharts'), { ssr: false });
|
const Chart = dynamic(() => import('react-apexcharts'), { ssr: false });
|
||||||
|
|
||||||
type Props = {
|
type Props = {
|
||||||
priorityCounts: CasePriorityCountType[];
|
priorityCounts: CasePriorityCountType[];
|
||||||
priorityMessages: PriorityMessages;
|
priorityMessages: PriorityMessages;
|
||||||
theme: string;
|
theme: string | undefined;
|
||||||
};
|
};
|
||||||
|
|
||||||
export default function TestPriorityDonutChart({ priorityCounts, priorityMessages, theme }: Props) {
|
export default function TestPriorityDonutChart({ priorityCounts, priorityMessages, theme }: Props) {
|
||||||
const [chartData, setChartData] = useState({
|
const [chartData, setChartData] = useState<ChartDataType>({
|
||||||
series: [],
|
series: [],
|
||||||
options: {
|
options: {
|
||||||
labels: [],
|
labels: [],
|
||||||
|
|||||||
@@ -3,16 +3,17 @@ import { useState, useEffect } from 'react';
|
|||||||
import dynamic from 'next/dynamic';
|
import dynamic from 'next/dynamic';
|
||||||
import { ProgressSeriesType } from '@/types/run';
|
import { ProgressSeriesType } from '@/types/run';
|
||||||
import { testRunCaseStatus } from '@/config/selection';
|
import { testRunCaseStatus } from '@/config/selection';
|
||||||
|
import { ChartDataType } from '@/types/chart';
|
||||||
const Chart = dynamic(() => import('react-apexcharts'), { ssr: false });
|
const Chart = dynamic(() => import('react-apexcharts'), { ssr: false });
|
||||||
|
|
||||||
type Props = {
|
type Props = {
|
||||||
progressSeries: ProgressSeriesType[];
|
progressSeries: ProgressSeriesType[];
|
||||||
progressCategories: string[];
|
progressCategories: string[];
|
||||||
theme: string;
|
theme: string | undefined;
|
||||||
};
|
};
|
||||||
|
|
||||||
export default function TestProgressBarChart({ progressSeries, progressCategories, theme }: Props) {
|
export default function TestProgressBarChart({ progressSeries, progressCategories, theme }: Props) {
|
||||||
const [chartData, setChartData] = useState({
|
const [chartData, setChartData] = useState<ChartDataType>({
|
||||||
series: [],
|
series: [],
|
||||||
options: {
|
options: {
|
||||||
labels: [],
|
labels: [],
|
||||||
|
|||||||
@@ -2,18 +2,18 @@ import React from 'react';
|
|||||||
import { useState, useEffect } from 'react';
|
import { useState, useEffect } from 'react';
|
||||||
import dynamic from 'next/dynamic';
|
import dynamic from 'next/dynamic';
|
||||||
import { testTypes } from '@/config/selection';
|
import { testTypes } from '@/config/selection';
|
||||||
import { CaseTypeCountType } from '@/types/case';
|
|
||||||
import { TestTypeMessages } from '@/types/testType';
|
import { TestTypeMessages } from '@/types/testType';
|
||||||
|
import { CaseTypeCountType, ChartDataType } from '@/types/chart';
|
||||||
const Chart = dynamic(() => import('react-apexcharts'), { ssr: false });
|
const Chart = dynamic(() => import('react-apexcharts'), { ssr: false });
|
||||||
|
|
||||||
type Props = {
|
type Props = {
|
||||||
typesCounts: CaseTypeCountType[];
|
typesCounts: CaseTypeCountType[];
|
||||||
testTypeMessages: TestTypeMessages;
|
testTypeMessages: TestTypeMessages;
|
||||||
theme: string;
|
theme: string | undefined;
|
||||||
};
|
};
|
||||||
|
|
||||||
export default function TestTypesDonutChart({ typesCounts, testTypeMessages, theme }: Props) {
|
export default function TestTypesDonutChart({ typesCounts, testTypeMessages, theme }: Props) {
|
||||||
const [chartData, setChartData] = useState({
|
const [chartData, setChartData] = useState<ChartDataType>({
|
||||||
series: [],
|
series: [],
|
||||||
options: {
|
options: {
|
||||||
labels: [],
|
labels: [],
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
import { ProjectType } from '@/types/project';
|
import { ProjectType } from '@/types/project';
|
||||||
import { testTypes, priorities, testRunCaseStatus } from '@/config/selection';
|
import { testTypes, priorities, testRunCaseStatus } from '@/config/selection';
|
||||||
import { TestRunCaseStatusMessages } from '@/types/status';
|
import { TestRunCaseStatusMessages } from '@/types/status';
|
||||||
|
import { CasePriorityCountType, CaseTypeCountType } from '@/types/chart';
|
||||||
|
|
||||||
// aggregate folder, case, run mum
|
// aggregate folder, case, run mum
|
||||||
function aggregateBasicInfo(project: ProjectType) {
|
function aggregateBasicInfo(project: ProjectType) {
|
||||||
@@ -15,48 +16,58 @@ function aggregateBasicInfo(project: ProjectType) {
|
|||||||
return { folderNum, runNum, caseNum };
|
return { folderNum, runNum, caseNum };
|
||||||
}
|
}
|
||||||
|
|
||||||
// aggregate test types of each case
|
function aggregateTestType(project: ProjectType): CaseTypeCountType[] {
|
||||||
function aggregateTestType(project: ProjectType) {
|
// count how many test cases are for each type
|
||||||
const typesCounts = {};
|
const typesCounts: number[] = testTypes.map((entry) => {
|
||||||
|
return 0;
|
||||||
|
});
|
||||||
project.Folders.forEach((folder) => {
|
project.Folders.forEach((folder) => {
|
||||||
folder.Cases.forEach((testcase) => {
|
folder.Cases.forEach((testcase) => {
|
||||||
const type = testcase.type;
|
const type = testcase.type;
|
||||||
typesCounts[type] = (typesCounts[type] || 0) + 1;
|
typesCounts[type]++;
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
const result = [];
|
const result: CaseTypeCountType[] = [];
|
||||||
for (let type = 0; type <= testTypes.length; type++) {
|
for (let type = 0; type <= testTypes.length; type++) {
|
||||||
result.push({ type: type, count: typesCounts[type] || 0 });
|
result.push({ type: type, count: typesCounts[type] });
|
||||||
}
|
}
|
||||||
|
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
function aggregateTestPriority(project: ProjectType) {
|
function aggregateTestPriority(project: ProjectType) {
|
||||||
const priorityCounts = {};
|
// count how many test cases are for each priority
|
||||||
|
const priorityCounts: number[] = priorities.map((entry) => {
|
||||||
|
return 0;
|
||||||
|
});
|
||||||
project.Folders.forEach((folder) => {
|
project.Folders.forEach((folder) => {
|
||||||
folder.Cases.forEach((testcase) => {
|
folder.Cases.forEach((testcase) => {
|
||||||
const priority = testcase.priority;
|
const priority = testcase.priority;
|
||||||
priorityCounts[priority] = (priorityCounts[priority] || 0) + 1;
|
priorityCounts[priority]++;
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
const result = [];
|
const result: CasePriorityCountType[] = [];
|
||||||
for (let priority = 0; priority <= priorities.length; priority++) {
|
for (let priority = 0; priority <= priorities.length; priority++) {
|
||||||
result.push({ priority: priority, count: priorityCounts[priority] || 0 });
|
result.push({ priority: priority, count: priorityCounts[priority] });
|
||||||
}
|
}
|
||||||
|
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
function aggregateProgress(project: ProjectType, testRunCaseStatusMessages: TestRunCaseStatusMessages) {
|
function aggregateProgress(project: ProjectType, testRunCaseStatusMessages: TestRunCaseStatusMessages) {
|
||||||
let series = testRunCaseStatus.map((status) => {
|
type ChartSeries = { name: string; data: number[] };
|
||||||
|
let series: ChartSeries[] = testRunCaseStatus.map((status) => {
|
||||||
return { name: testRunCaseStatusMessages[status.uid], data: [] };
|
return { name: testRunCaseStatusMessages[status.uid], data: [] };
|
||||||
});
|
});
|
||||||
let categories = [];
|
let categories: string[] = [];
|
||||||
|
|
||||||
project.Runs.forEach((run) => {
|
project.Runs.forEach((run) => {
|
||||||
|
if (!run.RunCases) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
run.RunCases.forEach((runCase) => {
|
run.RunCases.forEach((runCase) => {
|
||||||
const createdAtDate = new Date(runCase.createdAt);
|
const createdAtDate = new Date(runCase.createdAt);
|
||||||
const dateString = createdAtDate.toISOString().slice(0, 10);
|
const dateString = createdAtDate.toISOString().slice(0, 10);
|
||||||
@@ -72,6 +83,10 @@ function aggregateProgress(project: ProjectType, testRunCaseStatusMessages: Test
|
|||||||
});
|
});
|
||||||
|
|
||||||
project.Runs.forEach((run) => {
|
project.Runs.forEach((run) => {
|
||||||
|
if (!run.RunCases) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
run.RunCases.forEach((runCase) => {
|
run.RunCases.forEach((runCase) => {
|
||||||
const createdAtDate = new Date(runCase.createdAt);
|
const createdAtDate = new Date(runCase.createdAt);
|
||||||
const dateString = createdAtDate.toISOString().slice(0, 10);
|
const dateString = createdAtDate.toISOString().slice(0, 10);
|
||||||
|
|||||||
@@ -1,3 +1,4 @@
|
|||||||
|
import { ProjectMessages } from '@/types/project';
|
||||||
import Sidebar from './Sidebar';
|
import Sidebar from './Sidebar';
|
||||||
import { useTranslations } from 'next-intl';
|
import { useTranslations } from 'next-intl';
|
||||||
|
|
||||||
@@ -9,7 +10,7 @@ export default function SidebarLayout({
|
|||||||
params: { locale: string };
|
params: { locale: string };
|
||||||
}) {
|
}) {
|
||||||
const t = useTranslations('Project');
|
const t = useTranslations('Project');
|
||||||
const messages = {
|
const messages: ProjectMessages = {
|
||||||
home: t('home'),
|
home: t('home'),
|
||||||
testCases: t('test_cases'),
|
testCases: t('test_cases'),
|
||||||
testRuns: t('test_runs'),
|
testRuns: t('test_runs'),
|
||||||
|
|||||||
@@ -2,18 +2,18 @@
|
|||||||
import React from 'react';
|
import React from 'react';
|
||||||
import { useState, useEffect, useContext } from 'react';
|
import { useState, useEffect, useContext } from 'react';
|
||||||
import { Button, Input, Modal, ModalContent, ModalHeader, ModalBody, ModalFooter } from '@nextui-org/react';
|
import { Button, Input, Modal, ModalContent, ModalHeader, ModalBody, ModalFooter } from '@nextui-org/react';
|
||||||
import { SettingsMessages } from '@/types/settings';
|
|
||||||
import { TokenContext } from '@/utils/TokenProvider';
|
import { TokenContext } from '@/utils/TokenProvider';
|
||||||
import { UserType } from '@/types/user';
|
import { UserType } from '@/types/user';
|
||||||
import { searchUsers } from '@/utils/usersControl';
|
import { searchUsers } from '@/utils/usersControl';
|
||||||
import CandidatesTable from './CandidatesTable';
|
import CandidatesTable from './CandidatesTable';
|
||||||
|
import { MembersMessages } from '@/types/member';
|
||||||
|
|
||||||
type Props = {
|
type Props = {
|
||||||
isOpen: boolean;
|
isOpen: boolean;
|
||||||
projectId: string;
|
projectId: string;
|
||||||
onCancel: () => void;
|
onCancel: () => void;
|
||||||
onAddMember: (memberAdded: UserType) => void;
|
onAddMember: (memberAdded: UserType) => void;
|
||||||
messages: SettingsMessages;
|
messages: MembersMessages;
|
||||||
};
|
};
|
||||||
|
|
||||||
export default function AddMemberDialog({ isOpen, projectId, onCancel, onAddMember, messages }: Props) {
|
export default function AddMemberDialog({ isOpen, projectId, onCancel, onAddMember, messages }: Props) {
|
||||||
|
|||||||
@@ -1,24 +1,24 @@
|
|||||||
import { useMemo, useCallback } from 'react';
|
import { useMemo, useCallback } from 'react';
|
||||||
import { Button, Table, TableHeader, TableColumn, TableBody, TableRow, TableCell } from '@nextui-org/react';
|
import { Button, Table, TableHeader, TableColumn, TableBody, TableRow, TableCell } from '@nextui-org/react';
|
||||||
import { UserType } from '@/types/user';
|
import { UserType } from '@/types/user';
|
||||||
import { SettingsMessages } from '@/types/settings';
|
|
||||||
import Avatar from 'boring-avatars';
|
import Avatar from 'boring-avatars';
|
||||||
|
import { MembersMessages } from '@/types/member';
|
||||||
|
|
||||||
type Props = {
|
type Props = {
|
||||||
candidates: UserType[];
|
candidates: UserType[];
|
||||||
onAddPress: (userAdded: UserType) => void;
|
onAddPress: (userAdded: UserType) => void;
|
||||||
messages: SettingsMessages;
|
messages: MembersMessages;
|
||||||
};
|
};
|
||||||
|
|
||||||
export default function MembersTable({ candidates, onAddPress, messages }: Props) {
|
export default function MembersTable({ candidates, onAddPress, messages }: Props) {
|
||||||
const headerColumns = [
|
const headerColumns = [
|
||||||
{ name: messages.avatar, uid: 'avatar' },
|
{ name: messages.avatar, uid: 'avatar', sortable: false },
|
||||||
{ name: messages.email, uid: 'email' },
|
{ name: messages.email, uid: 'email', sortable: false },
|
||||||
{ name: messages.username, uid: 'username' },
|
{ name: messages.username, uid: 'username', sortable: false },
|
||||||
{ name: messages.add, uid: 'add' },
|
{ name: messages.add, uid: 'add', sortable: false },
|
||||||
];
|
];
|
||||||
|
|
||||||
const renderCell = useCallback((candidate: UserType, columnKey: Key) => {
|
const renderCell = useCallback((candidate: UserType, columnKey: string) => {
|
||||||
const cellValue = candidate[columnKey as keyof UserType];
|
const cellValue = candidate[columnKey as keyof UserType];
|
||||||
|
|
||||||
switch (columnKey) {
|
switch (columnKey) {
|
||||||
@@ -81,7 +81,9 @@ export default function MembersTable({ candidates, onAddPress, messages }: Props
|
|||||||
</TableHeader>
|
</TableHeader>
|
||||||
<TableBody emptyContent={messages.noMembersFound} items={candidates}>
|
<TableBody emptyContent={messages.noMembersFound} items={candidates}>
|
||||||
{(item) => (
|
{(item) => (
|
||||||
<TableRow key={item.id}>{(columnKey) => <TableCell>{renderCell(item, columnKey)}</TableCell>}</TableRow>
|
<TableRow key={item.id}>
|
||||||
|
{(columnKey) => <TableCell>{renderCell(item, columnKey as string)}</TableCell>}
|
||||||
|
</TableRow>
|
||||||
)}
|
)}
|
||||||
</TableBody>
|
</TableBody>
|
||||||
</Table>
|
</Table>
|
||||||
|
|||||||
@@ -40,11 +40,13 @@ export default function MembersPage({ projectId, messages, locale }: Props) {
|
|||||||
}, [context]);
|
}, [context]);
|
||||||
|
|
||||||
const handleAddMember = async (userAdded: UserType) => {
|
const handleAddMember = async (userAdded: UserType) => {
|
||||||
const newMember = await addMember(context.token.access_token, userAdded.id, projectId);
|
if (userAdded.id) {
|
||||||
newMember.User = userAdded;
|
const newMember = await addMember(context.token.access_token, userAdded.id, Number(projectId));
|
||||||
const updateMembers = [...members];
|
newMember.User = userAdded;
|
||||||
updateMembers.push(newMember);
|
const updateMembers = [...members];
|
||||||
setMembers(updateMembers);
|
updateMembers.push(newMember);
|
||||||
|
setMembers(updateMembers);
|
||||||
|
}
|
||||||
|
|
||||||
setIsDialogOpen(false);
|
setIsDialogOpen(false);
|
||||||
};
|
};
|
||||||
@@ -64,22 +66,24 @@ export default function MembersPage({ projectId, messages, locale }: Props) {
|
|||||||
|
|
||||||
const onConfirm = async () => {
|
const onConfirm = async () => {
|
||||||
if (deleteMemberId) {
|
if (deleteMemberId) {
|
||||||
await deleteMember(context.token.access_token, deleteMemberId, projectId);
|
await deleteMember(context.token.access_token, deleteMemberId, Number(projectId));
|
||||||
setMembers(members.filter((member) => member.User.id !== deleteMemberId));
|
setMembers(members.filter((member) => member.User.id !== deleteMemberId));
|
||||||
closeDeleteConfirmDialog();
|
closeDeleteConfirmDialog();
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
const handleChangeRole = async (userEdit: UserType, role: number) => {
|
const handleChangeRole = async (userEdit: UserType, role: number) => {
|
||||||
await updateMember(context.token.access_token, userEdit.id, projectId, role);
|
if (userEdit.id) {
|
||||||
setMembers((prevMembers) => {
|
await updateMember(context.token.access_token, userEdit.id, Number(projectId), role);
|
||||||
return prevMembers.map((member) => {
|
setMembers((prevMembers) => {
|
||||||
if (member.User.id === userEdit.id) {
|
return prevMembers.map((member) => {
|
||||||
return { ...member, role: role };
|
if (member.User.id === userEdit.id) {
|
||||||
}
|
return { ...member, role: role };
|
||||||
return member;
|
}
|
||||||
|
return member;
|
||||||
|
});
|
||||||
});
|
});
|
||||||
});
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
return (
|
return (
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
import { useState, useMemo } from 'react';
|
import { useState, useMemo, ReactNode } from 'react';
|
||||||
import {
|
import {
|
||||||
Button,
|
Button,
|
||||||
Table,
|
Table,
|
||||||
@@ -15,16 +15,16 @@ import {
|
|||||||
} from '@nextui-org/react';
|
} from '@nextui-org/react';
|
||||||
import { ChevronDown } from 'lucide-react';
|
import { ChevronDown } from 'lucide-react';
|
||||||
import { MemberType, UserType } from '@/types/user';
|
import { MemberType, UserType } from '@/types/user';
|
||||||
import { SettingsMessages } from '@/types/settings';
|
|
||||||
import { memberRoles } from '@/config/selection';
|
import { memberRoles } from '@/config/selection';
|
||||||
import Avatar from 'boring-avatars';
|
import Avatar from 'boring-avatars';
|
||||||
|
import { MembersMessages } from '@/types/member';
|
||||||
|
|
||||||
type Props = {
|
type Props = {
|
||||||
members: MemberType[];
|
members: MemberType[];
|
||||||
isDisabled: boolean;
|
isDisabled: boolean;
|
||||||
onChangeRole: (userEdit: UserType, role: number) => void;
|
onChangeRole: (userEdit: UserType, role: number) => void;
|
||||||
onDeleteMember: (deletedUserId: number) => void;
|
onDeleteMember: (deletedUserId: number) => void;
|
||||||
messages: SettingsMessages;
|
messages: MembersMessages;
|
||||||
};
|
};
|
||||||
|
|
||||||
export default function MembersTable({ members, isDisabled, onChangeRole, onDeleteMember, messages }: Props) {
|
export default function MembersTable({ members, isDisabled, onChangeRole, onDeleteMember, messages }: Props) {
|
||||||
@@ -42,17 +42,17 @@ export default function MembersTable({ members, isDisabled, onChangeRole, onDele
|
|||||||
});
|
});
|
||||||
|
|
||||||
const sortedItems = useMemo(() => {
|
const sortedItems = useMemo(() => {
|
||||||
return [...members].sort((a: UserType, b: UserType) => {
|
return [...members].sort((a: MemberType, b: MemberType) => {
|
||||||
const first = a[sortDescriptor.column as keyof UserType] as number;
|
const first = a[sortDescriptor.column as keyof MemberType] as number;
|
||||||
const second = b[sortDescriptor.column as keyof UserType] as number;
|
const second = b[sortDescriptor.column as keyof MemberType] as number;
|
||||||
const cmp = first < second ? -1 : first > second ? 1 : 0;
|
const cmp = first < second ? -1 : first > second ? 1 : 0;
|
||||||
|
|
||||||
return sortDescriptor.direction === 'descending' ? -cmp : cmp;
|
return sortDescriptor.direction === 'descending' ? -cmp : cmp;
|
||||||
});
|
});
|
||||||
}, [sortDescriptor, members]);
|
}, [sortDescriptor, members]);
|
||||||
|
|
||||||
const renderCell = (member: UserType, columnKey: Key) => {
|
const renderCell = (member: MemberType, columnKey: string) => {
|
||||||
const cellValue = member[columnKey as keyof UserType];
|
const cellValue = member[columnKey as keyof MemberType];
|
||||||
|
|
||||||
switch (columnKey) {
|
switch (columnKey) {
|
||||||
case 'avatar':
|
case 'avatar':
|
||||||
@@ -73,7 +73,7 @@ export default function MembersTable({ members, isDisabled, onChangeRole, onDele
|
|||||||
<Dropdown>
|
<Dropdown>
|
||||||
<DropdownTrigger>
|
<DropdownTrigger>
|
||||||
<Button size="sm" isDisabled={isDisabled} variant="light" endContent={<ChevronDown size={16} />}>
|
<Button size="sm" isDisabled={isDisabled} variant="light" endContent={<ChevronDown size={16} />}>
|
||||||
<span className="w-12">{messages[memberRoles[cellValue].uid]}</span>
|
<span className="w-12">{messages[memberRoles[cellValue as number].uid]}</span>
|
||||||
</Button>
|
</Button>
|
||||||
</DropdownTrigger>
|
</DropdownTrigger>
|
||||||
<DropdownMenu aria-label="test case actions">
|
<DropdownMenu aria-label="test case actions">
|
||||||
@@ -92,7 +92,11 @@ export default function MembersTable({ members, isDisabled, onChangeRole, onDele
|
|||||||
isDisabled={isDisabled}
|
isDisabled={isDisabled}
|
||||||
color="danger"
|
color="danger"
|
||||||
variant="light"
|
variant="light"
|
||||||
onClick={() => onDeleteMember(member.User.id)}
|
onClick={() => {
|
||||||
|
if (member.User.id) {
|
||||||
|
onDeleteMember(member.User.id);
|
||||||
|
}
|
||||||
|
}}
|
||||||
>
|
>
|
||||||
{messages.deleteMember}
|
{messages.deleteMember}
|
||||||
</Button>
|
</Button>
|
||||||
@@ -143,7 +147,9 @@ export default function MembersTable({ members, isDisabled, onChangeRole, onDele
|
|||||||
</TableHeader>
|
</TableHeader>
|
||||||
<TableBody emptyContent={messages.noMembersFound} items={sortedItems}>
|
<TableBody emptyContent={messages.noMembersFound} items={sortedItems}>
|
||||||
{(item) => (
|
{(item) => (
|
||||||
<TableRow key={item.id}>{(columnKey) => <TableCell>{renderCell(item, columnKey)}</TableCell>}</TableRow>
|
<TableRow key={item.id}>
|
||||||
|
{(columnKey) => <TableCell>{renderCell(item, columnKey as string) as ReactNode}</TableCell>}
|
||||||
|
</TableRow>
|
||||||
)}
|
)}
|
||||||
</TableBody>
|
</TableBody>
|
||||||
</Table>
|
</Table>
|
||||||
|
|||||||
@@ -24,7 +24,7 @@ async function fetchProjectMembers(jwt: string, projectId: string) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
async function addMember(jwt: string, userId: string, projectId: string) {
|
async function addMember(jwt: string, userId: number, projectId: number) {
|
||||||
const fetchOptions = {
|
const fetchOptions = {
|
||||||
method: 'POST',
|
method: 'POST',
|
||||||
headers: {
|
headers: {
|
||||||
@@ -47,7 +47,7 @@ async function addMember(jwt: string, userId: string, projectId: string) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
async function deleteMember(jwt: string, userId: string, projectId: string) {
|
async function deleteMember(jwt: string, userId: number, projectId: number) {
|
||||||
const fetchOptions = {
|
const fetchOptions = {
|
||||||
method: 'DELETE',
|
method: 'DELETE',
|
||||||
headers: {
|
headers: {
|
||||||
@@ -68,7 +68,7 @@ async function deleteMember(jwt: string, userId: string, projectId: string) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
async function updateMember(jwt: string, userId: string, projectId: string, role: number) {
|
async function updateMember(jwt: string, userId: number, projectId: number, role: number) {
|
||||||
const fetchOptions = {
|
const fetchOptions = {
|
||||||
method: 'PUT',
|
method: 'PUT',
|
||||||
headers: {
|
headers: {
|
||||||
|
|||||||
@@ -8,10 +8,11 @@ import { RunType, RunsMessages } from '@/types/run';
|
|||||||
import RunDialog from './RunDialog';
|
import RunDialog from './RunDialog';
|
||||||
import DeleteConfirmDialog from '@/components/DeleteConfirmDialog';
|
import DeleteConfirmDialog from '@/components/DeleteConfirmDialog';
|
||||||
import { TokenContext } from '@/utils/TokenProvider';
|
import { TokenContext } from '@/utils/TokenProvider';
|
||||||
|
import { LocaleCodeType } from '@/types/locale';
|
||||||
|
|
||||||
type Props = {
|
type Props = {
|
||||||
projectId: string;
|
projectId: string;
|
||||||
locale: string;
|
locale: LocaleCodeType;
|
||||||
messages: RunsMessages;
|
messages: RunsMessages;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
import { useState, useEffect, useMemo } from 'react';
|
import { useState, useEffect, useMemo, ReactNode } from 'react';
|
||||||
import {
|
import {
|
||||||
Table,
|
Table,
|
||||||
TableHeader,
|
TableHeader,
|
||||||
@@ -17,6 +17,7 @@ import { Link, NextUiLinkClasses } from '@/src/navigation';
|
|||||||
import { MoreVertical } from 'lucide-react';
|
import { MoreVertical } from 'lucide-react';
|
||||||
import { RunsMessages, RunType } from '@/types/run';
|
import { RunsMessages, RunType } from '@/types/run';
|
||||||
import dayjs from 'dayjs';
|
import dayjs from 'dayjs';
|
||||||
|
import { LocaleCodeType } from '@/types/locale';
|
||||||
|
|
||||||
type Props = {
|
type Props = {
|
||||||
projectId: string;
|
projectId: string;
|
||||||
@@ -24,7 +25,7 @@ type Props = {
|
|||||||
runs: RunType[];
|
runs: RunType[];
|
||||||
onDeleteRun: (runId: number) => void;
|
onDeleteRun: (runId: number) => void;
|
||||||
messages: RunsMessages;
|
messages: RunsMessages;
|
||||||
locale: string;
|
locale: LocaleCodeType;
|
||||||
};
|
};
|
||||||
|
|
||||||
export default function RunsTable({ projectId, isDisabled, runs, onDeleteRun, messages, locale }: Props) {
|
export default function RunsTable({ projectId, isDisabled, runs, onDeleteRun, messages, locale }: Props) {
|
||||||
@@ -63,19 +64,19 @@ export default function RunsTable({ projectId, isDisabled, runs, onDeleteRun, me
|
|||||||
return text.length > maxLength ? text.slice(0, maxLength) + '...' : text;
|
return text.length > maxLength ? text.slice(0, maxLength) + '...' : text;
|
||||||
};
|
};
|
||||||
|
|
||||||
const renderCell = (run: RunType, columnKey: Key) => {
|
const renderCell = (run: RunType, columnKey: string) => {
|
||||||
const cellValue = run[columnKey as keyof RunType];
|
const cellValue = run[columnKey as keyof RunType];
|
||||||
|
|
||||||
switch (columnKey) {
|
switch (columnKey) {
|
||||||
case 'id':
|
case 'id':
|
||||||
return <span>{cellValue}</span>;
|
return <span>{cellValue as number}</span>;
|
||||||
case 'name':
|
case 'name':
|
||||||
const maxLength = 30;
|
const maxLength = 30;
|
||||||
const truncatedDescription = truncateText(run.description, maxLength);
|
const truncatedDescription = truncateText(run.description, maxLength);
|
||||||
return (
|
return (
|
||||||
<div>
|
<div>
|
||||||
<Link href={`/projects/${projectId}/runs/${run.id}`} locale={locale} className={NextUiLinkClasses}>
|
<Link href={`/projects/${projectId}/runs/${run.id}`} locale={locale} className={NextUiLinkClasses}>
|
||||||
{cellValue}
|
{cellValue as string}
|
||||||
</Link>
|
</Link>
|
||||||
<div className="text-xs text-default-500">
|
<div className="text-xs text-default-500">
|
||||||
<div>{truncatedDescription}</div>
|
<div>{truncatedDescription}</div>
|
||||||
@@ -83,7 +84,7 @@ export default function RunsTable({ projectId, isDisabled, runs, onDeleteRun, me
|
|||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
case 'updatedAt':
|
case 'updatedAt':
|
||||||
return <span>{dayjs(cellValue).format('YYYY/MM/DD HH:mm')}</span>;
|
return <span>{dayjs(cellValue as string).format('YYYY/MM/DD HH:mm')}</span>;
|
||||||
case 'actions':
|
case 'actions':
|
||||||
return (
|
return (
|
||||||
<Dropdown>
|
<Dropdown>
|
||||||
@@ -145,7 +146,9 @@ export default function RunsTable({ projectId, isDisabled, runs, onDeleteRun, me
|
|||||||
</TableHeader>
|
</TableHeader>
|
||||||
<TableBody emptyContent={messages.noRunsFound} items={sortedItems}>
|
<TableBody emptyContent={messages.noRunsFound} items={sortedItems}>
|
||||||
{(item) => (
|
{(item) => (
|
||||||
<TableRow key={item.id}>{(columnKey) => <TableCell>{renderCell(item, columnKey)}</TableCell>}</TableRow>
|
<TableRow key={item.id}>
|
||||||
|
{(columnKey) => <TableCell>{renderCell(item, columnKey as string) as ReactNode}</TableCell>}
|
||||||
|
</TableRow>
|
||||||
)}
|
)}
|
||||||
</TableBody>
|
</TableBody>
|
||||||
</Table>
|
</Table>
|
||||||
|
|||||||
@@ -77,7 +77,7 @@ export default function RunEditor({
|
|||||||
const { theme, setTheme } = useTheme();
|
const { theme, setTheme } = useTheme();
|
||||||
const [testRun, setTestRun] = useState<RunType>(defaultTestRun);
|
const [testRun, setTestRun] = useState<RunType>(defaultTestRun);
|
||||||
const [folders, setFolders] = useState<FolderType[]>([]);
|
const [folders, setFolders] = useState<FolderType[]>([]);
|
||||||
const [runStatusCounts, setRunStatusCounts] = useState<RunStatusCountType[]>();
|
const [runStatusCounts, setRunStatusCounts] = useState<RunStatusCountType[]>([]);
|
||||||
const [selectedKeys, setSelectedKeys] = useState<Selection>(new Set([]));
|
const [selectedKeys, setSelectedKeys] = useState<Selection>(new Set([]));
|
||||||
const [selectedFolder, setSelectedFolder] = useState<FolderType | null>(null);
|
const [selectedFolder, setSelectedFolder] = useState<FolderType | null>(null);
|
||||||
const [testCases, setTestCases] = useState<CaseType[]>([]);
|
const [testCases, setTestCases] = useState<CaseType[]>([]);
|
||||||
@@ -256,10 +256,12 @@ export default function RunEditor({
|
|||||||
size="sm"
|
size="sm"
|
||||||
variant="bordered"
|
variant="bordered"
|
||||||
selectedKeys={[testRunStatus[testRun.state].uid]}
|
selectedKeys={[testRunStatus[testRun.state].uid]}
|
||||||
onSelectionChange={(e) => {
|
onSelectionChange={(newSelection) => {
|
||||||
const selectedUid = e.anchorKey;
|
if (newSelection !== 'all' && newSelection.size !== 0) {
|
||||||
const index = testRunStatus.findIndex((template) => template.uid === selectedUid);
|
const selectedUid = Array.from(newSelection)[0];
|
||||||
setTestRun({ ...testRun, state: index });
|
const index = testRunStatus.findIndex((template) => template.uid === selectedUid);
|
||||||
|
setTestRun({ ...testRun, state: index });
|
||||||
|
}
|
||||||
}}
|
}}
|
||||||
label={messages.status}
|
label={messages.status}
|
||||||
className="mt-3 max-w-xs"
|
className="mt-3 max-w-xs"
|
||||||
@@ -278,7 +280,7 @@ export default function RunEditor({
|
|||||||
<div className="flex items-center justify-between">
|
<div className="flex items-center justify-between">
|
||||||
<h6 className="h-8 font-bold">{messages.selectTestCase}</h6>
|
<h6 className="h-8 font-bold">{messages.selectTestCase}</h6>
|
||||||
<div>
|
<div>
|
||||||
{(selectedKeys.size > 0 || selectedKeys === 'all') && (
|
{(selectedKeys === 'all' || selectedKeys.size > 0) && (
|
||||||
<Dropdown>
|
<Dropdown>
|
||||||
<DropdownTrigger>
|
<DropdownTrigger>
|
||||||
<Button
|
<Button
|
||||||
|
|||||||
@@ -4,6 +4,7 @@ import dynamic from 'next/dynamic';
|
|||||||
import { testRunCaseStatus } from '@/config/selection';
|
import { testRunCaseStatus } from '@/config/selection';
|
||||||
import { RunStatusCountType } from '@/types/run';
|
import { RunStatusCountType } from '@/types/run';
|
||||||
import { TestRunCaseStatusMessages } from '@/types/status';
|
import { TestRunCaseStatusMessages } from '@/types/status';
|
||||||
|
import { ChartDataType } from '@/types/chart';
|
||||||
const Chart = dynamic(() => import('react-apexcharts'), { ssr: false });
|
const Chart = dynamic(() => import('react-apexcharts'), { ssr: false });
|
||||||
|
|
||||||
type Props = {
|
type Props = {
|
||||||
@@ -13,7 +14,7 @@ type Props = {
|
|||||||
};
|
};
|
||||||
|
|
||||||
export default function RunProgressDounut({ statusCounts, testRunCaseStatusMessages, theme }: Props) {
|
export default function RunProgressDounut({ statusCounts, testRunCaseStatusMessages, theme }: Props) {
|
||||||
const [chartData, setChartData] = useState({
|
const [chartData, setChartData] = useState<ChartDataType>({
|
||||||
series: [],
|
series: [],
|
||||||
options: {
|
options: {
|
||||||
labels: [],
|
labels: [],
|
||||||
|
|||||||
@@ -1,3 +1,4 @@
|
|||||||
|
import { LocaleCodeType } from '@/types/locale';
|
||||||
import RunsPage from './RunsPage';
|
import RunsPage from './RunsPage';
|
||||||
import { useTranslations } from 'next-intl';
|
import { useTranslations } from 'next-intl';
|
||||||
|
|
||||||
@@ -27,7 +28,7 @@ export default function Page({ params }: { params: { projectId: string; locale:
|
|||||||
|
|
||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
<RunsPage projectId={params.projectId} locale={params.locale} messages={messages} />
|
<RunsPage projectId={params.projectId} locale={params.locale as LocaleCodeType} messages={messages} />
|
||||||
</>
|
</>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -246,6 +246,8 @@ async function updateRunCases(jwt: string, runId: number, testCases: CaseType[])
|
|||||||
runId: runId,
|
runId: runId,
|
||||||
status: itr.RunCases[0].status,
|
status: itr.RunCases[0].status,
|
||||||
editState: itr.RunCases[0].editState,
|
editState: itr.RunCases[0].editState,
|
||||||
|
createdAt: '0',
|
||||||
|
updatedAt: '0',
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -7,7 +7,7 @@ import { Pencil, Trash } from 'lucide-react';
|
|||||||
import { SettingsMessages } from '@/types/settings';
|
import { SettingsMessages } from '@/types/settings';
|
||||||
import { TokenContext } from '@/utils/TokenProvider';
|
import { TokenContext } from '@/utils/TokenProvider';
|
||||||
import { deleteProject, fetchProject, updateProject } from '@/utils/projectsControl';
|
import { deleteProject, fetchProject, updateProject } from '@/utils/projectsControl';
|
||||||
import { ProjectType } from '@/types/project';
|
import { ProjectDialogMessages, ProjectType } from '@/types/project';
|
||||||
import DeleteConfirmDialog from '@/components/DeleteConfirmDialog';
|
import DeleteConfirmDialog from '@/components/DeleteConfirmDialog';
|
||||||
import { useRouter } from '@/src/navigation';
|
import { useRouter } from '@/src/navigation';
|
||||||
import ProjectDialog from '@/components/ProjectDialog';
|
import ProjectDialog from '@/components/ProjectDialog';
|
||||||
@@ -17,10 +17,11 @@ import { findUser } from '@/utils/usersControl';
|
|||||||
type Props = {
|
type Props = {
|
||||||
projectId: string;
|
projectId: string;
|
||||||
messages: SettingsMessages;
|
messages: SettingsMessages;
|
||||||
|
projectDialogMessages: ProjectDialogMessages;
|
||||||
locale: string;
|
locale: string;
|
||||||
};
|
};
|
||||||
|
|
||||||
export default function SettingsPage({ projectId, messages, locale }: Props) {
|
export default function SettingsPage({ projectId, messages, projectDialogMessages, locale }: Props) {
|
||||||
const context = useContext(TokenContext);
|
const context = useContext(TokenContext);
|
||||||
const router = useRouter();
|
const router = useRouter();
|
||||||
const [project, setProject] = useState<ProjectType>({
|
const [project, setProject] = useState<ProjectType>({
|
||||||
@@ -152,7 +153,7 @@ export default function SettingsPage({ projectId, messages, locale }: Props) {
|
|||||||
editingProject={project}
|
editingProject={project}
|
||||||
onCancel={() => setIsProjectDialogOpen(false)}
|
onCancel={() => setIsProjectDialogOpen(false)}
|
||||||
onSubmit={onSubmit}
|
onSubmit={onSubmit}
|
||||||
messages={messages}
|
projectDialogMessages={projectDialogMessages}
|
||||||
/>
|
/>
|
||||||
|
|
||||||
<DeleteConfirmDialog
|
<DeleteConfirmDialog
|
||||||
|
|||||||
@@ -1,29 +1,46 @@
|
|||||||
|
import { ProjectDialogMessages } from '@/types/project';
|
||||||
import SettingsPage from './SettingsPage';
|
import SettingsPage from './SettingsPage';
|
||||||
import { useTranslations } from 'next-intl';
|
import { useTranslations } from 'next-intl';
|
||||||
|
import { SettingsMessages } from '@/types/settings';
|
||||||
|
|
||||||
export default function Page({ params }: { params: { projectId: string; locale: string } }) {
|
export default function Page({ params }: { params: { projectId: string; locale: string } }) {
|
||||||
const t = useTranslations('Settings');
|
const t = useTranslations('Settings');
|
||||||
const messages = {
|
const messages: SettingsMessages = {
|
||||||
projectManagement: t('project_management'),
|
projectManagement: t('project_management'),
|
||||||
projectName: t('project_name'),
|
projectName: t('project_name'),
|
||||||
projectDetail: t('project_detail'),
|
projectDetail: t('project_detail'),
|
||||||
projectOwner: t('project_owner'),
|
projectOwner: t('project_owner'),
|
||||||
editProject: t('edit_project'),
|
editProject: t('edit_project'),
|
||||||
project: t('project'),
|
|
||||||
ifYouMakePublic: t('if_you_make_public'),
|
|
||||||
public: t('public'),
|
public: t('public'),
|
||||||
publicity: t('publicity'),
|
publicity: t('publicity'),
|
||||||
private: t('private'),
|
private: t('private'),
|
||||||
update: t('update'),
|
|
||||||
deleteProject: t('delete_project'),
|
deleteProject: t('delete_project'),
|
||||||
delete: t('delete'),
|
delete: t('delete'),
|
||||||
close: t('close'),
|
close: t('close'),
|
||||||
areYouSure: t('are_you_sure'),
|
areYouSure: t('are_you_sure'),
|
||||||
};
|
};
|
||||||
|
|
||||||
|
const projectDialogMessages: ProjectDialogMessages = {
|
||||||
|
project: t('project'),
|
||||||
|
projectName: t('project_name'),
|
||||||
|
projectDetail: t('project_detail'),
|
||||||
|
public: t('public'),
|
||||||
|
private: t('private'),
|
||||||
|
ifYouMakePublic: t('if_you_make_public'),
|
||||||
|
close: t('close'),
|
||||||
|
create: t('create'),
|
||||||
|
update: t('update'),
|
||||||
|
pleaseEnter: t('please_enter'),
|
||||||
|
};
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
<SettingsPage projectId={params.projectId} messages={messages} locale={params.locale} />
|
<SettingsPage
|
||||||
|
projectId={params.projectId}
|
||||||
|
messages={messages}
|
||||||
|
projectDialogMessages={projectDialogMessages}
|
||||||
|
locale={params.locale}
|
||||||
|
/>
|
||||||
</>
|
</>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,17 +1,26 @@
|
|||||||
|
import { PageType } from '@/types/base';
|
||||||
import ProjectsPage from './ProjectsPage';
|
import ProjectsPage from './ProjectsPage';
|
||||||
import { useTranslations } from 'next-intl';
|
import { useTranslations } from 'next-intl';
|
||||||
|
import { LocaleCodeType } from '@/types/locale';
|
||||||
|
import { ProjectDialogMessages, ProjectsMessages } from '@/types/project';
|
||||||
|
|
||||||
export default function Page(params: { locale: string }) {
|
export default function Page({ params }: PageType) {
|
||||||
const t = useTranslations('Projects');
|
const t = useTranslations('Projects');
|
||||||
const messages = {
|
const messages: ProjectsMessages = {
|
||||||
projectList: t('projectList'),
|
projectList: t('projectList'),
|
||||||
project: t('project'),
|
|
||||||
newProject: t('new_project'),
|
newProject: t('new_project'),
|
||||||
id: t('id'),
|
id: t('id'),
|
||||||
publicity: t('publicity'),
|
publicity: t('publicity'),
|
||||||
|
public: t('public'),
|
||||||
|
private: t('private'),
|
||||||
name: t('name'),
|
name: t('name'),
|
||||||
detail: t('detail'),
|
detail: t('detail'),
|
||||||
lastUpdate: t('last_update'),
|
lastUpdate: t('last_update'),
|
||||||
|
noProjectsFound: t('no_projects_found'),
|
||||||
|
};
|
||||||
|
|
||||||
|
const projectDialogMessages: ProjectDialogMessages = {
|
||||||
|
project: t('project'),
|
||||||
projectName: t('project_name'),
|
projectName: t('project_name'),
|
||||||
projectDetail: t('project_detail'),
|
projectDetail: t('project_detail'),
|
||||||
public: t('public'),
|
public: t('public'),
|
||||||
@@ -19,12 +28,17 @@ export default function Page(params: { locale: string }) {
|
|||||||
ifYouMakePublic: t('if_you_make_public'),
|
ifYouMakePublic: t('if_you_make_public'),
|
||||||
close: t('close'),
|
close: t('close'),
|
||||||
create: t('create'),
|
create: t('create'),
|
||||||
|
update: t('update'),
|
||||||
pleaseEnter: t('please_enter'),
|
pleaseEnter: t('please_enter'),
|
||||||
noProjectsFound: t('no_projects_found'),
|
|
||||||
};
|
};
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
<ProjectsPage messages={messages} locale={params.locale} />
|
<ProjectsPage
|
||||||
|
messages={messages}
|
||||||
|
projectDialogMessages={projectDialogMessages}
|
||||||
|
locale={params.locale as LocaleCodeType}
|
||||||
|
/>
|
||||||
</>
|
</>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,7 +1,8 @@
|
|||||||
import { notFound } from 'next/navigation';
|
import { notFound } from 'next/navigation';
|
||||||
import { getRequestConfig } from 'next-intl/server';
|
import { getRequestConfig } from 'next-intl/server';
|
||||||
|
import { LocaleCodeType } from '@/types/locale';
|
||||||
|
|
||||||
const locales = ['en', 'ja'];
|
const locales: LocaleCodeType[] = ['en', 'ja'];
|
||||||
|
|
||||||
export default getRequestConfig(async ({ locale }) => {
|
export default getRequestConfig(async ({ locale }) => {
|
||||||
if (!locales.includes(locale as any)) notFound();
|
if (!locales.includes(locale as any)) notFound();
|
||||||
|
|||||||
21
frontend/types/base.ts
Normal file
21
frontend/types/base.ts
Normal file
@@ -0,0 +1,21 @@
|
|||||||
|
export type PageType = {
|
||||||
|
params: {
|
||||||
|
locale: string;
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
||||||
|
export type GlobalRoleType = {
|
||||||
|
uid: 'administrator' | 'user';
|
||||||
|
};
|
||||||
|
|
||||||
|
export type MemberRoleType = {
|
||||||
|
uid: 'manager' | 'developer' | 'reporter';
|
||||||
|
};
|
||||||
|
|
||||||
|
export type AutomationStatusType = {
|
||||||
|
uid: 'automated' | 'automation-not-required' | 'cannot-be-automated' | 'obsolete';
|
||||||
|
};
|
||||||
|
|
||||||
|
export type TemplateType = {
|
||||||
|
uid: 'text' | 'step';
|
||||||
|
};
|
||||||
@@ -45,8 +45,8 @@ type RunCaseType = {
|
|||||||
type CaseAttachmentType = {
|
type CaseAttachmentType = {
|
||||||
createdAt: Date;
|
createdAt: Date;
|
||||||
updatedAt: Date;
|
updatedAt: Date;
|
||||||
CaseId: number;
|
caseId: number;
|
||||||
AttachmentId: number;
|
attachmentId: number;
|
||||||
};
|
};
|
||||||
|
|
||||||
type AttachmentType = {
|
type AttachmentType = {
|
||||||
@@ -59,16 +59,6 @@ type AttachmentType = {
|
|||||||
caseAttachments: CaseAttachmentType;
|
caseAttachments: CaseAttachmentType;
|
||||||
};
|
};
|
||||||
|
|
||||||
type CaseTypeCountType = {
|
|
||||||
type: number;
|
|
||||||
count: number;
|
|
||||||
};
|
|
||||||
|
|
||||||
type CasePriorityCountType = {
|
|
||||||
priority: number;
|
|
||||||
count: number;
|
|
||||||
};
|
|
||||||
|
|
||||||
type CasesMessages = {
|
type CasesMessages = {
|
||||||
testCaseList: string;
|
testCaseList: string;
|
||||||
id: string;
|
id: string;
|
||||||
@@ -97,6 +87,7 @@ type CaseMessages = {
|
|||||||
pleaseEnterTitle: string;
|
pleaseEnterTitle: string;
|
||||||
description: string;
|
description: string;
|
||||||
testCaseDescription: string;
|
testCaseDescription: string;
|
||||||
|
priority: string;
|
||||||
type: string;
|
type: string;
|
||||||
template: string;
|
template: string;
|
||||||
testDetail: string;
|
testDetail: string;
|
||||||
@@ -119,12 +110,4 @@ type CaseMessages = {
|
|||||||
areYouSureLeave: string;
|
areYouSureLeave: string;
|
||||||
};
|
};
|
||||||
|
|
||||||
export type {
|
export type { CaseType, StepType, AttachmentType, CasesMessages, CaseMessages };
|
||||||
CaseType,
|
|
||||||
StepType,
|
|
||||||
AttachmentType,
|
|
||||||
CaseTypeCountType,
|
|
||||||
CasePriorityCountType,
|
|
||||||
CasesMessages,
|
|
||||||
CaseMessages,
|
|
||||||
};
|
|
||||||
|
|||||||
16
frontend/types/chart.ts
Normal file
16
frontend/types/chart.ts
Normal file
@@ -0,0 +1,16 @@
|
|||||||
|
import { ApexOptions } from 'apexcharts';
|
||||||
|
|
||||||
|
export type ChartDataType = {
|
||||||
|
series: ApexOptions['series'];
|
||||||
|
options: ApexOptions;
|
||||||
|
};
|
||||||
|
|
||||||
|
export type CaseTypeCountType = {
|
||||||
|
type: number;
|
||||||
|
count: number;
|
||||||
|
};
|
||||||
|
|
||||||
|
export type CasePriorityCountType = {
|
||||||
|
priority: number;
|
||||||
|
count: number;
|
||||||
|
};
|
||||||
6
frontend/types/locale.ts
Normal file
6
frontend/types/locale.ts
Normal file
@@ -0,0 +1,6 @@
|
|||||||
|
export type LocaleCodeType = 'en' | 'ja';
|
||||||
|
|
||||||
|
export type LocaleType = {
|
||||||
|
code: LocaleCodeType;
|
||||||
|
name: string;
|
||||||
|
};
|
||||||
@@ -13,14 +13,8 @@ export type ProjectType = {
|
|||||||
Runs: RunType[]; // additional property
|
Runs: RunType[]; // additional property
|
||||||
};
|
};
|
||||||
|
|
||||||
export type ProjectsMessages = {
|
export type ProjectDialogMessages = {
|
||||||
projectList: string;
|
project: string;
|
||||||
newProject: string;
|
|
||||||
id: string;
|
|
||||||
publicity: string;
|
|
||||||
name: string;
|
|
||||||
detail: string;
|
|
||||||
lastUpdate: string;
|
|
||||||
projectName: string;
|
projectName: string;
|
||||||
projectDetail: string;
|
projectDetail: string;
|
||||||
public: string;
|
public: string;
|
||||||
@@ -28,7 +22,20 @@ export type ProjectsMessages = {
|
|||||||
ifYouMakePublic: string;
|
ifYouMakePublic: string;
|
||||||
close: string;
|
close: string;
|
||||||
create: string;
|
create: string;
|
||||||
|
update: string;
|
||||||
pleaseEnter: string;
|
pleaseEnter: string;
|
||||||
|
};
|
||||||
|
|
||||||
|
export type ProjectsMessages = {
|
||||||
|
projectList: string;
|
||||||
|
newProject: string;
|
||||||
|
id: string;
|
||||||
|
publicity: string;
|
||||||
|
public: string;
|
||||||
|
private: string;
|
||||||
|
name: string;
|
||||||
|
detail: string;
|
||||||
|
lastUpdate: string;
|
||||||
noProjectsFound: string;
|
noProjectsFound: string;
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -36,5 +43,6 @@ export type ProjectMessages = {
|
|||||||
home: string;
|
home: string;
|
||||||
testCases: string;
|
testCases: string;
|
||||||
testRuns: string;
|
testRuns: string;
|
||||||
|
members: string;
|
||||||
settings: string;
|
settings: string;
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -7,6 +7,7 @@ type RunType = {
|
|||||||
projectId: number;
|
projectId: number;
|
||||||
createdAt: string;
|
createdAt: string;
|
||||||
updatedAt: string;
|
updatedAt: string;
|
||||||
|
RunCases?: RunCaseType[];
|
||||||
};
|
};
|
||||||
|
|
||||||
type RunCaseType = {
|
type RunCaseType = {
|
||||||
@@ -15,6 +16,8 @@ type RunCaseType = {
|
|||||||
caseId: number;
|
caseId: number;
|
||||||
status: number;
|
status: number;
|
||||||
editState: 'notChanged' | 'changed' | 'new' | 'deleted';
|
editState: 'notChanged' | 'changed' | 'new' | 'deleted';
|
||||||
|
createdAt: string;
|
||||||
|
updatedAt: string;
|
||||||
};
|
};
|
||||||
|
|
||||||
type RunStatusCountType = {
|
type RunStatusCountType = {
|
||||||
|
|||||||
@@ -4,12 +4,9 @@ export type SettingsMessages = {
|
|||||||
projectDetail: string;
|
projectDetail: string;
|
||||||
projectOwner: string;
|
projectOwner: string;
|
||||||
editProject: string;
|
editProject: string;
|
||||||
project: string;
|
|
||||||
publicity: string;
|
publicity: string;
|
||||||
public: string;
|
public: string;
|
||||||
private: string;
|
private: string;
|
||||||
ifYouMakePublic: string;
|
|
||||||
update: string;
|
|
||||||
deleteProject: string;
|
deleteProject: string;
|
||||||
delete: string;
|
delete: string;
|
||||||
close: string;
|
close: string;
|
||||||
|
|||||||
@@ -8,5 +8,5 @@ export type ToastMessages = {
|
|||||||
};
|
};
|
||||||
|
|
||||||
export type ToastContextType = {
|
export type ToastContextType = {
|
||||||
showToast: (text: string, mode: string) => {};
|
showToast: (text: string, mode: string) => void;
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -1,3 +1,4 @@
|
|||||||
|
import { LocaleCodeType } from './locale';
|
||||||
import { ToastMessages } from './toast';
|
import { ToastMessages } from './toast';
|
||||||
|
|
||||||
export type UserType = {
|
export type UserType = {
|
||||||
@@ -10,8 +11,8 @@ export type UserType = {
|
|||||||
};
|
};
|
||||||
|
|
||||||
export type TokenProps = {
|
export type TokenProps = {
|
||||||
toastMessages: ToastMessages;
|
toastMessages?: ToastMessages;
|
||||||
locale: string;
|
locale?: LocaleCodeType;
|
||||||
children?: React.ReactNode;
|
children?: React.ReactNode;
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -73,6 +74,8 @@ export type AdminMessages = {
|
|||||||
username: string;
|
username: string;
|
||||||
role: string;
|
role: string;
|
||||||
noUsersFound: string;
|
noUsersFound: string;
|
||||||
|
administrator: string;
|
||||||
|
user: string;
|
||||||
};
|
};
|
||||||
|
|
||||||
export type AccountDropDownMessages = {
|
export type AccountDropDownMessages = {
|
||||||
|
|||||||
@@ -136,9 +136,13 @@ const TokenProvider = ({ toastMessages, locale, children }: TokenProps) => {
|
|||||||
const ret = tokenCheckSignInPage(token, pathname);
|
const ret = tokenCheckSignInPage(token, pathname);
|
||||||
if (!ret.ok) {
|
if (!ret.ok) {
|
||||||
if (ret.reason === 'notoken') {
|
if (ret.reason === 'notoken') {
|
||||||
toastContext.showToast(toastMessages.needSignedIn, 'error');
|
if (toastMessages) {
|
||||||
|
toastContext.showToast(toastMessages.needSignedIn, 'error');
|
||||||
|
}
|
||||||
} else if (ret.reason === 'expired') {
|
} else if (ret.reason === 'expired') {
|
||||||
toastContext.showToast(toastMessages.sessionExpired, 'error');
|
if (toastMessages) {
|
||||||
|
toastContext.showToast(toastMessages.sessionExpired, 'error');
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
router.push(ret.redirectPath, { locale: locale });
|
router.push(ret.redirectPath, { locale: locale });
|
||||||
|
|||||||
Reference in New Issue
Block a user