这是indexloc提供的服务,不要输入任何密码
Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
26 commits
Select commit Hold shift + click to select a range
6aff448
allow downloading framework starter kit
Apr 6, 2020
6e8943e
derive: improve error message for invalid query
Apr 6, 2020
3d6fe9a
move action buttons to extreme right
Apr 6, 2020
5b7ebed
improve error message
Apr 7, 2020
e66d348
Merge branch 'master' into issue-4306
Apr 7, 2020
5d37b58
cli: actions_use_codegen, clone the starter kit before asking for out…
arvi3411301 Apr 8, 2020
c7c6ed7
requested changes; hide clone type anchor
Apr 9, 2020
1595e7a
Merge branch 'issue-4306' of github.com:wawhal/graphql-engine into is…
Apr 9, 2020
e0bc4b2
improve icon component; move github out of button
Apr 9, 2020
b1c54b9
allow deriving actions from operations without variables
Apr 10, 2020
65d9c94
add helper text for codegen buttons
Apr 10, 2020
1769ba1
remove unnecessary files
Apr 10, 2020
77be7aa
Merge branch 'master' into issue-4306
Apr 10, 2020
3426309
Merge branch 'issue-4311' of github.com:arvi3411301/graphql-engine in…
Apr 10, 2020
5369e2d
Merge branch 'master' of github.com:hasura/graphql-engine into issue-…
Apr 10, 2020
7b310b3
Merge branch 'issue-4306' of github.com:wawhal/graphql-engine into is…
Apr 10, 2020
30472e6
Merge branch 'master' into issue-4306
Apr 13, 2020
7a198bd
merge with master
Apr 13, 2020
7e792f5
Merge branch 'issue-4306' of github.com:wawhal/graphql-engine into is…
Apr 13, 2020
3ecbc5f
change cli-ext runtime to node12; stop cli spinner after cloning star…
Apr 13, 2020
2250014
add helper comments for query type actions
Apr 14, 2020
8d05d9d
Merge branch 'master' of github.com:hasura/graphql-engine into issue-…
Apr 14, 2020
8a26e08
show warning if operation without a variable is derived
Apr 15, 2020
f3706b7
hide the helper tools section if no helper tools exist
Apr 15, 2020
dee24a1
make helper links on codegen page blue
Apr 15, 2020
89db176
Merge branch 'master' into issue-4306
tirumaraiselvan Apr 16, 2020
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 changes: 2 additions & 2 deletions cli-ext/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
"pretranspile": "npm run get-shared-modules",
"transpile": "rm -rf build/* && babel ./src ./tests --out-dir build",
"prebuild": "npm run transpile",
"build": "rm -rf ./bin/* && pkg ./build/command.js --output ./bin/cli-ext-hasura -t node8-linux-x64,node8-macos-x64,node8-win-x64",
"build": "rm -rf ./bin/* && pkg ./build/command.js --output ./bin/cli-ext-hasura -t node12-linux-x64,node12-macos-x64,node12-win-x64",
"pretest": "npm run transpile && babel ./tests --out-dir _tmptests",
"posttest": "rm -rf _tmptests",
"test": "node ./_tmptests/index.js"
Expand All @@ -29,4 +29,4 @@
"@babel/plugin-transform-async-to-generator": "^7.7.4",
"@babel/preset-env": "^7.7.6"
}
}
}
23 changes: 12 additions & 11 deletions cli/commands/actions_use_codegen.go
Original file line number Diff line number Diff line change
Expand Up @@ -120,17 +120,6 @@ func (o *actionsUseCodegenOptions) run() error {
o.withStarterKit = shouldCloneStarterKit == "y"
}

// if output directory is not provided, make them enter it
if o.outputDir == "" {
outputDir, err := util.GetFSPathPrompt("Where do you want to place the codegen files?", o.EC.Config.ActionConfig.Codegen.OutputDir)
if err != nil {
return errors.Wrap(err, "error in getting output directory input")
}
newCodegenExecutionConfig.OutputDir = outputDir
} else {
newCodegenExecutionConfig.OutputDir = o.outputDir
}

// clone the starter kit
o.EC.Spin("Clonning the starter kit...")
if o.withStarterKit && hasStarterKit {
Expand Down Expand Up @@ -158,6 +147,18 @@ func (o *actionsUseCodegenOptions) run() error {
}
o.EC.Logger.Info("Starter kit cloned at " + destinationDir)
}
o.EC.Spinner.Stop()

// if output directory is not provided, make them enter it
if o.outputDir == "" {
outputDir, err := util.GetFSPathPrompt("Where do you want to place the codegen files?", o.EC.Config.ActionConfig.Codegen.OutputDir)
if err != nil {
return errors.Wrap(err, "error in getting output directory input")
}
newCodegenExecutionConfig.OutputDir = outputDir
} else {
newCodegenExecutionConfig.OutputDir = o.outputDir
}

