diff --git a/src/components/notes-list/note-card/NoteCard.scss b/src/components/notes-list/note-card/NoteCard.scss index 6027457..8e791cb 100644 --- a/src/components/notes-list/note-card/NoteCard.scss +++ b/src/components/notes-list/note-card/NoteCard.scss @@ -40,6 +40,14 @@ color: lighten($dark, 20%); } } + + #convert-note { + color: $dark; + + &:hover { + color: lighten($dark, 20%); + } + } } } diff --git a/src/components/notes-list/note-card/NoteCard.vue b/src/components/notes-list/note-card/NoteCard.vue index 73c0418..f35198d 100644 --- a/src/components/notes-list/note-card/NoteCard.vue +++ b/src/components/notes-list/note-card/NoteCard.vue @@ -7,10 +7,7 @@

{{ note.description }} - +

{{ note.name }}

@@ -25,17 +22,18 @@ + + + + - + @@ -49,18 +47,13 @@ :data="tag" :style="'background-color: ' + stringToColour(tag) + ';'" :key="tag.text" - >{{ tag }} + >{{ tag }} -
+

{{ value.name }} - ({{ value.language }}) + + ({{ value.language }}) { + this.$buefy.dialog.confirm({ + title: "Successful", + message: + "Note was converted to gist.
Do you want to delete local note ?", + confirmText: "Delete", + cancelText: "Keep", + type: "is-success", + icon: "check-circle", + hasIcon: true, + onConfirm: () => { + this.deleteNote(this.note); + this.selectGists(true); + }, + onCancel: () => { + this.selectGists(true); + } + }); + }) + .catch(() => { + this.$buefy.dialog.alert({ + title: "Error", + message: "Note was not converted to gist.
Please retry later.", + type: "is-danger", + hasIcon: true, + icon: "times-circle" + }); + }); + }, onCopyClipboardSuccess() { this.$toast.open({ message: "Copied", diff --git a/src/converter.js b/src/converter.js index 9bd4741..d3903d8 100644 --- a/src/converter.js +++ b/src/converter.js @@ -48,17 +48,20 @@ const converter = { }, noteToGist(note) { const files = {}; - - note.files.forEach(file => { - files[`${file.name}.${this.languageToExtension(file.language)}`] = { - content: file.content + Object.keys(note.files).forEach(key => { + files[ + `${note.files[key].name}.${this.languageToExtension( + note.files[key].language + )}` + ] = { + content: note.files[key].content }; }); return { id: note.id, public: note.public, - description: note.description, + description: `${note.name} - ${note.description}`, files }; } diff --git a/src/store/modules/Note.js b/src/store/modules/Note.js index 83f41ea..6d2a496 100644 --- a/src/store/modules/Note.js +++ b/src/store/modules/Note.js @@ -114,6 +114,10 @@ const actions = { actions.writeFileToFS(note, false); } }, + convertToGist(store, note) { + const octokit = getOctokit(store.rootState.Settings.settings); + return octokit.gists.create(converter.noteToGist(note)); + }, updateNote(store, note) { if (store.state.gistsSelected) { const octokit = getOctokit(store.rootState.Settings.settings); diff --git a/src/store/modules/Settings.js b/src/store/modules/Settings.js index cd34bf4..d94978b 100644 --- a/src/store/modules/Settings.js +++ b/src/store/modules/Settings.js @@ -43,7 +43,8 @@ const actions = { }; const getters = { - settings: state => state.settings + settings: state => state.settings, + githubToken: state => state.settings.githubPersonalAccessToken }; export default {