Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions src/app/workspaces/[workspaceId]/meeting-notes/new/page.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { NewMeetingNotePage } from '@/views/meeting-notes';
import { assertWorkspaceRouteAccess } from '@/entities/workspace/lib/assert-workspace-route-access';

interface WorkspaceNewMeetingNotePageProps {
params: Promise<{
Expand All @@ -10,6 +11,7 @@ export default async function WorkspaceNewMeetingNotePage({
params,
}: WorkspaceNewMeetingNotePageProps) {
const { workspaceId } = await params;
await assertWorkspaceRouteAccess(workspaceId, 'meeting-notes');

return <NewMeetingNotePage workspaceId={workspaceId} />;
}
2 changes: 2 additions & 0 deletions src/app/workspaces/[workspaceId]/meeting-notes/page.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { MeetingNotesPage } from '@/views/meeting-notes';
import { assertWorkspaceRouteAccess } from '@/entities/workspace/lib/assert-workspace-route-access';

interface WorkspaceMeetingNotesPageProps {
params: Promise<{
Expand All @@ -10,6 +11,7 @@ export default async function WorkspaceMeetingNotesPage({
params,
}: WorkspaceMeetingNotesPageProps) {
const { workspaceId } = await params;
await assertWorkspaceRouteAccess(workspaceId, 'meeting-notes');

return <MeetingNotesPage workspaceId={workspaceId} />;
}
2 changes: 2 additions & 0 deletions src/app/workspaces/[workspaceId]/notices/page.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
// 워크스페이스 공지 페이지의 라우트 진입점입니다.
import { getNoticeBoard } from '@/entities/notice/api/get-notice-board';
import { assertWorkspaceRouteAccess } from '@/entities/workspace/lib/assert-workspace-route-access';
import { NoticesView } from '@/views/store-operation/notices';

interface NoticesPageProps {
Expand All @@ -10,6 +11,7 @@ interface NoticesPageProps {

export default async function NoticesPage({ params }: NoticesPageProps) {
const { workspaceId } = await params;
await assertWorkspaceRouteAccess(workspaceId, 'notices');
const initialData = await getNoticeBoard(workspaceId);

return <NoticesView workspaceId={workspaceId} initialData={initialData} />;
Expand Down
2 changes: 2 additions & 0 deletions src/app/workspaces/[workspaceId]/progress-chart/page.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
// 진행률 차트 라우트 — 워크스페이스 존재/용도만 서버에서 판정하고, 데이터 조회·조립은 client 컨테이너(useQuery)에 위임한다.
import { ProgressChartPage } from '@/views/progress-chart';
import { assertWorkspaceRouteAccess } from '@/entities/workspace/lib/assert-workspace-route-access';

interface WorkspaceProgressChartPageProps {
params: Promise<{
Expand All @@ -11,6 +12,7 @@ export default async function WorkspaceProgressChartPage({
params,
}: WorkspaceProgressChartPageProps) {
const { workspaceId } = await params;
await assertWorkspaceRouteAccess(workspaceId, 'progress-chart');

return <ProgressChartPage workspaceId={workspaceId} />;
}
2 changes: 2 additions & 0 deletions src/app/workspaces/[workspaceId]/project-management/page.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { ProjectManagementPage } from '@/views/project-management';
import { assertWorkspaceRouteAccess } from '@/entities/workspace/lib/assert-workspace-route-access';

interface WorkspaceProjectManagementPageProps {
params: Promise<{
Expand All @@ -10,6 +11,7 @@ export default async function WorkspaceProjectManagementPage({
params,
}: WorkspaceProjectManagementPageProps) {
const { workspaceId } = await params;
await assertWorkspaceRouteAccess(workspaceId, 'project-management');

return <ProjectManagementPage workspaceId={workspaceId} />;
}
2 changes: 2 additions & 0 deletions src/app/workspaces/[workspaceId]/sprint-board/page.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
// 스프린트 보드 라우트 — 선택 스프린트를 searchParam(?sprint=id)으로 읽어 client 컨테이너에 넘긴다.
// 스프린트/태스크는 컨테이너가 useQuery로 조회하고, 담당자 표시명 해석용 members만 서버에서 조회해 주입한다.
import { getWorkspaceMembersByWorkspaceId } from '@/entities/workspace-member/api/get-workspace-members-by-id';
import { assertWorkspaceRouteAccess } from '@/entities/workspace/lib/assert-workspace-route-access';
import { SprintBoardView } from '@/views/side-project/sprint-board';

interface SprintBoardRouteProps {
Expand All @@ -10,6 +11,7 @@ interface SprintBoardRouteProps {

export default async function SprintBoardPage({ params, searchParams }: SprintBoardRouteProps) {
const { workspaceId } = await params;
await assertWorkspaceRouteAccess(workspaceId, 'sprint-board');
const { sprint: sprintParam } = await searchParams;
const selectedSprintId = typeof sprintParam === 'string' ? sprintParam : undefined;

Expand Down
14 changes: 14 additions & 0 deletions src/app/workspaces/[workspaceId]/unavailable/page.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
// 목적에 맞지 않는 워크스페이스 전용 모듈에 직접 접근했을 때 표시하는 라우트입니다.
import { WorkspaceUnavailableView } from '@/views/workspace-unavailable';

interface WorkspaceUnavailablePageProps {
params: Promise<{
workspaceId: string;
}>;
}

export default async function WorkspaceUnavailablePage({ params }: WorkspaceUnavailablePageProps) {
const { workspaceId } = await params;

return <WorkspaceUnavailableView workspaceId={workspaceId} />;
}
2 changes: 2 additions & 0 deletions src/app/workspaces/[workspaceId]/work-schedule/page.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
// 현재 주의 멤버, 근무유형, 스케줄 데이터를 병렬 조회해 근무 스케줄 화면에 전달하는 서버 페이지입니다.
import { getWorkspaceMembersByWorkspaceId } from '@/entities/workspace-member/api/get-workspace-members-by-id';
import { assertWorkspaceRouteAccess } from '@/entities/workspace/lib/assert-workspace-route-access';
import { getWorkScheduleEntriesByWeek } from '@/entities/work-schedule/api/get-work-schedule-entries-by-week';
import { getWorkShiftTypesByWorkspaceId } from '@/entities/work-schedule/api/get-work-shift-types-by-workspace-id';
import { ensureWeeklyWorkScheduleEntries } from '@/entities/work-schedule/api/ensure-weekly-work-schedule-entries';
Expand All @@ -14,6 +15,7 @@ interface WorkSchedulePageProps {

export default async function WorkSchedulePage({ params }: WorkSchedulePageProps) {
const { workspaceId } = await params;
await assertWorkspaceRouteAccess(workspaceId, 'work-schedule');
const { startDate, endDate } = getCurrentWeekRange();
await ensureWeeklyWorkScheduleEntries(workspaceId, startDate);
const [members, shifts, schedule] = await Promise.all([
Expand Down
33 changes: 33 additions & 0 deletions src/entities/workspace/lib/assert-workspace-route-access.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
// 워크스페이스 목적에 맞지 않는 전용 모듈 URL의 직접 접근을 서버에서 차단합니다.
import { redirect } from 'next/navigation';
import { getWorkspaceById } from '../api/get-workspace-by-id';
import type { WorkspacePurpose } from '../model/workspace.types';

type WorkspaceProtectedRoute =
| 'meeting-notes'
| 'notices'
| 'progress-chart'
| 'project-management'
| 'sprint-board'
| 'work-schedule';

// 각 목적에서 제공하는 전용 모듈 라우트를 정의합니다. 공통 모듈은 별도 보호가 필요하지 않습니다.
const workspaceRoutePurposes: Record<WorkspaceProtectedRoute, readonly WorkspacePurpose[]> = {
'meeting-notes': ['team-project', 'side-project'],
notices: ['team-project', 'store-operation'],
'progress-chart': ['team-project', 'side-project'],
'project-management': ['team-project'],
'sprint-board': ['side-project'],
'work-schedule': ['store-operation'],
};

export async function assertWorkspaceRouteAccess(
workspaceId: string,
route: WorkspaceProtectedRoute,
): Promise<void> {
const workspace = await getWorkspaceById(workspaceId);

if (!workspace || !workspaceRoutePurposes[route].includes(workspace.purpose)) {
redirect(`/workspaces/${workspaceId}/unavailable`);
}
}
2 changes: 2 additions & 0 deletions src/views/workspace-unavailable/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
// 접근할 수 없는 워크스페이스 전용 모듈 화면의 Public API입니다.
export { WorkspaceUnavailableView } from './ui/WorkspaceUnavailableView';
30 changes: 30 additions & 0 deletions src/views/workspace-unavailable/ui/WorkspaceUnavailableView.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
// 현재 워크스페이스 목적에서 제공하지 않는 모듈에 접근했을 때 안내하는 화면입니다.
import { ArrowLeft, ShieldAlert } from 'lucide-react';
import Link from 'next/link';

interface WorkspaceUnavailableViewProps {
workspaceId: string;
}

export function WorkspaceUnavailableView({ workspaceId }: WorkspaceUnavailableViewProps) {
return (
<section className="mx-auto flex min-h-[calc(100vh-72px)] w-full max-w-2xl items-center justify-center px-4 py-10 sm:px-8">
<div className="w-full rounded-2xl border border-slate-200 bg-white p-8 text-center shadow-sm sm:p-12">
<span className="mx-auto flex h-14 w-14 items-center justify-center rounded-2xl bg-rose-50 text-rose-500">
<ShieldAlert className="h-7 w-7" aria-hidden="true" />
</span>
<h1 className="mt-5 text-2xl font-bold text-slate-950">접근할 수 없는 페이지입니다.</h1>
<p className="mt-2 text-sm leading-6 text-slate-500">
현재 워크스페이스 템플릿에서는 이 기능을 사용할 수 없습니다.
</p>
<Link
href={`/workspaces/${workspaceId}/dashboard`}
className="mt-7 inline-flex h-11 items-center gap-2 rounded-xl bg-[var(--color-brand)] px-4 text-sm font-bold text-white hover:bg-indigo-500"
>
<ArrowLeft className="h-4 w-4" aria-hidden="true" />
대시보드로 돌아가기
</Link>
</div>
</section>
);
}
1 change: 1 addition & 0 deletions src/widgets/workspace-shell/ui/WorkspaceHeader.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ interface WorkspaceHeaderProps {

function getCurrentPageTitle(pathname: string, navigationItems: WorkspaceNavigationItem[]): string {
if (pathname.endsWith('/notifications')) return '알림';
if (pathname.endsWith('/unavailable')) return '접근 제한';

const currentNavigationItem = navigationItems.find((item) => pathname.endsWith(`/${item.href}`));
return currentNavigationItem?.label ?? '대시보드';
Expand Down