newConfig := o.EC.Config
newConfig.ActionConfig.Codegen = newCodegenExecutionConfig
Expand Down
13 changes: 1 addition & 12 deletions cli/util/prompt.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ const (
)

func GetYesNoPrompt(message string) (promptResp string, err error) {

prompt := promptui.Prompt{
Label: message + " (y/n)",
Validate: func(_resp string) (err error) {
Expand All @@ -28,38 +27,28 @@ func GetYesNoPrompt(message string) (promptResp string, err error) {
},
Default: "y",
}

promptResp, err = prompt.Run()
if err != nil {
return
}
promptResp = string(strings.ToLower(promptResp)[0])

return

}

func GetSelectPrompt(message string, options []string) (selection string, err error) {
prompt := promptui.Select{
Label: message,
Items: options,
}

_, selection, err = prompt.Run()

return
}

func GetFSPathPrompt(message string, def string) (input string, err error) {

prompt := promptui.Prompt{
Label: message,
Validate: FSCheckIfDirPathExists,
Default: def,
}

input, err = prompt.Run()

return

return prompt.Run()
}
7 changes: 7 additions & 0 deletions console/src/components/Common/Common.scss
Original file line number Diff line number Diff line change
Expand Up @@ -1404,6 +1404,13 @@ code {
margin-right: 50px !important;
}

.marginLeftAuto {
margin-left: auto;
}

.textAlignRight {
text-align: right;
}
/* container height subtracting top header and bottom scroll bar */
$mainContainerHeight: calc(100vh - 50px - 25px);

Expand Down
30 changes: 15 additions & 15 deletions console/src/components/Services/Actions/Add/Add.js
Original file line number Diff line number Diff line change
Expand Up @@ -86,9 +86,11 @@ const AddAction = ({
let actionType;
if (!actionDefinitionError) {
// TODO optimise
const { type, error } = getActionDefinitionFromSdl(actionDefinitionSdl);
if (!error) {
actionType = type;
if (!actionParseTimer) {
const { type, error } = getActionDefinitionFromSdl(actionDefinitionSdl);
if (!error) {
actionType = type;
}
}
}

Expand Down Expand Up @@ -120,18 +122,16 @@ const AddAction = ({
service="create-action"
/>
<hr />
{
actionType === "query" ? null : (
<React.Fragment>
<KindEditor
value={kind}
onChange={kindOnChange}
className={styles.add_mar_bottom_mid}
/>
<hr />
</React.Fragment>
)
}
{actionType === 'query' ? null : (
<React.Fragment>
<KindEditor
value={kind}
onChange={kindOnChange}
className={styles.add_mar_bottom_mid}
/>
<hr />
</React.Fragment>
)}
<HeadersConfEditor
forwardClientHeaders={forwardClientHeaders}
toggleForwardClientHeaders={toggleForwardClientHeaders}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import TSEditor from '../../../Common/AceEditor/TypescriptEditor';
import { getFrameworkCodegen } from './utils';
import { getFileExtensionFromFilename } from '../../../Common/utils/jsUtils';
import { Tabs, Tab } from 'react-bootstrap';
import styles from '../Actions.scss';

const CodeTabs = ({
framework,
Expand All @@ -19,6 +20,7 @@ const CodeTabs = ({

const init = () => {
setLoading(true);
setError(null);
getFrameworkCodegen(
framework,
currentAction.action_name,
Expand All @@ -45,7 +47,7 @@ const CodeTabs = ({
return (
<div>
Error generating code.&nbsp;
<a onClick={init}>Try again</a>
<a onClick={init} className={styles.cursorPointer}>Try again</a>
</div>
);
}
Expand Down
71 changes: 52 additions & 19 deletions console/src/components/Services/Actions/Codegen/Codegen.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,13 @@ import { getSdlComplete } from '../../../../shared/utils/sdlUtils';
import {
getAllCodegenFrameworks,
getStarterKitPath,
getStarterKitDownloadPath,
getGlitchProjectURL,
} from './utils';
import { getPersistedDerivedAction } from '../lsUtils';
import Spinner from '../../../Common/Spinner/Spinner';
import styles from '../Common/components/Styles.scss';
import Button from '../../../Common/Button/Button';
import { Icon } from '../../../UIKit/atoms';
import CodeTabs from './CodeTabs';
import DerivedFrom from './DerivedFrom';

Expand All @@ -31,6 +32,7 @@ const Codegen = ({ allActions, allTypes, currentAction }) => {

const init = () => {
setLoading(true);
setError(null);
getAllCodegenFrameworks()
.then(frameworks => {
setAllFrameworks(frameworks);
Expand All @@ -54,7 +56,9 @@ const Codegen = ({ allActions, allTypes, currentAction }) => {
return (
<div>
Error fetching codegen assets.&nbsp;
<a onClick={init}>Try again</a>
<a onClick={init} className={styles.cursorPointer}>
Try again
</a>
</div>
);
}
Expand Down Expand Up @@ -89,13 +93,9 @@ const Codegen = ({ allActions, allTypes, currentAction }) => {
href={getGlitchProjectURL()}
target="_blank"
rel="noopener noreferrer"
className={styles.add_mar_right}
>
<Button
color="white"
className={`${styles.add_mar_right_mid} ${styles.default_button}`}
>
Try on glitch
</Button>
<Icon type="link" /> Try on glitch
</a>
);
};
Expand All @@ -110,24 +110,57 @@ const Codegen = ({ allActions, allTypes, currentAction }) => {
) {
return null;
}

return (
<a
href={getStarterKitPath(selectedFramework)}
target="_blank"
rel="noopener noreferrer"
>
<Button color="white" className={`${styles.add_mar_right_mid}`}>
Get starter kit
</Button>
</a>
<React.Fragment>
<a
href={getStarterKitDownloadPath(selectedFramework)}
target="_blank"
rel="noopener noreferrer"
className={styles.add_mar_right}
title={`Download starter kit for ${selectedFramework}`}
>
<Icon type="download" /> Starter-kit.zip
</a>
<a
href={getStarterKitPath(selectedFramework)}
target="_blank"
rel="noopener noreferrer"
className={styles.display_flex}
title={`View the starter kit for ${selectedFramework} on GitHub`}
>
<Icon type="github" className={styles.add_mar_right_small} /> View
on GitHub
</a>
</React.Fragment>
);
};

const getHelperToolsSection = () => {
const glitchButton = getGlitchButton();
const starterKitButtons = getStarterKitButton();
if (!glitchButton && !starterKitButtons) {
return null;
}
return (
<div className={styles.marginLeftAuto}>
<div
className={`${styles.add_mar_bottom_small} ${styles.textAlignRight}`}
>
<b>Need help getting started quickly?</b>
</div>
<div className={`${styles.display_flex}`}>
{getGlitchButton()}
{getStarterKitButton()}
</div>
</div>
);
};

return (
<div className={`${styles.add_mar_bottom} ${styles.display_flex}`}>
{getDrodown()}
{getGlitchButton()}
{getStarterKitButton()}
{getHelperToolsSection()}
</div>
);
};
Expand Down
3 changes: 3 additions & 0 deletions console/src/components/Services/Actions/Codegen/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,9 @@ export const getStarterKitPath = framework => {
return `https://github.com/${CODEGEN_REPO}/tree/master/${framework}/starter-kit/`;
};

export const getStarterKitDownloadPath = framework => {
return `https://github.com/${CODEGEN_REPO}/raw/master/${framework}/${framework}.zip`;
};
export const getGlitchProjectURL = () => {
return 'https://glitch.com/edit/?utm_content=project_hasura-actions-starter-kit&utm_source=remix_this&utm_medium=button&utm_campaign=glitchButton#!/remix/hasura-actions-starter-kit';
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ const ActionDefinitionEditor = ({
{error && (
<div className={`${styles.display_flex} ${styles.errorMessage}`}>
<CrossIcon className={styles.add_mar_right_small} />
<p>{errorMessage}</p>
<div>{errorMessage}</div>
</div>
)}
</div>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,4 +31,3 @@
.cloneTypeText {
margin-left: auto;
}

Original file line number Diff line number Diff line change
Expand Up @@ -79,24 +79,27 @@ const ActionDefinitionEditor = ({
<div>{errorMessage}</div>
</div>
)}
<a
className={`${styles.cloneTypeText} ${styles.cursorPointer} ${styles.add_mar_right}`}
onClick={toggleModal}
>
<CopyIcon className={styles.add_mar_right_small} />
Clone an existing type
</a>
<Modal
show={modalOpen}
title={'Clone an existing type'}
onClose={toggleModal}
customClass={styles.modal}
>
<CloneTypeModal
handleClonedTypes={handleClonedTypes}
toggleModal={toggleModal}
/>
</Modal>
{/*
<a
className={`${styles.cloneTypeText} ${styles.cursorPointer} ${styles.add_mar_right}`}
onClick={toggleModal}
>
<CopyIcon className={styles.add_mar_right_small} />
Clone an existing type
</a>
<Modal
show={modalOpen}
title={'Clone an existing type'}
onClose={toggleModal}
customClass={styles.modal}
>
<CloneTypeModal
handleClonedTypes={handleClonedTypes}
toggleModal={toggleModal}
/>
</Modal>

*/}
</div>
<SDLEditor
name="sdl-editor"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,12 @@ export const defaultEnumType = {
values: [{ ...defaultEnumValue }],
};

export const defaultActionDefSdl = `type Mutation {
## Define your action as a mutation here
export const defaultActionDefSdl = `## Use "type Query" for query type actions
## Use "type Mutation" for mutation type actions

#type Query {
type Mutation {
# Define your action here
actionName (arg1: SampleInput!): SampleOutput
}
`;
Expand Down
1 change: 0 additions & 1 deletion console/src/components/Services/Actions/Common/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -292,4 +292,3 @@ export const getOverlappingTypeConfirmation = (

return isOk;
};

Loading