diff --git a/packages/compass-aggregations/README.md b/packages/compass-aggregations/README.md index 4425d97c165..9d5a92c689b 100644 --- a/packages/compass-aggregations/README.md +++ b/packages/compass-aggregations/README.md @@ -94,7 +94,6 @@ const aggregationsStore = configureAggregationsStore({ namespace: 'db.coll', serverVersion: '4.2.0', fields: [], - isAtlasDeployed: true, outResultsFn: handleOut, env: 'atlas', localAppRegistry: appRegistry diff --git a/packages/compass-aggregations/src/components/aggregations/aggregations.jsx b/packages/compass-aggregations/src/components/aggregations/aggregations.jsx index 29f34d817c8..b38a56a6ce8 100644 --- a/packages/compass-aggregations/src/components/aggregations/aggregations.jsx +++ b/packages/compass-aggregations/src/components/aggregations/aggregations.jsx @@ -52,7 +52,6 @@ const mapStateToProps = (state) => ({ name: state.name, collationString: state.collationString, isCommenting: state.comments, - isAtlasDeployed: state.isAtlasDeployed, isAutoPreviewing: state.autoPreview, settings: state.settings, limit: state.limit, diff --git a/packages/compass-aggregations/src/components/pipeline-builder-workspace/pipeline-as-text-workspace/pipeline-stages-preview.spec.tsx b/packages/compass-aggregations/src/components/pipeline-builder-workspace/pipeline-as-text-workspace/pipeline-stages-preview.spec.tsx index b9fc883cbf6..f9d483311f1 100644 --- a/packages/compass-aggregations/src/components/pipeline-builder-workspace/pipeline-as-text-workspace/pipeline-stages-preview.spec.tsx +++ b/packages/compass-aggregations/src/components/pipeline-builder-workspace/pipeline-as-text-workspace/pipeline-stages-preview.spec.tsx @@ -9,6 +9,7 @@ import userEvent from '@testing-library/user-event'; import configureStore from '../../../../test/configure-store'; import { OutputStagePreview } from './pipeline-stages-preview'; +import preferencesAccess from 'compass-preferences-model'; const renderStageBanner = ( props: Partial> = {} @@ -17,7 +18,6 @@ const renderStageBanner = ( {}} @@ -30,12 +30,9 @@ const renderStageBanner = ( describe('OutputStagePreview', function () { (['$out', '$merge'] as const).forEach((stageOperator) => { - describe(`${stageOperator} - not on atlas`, function () { + describe(`${stageOperator} with run aggregation enabled`, function () { it('renders stage banner', function () { - renderStageBanner({ - stageOperator, - isAtlas: false, - }); + renderStageBanner({ stageOperator }); expect(screen.getByTestId(`${stageOperator}-preview-banner`)).to.exist; expect(() => { screen.getByRole('button', { @@ -45,11 +42,28 @@ describe('OutputStagePreview', function () { }); }); - describe(`${stageOperator} on atlas`, function () { + describe(`${stageOperator} with run aggregation disabled`, function () { + let enableAggregationBuilderRunPipeline: boolean; + + before(async function () { + enableAggregationBuilderRunPipeline = + preferencesAccess.getPreferences() + .enableAggregationBuilderRunPipeline; + + await preferencesAccess.savePreferences({ + enableAggregationBuilderRunPipeline: false, + }); + }); + + after(async function () { + await preferencesAccess.savePreferences({ + enableAggregationBuilderRunPipeline, + }); + }); + it(`renders stage banner`, function () { renderStageBanner({ stageOperator, - isAtlas: true, }); expect(screen.getByTestId(`${stageOperator}-preview-banner`)).to.exist; }); @@ -57,7 +71,6 @@ describe('OutputStagePreview', function () { it(`renders stage action`, function () { renderStageBanner({ stageOperator, - isAtlas: true, }); expect( screen.getByRole('button', { @@ -70,7 +83,6 @@ describe('OutputStagePreview', function () { const onSaveCollection = sinon.spy(); renderStageBanner({ stageOperator, - isAtlas: true, onSaveCollection, }); const button = screen.getByRole('button', { @@ -84,7 +96,6 @@ describe('OutputStagePreview', function () { it('renders loading state', function () { renderStageBanner({ stageOperator, - isAtlas: true, isLoading: true, }); const button = screen.getByRole('button', { @@ -96,7 +107,6 @@ describe('OutputStagePreview', function () { it('renders complete state', function () { renderStageBanner({ stageOperator, - isAtlas: true, isComplete: true, }); expect(screen.getByTestId(`${stageOperator}-is-complete-banner`)).to @@ -106,7 +116,6 @@ describe('OutputStagePreview', function () { it('renders complete state action button', function () { renderStageBanner({ stageOperator, - isAtlas: true, isComplete: true, }); const button = screen.getByRole('button', { @@ -119,7 +128,6 @@ describe('OutputStagePreview', function () { const onOpenCollection = sinon.spy(); renderStageBanner({ stageOperator, - isAtlas: true, isComplete: true, onOpenCollection, }); diff --git a/packages/compass-aggregations/src/components/pipeline-builder-workspace/pipeline-as-text-workspace/pipeline-stages-preview.tsx b/packages/compass-aggregations/src/components/pipeline-builder-workspace/pipeline-as-text-workspace/pipeline-stages-preview.tsx index 8878e17e137..1c6cdec0e61 100644 --- a/packages/compass-aggregations/src/components/pipeline-builder-workspace/pipeline-as-text-workspace/pipeline-stages-preview.tsx +++ b/packages/compass-aggregations/src/components/pipeline-builder-workspace/pipeline-as-text-workspace/pipeline-stages-preview.tsx @@ -20,6 +20,7 @@ import { MERGE_STAGE_PREVIEW_TEXT, OUT_STAGE_PREVIEW_TEXT, } from '../../../constants'; +import { usePreference } from 'compass-preferences-model'; const bannerStyles = css({ alignItems: 'center', @@ -39,7 +40,6 @@ const actionButtonStyles = css({ type OutputStageProps = { stageOperator: '$out' | '$merge' | null; - isAtlas: boolean; isLoading: boolean; isComplete: boolean; onSaveCollection: () => void; @@ -77,16 +77,23 @@ const PipelineStageBanner = ({ export const OutputStagePreview = ({ stageOperator, - isAtlas, isLoading, isComplete, onSaveCollection, onOpenCollection, }: OutputStageProps) => { + // When explicit pipeline run is not enabled, we allow to run output stage + // from the preview + const showOutputActions = !usePreference( + 'enableAggregationBuilderRunPipeline', + React + ); + if (!stageOperator) { return null; } - if (isComplete && isAtlas) { + + if (isComplete && showOutputActions) { return ( { return { - isAtlas: isAtlasDeployed, isComplete, isLoading, }; diff --git a/packages/compass-aggregations/src/components/pipeline-toolbar/pipeline-header/index.tsx b/packages/compass-aggregations/src/components/pipeline-toolbar/pipeline-header/index.tsx index 0ee2a8f8e0a..bbb0aa3c074 100644 --- a/packages/compass-aggregations/src/components/pipeline-toolbar/pipeline-header/index.tsx +++ b/packages/compass-aggregations/src/components/pipeline-toolbar/pipeline-header/index.tsx @@ -147,6 +147,6 @@ export const PipelineHeader: React.FunctionComponent = ({ export default connect((state: RootState) => { return { - isOpenPipelineVisible: !state.editViewName && !state.isAtlasDeployed, + isOpenPipelineVisible: !state.editViewName, }; })(PipelineHeader); diff --git a/packages/compass-aggregations/src/components/pipeline-toolbar/pipeline-header/pipeline-actions.spec.tsx b/packages/compass-aggregations/src/components/pipeline-toolbar/pipeline-header/pipeline-actions.spec.tsx index 53b51c1a1ed..0d53a3d8b15 100644 --- a/packages/compass-aggregations/src/components/pipeline-toolbar/pipeline-header/pipeline-actions.spec.tsx +++ b/packages/compass-aggregations/src/components/pipeline-toolbar/pipeline-header/pipeline-actions.spec.tsx @@ -8,6 +8,7 @@ import ConnectedPipelineActions, { PipelineActions } from './pipeline-actions'; import configureStore from '../../../../test/configure-store'; import { Provider } from 'react-redux'; import { changeStageDisabled } from '../../../modules/pipeline-builder/stage-editor'; +import preferencesAccess from 'compass-preferences-model'; describe('PipelineActions', function () { afterEach(cleanup); @@ -104,7 +105,6 @@ describe('PipelineActions', function () { onExportAggregationResults={() => {}} onUpdateView={() => {}} onExplainAggregation={() => {}} - isAtlasDeployed={false} onCollectionScanInsightActionButtonClick={() => {}} onShowAIInputClick={() => {}} /> @@ -125,9 +125,25 @@ describe('PipelineActions', function () { }); }); - describe('options disabled in atlas', function () { + describe('extra options disabled', function () { + let enableAggregationBuilderExtraOptions: boolean; let onRunAggregationSpy: SinonSpy; let onToggleOptionsSpy: SinonSpy; + + before(async function () { + enableAggregationBuilderExtraOptions = + preferencesAccess.getPreferences().enableAggregationBuilderExtraOptions; + await preferencesAccess.savePreferences({ + enableAggregationBuilderExtraOptions: false, + }); + }); + + after(async function () { + await preferencesAccess.savePreferences({ + enableAggregationBuilderExtraOptions, + }); + }); + beforeEach(function () { onRunAggregationSpy = spy(); onToggleOptionsSpy = spy(); @@ -143,7 +159,6 @@ describe('PipelineActions', function () { onExportAggregationResults={() => {}} onUpdateView={() => {}} onExplainAggregation={() => {}} - isAtlasDeployed={true} onCollectionScanInsightActionButtonClick={() => {}} onShowAIInputClick={() => {}} /> diff --git a/packages/compass-aggregations/src/components/pipeline-toolbar/pipeline-header/pipeline-actions.tsx b/packages/compass-aggregations/src/components/pipeline-toolbar/pipeline-header/pipeline-actions.tsx index 0696b0058aa..beb20d4fb5c 100644 --- a/packages/compass-aggregations/src/components/pipeline-toolbar/pipeline-header/pipeline-actions.tsx +++ b/packages/compass-aggregations/src/components/pipeline-toolbar/pipeline-header/pipeline-actions.tsx @@ -54,8 +54,6 @@ type PipelineActionsProps = { isOptionsVisible?: boolean; onToggleOptions: () => void; - isAtlasDeployed?: boolean; - showAIEntry: boolean; onShowAIInputClick: () => void; @@ -80,10 +78,13 @@ export const PipelineActions: React.FunctionComponent = ({ onToggleOptions, onExportAggregationResults, onExplainAggregation, - isAtlasDeployed, showCollectionScanInsight, onCollectionScanInsightActionButtonClick, }) => { + const enableAggregationBuilderExtraOptions = usePreference( + 'enableAggregationBuilderExtraOptions', + React + ); const showInsights = usePreference('showInsights', React); const isAIFeatureEnabled = useIsAIFeatureEnabled(React); @@ -151,7 +152,7 @@ export const PipelineActions: React.FunctionComponent = ({ Run )} - {!isAtlasDeployed && ( + {enableAggregationBuilderExtraOptions && ( { isBuilderView, showUpdateViewButton: Boolean(state.editViewName), isUpdateViewButtonDisabled: !state.isModified || hasSyntaxErrors, - isAtlasDeployed: state.isAtlasDeployed, showCollectionScanInsight: state.insights.isCollectionScan, }; }; diff --git a/packages/compass-aggregations/src/components/pipeline-toolbar/pipeline-settings/index.spec.tsx b/packages/compass-aggregations/src/components/pipeline-toolbar/pipeline-settings/index.spec.tsx index 369d4a6302c..241b43e87eb 100644 --- a/packages/compass-aggregations/src/components/pipeline-toolbar/pipeline-settings/index.spec.tsx +++ b/packages/compass-aggregations/src/components/pipeline-toolbar/pipeline-settings/index.spec.tsx @@ -20,7 +20,6 @@ describe('PipelineSettings', function () { diff --git a/packages/compass-aggregations/src/components/pipeline-toolbar/pipeline-settings/index.tsx b/packages/compass-aggregations/src/components/pipeline-toolbar/pipeline-settings/index.tsx index a69b15852cf..49696b968fa 100644 --- a/packages/compass-aggregations/src/components/pipeline-toolbar/pipeline-settings/index.tsx +++ b/packages/compass-aggregations/src/components/pipeline-toolbar/pipeline-settings/index.tsx @@ -8,6 +8,7 @@ import PipelineExtraSettings from './pipeline-extra-settings'; import type { RootState } from '../../../modules'; import { getIsPipelineInvalidFromBuilderState } from '../../../modules/pipeline-builder/builder-helpers'; import { confirmNewPipeline } from '../../../modules/is-new-pipeline-confirm'; +import { usePreference } from 'compass-preferences-model'; const containerStyles = css({ display: 'grid', @@ -30,8 +31,7 @@ const extraSettingsStyles = css({ }); type PipelineSettingsProps = { - isSavePipelineDisplayed?: boolean; - isCreatePipelineDisplayed?: boolean; + isEditingViewPipeline?: boolean; isExportToLanguageEnabled?: boolean; onExportToLanguage: () => void; onCreateNewPipeline: () => void; @@ -40,12 +40,19 @@ type PipelineSettingsProps = { export const PipelineSettings: React.FunctionComponent< PipelineSettingsProps > = ({ - isSavePipelineDisplayed, - isCreatePipelineDisplayed, + isEditingViewPipeline = false, isExportToLanguageEnabled, onExportToLanguage, onCreateNewPipeline, }) => { + const enableSavedAggregationsQueries = usePreference( + 'enableSavedAggregationsQueries', + React + ); + const isSavePipelineDisplayed = + !isEditingViewPipeline && enableSavedAggregationsQueries; + const isCreatePipelineDisplayed = !isEditingViewPipeline; + return (
@@ -88,8 +95,7 @@ export default connect( (state: RootState) => { const hasSyntaxErrors = getIsPipelineInvalidFromBuilderState(state, false); return { - isSavePipelineDisplayed: !state.editViewName && !state.isAtlasDeployed, - isCreatePipelineDisplayed: !state.editViewName, + isEditingViewPipeline: state.editViewName, isExportToLanguageEnabled: !hasSyntaxErrors, }; }, diff --git a/packages/compass-aggregations/src/components/pipeline/pipeline.jsx b/packages/compass-aggregations/src/components/pipeline/pipeline.jsx index 442ae14e4d8..dababf4cbc1 100644 --- a/packages/compass-aggregations/src/components/pipeline/pipeline.jsx +++ b/packages/compass-aggregations/src/components/pipeline/pipeline.jsx @@ -23,7 +23,6 @@ class Pipeline extends PureComponent { static displayName = 'PipelineComponent'; static propTypes = { - isAtlasDeployed: PropTypes.bool.isRequired, saveCurrentPipeline: PropTypes.func.isRequired, clonePipeline: PropTypes.func.isRequired, isCommenting: PropTypes.bool.isRequired, @@ -115,7 +114,6 @@ class Pipeline extends PureComponent { return (
); expect(component.find('label[innerText="Limit"]')).to.not.be.present(); }); diff --git a/packages/compass-aggregations/src/components/settings/settings.tsx b/packages/compass-aggregations/src/components/settings/settings.tsx index 23efac04e67..9822fcc3865 100644 --- a/packages/compass-aggregations/src/components/settings/settings.tsx +++ b/packages/compass-aggregations/src/components/settings/settings.tsx @@ -14,6 +14,7 @@ import { } from '@mongodb-js/compass-components'; import { DEFAULT_SAMPLE_SIZE, DEFAULT_LARGE_LIMIT } from '../../constants'; +import { usePreference } from 'compass-preferences-model'; const aggregationCommentModeId = 'aggregation-comment-mode'; const aggregationCommentModeDescriptionId = @@ -90,7 +91,6 @@ const inputControlStyles = css({ const inputMetaStyles = css({ flexGrow: 1, p: { marginTop: spacing[2] } }); type SettingsProps = { - isAtlasDeployed: boolean; isCommenting: boolean; isExpanded: boolean; largeLimit: number; @@ -110,7 +110,6 @@ type SettingsProps = { }; function Settings({ - isAtlasDeployed, isCommenting, isExpanded, largeLimit, @@ -122,6 +121,10 @@ function Settings({ toggleSettingsIsCommentMode, toggleSettingsIsExpanded, }: SettingsProps) { + const enableAggregationBuilderExtraOptions = usePreference( + 'enableAggregationBuilderExtraOptions', + React + ); const darkMode = useDarkMode(); const onSampleSizeChanged = useCallback( (evt: React.ChangeEvent) => { @@ -233,7 +236,7 @@ function Settings({ />
- {!isAtlasDeployed && ( + {enableAggregationBuilderExtraOptions && (
- {isAtlasDeployed && ( + {enableAggregationBuilderRunPipeline && (
); - expect(screen.getByTestId('query-history-button')).to.exist; + let enableSavedAggregationsQueries: boolean; + + before(function () { + enableSavedAggregationsQueries = + preferencesAccess.getPreferences().enableSavedAggregationsQueries; }); - it('query history button renders when showQueryHistoryButton prop is passed and set to true', function () { - render(); + after(async function () { + await preferencesAccess.savePreferences({ + enableSavedAggregationsQueries, + }); + }); + + it('query history button renders when saved queries are enabled', async function () { + await preferencesAccess.savePreferences({ + enableSavedAggregationsQueries: true, + }); + render(); expect(screen.getByTestId('query-history-button')).to.exist; }); - it('query history button does not render when showQueryHistoryButton prop is passed and set to false', function () { - render(); + it('query history button does not render when ssaved queries are disabled', async function () { + await preferencesAccess.savePreferences({ + enableSavedAggregationsQueries: false, + }); + render(); expect(screen.queryByTestId('query-history-button')).to.not.exist; }); });