feat(gdpr): 마이페이지 쿠키 동의 관리 버튼 재설계

- 토글 스위치 → 상태 배지 + 동의/철회 버튼으로 재설계
 (user 템플릿 미해석 클래스로 인한 스타일 회귀 + "켜짐/꺼짐" 표현 개선)
- 동의 시에도 확인 모달 경유, 라벨에 "쿠키" 접미사, "모두 동의" 바
- 동의한 항목만 동의일 표시 (상태는 라벨 옆 배지가 표현)
- 카테고리 설명을 코드 기본값에서 조회 — 관리자 설정 화면에 설명 편집 UI가
 없어 라벨만 저장 시 설명이 유실되던 문제 해결
- 철회/동의 모달 버튼을 목록 버튼과 톤 맞춰 정리 (취소=테두리형)
- cookie_banner 운영주체 라인 admin 전용 클래스 → 공통 클래스 치환
This commit is contained in:
chym1217 committed 2026-07-27 15:58:29 +09:00
1 parent ef13a1ddff
commit 1c6217f90d
20 files changed
+801 -366

No files matched your search

@@ -248,7 +248,7 @@ _단건 응답: `data` 객체의 필드._
| user_id | integer | `166` | user 식별자 (연관 리소스 참조) |
| needs_renewal | boolean | `false` | 회원의 활성 동의 중 옛 정책 버전인 항목이 있어 재동의가 필요한지 여부. 마이페이지가 「전체 다시 동의」 안내를 노출할지 판단합니다 |
| current_policy_version | string | `10` | 현재 발행된 최신 정책 버전 문자열. 각 동의 항목의 `policy_version`과 비교해 항목별 갱신 필요 여부를 계산하는 기준입니다 |
| consents | array | `[{"id":null,"consent_key":"cookie_necessary","consent_lab…` | 카탈로그의 모든 쿠키 카테고리와 회원 status를 합친 동의 매트릭스. 항목마다 다국어 라벨(`consent_label`), 필수 여부(`is_required`), 현재 동의 상태(`is_consented`), 명시적 거부 여부(`is_rejected`)와 거부 일시(`rejected_at`), 철회/재동의 가능 여부(`can_revoke`/`can_grant`), 항목별 갱신 필요(`needs_renewal_this_item`)를 담아 한 화면에서 철회·재동의·신규 동의를 처리하게 합니다. `is_rejected=true`는 마이페이지에서 「거부」 배지로 표시됩니다 |
| consents | array | `[{"id":null,"consent_key":"cookie_necessary","consent_lab…` | 카탈로그의 모든 쿠키 카테고리와 회원 status를 합친 동의 매트릭스. 항목마다 다국어 라벨(`consent_label`), 필수 여부(`is_required`), 현재 동의 상태(`is_consented`), 명시적 거부 여부(`is_rejected`)와 거부 일시(`rejected_at`), 철회/재동의 가능 여부(`can_revoke`/`can_grant`), 항목별 갱신 필요(`needs_renewal_this_item`)를 담아 한 화면에서 철회·재동의·신규 동의를 처리하게 합니다. `is_rejected=true`는 마이페이지에서 「거부」 배지로 표시됩니다. 각 항목은 마이페이지 표시용 상태 파생 필드도 함께 내려줍니다 — `status`(`required`/`consented`/`revoked`/`rejected`/`none`), 상태 배지 문구(`status_badge_label`, 다국어 — 필수=항상 적용 / 동의함 / 거부함 / 미설정), 동의한 항목의 표시 동사·날짜(`status_label`·`status_at_formatted` — 동의 상태(required·consented)만 '동의' + 동의일을 내려주고, 거부·철회·미설정은 둘 다 null) |
**응답 예시**
@@ -231,6 +231,20 @@ return [
'consented' => 'Consented',
'revoked' => 'Revoked',
'rejected_label' => 'Rejected',
// Issue #430 — per-item status verb chosen by the Resource (status_label) from status.
'status' => [
'granted' => 'Consented',
'consented' => 'Consented',
'revoked' => 'Revoked',
'rejected' => 'Rejected',
],
// Issue #430 (button redesign) — status badge text. Resource(status_badge_label).
'badge' => [
'required' => 'Always on',
'consented' => 'Consented',
'rejected' => 'Declined',
'unset' => 'Not set',
],
'revoke' => 'Revoke',
'grant' => 'Consent',
'grant_again' => 'Consent Again',
@@ -231,6 +231,20 @@ return [
'consented' => '동의',
'revoked' => '철회',
'rejected_label' => '거부',
// 이슈 #430 — 각 동의 항목 상태별 표시 동사. Resource(status_label)가 status 로 골라 내려준다.
'status' => [
'granted' => '동의',
'consented' => '동의',
'revoked' => '철회',
'rejected' => '거부',
],
// 이슈 #430 (버튼 재설계) — 상태 배지 문구. Resource(status_badge_label).
'badge' => [
'required' => '항상 적용',
'consented' => '동의함',
'rejected' => '거부함',
'unset' => '미설정',
],
'revoke' => '철회',
'grant' => '동의',
'grant_again' => '다시 동의',
@@ -370,7 +370,7 @@
"name": "Div",
"if": "{{!!gdprPublicSettings?.data?.legal_entity_name || !!gdprPublicSettings?.data?.data_storage_location}}",
"props": {
"className": "mt-3 pt-2 border-t border-gray-100 dark:border-gray-700 text-tertiary"
"className": "mt-3 pt-2 border-t border-gray-100 dark:border-gray-700 text-xs text-gray-500 dark:text-gray-400"
},
"children": [
{
@@ -54,7 +54,7 @@
{
"type": "basic",
"name": "P",
"props": { "className": "text-body" },
"props": { "className": "text-sm text-gray-700 dark:text-gray-300" },
"text": "$t:sirsoft-gdpr.mypage.privacy.revoke_confirm_message"
},
{
@@ -73,8 +73,16 @@
"type": "basic",
"name": "Span",
"if": "{{!!_global.revokeTargetDescription}}",
"props": { "className": "block text-tertiary mt-0.5 leading-relaxed" },
"props": { "className": "block text-xs text-gray-500 dark:text-gray-400 mt-0.5 leading-relaxed" },
"text": "{{_global.revokeTargetDescription ?? ''}}"
},
{
"comment": "이슈 #430 — 철회 대상의 마지막 동의일. 사용자가 언제 동의한 것을 철회하는지 인지 (informed). status_at_formatted 를 revokeTargetDate 로 전달받음.",
"type": "basic",
"name": "Span",
"if": "{{!!_global.revokeTargetDate}}",
"props": { "className": "block text-xs text-green-600 dark:text-green-400 mt-1.5" },
"text": "$t:sirsoft-gdpr.mypage.privacy.revoke_target_consented_at|date={{_global.revokeTargetDate ?? ''}}"
}
]
},
@@ -89,7 +97,7 @@
"props": {
"type": "button",
"disabled": "{{_local.isRevoking}}",
"className": "btn btn-secondary disabled:opacity-50"
"className": "px-4 py-1.5 text-sm border border-gray-300 dark:border-gray-600 text-gray-700 dark:text-gray-300 rounded-lg hover:bg-gray-50 dark:hover:bg-gray-700 transition-colors disabled:opacity-50"
},
"actions": [
{ "type": "click", "handler": "closeModal" }
@@ -105,7 +113,7 @@
"props": {
"type": "button",
"disabled": "{{_local.isRevoking || !_global.revokeTargetKey}}",
"className": "px-4 py-2 bg-red-600 text-white rounded-lg hover:bg-red-700 font-medium transition-colors disabled:opacity-50 disabled:cursor-not-allowed"
"className": "px-4 py-1.5 text-sm bg-red-600 text-white rounded-lg hover:bg-red-700 font-medium transition-colors disabled:opacity-50 disabled:cursor-not-allowed"
},
"actions": [
{
@@ -158,6 +166,128 @@
]
}
]
},
{
"comment": "동의 확인 모달 (이슈 #430 버튼 재설계) — 거부/미설정 항목의 '동의' 버튼 클릭 시. 즉시 grant 대신 한 번 더 확인. 대상은 _global.grantTarget* (모달 컨텍스트 분리).",
"id": "grant_confirm_modal",
"type": "composite",
"name": "Modal",
"props": {
"title": "$t:sirsoft-gdpr.mypage.privacy.grant_confirm_title",
"width": "min(420px, 95vw)",
"closeOnBackdropClick": true
},
"children": [
{
"type": "basic",
"name": "Div",
"props": { "className": "space-y-4" },
"children": [
{
"type": "basic",
"name": "P",
"props": { "className": "text-sm text-gray-700 dark:text-gray-300" },
"text": "$t:sirsoft-gdpr.mypage.privacy.grant_confirm_message"
},
{
"type": "basic",
"name": "Div",
"props": { "className": "rounded-lg bg-gray-50 dark:bg-gray-700 px-3 py-2 text-sm text-gray-700 dark:text-gray-200" },
"children": [
{
"type": "basic",
"name": "Span",
"props": { "className": "block font-medium" },
"text": "$t:sirsoft-gdpr.mypage.privacy.label_suffix|label={{_global.grantTargetLabel ?? _global.grantTargetKey ?? ''}}"
},
{
"type": "basic",
"name": "Span",
"if": "{{!!_global.grantTargetDescription}}",
"props": { "className": "block text-xs text-gray-500 dark:text-gray-400 mt-0.5 leading-relaxed" },
"text": "{{_global.grantTargetDescription ?? ''}}"
}
]
},
{
"type": "basic",
"name": "Div",
"props": { "className": "flex justify-end gap-2" },
"children": [
{
"type": "basic",
"name": "Button",
"props": {
"type": "button",
"disabled": "{{_local.isGranting}}",
"className": "px-4 py-1.5 text-sm border border-gray-300 dark:border-gray-600 text-gray-700 dark:text-gray-300 rounded-lg hover:bg-gray-50 dark:hover:bg-gray-700 transition-colors disabled:opacity-50"
},
"actions": [
{ "type": "click", "handler": "closeModal" }
],
"children": [
{ "type": "basic", "name": "Span", "text": "$t:common.cancel" }
]
},
{
"type": "basic",
"name": "Button",
"props": {
"type": "button",
"disabled": "{{_local.isGranting || !_global.grantTargetKey}}",
"className": "px-4 py-1.5 text-sm bg-blue-600 text-white rounded-lg hover:bg-blue-700 font-medium transition-colors disabled:opacity-50 disabled:cursor-not-allowed"
},
"actions": [
{
"type": "click",
"handler": "sequence",
"actions": [
{
"handler": "setState",
"params": { "target": "local", "isGranting": true }
},
{
"handler": "apiCall",
"auth_required": true,
"target": "/api/plugins/sirsoft-gdpr/consent/grant",
"params": {
"method": "POST",
"body": "{{{ consent_key: _global.grantTargetKey }}}"
},
"onSuccess": [
{
"handler": "setState",
"params": { "target": "local", "isGranting": false }
},
{
"handler": "setState",
"params": { "target": "global", "grantTargetKey": null, "grantTargetLabel": null, "grantTargetDescription": null }
},
{ "handler": "refetchDataSource", "params": { "dataSourceId": "gdprMeConsents" } },
{ "handler": "refetchDataSource", "params": { "dataSourceId": "gdprMyConsents" } },
{ "handler": "sirsoft-gdpr.syncConsent" },
{ "handler": "closeModal" },
{ "handler": "toast", "params": { "type": "success", "message": "$t:sirsoft-gdpr.consent.granted_again" } }
],
"onError": [
{ "handler": "setState", "params": { "target": "local", "isGranting": false } },
{ "handler": "toast", "params": { "type": "error", "message": "{{error?.message ?? 'Error'}}" } }
]
}
]
}
],
"children": [
{ "type": "basic", "name": "Icon", "if": "{{_local.isGranting}}", "props": { "name": "spinner", "size": "sm", "spin": true, "className": "mr-1" } },
{ "type": "basic", "name": "Span", "if": "{{!_local.isGranting}}", "text": "$t:sirsoft-gdpr.mypage.privacy.grant" },
{ "type": "basic", "name": "Span", "if": "{{_local.isGranting}}", "text": "$t:sirsoft-gdpr.consent.granting" }
]
}
]
}
]
}
]
}
],
"injections": [
@@ -189,7 +319,7 @@
{
"type": "basic",
"name": "H2",
"props": { "className": "section-heading-md" },
"props": { "className": "text-base font-semibold text-gray-900 dark:text-white" },
"text": "$t:sirsoft-gdpr.mypage.privacy.title"
}
]
@@ -200,7 +330,7 @@
"type": "basic",
"name": "Div",
"if": "{{!!gdprPublicSettings?.data?.legal_entity_name || !!gdprPublicSettings?.data?.data_storage_location}}",
"props": { "className": "mb-4 text-tertiary" },
"props": { "className": "mb-4 text-xs text-gray-500 dark:text-gray-400" },
"children": [
{
"type": "basic",
@@ -233,7 +363,7 @@
{
"type": "basic",
"name": "Div",
"props": { "className": "flex-center gap-3 flex-1" },
"props": { "className": "flex items-center gap-3 flex-1" },
"children": [
{
"type": "basic",
@@ -249,14 +379,14 @@
"type": "basic",
"name": "P",
"comment": "현재 정책 버전을 노출하여 사용자가 어느 버전에 동의하는지 인지 (#23 — informed consent). G7 표준 $t:key|param={{value}} 토큰 사용 — lang 파일의 {version} placeholder 가 치환됨.",
"props": { "className": "text-warning-soft" },
"props": { "className": "text-xs text-yellow-700 dark:text-yellow-300" },
"text": "$t:sirsoft-gdpr.mypage.privacy.needs_renewal_with_version|version={{gdprMeConsents?.data?.current_policy_version ?? '-'}}"
},
{
"type": "basic",
"name": "P",
"comment": "필수 쿠키는 ePrivacy Art.5(3) 면제로 정책 갱신 대상이 아님을 명시.",
"props": { "className": "mt-1 text-warning-soft" },
"props": { "className": "mt-1 text-xs text-yellow-700 dark:text-yellow-300" },
"text": "$t:sirsoft-gdpr.mypage.privacy.needs_renewal_hint"
}
]
@@ -266,7 +396,7 @@
{
"type": "basic",
"name": "Div",
"props": { "className": "flex-center flex-wrap gap-2 sm:flex-shrink-0" },
"props": { "className": "flex items-center flex-wrap gap-2 sm:flex-shrink-0" },
"children": [
{
"type": "basic",
@@ -317,24 +447,24 @@
"id": "gdpr_section_consents",
"type": "basic",
"name": "Div",
"comment": "내 동의 현황 — 회원 활성 동의 (status) 기반",
"props": { "className": "toggle-group" },
"comment": "내 동의 현황 — 회원 활성 동의 (status) 기반. admin 전용 toggle-group 클래스 → 공통 border/rounded 로 치환 (user 템플릿 미해석 회귀 수정, 이슈 #430).",
"props": { "className": "border border-gray-200 dark:border-gray-700 rounded-lg overflow-hidden" },
"children": [
{
"type": "basic",
"name": "Div",
"props": { "className": "px-4 bg-gray-50 dark:bg-gray-700/50" },
"props": { "className": "px-4 py-3 bg-gray-50 dark:bg-gray-700/50" },
"children": [
{
"type": "basic",
"name": "H3",
"props": { "className": "text-primary text-sm font-semibold" },
"props": { "className": "text-gray-900 dark:text-white text-sm font-semibold" },
"text": "$t:sirsoft-gdpr.mypage.privacy.section_consents"
},
{
"type": "basic",
"name": "P",
"props": { "className": "form-hint" },
"props": { "className": "text-xs text-gray-500 dark:text-gray-400 mt-1" },
"text": "$t:sirsoft-gdpr.mypage.privacy.section_consents_hint"
}
]
@@ -343,11 +473,11 @@
"type": "basic",
"name": "Div",
"if": "{{(gdprMeConsents?.data?.consents ?? []).length === 0}}",
"props": { "className": "py-10 text-center text-label-subtle" },
"props": { "className": "py-10 text-center text-sm text-gray-500 dark:text-gray-400" },
"text": "$t:sirsoft-gdpr.mypage.privacy.no_consents"
},
{
"comment": "「모두 켜기」 일괄 동의 바 — 선택형(is_required=false) 중 꺼진(is_consented=false) 항목이 하나라도 있을 때만 노출. 필수는 대상 외. renew-all 이 아니라 신규/재동의 축이므로 grant 를 항목별로 반복 호출하는 대신, 서버 renew-all 은 '이미 활성 항목의 정책 갱신' 전용이라 여기서는 각 꺼진 선택형 항목을 grant 로 순차 켠다. 다만 레이아웃 반복 호출은 표현이 어렵기에, 배너의 '모두 동의' 와 동일하게 consent/cookie(intent 없음, 전체 true) 로 한 번에 처리.",
"comment": "「모두 동의」 일괄 동의 바 — 선택형(is_required=false) 중 미동의(is_consented=false) 항목이 하나라도 있을 때만 노출. 필수는 대상 외. renew-all 이 아니라 신규/재동의 축이므로 grant 를 항목별로 반복 호출하는 대신, 서버 renew-all 은 '이미 활성 항목의 정책 갱신' 전용이라 여기서는 각 미동의 선택형 항목을 grant 로 순차 처리한다. 다만 레이아웃 반복 호출은 표현이 어렵기에, 배너의 '모두 동의' 와 동일하게 consent/cookie(intent 없음, 전체 true) 로 한 번에 처리.",
"type": "basic",
"name": "Div",
"if": "{{(gdprMeConsents?.data?.consents ?? []).filter(c => c?.is_required !== true && c?.is_consented !== true).length > 0}}",
@@ -404,7 +534,7 @@
]
},
{
"comment": "토글 리스트 (이슈 #430 재설계) — 업계 표준 CMP(OneTrust/Cookiebot) 패턴: 필수=잠긴 '항상 켜짐', 선택=on/off 스위치. 동의일 컬럼은 사용자 화면에서 제거(감사 로그/관리자 화면에만 존재). 스위치는 Checkbox/Toggle 컴포넌트 부재로 클릭 가능한 Div 로 구현 — 필수는 클릭 액션 없이 시각적 잠금.",
"comment": "항목 리스트 (이슈 #430 재설계) — 상태 배지 + 동의/철회 버튼 방식. 필수=상태 배지 '항상 적용' + 잠금 버튼(액션 없음), 선택=상태 배지(동의함/거부함/미설정) + 동의·철회 버튼(확인 모달 경유). 동의일 컬럼은 사용자 화면에서 제거(동의한 항목만 라벨 아래 날짜 표시, 감사 로그 전체는 관리자 화면에만 존재). 초기 설계였던 on/off 스위치는 user 템플릿 스타일 회귀 + PO 지시로 배지+버튼 방식으로 대체됨(2026-07-21).",
"type": "basic",
"name": "Div",
"if": "{{(gdprMeConsents?.data?.consents ?? []).length > 0}}",
@@ -418,7 +548,7 @@
{
"type": "basic",
"name": "Div",
"props": { "className": "flex items-center justify-between gap-4 px-4 py-3" },
"props": { "className": "flex items-center justify-between gap-4 px-4 py-4" },
"children": [
{
"type": "basic",
@@ -429,13 +559,14 @@
{
"type": "basic",
"name": "Div",
"props": { "className": "flex items-center gap-2" },
"props": { "className": "flex items-center gap-2 flex-wrap" },
"children": [
{
"comment": "라벨 뒤에 '쿠키' 접미사 (이슈 #430) — label_suffix='{label} 쿠키'. 운영자 카탈로그 라벨이 '기능' 이어도 화면엔 '기능 쿠키' 로 노출.",
"type": "basic",
"name": "Span",
"props": { "className": "text-primary font-medium text-sm" },
"text": "{{consent?.consent_label ?? consent?.consent_key ?? ''}}"
"props": { "className": "text-gray-900 dark:text-white font-medium text-sm" },
"text": "$t:sirsoft-gdpr.mypage.privacy.label_suffix|label={{consent?.consent_label ?? consent?.consent_key ?? ''}}"
},
{
"type": "basic",
@@ -443,6 +574,13 @@
"if": "{{consent?.is_required === true}}",
"props": { "className": "inline-flex items-center px-1.5 py-0.5 rounded text-xs font-medium bg-gray-100 dark:bg-gray-700 text-gray-500 dark:text-gray-400" },
"text": "$t:sirsoft-gdpr.mypage.privacy.required_label"
},
{
"comment": "이슈 #430 (3안) — 상태 배지를 라벨 옆으로. 서버 status_badge_label (필수=항상 적용 / 동의함 / 거부함 / 미설정). status 로 색 분기.",
"type": "basic",
"name": "Span",
"props": { "className": "inline-flex items-center px-2.5 py-0.5 rounded-full text-xs font-semibold {{consent?.status === 'consented' ? 'bg-green-50 text-green-700 dark:bg-green-900/30 dark:text-green-300' : (consent?.status === 'required' ? 'bg-blue-50 text-blue-700 dark:bg-blue-900/30 dark:text-blue-300' : 'bg-gray-100 text-gray-500 dark:bg-gray-700 dark:text-gray-400')}}" },
"text": "{{consent?.status_badge_label ?? ''}}"
}
]
},
@@ -450,129 +588,106 @@
"type": "basic",
"name": "Span",
"if": "{{!!consent?.consent_description}}",
"props": { "className": "block text-tertiary mt-0.5 text-xs leading-relaxed" },
"props": { "className": "block text-xs text-gray-500 dark:text-gray-400 mt-1 leading-relaxed" },
"text": "{{consent?.consent_description ?? ''}}"
},
{
"comment": "이슈 #430 (3안) — 라벨 아래 이력 줄: '날짜 + 동의'. 상태는 이미 라벨 옆 배지가 말하므로 여기선 시점만 강조. 서버가 동의한 항목만 status_label·status_at_formatted 를 채워 내려주므로(거부/미설정은 null) 둘 다 있을 때만 렌더.",
"type": "basic",
"name": "Div",
"if": "{{!!consent?.status_label && !!consent?.status_at_formatted}}",
"props": { "className": "mt-1.5 text-xs text-gray-400 dark:text-gray-500" },
"children": [
{ "type": "basic", "name": "Span", "text": "{{consent?.status_at_formatted ?? ''}}" },
{ "type": "basic", "name": "Span", "props": { "className": "ml-1" }, "text": "{{consent?.status_label ?? ''}}" }
]
}
]
},
{
"comment": "이슈 #430 (3안) — 오른쪽 클러스터: 단일 액션 버튼만. 상태 배지는 라벨 옆으로 이동. 필수=잠금버튼(액션X), 동의함=철회버튼(철회 모달), 그 외=동의버튼(동의 모달).",
"type": "basic",
"name": "Div",
"props": { "className": "shrink-0 flex items-center gap-2" },
"props": { "className": "shrink-0 flex items-center" },
"children": [
{
"comment": "필수 카테고리 — 잠긴 '항상 켜짐' 스위치. 클릭 액션 없음(철회 불가, ePrivacy Art.5(3) 면제). 파란 채움 + 오른쪽 knob + not-allowed 커서로 잠금 표현.",
"comment": "필수 — 잠금 버튼 (비활성, 액션 없음). ePrivacy Art.5(3) 면제.",
"type": "basic",
"name": "Div",
"name": "Button",
"if": "{{consent?.is_required === true}}",
"props": { "className": "flex items-center gap-2" },
"props": {
"type": "button",
"disabled": true,
"className": "inline-flex items-center gap-1.5 px-3 py-1.5 rounded-lg text-xs font-medium border border-gray-200 dark:border-gray-700 text-gray-400 dark:text-gray-500 cursor-not-allowed"
},
"children": [
{
"type": "basic",
"name": "Span",
"props": { "className": "text-xs font-medium text-gray-500 dark:text-gray-400" },
"text": "$t:sirsoft-gdpr.mypage.privacy.always_on"
},
{
"type": "basic",
"name": "Div",
"props": { "className": "relative inline-flex h-6 w-11 items-center rounded-full bg-blue-600/60 dark:bg-blue-500/60 cursor-not-allowed" },
"children": [
{ "type": "basic", "name": "Icon", "props": { "name": "lock", "size": "xs", "className": "absolute left-1.5 text-white/80" } },
{ "type": "basic", "name": "Span", "props": { "className": "inline-block h-4 w-4 translate-x-6 rounded-full bg-white shadow transition-transform" } }
]
}
{ "type": "basic", "name": "Icon", "props": { "name": "lock", "size": "xs" } },
{ "type": "basic", "name": "Span", "text": "$t:sirsoft-gdpr.mypage.privacy.locked_label" }
]
},
{
"comment": "선택형 카테고리 — on/off 스위치. 켜짐(is_consented=true)이면 녹색+revoke 확인 모달, 꺼짐이면 회색+grant 즉시 호출. grantingKey 로 해당 행만 처리 중 표시.",
"comment": "동의함(선택) — 철회 버튼. 클릭 시 철회 확인 모달 (즉시 철회 아님, 오조작 방지).",
"type": "basic",
"name": "Div",
"if": "{{consent?.is_required !== true}}",
"props": { "className": "flex items-center gap-2" },
"children": [
"name": "Button",
"if": "{{consent?.is_required !== true && consent?.is_consented === true}}",
"props": {
"type": "button",
"aria-label": "{{consent?.consent_label ?? consent?.consent_key}}",
"className": "inline-flex items-center px-3 py-1.5 rounded-lg text-xs font-semibold border border-red-200 dark:border-red-800 text-red-600 dark:text-red-400 hover:bg-red-50 dark:hover:bg-red-900/20 transition-colors"
},
"actions": [
{
"type": "basic",
"name": "Span",
"props": { "className": "text-xs font-medium {{consent?.is_consented ? 'text-green-600 dark:text-green-400' : 'text-gray-400 dark:text-gray-500'}}" },
"text": "{{consent?.is_consented ? '$t:sirsoft-gdpr.mypage.privacy.toggle_on' : '$t:sirsoft-gdpr.mypage.privacy.toggle_off'}}"
},
{
"comment": "켜짐 상태 스위치 — 클릭 시 철회 확인 모달. 녹색 채움 + knob 오른쪽.",
"type": "basic",
"name": "Button",
"if": "{{consent?.is_consented === true}}",
"props": {
"type": "button",
"aria-label": "{{consent?.consent_label ?? consent?.consent_key}}",
"className": "relative inline-flex h-6 w-11 items-center rounded-full bg-green-500 dark:bg-green-600 transition-colors focus:outline-none focus:ring-2 focus:ring-green-400 focus:ring-offset-1"
},
"type": "click",
"handler": "sequence",
"actions": [
{
"type": "click",
"handler": "sequence",
"actions": [
{
"handler": "setState",
"params": {
"target": "global",
"revokeTargetKey": "{{consent?.consent_key}}",
"revokeTargetLabel": "{{consent?.consent_label ?? consent?.consent_key}}",
"revokeTargetDescription": "{{consent?.consent_description ?? ''}}"
}
},
{ "handler": "openModal", "target": "revoke_confirm_modal" }
]
}
],
"children": [
{ "type": "basic", "name": "Span", "props": { "className": "inline-block h-4 w-4 translate-x-6 rounded-full bg-white shadow transition-transform" } }
]
},
{
"comment": "꺼짐 상태 스위치 — 클릭 시 즉시 grant. 회색 채움 + knob 왼쪽. 정책 갱신 항목도 별도 색 분기 없이 grant 로 통합(정책 갱신도 결국 동의 표명, grant 는 항상 현재 정책 버전 기록).",
"type": "basic",
"name": "Button",
"if": "{{consent?.is_consented !== true}}",
"props": {
"type": "button",
"aria-label": "{{consent?.consent_label ?? consent?.consent_key}}",
"disabled": "{{_local.grantingKey === consent?.consent_key}}",
"className": "relative inline-flex h-6 w-11 items-center rounded-full bg-gray-300 dark:bg-gray-600 transition-colors focus:outline-none focus:ring-2 focus:ring-blue-400 focus:ring-offset-1 disabled:opacity-50 disabled:cursor-wait"
},
"actions": [
{
"type": "click",
"handler": "sequence",
"actions": [
{ "handler": "setState", "params": { "target": "local", "grantingKey": "{{consent?.consent_key}}" } },
{
"handler": "apiCall",
"auth_required": true,
"target": "/api/plugins/sirsoft-gdpr/consent/grant",
"params": {
"method": "POST",
"body": "{{{ consent_key: consent?.consent_key }}}"
},
"onSuccess": [
{ "handler": "setState", "params": { "target": "local", "grantingKey": null } },
{ "handler": "refetchDataSource", "params": { "dataSourceId": "gdprMeConsents" } },
{ "handler": "refetchDataSource", "params": { "dataSourceId": "gdprMyConsents" } },
{ "handler": "sirsoft-gdpr.syncConsent" },
{ "handler": "toast", "params": { "type": "success", "message": "$t:sirsoft-gdpr.consent.granted_again" } }
],
"onError": [
{ "handler": "setState", "params": { "target": "local", "grantingKey": null } },
{ "handler": "toast", "params": { "type": "error", "message": "{{error?.message ?? 'Error'}}" } }
]
}
]
}
],
"children": [
{ "type": "basic", "name": "Span", "props": { "className": "inline-block h-4 w-4 translate-x-1 rounded-full bg-white shadow transition-transform" } }
"handler": "setState",
"params": {
"target": "global",
"revokeTargetKey": "{{consent?.consent_key}}",
"revokeTargetLabel": "{{consent?.consent_label ?? consent?.consent_key}}",
"revokeTargetDescription": "{{consent?.consent_description ?? ''}}",
"revokeTargetDate": "{{consent?.status_at_formatted ?? ''}}"
}
},
{ "handler": "openModal", "target": "revoke_confirm_modal" }
]
}
],
"children": [
{ "type": "basic", "name": "Span", "text": "$t:sirsoft-gdpr.mypage.privacy.revoke" }
]
},
{
"comment": "거부함/미설정(선택) — 동의 버튼. 클릭 시 동의 확인 모달 (신규, 즉시 grant 아님).",
"type": "basic",
"name": "Button",
"if": "{{consent?.is_required !== true && consent?.is_consented !== true}}",
"props": {
"type": "button",
"aria-label": "{{consent?.consent_label ?? consent?.consent_key}}",
"className": "inline-flex items-center px-3 py-1.5 rounded-lg text-xs font-semibold bg-blue-600 text-white hover:bg-blue-700 transition-colors"
},
"actions": [
{
"type": "click",
"handler": "sequence",
"actions": [
{
"handler": "setState",
"params": {
"target": "global",
"grantTargetKey": "{{consent?.consent_key}}",
"grantTargetLabel": "{{consent?.consent_label ?? consent?.consent_key}}",
"grantTargetDescription": "{{consent?.consent_description ?? ''}}"
}
},
{ "handler": "openModal", "target": "grant_confirm_modal" }
]
}
],
"children": [
{ "type": "basic", "name": "Span", "text": "$t:sirsoft-gdpr.mypage.privacy.grant" }
]
}
]
@@ -528,11 +528,14 @@ describe('extensions/cookie_banner.json — 쿠키 동의 배너', () => {
expect(text).toContain('sirsoft-gdpr.banner.storage_only_line|location=');
});
it('푸터 라인은 시각적 무게 최소화 — 작은 보조 텍스트 시맨틱 + 상단 구분선', () => {
it('푸터 라인은 시각적 무게 최소화 — 작은 보조 텍스트 (공통 Tailwind 코어 클래스) + 상단 구분선', () => {
// 동의 행위 자체에 시선이 가도록 운영 주체는 부드러운 보조 정보로 처리.
// 작은 회색 텍스트 톤은 표준 시맨틱(.text-tertiary)으로 통일 (#399).
// 이슈 #430 — 배너는 user 페이지에 렌더되므로 admin 전용 시맨틱(.text-tertiary)은 미해석.
// 동등한 공통 Tailwind 코어 클래스로 치환 (회귀 수정).
const className = (footer?.props as { className?: string })?.className ?? '';
expect(className).toContain('text-tertiary');
expect(className).toContain('text-xs');
expect(className).toContain('text-gray-500');
expect(className).not.toContain('text-tertiary');
expect(className).toContain('border-t');
});
});
@@ -143,10 +143,13 @@ describe('extensions/mypage_privacy_tab.json — 마이페이지 GDPR 동의 매
expect(text).toContain('sirsoft-gdpr.mypage.privacy.storage_only_meta|location=');
});
it('시각적 무게 최소화 — 작은 보조 텍스트 시맨틱', () => {
// 작은 회색 텍스트 톤은 표준 시맨틱(.text-tertiary)으로 통일 (#399).
it('시각적 무게 최소화 — 작은 보조 텍스트 (공통 Tailwind 코어 클래스)', () => {
// 이슈 #430 — 이 카드는 user 페이지(sirsoft-basic)에 렌더되므로 admin 전용 시맨틱(.text-tertiary)은
// CSS 미해석. 동등한 공통 Tailwind 코어 클래스로 치환 (회귀 수정).
const className = (meta?.props as { className?: string })?.className ?? '';
expect(className).toContain('text-tertiary');
expect(className).toContain('text-xs');
expect(className).toContain('text-gray-500');
expect(className).not.toContain('text-tertiary');
});
});
@@ -157,6 +160,21 @@ describe('extensions/mypage_privacy_tab.json — 마이페이지 GDPR 동의 매
expect(modal?.name).toBe('Modal');
});
it('이슈 #430 — grant_confirm_modal(동의 확인 모달)이 modals 배열에 포함', () => {
const modal = (root.modals ?? []).find((m) => m.id === 'grant_confirm_modal');
expect(modal).toBeTruthy();
expect(modal?.name).toBe('Modal');
const text = serializeForSearch(modal);
// 동의 확인 문구 + grant API + 대상 _global.grantTargetKey
expect(text).toContain('mypage.privacy.grant_confirm_message');
expect(text).toContain('"target": "/api/plugins/sirsoft-gdpr/consent/grant"');
expect(text).toContain('_global.grantTargetKey');
// 확인 후 refetch + syncConsent + closeModal
expect(text).toContain('"dataSourceId": "gdprMeConsents"');
expect(text).toContain('"handler": "sirsoft-gdpr.syncConsent"');
expect(text).toContain('"handler": "closeModal"');
});
it('제거된 데이터 요청·자가 취소 모달은 존재하지 않는다', () => {
const ids = (root.modals ?? []).map((m) => m.id);
expect(ids).not.toContain('gdpr_data_request_modal');
@@ -203,6 +221,8 @@ describe('extensions/mypage_privacy_tab.json — 마이페이지 GDPR 동의 매
// raw key (cookie_functional 등) 대신 사용자 친화 description 을 모달에 표시하기 위해
// 행 핸들러에서 consent_description 을 _global 에 세팅한다.
expect(text).toContain('"revokeTargetDescription": "{{consent?.consent_description ?? \'\'}}"');
// 이슈 #430 — 철회 모달에서 마지막 동의일을 보여주기 위해 status_at_formatted 를 _global 로 전달.
expect(text).toContain('"revokeTargetDate": "{{consent?.status_at_formatted ?? \'\'}}"');
});
it('동의 항목 컬럼이 라벨 우선 표시 (consent_label fallback consent_key)', () => {
@@ -233,6 +253,13 @@ describe('extensions/mypage_privacy_tab.json — 마이페이지 GDPR 동의 매
expect(text).not.toContain('font-mono break-all');
});
it('이슈 #430 — 모달에 철회 대상의 마지막 동의일 노출 (revokeTargetDate 있을 때만)', () => {
const text = serializeForSearch(modal);
// 사용자가 언제 동의한 것을 철회하는지 인지하도록 마지막 동의일을 표시.
expect(text).toContain('_global.revokeTargetDate');
expect(text).toContain('sirsoft-gdpr.mypage.privacy.revoke_target_consented_at|date=');
});
it('확인 버튼 → POST /consent/revoke + onSuccess 에 refetch + closeModal + toast', () => {
const text = serializeForSearch(modal);
expect(text).toContain('"target": "/api/plugins/sirsoft-gdpr/consent/revoke"');
@@ -270,77 +297,102 @@ describe('extensions/mypage_privacy_tab.json — 마이페이지 GDPR 동의 매
/**
* @scenario entry=reject, subject=member, category=required
* @effects mypage_no_consent_date_column_for_user
* @effects mypage_status_date_line_per_row
*/
it('사용자 화면에 동의일 컬럼이 없다 (감사/관리자 전용) — col_consented_at / col_action 헤더 제거', () => {
// 재설계 회귀 가드: 표 헤더(col_consent_key/col_consented/col_consented_at/col_action) 전면 제거.
// 동의일은 GDPR 감사 로그·관리자 화면에만 존재하고 사용자 토글 화면엔 노출하지 않음.
it('옛 표 헤더 컬럼 방식은 미사용 (col_consented_at / col_action 헤더 없음)', () => {
// 회귀 가드: 재설계로 표 헤더(col_consent_key/col_consented/col_consented_at/col_action) 방식은 제거.
// 날짜는 컬럼이 아니라 각 행의 상태별 한 줄(status_at_formatted)로 노출한다.
const text = serializeForSearch(section);
expect(text).not.toContain('mypage.privacy.col_consented_at');
expect(text).not.toContain('mypage.privacy.col_action');
// 행 단위 consented_at 바인딩도 사용자 화면에서 제거
expect(text).not.toContain('consent?.consented_at');
});
/**
* @scenario entry=reject, subject=member, category=optional
* @effects mypage_status_date_line_consented_only
*/
it('이슈 #430 — 동의한 항목만 날짜 줄 노출 (서버가 동의 상태에만 status_at_formatted 제공)', () => {
// PO 결정(2026-07-20): 날짜는 "동의한 항목만". 거부·철회·미설정은 서버가 status_at_formatted 를
// null 로 내려주므로 날짜 줄이 렌더되지 않는다. 프론트는 status_label && status_at_formatted 가 둘 다
// 있을 때만 날짜 줄을 그린다.
const text = serializeForSearch(section);
expect(text).toContain('consent?.status_label');
expect(text).toContain('consent?.status_at_formatted');
// 날짜 줄은 둘 다 있을 때만 (거부/미설정은 null → 미노출)
expect(text).toContain('!!consent?.status_label && !!consent?.status_at_formatted');
});
/**
* @scenario entry=reject, subject=member, category=required
* @effects mypage_required_shows_locked_always_on_toggle
* @effects mypage_required_shows_locked_button
*/
it('필수 카테고리 — 잠긴 「항상 켜짐」 토글 (액션 없음, lock 아이콘 + not-allowed)', () => {
it('필수 카테고리 — 상태 배지 + 잠금 버튼 (액션 없음, lock 아이콘 + not-allowed)', () => {
const text = serializeForSearch(section);
expect(text).toContain('consent?.is_required === true');
expect(text).toContain('mypage.privacy.always_on');
// 잠금 시각 표현: lock 아이콘 + not-allowed 커서
// 상태 배지는 서버 status_badge_label 사용
expect(text).toContain('consent?.status_badge_label');
// 잠금 버튼: lock 아이콘 + not-allowed + locked_label
expect(text).toContain('"name": "lock"');
expect(text).toContain('cursor-not-allowed');
// 필수 행에는 required_label 배지도 노출
expect(text).toContain('mypage.privacy.locked_label');
// 필수 행 라벨 옆 required_label 배지도 유지
expect(text).toContain('mypage.privacy.required_label');
});
/**
* @scenario entry=reject, subject=member, category=optional
* @effects mypage_optional_shows_on_off_toggle
* @effects mypage_optional_consented_shows_revoke_button
*/
it('선택형 켜짐(is_consented) — 녹색 토글 + 「켜짐」 라벨, 클릭 시 철회 확인 모달', () => {
it('선택형 동의함 — 철회 버튼, 클릭 시 철회 확인 모달 (즉시 철회 아님)', () => {
const text = serializeForSearch(section);
expect(text).toContain('consent?.is_consented === true');
expect(text).toContain('mypage.privacy.toggle_on');
// 켜짐 토글은 녹색
expect(text).toContain('bg-green-500');
// 클릭 시 철회 확인 모달 오픈 (즉시 철회 아님 — 오조작 방지)
expect(text).toContain('consent?.is_required !== true && consent?.is_consented === true');
expect(text).toContain('mypage.privacy.revoke');
// 클릭 시 철회 확인 모달 오픈 + 대상 키를 global 로 세팅
expect(text).toContain('"target": "revoke_confirm_modal"');
expect(text).toContain('"revokeTargetKey"');
});
it('선택형 꺼짐(!is_consented) — 회색 토글 + 「꺼짐」 라벨, 클릭 시 즉시 grant', () => {
/**
* @scenario entry=reject, subject=member, category=optional
* @effects mypage_optional_unset_shows_grant_button
*/
it('선택형 거부함/미설정 — 동의 버튼, 클릭 시 동의 확인 모달 (즉시 grant 아님)', () => {
const text = serializeForSearch(section);
expect(text).toContain('consent?.is_consented !== true');
expect(text).toContain('mypage.privacy.toggle_off');
// 꺼짐 토글은 회색
expect(text).toContain('bg-gray-300');
// 클릭 시 POST /consent/grant
expect(text).toContain('"target": "/api/plugins/sirsoft-gdpr/consent/grant"');
expect(text).toContain('consent?.is_required !== true && consent?.is_consented !== true');
expect(text).toContain('mypage.privacy.grant');
// 토글 즉시 grant 가 아니라 동의 확인 모달 경유 (grant_confirm_modal)
expect(text).toContain('"target": "grant_confirm_modal"');
expect(text).toContain('grantTargetKey');
});
it('grant onSuccess 에서 refetch + syncConsent + 토스트 호출', () => {
// 회귀 가드: 꺼짐→켜짐 시 interceptor functionalConsented 즉시 갱신 (동의 즉시성).
it('이슈 #430 (3안) — 상태 배지는 라벨 줄에, 날짜 줄은 날짜+동의 순서 (배지↔날짜 동의 중복 제거)', () => {
const text = serializeForSearch(section);
expect(text).toContain('"dataSourceId": "gdprMeConsents"');
const matches = text.match(/"handler":\s*"sirsoft-gdpr\.syncConsent"/g) ?? [];
expect(matches.length).toBeGreaterThanOrEqual(1);
// 배지가 라벨 옆 flex-wrap 줄에 위치 (라벨 label_suffix 와 같은 컨테이너)
expect(text).toContain('items-center gap-2 flex-wrap');
expect(text).toContain('consent?.status_badge_label');
// 날짜 줄은 날짜가 먼저, 그 뒤에 동의 라벨 (동사 중복 회피 — 상태는 배지가 말함)
const idxDate = text.indexOf('status_at_formatted');
const idxLabelAfter = text.indexOf('status_label', idxDate);
expect(idxDate).toBeGreaterThan(-1);
expect(idxLabelAfter).toBeGreaterThan(idxDate);
});
it('꺼짐 토글에 grantingKey 비교 disabled — 처리 중 중복 클릭 차단', () => {
it('「켜짐/꺼짐」 토글 표현 및 스위치 마크업이 부활하지 않는다 (회귀 가드)', () => {
// 토글 제거 회귀 가드: user 템플릿 w-11 safelist 붕괴 + '켜짐/꺼짐' 표현 어색함으로 버튼 전환.
const text = serializeForSearch(section);
expect(text).toContain("_local.grantingKey === consent?.consent_key");
expect(text).not.toContain('mypage.privacy.toggle_on');
expect(text).not.toContain('mypage.privacy.toggle_off');
// 스위치 knob 마크업(translate-x-6 / translate-x-1 + rounded-full 스위치 트랙)이 없어야 함
expect(text).not.toContain('h-6 w-11');
});
/**
* @scenario entry=reject, subject=member, category=optional
* @effects mypage_enable_all_bar_when_optional_off
*/
it('꺼진 선택 항목이 있을 때만 「모두 켜기」 바 노출 + POST /consent/cookie 로 일괄 동의', () => {
it('동의 안 한 선택 항목이 있을 때만 「모두 동의」 바 노출 + POST /consent/cookie 로 일괄 동의', () => {
const text = serializeForSearch(section);
// 노출 조건: 선택형(is_required !== true) 중 꺼진(is_consented !== true) 항목 존재
// 노출 조건: 선택형(is_required !== true) 중 미동의(is_consented !== true) 항목 존재
expect(text).toContain("c?.is_required !== true && c?.is_consented !== true");
expect(text).toContain('mypage.privacy.enable_all');
expect(text).toContain('mypage.privacy.enable_all_hint');
@@ -350,12 +402,15 @@ describe('extensions/mypage_privacy_tab.json — 마이페이지 GDPR 동의 매
expect(text).toContain('mypage.privacy.enable_all_success');
});
it('제거된 표 배지/버튼 구조가 부활하지 않는다 (회귀 가드)', () => {
// 재설계로 상태 배지(bg-amber-100)·철회 빨간 버튼(bg-red-600 버튼)·can_grant/can_revoke 분기가
// 토글로 대체됨. can_grant/can_revoke 메타는 서버 Resource 에 남아있으나 레이아웃은 미참조.
it('grant/revoke onSuccess 에서 refetch + syncConsent 호출 (동의 즉시성)', () => {
// 회귀 가드: 동의/철회 시 interceptor 즉시 갱신 — 모달의 sequence onSuccess 에 syncConsent 존재.
const text = serializeForSearch(root);
const matches = text.match(/"handler":\s*"sirsoft-gdpr\.syncConsent"/g) ?? [];
expect(matches.length).toBeGreaterThanOrEqual(2);
});
it('제거된 amber 갱신 분기 / rejected_label 이 부활하지 않는다 (회귀 가드)', () => {
const text = serializeForSearch(section);
expect(text).not.toContain('consent?.can_revoke === true');
expect(text).not.toContain('consent?.can_grant === true');
expect(text).not.toContain('mypage.privacy.rejected_label');
expect(text).not.toContain('needs_renewal_this_item');
});
@@ -271,16 +271,18 @@
"revoke": "Revoke",
"grant": "Consent",
"grant_again": "Consent Again",
"always_on": "Always On",
"toggle_on": "On",
"toggle_off": "Off",
"enable_all": "Enable All",
"enable_all_hint": "You have optional items turned off. Enable them all at once.",
"enable_all_success": "All optional items have been enabled.",
"label_suffix": "{label} cookies",
"locked_label": "Required",
"enable_all": "Consent to all",
"enable_all_hint": "You have optional items you haven't consented to. Consent to them all at once.",
"enable_all_success": "You have consented to all optional items.",
"required_label": "Required",
"required_hint": "This item is required for service operation and cannot be revoked.",
"grant_confirm_title": "Confirm Cookie Consent",
"grant_confirm_message": "Do you want to consent to this cookie? Once consented, this category's cookies will be used, and you can revoke it anytime.",
"revoke_confirm_title": "Revoke Consent",
"revoke_confirm_message": "Are you sure you want to revoke this consent? Revoking consent may limit features related to that category.",
"revoke_target_consented_at": "Consented · {date}",
"no_consents": "No active consent items.",
"needs_renewal": "The cookie policy has been updated. Please renew your consent.",
"needs_renewal_with_version": "The cookie policy has been updated to version {version}. Please review the optional consent items.",
@@ -271,16 +271,18 @@
"revoke": "철회",
"grant": "동의",
"grant_again": "다시 동의",
"always_on": "항상 켜짐",
"toggle_on": "켜짐",
"toggle_off": "꺼짐",
"enable_all": "모두 켜기",
"enable_all_hint": "동의하지 않은 선택 항목이 있습니다. 한 번에 모두 켤 수 있습니다.",
"enable_all_success": "선택 항목을 모두 켰습니다.",
"label_suffix": "{label} 쿠키",
"locked_label": "필수",
"enable_all": "모두 동의",
"enable_all_hint": "동의하지 않은 선택 항목이 있습니다. 한 번에 모두 동의할 수 있습니다.",
"enable_all_success": "선택 항목에 모두 동의했습니다.",
"required_label": "필수",
"required_hint": "서비스 제공에 필수적이라 철회할 수 없습니다.",
"grant_confirm_title": "쿠키 동의 확인",
"grant_confirm_message": "이 쿠키에 동의하시겠습니까? 동의하면 해당 카테고리의 쿠키가 사용되며, 언제든 다시 철회할 수 있습니다.",
"revoke_confirm_title": "동의 철회 확인",
"revoke_confirm_message": "이 항목을 철회하시겠습니까? 동의를 철회하면 해당 카테고리 관련 기능이 제한될 수 있습니다.",
"revoke_target_consented_at": "동의 · {date}",
"no_consents": "활성 동의 항목이 없습니다.",
"needs_renewal": "쿠키 정책이 변경되었습니다. 동의를 갱신해주세요.",
"needs_renewal_with_version": "쿠키 정책이 버전 {version} 으로 변경되었습니다. 선택 항목의 동의를 다시 확인해주세요.",
@@ -39,6 +39,39 @@ class GdprUserConsentResource extends BaseApiResource
// 선택형 항목 중 정책 버전이 옛 버전인지 — 필수는 ePrivacy Art.5(3) 면제로 갱신 대상 아님.
$needsRenewalThisItem = ! $isRequired && $isConsented && $policyVersion !== '' && $policyVersion !== $currentPolicyVersion;
// 이슈 #430 — 마이페이지 「내 동의 현황」 각 행의 상태를 서버가 판정한다.
// 상태 판정: 필수 → required(동의), 선택 동의중 → consented(동의),
// 선택 명시 거부 → rejected(거부), 선택 철회 이력 → revoked(철회), 그 외(신규 미선택) → none.
if ($isRequired) {
$status = 'required';
} elseif ($isConsented) {
$status = 'consented';
} elseif ((bool) $this->is_rejected) {
$status = 'rejected';
} elseif ($this->revoked_at !== null) {
$status = 'revoked';
} else {
$status = 'none';
}
// 표시 날짜/라벨은 "동의한 항목만" 노출한다 (PO 결정, 2026-07-20).
// 동의 상태(required·consented)만 동의일 + '동의' 라벨을 내려주고,
// 거부·철회·미선택은 status_label·status_at_formatted 를 null 로 두어 프론트가 날짜 줄을 렌더하지 않는다.
// (거부일·철회일은 사용자 화면 확인 가치가 낮고, 감사 로그·관리자 화면에서 확인 가능)
$isConsentState = $status === 'required' || $status === 'consented';
$statusRawDate = $isConsentState ? $this->consented_at : null;
$statusLabel = $isConsentState
? __('sirsoft-gdpr::messages.mypage.privacy.status.granted')
: null;
// 이슈 #430 (버튼 재설계) — 상태 배지 문구. 토글 대신 배지+단일버튼 UI 에서
// 오른쪽 배지에 노출한다. 철회 이력(revoked)과 신규 미선택(none)은 '미설정'으로 통합.
$statusBadgeKey = match ($status) {
'required' => 'required',
'consented' => 'consented',
'rejected' => 'rejected',
default => 'unset', // revoked, none
};
$statusBadgeLabel = __('sirsoft-gdpr::messages.mypage.privacy.badge.'.$statusBadgeKey);
return [
'id' => $this->id,
'consent_key' => $consentKey,
@@ -56,6 +89,13 @@ class GdprUserConsentResource extends BaseApiResource
// 비활성 (철회 또는 신규) → 다시 동의 (기존 동작).
'can_grant' => ! $isRequired && (! $isConsented || $needsRenewalThisItem),
'needs_renewal_this_item' => $needsRenewalThisItem,
// 이슈 #430 — 상태별 단일 표시 필드. 프론트는 status 로 색만 분기하고 나머지는 그대로 렌더.
'status' => $status,
'status_label' => $statusLabel,
'status_badge_label' => $statusBadgeLabel,
'status_at_formatted' => $statusRawDate !== null
? $this->formatDateTimeStringForUser($statusRawDate)
: null,
'consented_at' => $this->formatDateTimeStringForUser($this->consented_at),
'revoked_at' => $this->formatDateTimeStringForUser($this->revoked_at),
'consent_count' => (int) $this->consent_count,
@@ -157,9 +157,10 @@ class CookieCategoryService
/**
* consent_key 에 대응하는 사용자 친화 설명을 현재 locale 기준으로 반환합니다.
*
* 마이페이지 「내 동의 현황」 의 동의 항목 컬럼에서 영문 식별자 대신 회원이
* 즉시 이해할 수 있는 한 줄 설명을 노출하기 위함. 카탈로그에 매칭되는 카테고리가
* 없거나 설명이 비어 있으면 null 반환 — 호출 측이 fallback 처리.
* 설명(description)은 관리자 설정 화면에 편집 UI 가 없어(라벨만 편집 가능) 운영자가
* 카테고리를 저장하면 description 이 유실된다. 따라서 설명은 관리자 설정(getCategories)이
* 아니라 항상 코드 기본값(getDefaultCategories)에서 가져온다 — 운영자 라벨 커스텀과
* 무관하게 마이페이지·배너에 일관된 설명이 노출된다 (이슈 #430). 기본값에도 없으면 null.
*
* @param string $consentKey 동의 항목 키 (예: cookie_analytics)
* @return string|null
@@ -170,7 +171,7 @@ class CookieCategoryService
$locale = (string) app()->getLocale();
$fallbackLocale = (string) config('app.fallback_locale', 'en');
foreach ($this->getCategories() as $cat) {
foreach ($this->getDefaultCategories() as $cat) {
if (($cat['key'] ?? null) !== $bareKey) {
continue;
}
@@ -0,0 +1,124 @@
<?php
namespace Plugins\Sirsoft\Gdpr\Tests\Unit\Http\Resources;
use Illuminate\Http\Request;
use Plugins\Sirsoft\Gdpr\Http\Resources\GdprUserConsentResource;
use Plugins\Sirsoft\Gdpr\Models\GdprUserConsent;
use Plugins\Sirsoft\Gdpr\Tests\PluginTestCase;
/**
* 이슈 #430 — 마이페이지 「내 동의 현황」 각 행의 상태별 표시 필드
* (status / status_label / status_at_formatted) 계산을 검증한다.
*
* 프론트 레이아웃은 status 로 색만 분기하고 표시 텍스트·날짜는 서버가 계산한 값을 그대로 렌더하므로,
* 이 매핑이 상태별로 정확해야 화면 정보가 정확해진다.
*/
class GdprUserConsentResourceTest extends PluginTestCase
{
/**
* 주어진 동의 레코드를 Resource 배열로 변환합니다.
*
* @param GdprUserConsent $consent 대상 동의 레코드
* @return array<string, mixed>
*/
private function toArray(GdprUserConsent $consent): array
{
return (new GdprUserConsentResource($consent))->toArray(Request::create('/'));
}
public function test_required_category_maps_to_required_status_with_consented_date(): void
{
$consent = new GdprUserConsent([
'consent_key' => 'cookie_necessary',
'is_consented' => true,
'is_rejected' => false,
'consented_at' => '2026-07-14 09:00:00',
'policy_version' => '1',
]);
$result = $this->toArray($consent);
$this->assertSame('required', $result['status']);
// 필수는 '동의' 라벨을 granted 키로 공유.
$this->assertSame(__('sirsoft-gdpr::messages.mypage.privacy.status.granted'), $result['status_label']);
$this->assertNotNull($result['status_at_formatted']);
$this->assertSame(__('sirsoft-gdpr::messages.mypage.privacy.badge.required'), $result['status_badge_label']);
}
public function test_consented_optional_maps_to_consented_status_with_consented_date(): void
{
$consent = new GdprUserConsent([
'consent_key' => 'cookie_functional',
'is_consented' => true,
'is_rejected' => false,
'consented_at' => '2026-07-14 09:00:00',
'policy_version' => '1',
]);
$result = $this->toArray($consent);
$this->assertSame('consented', $result['status']);
$this->assertSame(__('sirsoft-gdpr::messages.mypage.privacy.status.consented'), $result['status_label']);
$this->assertNotNull($result['status_at_formatted']);
$this->assertSame(__('sirsoft-gdpr::messages.mypage.privacy.badge.consented'), $result['status_badge_label']);
}
public function test_rejected_optional_maps_to_rejected_status_with_no_date_label(): void
{
// PO 결정(2026-07-20) — 날짜/라벨은 "동의한 항목만" 노출. 거부는 상태만 rejected 로 내려주고
// status_label·status_at_formatted 는 null (프론트가 날짜 줄을 렌더하지 않음).
$consent = new GdprUserConsent([
'consent_key' => 'cookie_analytics',
'is_consented' => false,
'is_rejected' => true,
'rejected_at' => '2026-07-10 08:00:00',
'policy_version' => '1',
]);
$result = $this->toArray($consent);
$this->assertSame('rejected', $result['status']);
$this->assertNull($result['status_label']);
$this->assertNull($result['status_at_formatted']);
$this->assertSame(__('sirsoft-gdpr::messages.mypage.privacy.badge.rejected'), $result['status_badge_label']);
}
public function test_revoked_optional_maps_to_revoked_status_with_no_date_label(): void
{
// 철회도 거부와 동일 — 동의 상태가 아니므로 날짜/라벨 미노출.
$consent = new GdprUserConsent([
'consent_key' => 'cookie_marketing',
'is_consented' => false,
'is_rejected' => false,
'revoked_at' => '2026-07-12 07:00:00',
'policy_version' => '1',
]);
$result = $this->toArray($consent);
$this->assertSame('revoked', $result['status']);
$this->assertNull($result['status_label']);
$this->assertNull($result['status_at_formatted']);
// 철회는 신규 미선택과 함께 '미설정'(unset) 배지로 통합.
$this->assertSame(__('sirsoft-gdpr::messages.mypage.privacy.badge.unset'), $result['status_badge_label']);
}
public function test_new_untouched_optional_maps_to_none_with_null_label_and_date(): void
{
$consent = new GdprUserConsent([
'consent_key' => 'cookie_analytics',
'is_consented' => false,
'is_rejected' => false,
'policy_version' => '1',
]);
$result = $this->toArray($consent);
$this->assertSame('none', $result['status']);
// 신규 미선택은 라벨/날짜 모두 미노출 → 프론트가 날짜 줄 자체를 렌더하지 않음.
$this->assertNull($result['status_label']);
$this->assertNull($result['status_at_formatted']);
$this->assertSame(__('sirsoft-gdpr::messages.mypage.privacy.badge.unset'), $result['status_badge_label']);
}
}
@@ -162,4 +162,37 @@ class CookieCategoryServiceTest extends PluginTestCase
app()->setLocale('ko');
$this->assertNull($this->makeService()->getLabelForKey('cookie_analytics'));
}
public function test_get_description_uses_default_even_when_admin_setting_omits_description(): void
{
// 이슈 #430 회귀 가드: 관리자 설정 화면에 설명 편집 UI 가 없어, 운영자가 라벨만 저장하면
// cookie_categories 에 description 이 유실된다. 설명은 관리자 설정이 아니라 항상 코드
// 기본값에서 가져와야 한다 — 아래처럼 description 이 없는 설정이 저장돼도 기본 설명이 나온다.
$this->mockSettings([
'cookie_categories' => json_encode([
['key' => 'functional', 'required' => false, 'label' => ['ko' => '기능', 'en' => 'Functional']],
]),
]);
app()->setLocale('ko');
$desc = $this->makeService()->getDescriptionForKey('cookie_functional');
$this->assertNotNull($desc);
$this->assertNotSame('', $desc);
// 라벨은 운영자 커스텀('기능')을 유지하되, 설명은 코드 기본값에서 온다.
$this->assertSame('기능', $this->makeService()->getLabelForKey('cookie_functional'));
}
public function test_get_description_ignores_admin_custom_description(): void
{
// 설명은 관리자 설정이 아니라 코드 기본값 SSoT — 운영자가 설정에 다른 설명을 넣어도
// 코드 기본 설명이 우선한다 (설명 편집 UI 부재 정합).
$this->mockSettings([
'cookie_categories' => json_encode([
['key' => 'functional', 'required' => false, 'label' => ['ko' => '기능'], 'description' => ['ko' => '운영자가 임의로 넣은 설명']],
]),
]);
app()->setLocale('ko');
$this->assertNotSame('운영자가 임의로 넣은 설명', $this->makeService()->getDescriptionForKey('cookie_functional'));
}
}
@@ -73,10 +73,11 @@ effects:
- consent_action_from_decision_granted_revoked_rejected # value/isRejection → granted/revoked/rejected 3분기
# 화면 표기 (레이아웃 렌더링)
- mypage_required_shows_locked_always_on_toggle # 마이페이지 필수 = 잠긴 '항상 켜짐' 토글 (액션/동의일 없음)
- mypage_optional_shows_on_off_toggle # 마이페이지 선택 = on/off 토글 (켜짐 녹색→철회, 꺼짐 회색→동의)
- mypage_no_consent_date_column_for_user # 사용자 화면에 동의일 컬럼 미노출 (감사/관리자 전용)
- mypage_enable_all_bar_when_optional_off # 꺼진 선택 항목 있을 때 '모두 켜기' 바 노출
- mypage_required_shows_locked_button # 마이페이지 필수 = 상태 배지 + 잠금 버튼 (액션 없음)
- mypage_optional_consented_shows_revoke_button # 마이페이지 선택 동의함 = 철회 버튼 → 철회 확인 모달
- mypage_optional_unset_shows_grant_button # 마이페이지 선택 거부함/미설정 = 동의 버튼 → 동의 확인 모달
- mypage_status_date_line_consented_only # 동의한 항목만 날짜 줄 노출 (서버 status_at_formatted, 거부/미설정은 null)
- mypage_enable_all_bar_when_optional_off # 미동의 선택 항목 있을 때 '모두 동의' 바 노출
- admin_log_action_badge_rejected_amber # 관리자 동의이력 rejected 배지(amber)
- admin_log_filter_rejected_checkbox # 관리자 [거부] 필터 체크박스
- banner_reject_button_sends_intent_reject # 배너 거부 버튼이 intent:'reject' 전송