Skip to content

Commit

Permalink
chore(Queries): remove isQueryTrackerAllowed selector [YTFRONT-4463]
Browse files Browse the repository at this point in the history
  • Loading branch information
ma-efremoff committed Nov 26, 2024
1 parent 26a6c0a commit c132a20
Show file tree
Hide file tree
Showing 7 changed files with 12 additions and 53 deletions.
2 changes: 1 addition & 1 deletion packages/ui/src/ui/UIFactory/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -426,7 +426,7 @@ export interface UIFactory {

getAclPermissionsSettings(): typeof PERMISSIONS_SETTINGS;

onChytAliasSqlClick(params: {alias: string; cluster: string}): void;
onChytAliasSqlClick?: (params: {alias: string; cluster: string}) => void;

getNavigationExtraTabs(): Array<ExtraTab>;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ import React from 'react';
import {useSelector} from 'react-redux';

import {getGlobalLoadState} from '../../../store/selectors/global';
import {isQueryTrackerAllowed} from '../../../store/selectors/global/experimental-pages';

import {LOADING_STATUS, Page} from '../../../constants/index';
import {Route, Switch} from 'react-router';
Expand All @@ -30,7 +29,6 @@ import {QueryTrackerTopRowLazy} from '../../../pages/query-tracker/lazy';

export default function TopRowContent() {
const loadState = useSelector(getGlobalLoadState);
const allowQT = useSelector(isQueryTrackerAllowed);

return loadState !== LOADING_STATUS.LOADED ? null : (
<Switch>
Expand All @@ -50,12 +48,10 @@ export default function TopRowContent() {
<Route path={`/:cluster/${Page.DASHBOARD}`} component={DashboardTopRowLazy} />
<Route path={`/:cluster/${Page.COMPONENTS}`} component={ComponentsTopRowLazy} />
<Route path={`/:cluster/${Page.CHYT}`} component={ChytPageTopRowLazy} />
{allowQT && (
<Route
path={`/:cluster/${Page.QUERIES}`}
component={withLazyLoading(QueryTrackerTopRowLazy)}
/>
)}
<Route
path={`/:cluster/${Page.QUERIES}`}
component={withLazyLoading(QueryTrackerTopRowLazy)}
/>
{hasOdinPage() && (
<Route
path={`/:cluster/${odinPageInfo.pageId}`}
Expand Down
17 changes: 2 additions & 15 deletions packages/ui/src/ui/containers/ClusterPage/ClusterPage.js
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,6 @@ import {setSetting} from '../../store/actions/settings';
import {unmountCluster, updateCluster} from '../../store/actions/cluster-params';
import {updateTitle} from '../../store/actions/global';
import {getClusterUiConfig} from '../../store/selectors/global';
import {isQueryTrackerAllowed} from '../../store/selectors/global/experimental-pages';
import {getClusterConfig} from '../../utils';
import {NAMESPACES, SettingName} from '../../../shared/constants/settings';
import {getClusterPagePaneSizes, getStartingPage} from '../../store/selectors/settings';
Expand Down Expand Up @@ -87,7 +86,6 @@ class ClusterPage extends Component {
trackVisit: PropTypes.func.isRequired,

allowChyt: PropTypes.bool,
allowQueryTracker: PropTypes.bool,
};

state = {
Expand Down Expand Up @@ -185,15 +183,7 @@ class ClusterPage extends Component {
}

renderContent(clusterConfig) {
const {
cluster,
startingPage,
isLoaded,
hasError,
paramsError,
allowChyt,
allowQueryTracker,
} = this.props;
const {cluster, startingPage, isLoaded, hasError, paramsError, allowChyt} = this.props;

return isLoaded && !this.isParamsLoading() ? (
<Fragment>
Expand Down Expand Up @@ -223,9 +213,7 @@ class ClusterPage extends Component {
{allowChyt && (
<Route path={`/:cluster/${Page.CHYT}`} component={ChytPageLazy} />
)}
{allowQueryTracker && (
<Route path={`/:cluster/${Page.QUERIES}`} component={QueryTrackerLazy} />
)}
<Route path={`/:cluster/${Page.QUERIES}`} component={QueryTrackerLazy} />
{hasOdinPage() && (
<Route
path={`/:cluster/${odinPageInfo.pageId}`}
Expand Down Expand Up @@ -335,7 +323,6 @@ function mapStateToProps(state) {
clusterPagePaneSizes: getClusterPagePaneSizes(state),
startingPage: getStartingPage(state),
paramsCluster,
allowQueryTracker: isQueryTrackerAllowed(state),
allowChyt: Boolean(getClusterUiConfig(state).chyt_controller_base_url),
};
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ import {Button, DropdownMenu, DropdownMenuItem} from '@gravity-ui/uikit';

import Icon from '../../../components/Icon/Icon';
import {getCluster} from '../../../store/selectors/global';
import {isQueryTrackerAllowed} from '../../../store/selectors/global/experimental-pages';
import {updateQueryDraft} from '../../../pages/query-tracker/module/query/actions';
import {QueryEngine} from '../../../pages/query-tracker/module/engines';
import UIFactory from '../../../UIFactory';
Expand All @@ -19,12 +18,11 @@ const block = cn('chyt-clique-actions');

export function useCliqueOnSqlAction(openWidget: () => void) {
const cluster = useSelector(getCluster);
const allowQueryTracker = useSelector(isQueryTrackerAllowed);
const dispatch = useDispatch();

return React.useCallback(
(alias: string) => {
if (allowQueryTracker) {
if (!UIFactory.onChytAliasSqlClick) {
setTimeout(() => {
dispatch(
updateQueryDraft({
Expand All @@ -39,7 +37,7 @@ export function useCliqueOnSqlAction(openWidget: () => void) {
UIFactory.onChytAliasSqlClick({alias, cluster});
}
},
[cluster, openWidget, allowQueryTracker, dispatch],
[cluster, openWidget, dispatch],
);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,20 +19,17 @@ import {HEADER_HEIGHT} from '../../../../../constants/index';
import './TableOverview.scss';
import EditTableActions from './EditTableActions';
import DataLensButton from './DatalensButton';
import {isQueryTrackerAllowed} from '../../../../../store/selectors/global/experimental-pages';
import {YQLKitButton} from '../../../../../containers/YQLKitButton/YQLKitButton';

const block = cn('navigation-table-overview');

TableOverview.propTypes = {
// from connect
isFullScreen: PropTypes.bool.isRequired,
isSplit: PropTypes.bool.isRequired,
allowQueryTracker: PropTypes.bool,
};

function TableOverview(props) {
const {isFullScreen, isSplit, allowQueryTracker} = props;
const {isFullScreen, isSplit} = props;

// TODO: add sticky for the Overview in the split mode https://github.com/captivationsoftware/react-sticky/issues/282
return (
Expand All @@ -50,9 +47,7 @@ function TableOverview(props) {
<OffsetInput block={block} />
{!isFullScreen && <ColumnSelectorButton block={block} />}
{!isFullScreen && <SettingsButton block={block} />}
{!isFullScreen && allowQueryTracker && (
<CreateQueryFromTable className={block('query')} />
)}
{!isFullScreen && <CreateQueryFromTable className={block('query')} />}
{!isFullScreen && <JupyterButton block={block} />}
{!isFullScreen && <DataLensButton className={block('datalens')} />}
{!isFullScreen && <TableActions block={block} />}
Expand All @@ -72,7 +67,6 @@ const mapStateToProps = (state) => {
return {
isFullScreen,
isSplit,
allowQueryTracker: isQueryTrackerAllowed(state),
};
};

Expand Down
16 changes: 0 additions & 16 deletions packages/ui/src/ui/store/selectors/global/experimental-pages.ts
Original file line number Diff line number Diff line change
@@ -1,20 +1,4 @@
import {createSelector} from 'reselect';

import {Page} from '../../../../shared/constants/settings';

import UIFactory from '../../../UIFactory';
import {RootState} from '../../../store/reducers';
import {isDeveloper} from '../../../store/selectors/global/is-developer';

export const getAllowedExperimentalPages = (state: RootState) =>
state?.global.allowedExperimentalPages;

export const isQueryTrackerAllowed = createSelector(
[isDeveloper, getAllowedExperimentalPages],
(isDeveloper, allowedPages) => {
const expPages = UIFactory.getExperimentalPages();
return (
isDeveloper || !expPages.includes(Page.QUERIES) || allowedPages.includes(Page.QUERIES)
);
},
);
2 changes: 1 addition & 1 deletion packages/ui/src/ui/store/selectors/settings/navigation.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import {createSelector} from 'reselect';

import UIFactory from '../../../UIFactory';
import {isDeveloper} from '../../../store/selectors/global';
import {isDeveloper} from '../../../store/selectors/global/is-developer';
import {getSettingsData} from './settings-base';

export const getNavigationSqlService = createSelector(
Expand Down

0 comments on commit c132a20

Please sign in to comment.