This repository was archived by the owner on Sep 9, 2024. It is now read-only.
File tree Expand file tree Collapse file tree 5 files changed +35
-14
lines changed
Expand file tree Collapse file tree 5 files changed +35
-14
lines changed Original file line number Diff line number Diff line change @@ -9,6 +9,7 @@ import { getAdditionalLinks } from '@staticcms/core/lib/registry';
99import classNames from '@staticcms/core/lib/util/classNames.util' ;
1010import { selectCollections } from '@staticcms/core/reducers/selectors/collections' ;
1111import {
12+ selectIsMediaLinkEnabled ,
1213 selectIsSearchEnabled ,
1314 selectUseWorkflow ,
1415} from '@staticcms/core/reducers/selectors/config' ;
@@ -33,6 +34,7 @@ const SidebarContent: FC<SidebarContentProps> = ({ isMobile = false }) => {
3334
3435 const navigate = useNavigate ( ) ;
3536 const isSearchEnabled = useAppSelector ( selectIsSearchEnabled ) ;
37+ const isMediaLinkEnabled = useAppSelector ( selectIsMediaLinkEnabled ) ;
3638 const collections = useAppSelector ( selectCollections ) ;
3739 const useWorkflow = useAppSelector ( selectUseWorkflow ) ;
3840
@@ -151,14 +153,16 @@ const SidebarContent: FC<SidebarContentProps> = ({ isMobile = false }) => {
151153 ) : null }
152154 { collectionLinks }
153155 { links }
154- < NavLink
155- key = "Media"
156- to = "/media"
157- icon = { < PhotoIcon className = { sidebarClasses [ 'icon' ] } /> }
158- data-testid = { `${ isMobile ? 'mobile-nav' : 'sidebar-nav' } -Media` }
159- >
160- { t ( 'app.header.media' ) }
161- </ NavLink >
156+ { isMediaLinkEnabled ? (
157+ < NavLink
158+ key = "Media"
159+ to = "/media"
160+ icon = { < PhotoIcon className = { sidebarClasses [ 'icon' ] } /> }
161+ data-testid = { `${ isMobile ? 'mobile-nav' : 'sidebar-nav' } -Media` }
162+ >
163+ { t ( 'app.header.media' ) }
164+ </ NavLink >
165+ ) : null }
162166 </ ul >
163167 </ div >
164168 ) ;
Original file line number Diff line number Diff line change @@ -494,6 +494,7 @@ function getConfigSchema() {
494494 media_library : {
495495 type : 'object' ,
496496 properties : {
497+ display_in_navigation : { type : 'boolean' } ,
497498 max_file_size : { type : 'number' } ,
498499 folder_support : { type : 'boolean' } ,
499500 } ,
Original file line number Diff line number Diff line change @@ -674,6 +674,10 @@ export interface MediaLibraryConfig {
674674 folder_support ?: boolean ;
675675}
676676
677+ export interface RootMediaLibraryConfig extends MediaLibraryConfig {
678+ display_in_navigation ?: boolean ;
679+ }
680+
677681export type BackendType =
678682 | 'git-gateway'
679683 | 'github'
@@ -1046,7 +1050,7 @@ export interface Config<EF extends BaseField = UnknownField> {
10461050 media_folder ?: string ;
10471051 public_folder ?: string ;
10481052 media_folder_relative ?: boolean ;
1049- media_library ?: MediaLibraryConfig ;
1053+ media_library ?: RootMediaLibraryConfig ;
10501054 publish_mode ?: Workflow ;
10511055 slug ?: Slug ;
10521056 i18n ?: I18nInfo ;
Original file line number Diff line number Diff line change @@ -2,8 +2,8 @@ import { createSelector } from '@reduxjs/toolkit';
22
33import { EDITORIAL_WORKFLOW } from '@staticcms/core/constants/publishModes' ;
44
5- import type { Workflow } from '@staticcms/core/constants/publishModes' ;
65import type { ConfigWithDefaults } from '@staticcms/core' ;
6+ import type { Workflow } from '@staticcms/core/constants/publishModes' ;
77import type { RootState } from '@staticcms/core/store' ;
88
99export function selectLocale ( config ?: ConfigWithDefaults ) {
@@ -28,6 +28,17 @@ export const selectIsSearchEnabled = createSelector(
2828 } ,
2929) ;
3030
31+ export function selectMediaLinkEnabled ( state : RootState ) {
32+ return state . config . config ?. media_library ?. display_in_navigation ;
33+ }
34+
35+ export const selectIsMediaLinkEnabled = createSelector (
36+ [ selectMediaLinkEnabled ] ,
37+ ( display_in_navigation : boolean | undefined ) => {
38+ return display_in_navigation !== false ;
39+ } ,
40+ ) ;
41+
3142export function selectDisplayUrl ( state : RootState ) {
3243 return state . config . config ?. display_url ;
3344}
Original file line number Diff line number Diff line change @@ -138,10 +138,11 @@ The `media_library` settings allows customization of the media library.
138138
139139# ## Options
140140
141- | Name | Type | Default | Description |
142- | -------------- | ------- | -------- | -------------------------------------------------------------------------------------- |
143- | max_file_size | number | `512000` | _Optional_. The max size, in bytes, of files that can be uploaded to the media library |
144- | folder_support | boolean | `false` | _Optional_. Enables directory navigation and folder creation in your media library |
141+ | Name | Type | Default | Description |
142+ | --------------------- | ------- | -------- | -------------------------------------------------------------------------------------- |
143+ | max_file_size | number | `512000` | _Optional_. The max size, in bytes, of files that can be uploaded to the media library |
144+ | folder_support | boolean | `false` | _Optional_. Enables directory navigation and folder creation in your media library |
145+ | display_in_navigation | boolean | `true` | _Optional_. Displays the "Media" link in the main navigation |
145146
146147# ## Example
147148
You can’t perform that action at this time.
0 commit comments