Skip to content

Commit

Permalink
Merge branch 'update-appbuilder' of github.com:datalens-tech/datalens…
Browse files Browse the repository at this point in the history
…-ui into update-appbuilder
  • Loading branch information
melikhov-dev committed Oct 24, 2024
2 parents bb2b203 + 6155d47 commit 848f98b
Show file tree
Hide file tree
Showing 6 changed files with 13 additions and 7 deletions.
6 changes: 3 additions & 3 deletions src/ui/components/EntryContextMenu/constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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';

Expand Down Expand Up @@ -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 [
{
Expand All @@ -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);
},
},
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ jest.mock('../../../registry', () => ({
return {
getTopLevelEntryScopes: () => [EntryScope.Dash],
getAllEntryScopes: () => Object.values(EntryScope),
getEntryScopesWithRevisionsList: () => [EntryScope.Dash, EntryScope.Widget],
};
},
},
Expand Down Expand Up @@ -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
Expand Down
6 changes: 4 additions & 2 deletions src/ui/components/RevisionsPanel/RevisionsPanel.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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';

Expand Down Expand Up @@ -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(
Expand Down
2 changes: 1 addition & 1 deletion src/ui/components/RevisionsPanel/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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();

Expand Down
1 change: 1 addition & 0 deletions src/ui/registry/units/common/functions-map.ts
Original file line number Diff line number Diff line change
Expand Up @@ -147,4 +147,5 @@ export const commonFunctionsMap = {
getTopLevelEntryScopes: makeFunctionTemplate<() => EntryScope[]>(),
getAllEntryScopes: makeFunctionTemplate<() => EntryScope[]>(),
getScopeTypeIcon: makeFunctionTemplate<(scope: EntryScope) => string | null>(),
getEntryScopesWithRevisionsList: makeFunctionTemplate<() => EntryScope[]>(),
} as const;
2 changes: 2 additions & 0 deletions src/ui/registry/units/common/register.tsx
Original file line number Diff line number Diff line change
@@ -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';

Expand Down Expand Up @@ -92,5 +93,6 @@ export const registerCommonPlugins = () => {
getAllEntryScopes,
getTopLevelEntryScopes,
getScopeTypeIcon,
getEntryScopesWithRevisionsList,
});
};

0 comments on commit 848f98b

Please sign in to comment.