Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4,737 changes: 4,705 additions & 32 deletions package-lock.json

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,7 @@
"@leafygreen-ui/input-option": "^3.0.4",
"@leafygreen-ui/polymorphic": "^2.0.5",
"@leafygreen-ui/search-input": "^5.0.2",
"@leafygreen-ui/code": "^16.0.2",
"@leafygreen-ui/code": "^20.0.8",
"@leafygreen-ui/text-area": "^10.0.2",
"@leafygreen-ui/card": "^12.0.2",
"@leafygreen-ui/logo": "^10.0.2"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -153,7 +153,7 @@ const ScriptScreen = ({
mockdatascript.js (or any name you'd like).
</Body>
<Code
copyable={scriptResult.success}
copyButtonAppearance={scriptResult.success ? 'hover' : 'persist'}
language={Language.JavaScript}
className={scriptCodeBlockStyles}
>
Expand All @@ -175,9 +175,7 @@ const ScriptScreen = ({
reversible.
</em>
</Body>
<Code copyable language={Language.Bash}>
{RUN_SCRIPT_COMMAND}
</Code>
<Code language={Language.Bash}>{RUN_SCRIPT_COMMAND}</Code>
</section>
<section
className={cx(
Expand Down
2 changes: 1 addition & 1 deletion packages/compass-components/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@
"@leafygreen-ui/card": "^12.0.2",
"@leafygreen-ui/checkbox": "^14.0.2",
"@leafygreen-ui/chip": "^3.0.12",
"@leafygreen-ui/code": "^16.0.2",
"@leafygreen-ui/code": "^20.0.8",
"@leafygreen-ui/combobox": "^11.0.2",
"@leafygreen-ui/confirmation-modal": "^6.0.2",
"@leafygreen-ui/copyable": "^10.0.14",
Expand Down
3 changes: 2 additions & 1 deletion packages/compass-components/src/components/leafygreen.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import { default as Badge } from '@leafygreen-ui/badge';
import { default as Banner } from '@leafygreen-ui/banner';
import Checkbox from '@leafygreen-ui/checkbox';
import Card from '@leafygreen-ui/card';
import Code, { Language } from '@leafygreen-ui/code';
import Code, { Language, Panel } from '@leafygreen-ui/code';
import ConfirmationModal from '@leafygreen-ui/confirmation-modal';
import { default as LeafyGreenIcon } from '@leafygreen-ui/icon';
import type { Size as LeafyGreenIconSize } from '@leafygreen-ui/icon';
Expand Down Expand Up @@ -144,6 +144,7 @@ export {
Checkbox,
Chip,
Code,
Panel,
ConfirmationModal,
Copyable,
ExpandedContent,
Expand Down
2 changes: 2 additions & 0 deletions packages/compass-components/src/hooks/use-error-details.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,8 @@ export const showErrorDetails = function showErrorDetails({
buttonText: closeAction.replace(/\b\w/g, (c) => c.toUpperCase()),
confirmButtonProps: {
variant: ButtonVariant.Default,
// @ts-expect-error actually supported by leafygreen, but not in types
autoFocus: true,
},
});
};
Original file line number Diff line number Diff line change
Expand Up @@ -260,9 +260,7 @@ const openNotifyDeviceAuthModal = (
<br></br>
<Body>Enter the following code on that page:</Body>
<Body as="div">
<Code language="none" copyable>
{userCode}
</Code>
<Code language="none">{userCode}</Code>
</Body>
</div>
),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -675,8 +675,13 @@ describe('Collection aggregations tab', function () {
await errorDetailsJson.waitForDisplayed();

// exit details
// leafygreen autofocus triggers a tooltip on the error code element,
// "Tab" to remove the focus
await browser.keys('Tab');
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

All three e2e tests failing after the update were caused by the leafygreen autofocus first thing in the modal behavior. The way of dealing with it is the same everywhere and it's more than two places, but I still didn't feel like it warrants a shared helper of some kind. Tell me if you have a different opinion on this

// now click the close button
await browser.clickVisible(Selectors.confirmationModalConfirmButton());
await errorElement.waitForDisplayed();
// wait for the modal to go away
await errorDetailsJson.waitForDisplayed({ reverse: true });
});
});

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -731,8 +731,13 @@ FindIterable<Document> result = collection.find(filter);`);
await errorDetailsJson.waitForDisplayed();

// exit details
// leafygreen autofocus triggers a tooltip on the error code element,
// "Tab" to remove the focus
await browser.keys('Tab');
// now click the close button
await browser.clickVisible(Selectors.confirmationModalConfirmButton());
await errorElement.waitForDisplayed();
// wait for the modal to go away
await errorDetailsJson.waitForDisplayed({ reverse: true });
});

describe('Editing', function () {
Expand Down
6 changes: 6 additions & 0 deletions packages/compass-e2e-tests/tests/collection-import.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -595,7 +595,13 @@ describe('Collection import', function () {
expect(await errorDetailsJson.getText()).to.include(
'schemaRulesNotSatisfied'
);
// leafygreen autofocus triggers a tooltip on the error code element,
// "Tab" to remove the focus
await browser.keys('Tab');
// now click the close button
await browser.clickVisible(Selectors.confirmationModalConfirmButton());
// wait for the modal to go away
await errorDetailsJson.waitForDisplayed({ reverse: true });
});

it('with CSV + abort on error unchecked, it includes the details in a file', async function () {
Expand Down
56 changes: 39 additions & 17 deletions packages/compass-export-to-language/src/components/modal.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,9 @@ import {
Banner,
spacing,
FormFieldContainer,
Panel,
} from '@mongodb-js/compass-components';
import type { Language } from '@mongodb-js/compass-components';
import {
outputLanguageToCodeLanguage,
codeLanguageToOutputLanguage,
} from '../modules/languages';
import type { OutputLanguage } from '../modules/languages';
import { isQueryExpression, runTranspiler } from '../modules/transpiler';
import type { InputExpression } from '../modules/transpiler';
Expand All @@ -33,14 +30,24 @@ type LanguageOption = {
const languageOptions: LanguageOption[] = [
{ displayName: 'Java', language: 'java' },
{ displayName: 'Node', language: 'javascript' },
{ displayName: 'C#', language: 'cs' },
{ displayName: 'C#', language: 'csharp' },
{ displayName: 'Python', language: 'python' },
{ displayName: 'Ruby', language: 'ruby' },
{ displayName: 'Go', language: 'go' },
{ displayName: 'Rust', language: 'rust' },
{ displayName: 'PHP', language: 'php' },
];

const SUPPORTED_LANGUAGES = new Set<string>(
languageOptions.map((opt) => {
return opt.language;
})
);

function isSupportedLanguage(lang: string): lang is OutputLanguage {
return SUPPORTED_LANGUAGES.has(lang);
}

const shellLanguageOptions: LanguageOption[] = [
{ displayName: 'Shell', language: 'javascript' },
];
Expand Down Expand Up @@ -73,6 +80,13 @@ const editorHeadingStyles = css({
const codeStyles = css({
alignItems: 'start',
height: `${spacing[1600] * 4 - spacing[800]}px`,
'& > div': {
height: '100%',
gridTemplateRows: 'min-content auto',
},
'& pre': {
alignItems: 'flex-start',
},
});

const checkboxStyles = css({
Expand Down Expand Up @@ -240,13 +254,16 @@ const ExportToLanguageModal: React.FunctionComponent<
className={codeStyles}
id="export-to-language-input"
data-testid="export-to-language-input"
languageOptions={shellLanguageOptions}
onChange={() => {
// There is only one language option and we don't allow to change
// the value
}}
language="Shell"
copyable={true}
panel={
<Panel
languageOptions={shellLanguageOptions}
onChange={() => {
// There is only one language option and we don't allow to change
// the value
}}
></Panel>
}
>
{prettyInput}
</Code>
Expand All @@ -265,14 +282,19 @@ const ExportToLanguageModal: React.FunctionComponent<
<Code
className={codeStyles}
id="export-to-language-output"
language={outputLanguage}
data-testid="export-to-language-output"
languageOptions={languageOptions}
onChange={(option: LanguageOption) =>
setOutputLanguage(codeLanguageToOutputLanguage(option.language))
panel={
<Panel
languageOptions={languageOptions}
onChange={(option: LanguageOption) => {
if (isSupportedLanguage(option.language)) {
return setOutputLanguage(option.language);
}
}}
onCopy={trackCopiedOutput}
></Panel>
}
language={outputLanguageToCodeLanguage(outputLanguage)}
copyable={true}
onCopy={trackCopiedOutput}
>
{transpiledExpression || ''}
</Code>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,6 @@ function ExportCodeView({
data-testid="export-collection-code-preview-wrapper"
id={codeElementId}
language="javascript"
copyable
>
{code}
</Code>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ export const QueryItemContent: React.FunctionComponent<{
className={queryCodeStyles}
data-testid="query-history-query-code"
language="javascript"
copyable={false}
copyButtonAppearance="none"
>
{formatQuery(value)}
</Code>
Expand Down