Skip to content

Commit

Permalink
pure ide: improvements (#3643)
Browse files Browse the repository at this point in the history
* datacube: fix problem with no-column selected but drilldown with more than 1 col

* pure ide: improvements
  • Loading branch information
akphi authored Nov 3, 2024
1 parent 18e03b6 commit fa63201
Show file tree
Hide file tree
Showing 25 changed files with 764 additions and 151 deletions.
6 changes: 6 additions & 0 deletions .changeset/red-foxes-cry.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
---
'@finos/legend-application-pure-ide': patch
'@finos/legend-application': patch
'@finos/legend-data-cube': patch
'@finos/legend-dev-utils': patch
---
7 changes: 7 additions & 0 deletions .changeset/shy-beers-cough.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
---
'@finos/legend-application-pure-ide': patch
'@finos/legend-application': patch
'@finos/legend-data-cube': patch
'@finos/legend-dev-utils': patch
'@finos/legend-lego': patch
---
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ import {
getCollapsiblePanelGroupProps,
} from '@finos/legend-art';
import { LEGEND_PURE_IDE_ROUTE_PATTERN_TOKEN } from '../__lib__/LegendPureIDENavigation.js';
import { SelectPCTAdapterCommand } from './command-center/SelectPCTAdapterCommand.js';

export const Editor = withEditorStore(
observer(() => {
Expand Down Expand Up @@ -171,6 +172,7 @@ export const Editor = withEditorStore(
</div>
<StatusBar />
<FileSearchCommand />
<SelectPCTAdapterCommand />
</div>
);
}),
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,112 @@
/**
* Copyright (c) 2020-present, Goldman Sachs
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

import { observer } from 'mobx-react-lite';
import {
compareLabelFn,
CustomSelectorInput,
Dialog,
type SelectComponent,
} from '@finos/legend-art';
import { useApplicationStore } from '@finos/legend-application';
import { usePureIDEStore } from '../PureIDEStoreProvider.js';
import { flowResult } from 'mobx';
import type { PCTAdapter } from '../../server/models/Test.js';
import { useRef, useState } from 'react';

function buildPCTAdapterOption(adapter: PCTAdapter) {
return {
label: adapter.name === '' ? adapter.func : adapter.name,
value: adapter,
};
}

export const SelectPCTAdapterCommand = observer(() => {
const ideStore = usePureIDEStore();
const applicationStore = useApplicationStore();
const selectorRef = useRef<SelectComponent>(null);
const [menuOpen, setMenuOpen] = useState(false);

const closeModal = (): void => ideStore.setPCTRunPath(undefined);
const runPCT = (val: { label: string; value: PCTAdapter } | null): void => {
if (val) {
ideStore.setSelectedPCTAdapter(val.value);
if (ideStore.PCTRunPath) {
flowResult(
ideStore.executeTests(
ideStore.PCTRunPath,
false,
ideStore.selectedPCTAdapter?.func,
),
).catch(applicationStore.alertUnhandledError);
}
closeModal();
}
};
const handleEnter = (): void => {
selectorRef.current?.focus();
};

return (
<Dialog
open={Boolean(ideStore.PCTRunPath)}
onClose={closeModal}
TransitionProps={{
onEnter: handleEnter,
}}
classes={{ container: 'command-modal__container' }}
PaperProps={{ classes: { root: 'command-modal__inner-container' } }}
>
<div className="modal modal--dark command-modal">
<div className="modal__title">Select PCT Adapter</div>
<div className="command-modal__content">
<CustomSelectorInput
inputRef={selectorRef}
className="command-modal__content__input"
options={ideStore.PCTAdapters.map(buildPCTAdapterOption).sort(
compareLabelFn,
)}
onMenuOpen={() => setMenuOpen(true)}
onMenuClose={() => setMenuOpen(false)}
onKeyDown={(event) => {
if (
event.key === 'Enter' &&
ideStore.selectedPCTAdapter &&
!menuOpen
) {
event.stopPropagation();
event.preventDefault();
runPCT(buildPCTAdapterOption(ideStore.selectedPCTAdapter));
}
}}
value={
ideStore.selectedPCTAdapter
? buildPCTAdapterOption(ideStore.selectedPCTAdapter)
: null
}
onChange={runPCT}
placeholder="Select a PCT adapter"
escapeClearsValue={true}
darkMode={
!applicationStore.layoutService
.TEMPORARY__isLightColorThemeEnabled
}
/>
</div>
</div>
</Dialog>
);
});
Loading

0 comments on commit fa63201

Please sign in to comment.