> For the complete documentation index, see [llms.txt](https://docs.wellcomecollection.org/request-for-comments-rfcs/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.wellcomecollection.org/request-for-comments-rfcs/086-item-viewer-refactor/11-phase-5-restriction-status.md).

# Phase 5: Restriction Status

[← Back to Index](/request-for-comments-rfcs/086-item-viewer-refactor.md)

**Effort:** 1 hour\
**Risk:** Low\
**Priority:** Low\
**Previous:** [Phase 4: Download Logic](/request-for-comments-rfcs/086-item-viewer-refactor/10-phase-4-download-logic.md)\
**Next:** [Phase 6: Duplicate Index Calls](/request-for-comments-rfcs/086-item-viewer-refactor/12-phase-6-duplicate-calls.md)

## Goal

Add `isCurrentCanvasRestricted` to context instead of calculating it in `ViewerTopBar`.

## Why?

* `ViewerTopBar` calculates this value
* Other components might need it too
* Centralise restriction logic in one place
* Clear boolean name makes intent obvious

**Note:** The `restricted-images` merge added the canonical `hasRestrictedItem()` helper that should be used for all restriction checks.

## Steps

### 3.1 Add to Context Type

**File:** `content/webapp/contexts/ItemViewerContextV2/index.tsx`

```typescript
type Props = {
  // ... existing ...
  isCurrentCanvasRestricted: boolean;  // Current canvas has restricted access
};
```

### 3.2 Calculate in `IIIFViewer.refactored.tsx`

```typescript
const isCurrentCanvasRestricted = currentCanvas 
  ? hasRestrictedItem(currentCanvas) 
  : false;

<ItemViewerContextV2.Provider value={{
  // ... existing ...
  isCurrentCanvasRestricted,
}}>
```

### 3.3 Update `ViewerTopBar.refactored.tsx`

```typescript
// REMOVE:
const isRestricted = currentCanvas && hasRestrictedItem(currentCanvas);

// ADD to destructuring:
const { isCurrentCanvasRestricted } = useItemViewerContextV2();

// UPDATE usage:
- {isRestricted && <RestrictedBadge />}
+ {isCurrentCanvasRestricted && <RestrictedBadge />}
```

## Testing

* [ ] Restricted badge appears on restricted canvases
* [ ] Badge doesn't appear on unrestricted canvases
* [ ] Download options respect restriction status

## Success Criteria

* [ ] `isCurrentCanvasRestricted` in context
* [ ] `ViewerTopBar` uses context value
* [ ] Restricted badge appears correctly

## Time: \~1 hour

***

**Next:** [Phase 6: Duplicate Index Calls](/request-for-comments-rfcs/086-item-viewer-refactor/12-phase-6-duplicate-calls.md)


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.wellcomecollection.org/request-for-comments-rfcs/086-item-viewer-refactor/11-phase-5-restriction-status.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
