Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Fix showing OK sign in spite of error#14
  • Loading branch information
jahn96 committed Jul 8, 2020
commit 0de36bcf1ab73ffa3fc9643fa237fbde3466b88b
36 changes: 15 additions & 21 deletions src/CodeSnippetForm.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,9 @@ import { ICodeSnippet } from './CodeSnippetService';
import { IDocumentManager } from '@jupyterlab/docmanager';
import { CodeSnippetWidget } from './CodeSnippetWidget';

// import { ServerConnection } from '@jupyterlab/services';
// import { URLExt } from '@jupyterlab/coreutils';

/**
* The class name added to file dialogs.
*/
Expand Down Expand Up @@ -60,7 +63,7 @@ export function inputDialog(
} else {
/* TODO: if name is already there call shouldOverwrite and change to a put request*/
// Workaround: make a get request with result.value[0] to check... but could be slow
RequestHandler.makePostRequest(
const request = RequestHandler.makePostRequest(
//If i use their handler then I can't interrupt any error messages without editing their stuff.
url,
JSON.stringify({
Expand All @@ -75,27 +78,18 @@ export function inputDialog(
}),
false
);
codeSnippet.fetchData().then((codeSnippets: ICodeSnippet[]) => {
console.log('HELLLO');
codeSnippet.renderCodeSnippetsSignal.emit(codeSnippets);
});
showMessage({
body: /*"Saved as Snippet"*/ new MessageHandler()
});
// console.log(request);
request.then(_ => {
codeSnippet.fetchData().then((codeSnippets: ICodeSnippet[]) => {
console.log('HELLLO');
codeSnippet.renderCodeSnippetsSignal.emit(codeSnippets);
});
showMessage({
body: /*"Saved as Snippet"*/ new MessageHandler()
});
}
);
}
// if (!isValidFileName(result.value)) {
// void showErrorMessage(
// 'Rename Error',
// Error(
// `"${result.value}" is not a valid name for a file. ` +
// `Names must have nonzero length, ` +
// `and cannot include "/", "\\", or ":"`
// )
// );
// return null;
// }
//const basePath = PathExt.dirname(oldPath);
//const newPath = PathExt.join(basePath, result.value);
});
}

Expand Down
23 changes: 2 additions & 21 deletions src/CodeSnippetWidget.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -418,7 +418,7 @@ export class CodeSnippetWidget extends ReactWidget {
/**
* Hanlde the `'lm-drop'` event for the widget.
*/
private async _evtDrop(event: IDragEvent): Promise<void> {
private _evtDrop(event: IDragEvent): Promise<void> {
const data = Private.findData(event.mimeData);
if (data === undefined) {
return;
Expand Down Expand Up @@ -448,27 +448,8 @@ export class CodeSnippetWidget extends ReactWidget {
const url = 'elyra/metadata/code-snippets';
const code = Private.findData(event.mimeData);

await inputDialog(this,url, code);
inputDialog(this,url, code);
console.log(code);
// await RequestHandler.makePostRequest(
// url,
// JSON.stringify({
// display_name: 'drag_dropped',
// metadata: {
// code: [
// code
// ],
// description: 'Print dragged and dropped',
// language: 'python',
// },
// name: 'dragdropped',
// schema_name: 'code-snippet',
// }),
// false
// );
this.fetchData().then((codeSnippets: ICodeSnippet[]) => {
this.renderCodeSnippetsSignal.emit(codeSnippets);
});
}

render(): React.ReactElement {
Expand Down