diff --git a/src/ui/components/EntryContextMenu/constants.ts b/src/ui/components/EntryContextMenu/constants.ts index 48810d5486..a2ed95dbf0 100644 --- a/src/ui/components/EntryContextMenu/constants.ts +++ b/src/ui/components/EntryContextMenu/constants.ts @@ -17,7 +17,6 @@ import {EntryScope, Feature, PLACE, isUsersFolder} from '../../../shared'; import {URL_QUERY} from '../../constants'; import {registry} from '../../registry'; import Utils from '../../utils/utils'; -import {getAvailableScopes} from '../RevisionsPanel/utils'; import type {ContextMenuItem, ContextMenuParams} from './types'; @@ -83,7 +82,8 @@ const isVisibleEntryContextShareItem = ({entry, showSpecificItems}: ContextMenuP Utils.isEnabledFeature(Feature.EnableEntryMenuItemShare); export const getEntryContextMenu = (): ContextMenuItem[] => { - const {getTopLevelEntryScopes, getAllEntryScopes} = registry.common.functions.getAll(); + const {getTopLevelEntryScopes, getAllEntryScopes, getEntryScopesWithRevisionsList} = + registry.common.functions.getAll(); return [ { @@ -99,7 +99,7 @@ export const getEntryContextMenu = (): ContextMenuItem[] => { isVisible({entry, isLimitedView}: ContextMenuParams) { if (!entry || !entry.scope || isLimitedView) return false; - return getAvailableScopes().includes(entry.scope as EntryScope); + return getEntryScopesWithRevisionsList().includes(entry.scope as EntryScope); }, }, { diff --git a/src/ui/components/EntryContextMenu/test/withConfiguredEntryContextMenu.test.ts b/src/ui/components/EntryContextMenu/test/withConfiguredEntryContextMenu.test.ts index 490f71bef6..bd02cfd40e 100644 --- a/src/ui/components/EntryContextMenu/test/withConfiguredEntryContextMenu.test.ts +++ b/src/ui/components/EntryContextMenu/test/withConfiguredEntryContextMenu.test.ts @@ -40,6 +40,7 @@ jest.mock('../../../registry', () => ({ return { getTopLevelEntryScopes: () => [EntryScope.Dash], getAllEntryScopes: () => Object.values(EntryScope), + getEntryScopesWithRevisionsList: () => [EntryScope.Dash, EntryScope.Widget], }; }, }, @@ -457,7 +458,7 @@ describe('withConfiguredEntryContextMenu', () => { for (const testData of testDataContextMenu) { // description of the showMenuInCharts parameter: // - The page is not editor, the page path does not contain (part !== 'editor') - // affects the result of the getAvailableScopes() function for the REVISIONS action + // affects the result of the getEntryScopesWithRevisionsList() function for the REVISIONS action const testSuffix = `${testData.input.params.entry.scope} - [testId: ${testData.testId}]`; // eslint-disable-next-line @typescript-eslint/no-loop-func diff --git a/src/ui/components/RevisionsPanel/RevisionsPanel.tsx b/src/ui/components/RevisionsPanel/RevisionsPanel.tsx index 829cc95729..506f1f274e 100644 --- a/src/ui/components/RevisionsPanel/RevisionsPanel.tsx +++ b/src/ui/components/RevisionsPanel/RevisionsPanel.tsx @@ -19,7 +19,7 @@ import history from '../../utils/history'; import {getCapitalizedStr} from '../../utils/stringUtils'; import RevisionsControls from './components/RevisionsControls'; -import {getAvailableScopes, getDraftWarningAvailableScopes} from './utils'; +import {getDraftWarningAvailableScopes} from './utils'; import './RevisionsPanel.scss'; @@ -134,9 +134,11 @@ const RevisionsPanel = ({ const {scope, updatedBy, updatedAt} = entry; const {publishedId, currentRevId, savedId, revisionsLoadingStatus} = storedEntryContent; + const {getEntryScopesWithRevisionsList} = registry.common.functions.getAll(); + const urlRevId = getUrlParamFromStr(location.search, URL_QUERY.REV_ID); const isInAvailableScopes = React.useMemo( - () => getAvailableScopes().includes(scope as EntryScope), + () => getEntryScopesWithRevisionsList().includes(scope as EntryScope), [location, scope], ); const isDraftInAvailableScopes = React.useMemo( diff --git a/src/ui/components/RevisionsPanel/utils.ts b/src/ui/components/RevisionsPanel/utils.ts index a4686e776a..1574ce00e4 100644 --- a/src/ui/components/RevisionsPanel/utils.ts +++ b/src/ui/components/RevisionsPanel/utils.ts @@ -8,7 +8,7 @@ const isChartsPage = (part: string) => part !== 'editor'; /** * Which sections should be allowed to show a new panel with versions */ -export function getAvailableScopes() { +export function getEntryScopesWithRevisionsList(): EntryScope[] { const res = [EntryScope.Dash]; const currentPathPart = getCurrentPageFirstPathPart(); diff --git a/src/ui/registry/units/common/functions-map.ts b/src/ui/registry/units/common/functions-map.ts index 925493ee67..8079c12c67 100644 --- a/src/ui/registry/units/common/functions-map.ts +++ b/src/ui/registry/units/common/functions-map.ts @@ -147,4 +147,5 @@ export const commonFunctionsMap = { getTopLevelEntryScopes: makeFunctionTemplate<() => EntryScope[]>(), getAllEntryScopes: makeFunctionTemplate<() => EntryScope[]>(), getScopeTypeIcon: makeFunctionTemplate<(scope: EntryScope) => string | null>(), + getEntryScopesWithRevisionsList: makeFunctionTemplate<() => EntryScope[]>(), } as const; diff --git a/src/ui/registry/units/common/register.tsx b/src/ui/registry/units/common/register.tsx index 4e2171dcad..875f8195e9 100644 --- a/src/ui/registry/units/common/register.tsx +++ b/src/ui/registry/units/common/register.tsx @@ -1,4 +1,5 @@ import {extractEntryId, isEntryId} from 'shared'; +import {getEntryScopesWithRevisionsList} from 'ui/components/RevisionsPanel/utils'; import {getIsCompact, updateIsCompact} from 'ui/store/utils/asideHeader'; import {setEntryKey} from 'ui/utils/setEntryKey'; @@ -92,5 +93,6 @@ export const registerCommonPlugins = () => { getAllEntryScopes, getTopLevelEntryScopes, getScopeTypeIcon, + getEntryScopesWithRevisionsList, }); };