|
| 1 | +import React from 'react'; |
| 2 | +import { |
| 3 | + Body, |
| 4 | + Code, |
| 5 | + Copyable, |
| 6 | + css, |
| 7 | + cx, |
| 8 | + InlineCode, |
| 9 | + Language, |
| 10 | + Link, |
| 11 | + Overline, |
| 12 | + palette, |
| 13 | + spacing, |
| 14 | + useDarkMode, |
| 15 | +} from '@mongodb-js/compass-components'; |
| 16 | + |
| 17 | +const RUN_SCRIPT_COMMAND = ` |
| 18 | +mongosh "mongodb+srv://<your-cluster>.mongodb.net/mockDataDB" \\ |
| 19 | + --username <yourUsername> \\ |
| 20 | + --password "<yourPassword>" \\ |
| 21 | + mockdatascript.js |
| 22 | +`; |
| 23 | + |
| 24 | +const outerSectionStyles = css({ |
| 25 | + display: 'flex', |
| 26 | + flexDirection: 'column', |
| 27 | + gap: spacing[400], |
| 28 | +}); |
| 29 | + |
| 30 | +const listStyles = css({ |
| 31 | + listStylePosition: 'inside', |
| 32 | + listStyleType: 'disc', |
| 33 | + marginLeft: spacing[200], |
| 34 | +}); |
| 35 | + |
| 36 | +const copyableStyles = css({ |
| 37 | + marginLeft: spacing[400], |
| 38 | +}); |
| 39 | + |
| 40 | +const sectionInstructionStyles = css({ |
| 41 | + margin: `${spacing[200]}px 0`, |
| 42 | +}); |
| 43 | + |
| 44 | +const resourceSectionStyles = css({ |
| 45 | + padding: `${spacing[400]}px ${spacing[800]}px`, |
| 46 | + borderRadius: spacing[400], |
| 47 | +}); |
| 48 | + |
| 49 | +const resourceSectionLightStyles = css({ |
| 50 | + backgroundColor: palette.gray.light3, |
| 51 | +}); |
| 52 | + |
| 53 | +const resourceSectionDarkStyles = css({ |
| 54 | + backgroundColor: palette.gray.dark3, |
| 55 | +}); |
| 56 | + |
| 57 | +const resourceSectionHeader = css({ |
| 58 | + marginBottom: spacing[300], |
| 59 | +}); |
| 60 | + |
| 61 | +const ScriptScreen = () => { |
| 62 | + const isDarkMode = useDarkMode(); |
| 63 | + |
| 64 | + return ( |
| 65 | + <section className={outerSectionStyles}> |
| 66 | + <section> |
| 67 | + <Body baseFontSize={16} weight="medium"> |
| 68 | + Prerequisites |
| 69 | + </Body> |
| 70 | + <Body className={css({ marginTop: spacing[200] })}> |
| 71 | + To run the generated script, you must: |
| 72 | + </Body> |
| 73 | + <ul className={listStyles}> |
| 74 | + <li> |
| 75 | + Install{' '} |
| 76 | + <Link href="https://www.mongodb.com/docs/mongodb-shell/install/"> |
| 77 | + mongosh |
| 78 | + </Link> |
| 79 | + </li> |
| 80 | + <li> |
| 81 | + Install{' '} |
| 82 | + <Link href="https://fakerjs.dev/guide/#installation">faker.js</Link> |
| 83 | + <Copyable className={copyableStyles}> |
| 84 | + npm install @faker-js/faker |
| 85 | + </Copyable> |
| 86 | + </li> |
| 87 | + </ul> |
| 88 | + </section> |
| 89 | + <section> |
| 90 | + <Body baseFontSize={16} weight="medium"> |
| 91 | + 1. Create a .js file with the following script |
| 92 | + </Body> |
| 93 | + <Body className={sectionInstructionStyles}> |
| 94 | + In the directory that you created, create a file |
| 95 | + named mockdatascript.js (or any name you’d like). |
| 96 | + </Body> |
| 97 | + {/* TODO: Fill in with real code */} |
| 98 | + <Code copyable language={Language.JavaScript}> |
| 99 | + TK |
| 100 | + </Code> |
| 101 | + </section> |
| 102 | + <section> |
| 103 | + <Body baseFontSize={16} weight="medium"> |
| 104 | + 2. Run the script with <InlineCode>mongosh</InlineCode> |
| 105 | + </Body> |
| 106 | + <Body className={sectionInstructionStyles}> |
| 107 | + In the same working directory run the command below. Please{' '} |
| 108 | + <strong>paste in your username and password</strong> where there are |
| 109 | + placeholders.{' '} |
| 110 | + <em> |
| 111 | + Note that this will add data to your cluster and will not be |
| 112 | + reversible. |
| 113 | + </em> |
| 114 | + </Body> |
| 115 | + <Code copyable language={Language.Bash}> |
| 116 | + {RUN_SCRIPT_COMMAND} |
| 117 | + </Code> |
| 118 | + </section> |
| 119 | + <section |
| 120 | + className={cx( |
| 121 | + resourceSectionStyles, |
| 122 | + isDarkMode ? resourceSectionDarkStyles : resourceSectionLightStyles |
| 123 | + )} |
| 124 | + > |
| 125 | + <Overline className={resourceSectionHeader}>Resources</Overline> |
| 126 | + <ul> |
| 127 | + <li> |
| 128 | + <Link href="https://www.mongodb.com/docs/atlas/synthetic-data/"> |
| 129 | + Generating Synthetic Data with MongoDB |
| 130 | + </Link> |
| 131 | + </li> |
| 132 | + <li> |
| 133 | + <Link href="https://www.mongodb.com/docs/mongodb-shell/"> |
| 134 | + Learn About the MongoDB Shell |
| 135 | + </Link> |
| 136 | + </li> |
| 137 | + <li> |
| 138 | + {/* TODO: Update URL */} |
| 139 | + <Link href="#">Access your Database Users</Link> |
| 140 | + </li> |
| 141 | + </ul> |
| 142 | + </section> |
| 143 | + </section> |
| 144 | + ); |
| 145 | +}; |
| 146 | + |
| 147 | +export default ScriptScreen; |
0 commit comments