diff --git a/src/renderer/App.js b/src/renderer/App.js index 7d98ff1aa3859..b480b92d04a11 100644 --- a/src/renderer/App.js +++ b/src/renderer/App.js @@ -9,6 +9,8 @@ import FtPrompt from './components/ft-prompt/ft-prompt.vue' import FtButton from './components/ft-button/ft-button.vue' import FtToast from './components/ft-toast/ft-toast.vue' import FtProgressBar from './components/ft-progress-bar/ft-progress-bar.vue' +import FtPlaylistAddVideoPrompt from './components/ft-playlist-add-video-prompt/ft-playlist-add-video-prompt.vue' +import FtCreatePlaylistPrompt from './components/ft-create-playlist-prompt/ft-create-playlist-prompt.vue' import { marked } from 'marked' import { IpcChannels } from '../constants' import packageDetails from '../../package.json' @@ -28,7 +30,9 @@ export default defineComponent({ FtPrompt, FtButton, FtToast, - FtProgressBar + FtProgressBar, + FtPlaylistAddVideoPrompt, + FtCreatePlaylistPrompt, }, data: function () { return { @@ -63,6 +67,12 @@ export default defineComponent({ checkForBlogPosts: function () { return this.$store.getters.getCheckForBlogPosts }, + showAddToPlaylistPrompt: function () { + return this.$store.getters.getShowAddToPlaylistPrompt + }, + showCreatePlaylistPrompt: function () { + return this.$store.getters.getShowCreatePlaylistPrompt + }, windowTitle: function () { const routeTitle = this.$route.meta.title if (routeTitle !== 'Channel' && routeTitle !== 'Watch' && routeTitle !== 'Hashtag') { diff --git a/src/renderer/App.vue b/src/renderer/App.vue index b4d7faa4ef45d..2e7ae23b9340c 100644 --- a/src/renderer/App.vue +++ b/src/renderer/App.vue @@ -74,6 +74,12 @@ :option-values="externalLinkOpeningPromptValues" @click="handleExternalLinkOpeningPromptAnswer" /> + + . +*/ + +/* +* Credit goes to pavelvaravko for making this css. +* https://codepen.io/pavelvaravko/pen/qjojOr +*/ + +/* select starting stylings ------------------------------*/ +.center { + text-align: center; +} + +.playlistNameInput { + width: 80%; + max-width: 600px; +} diff --git a/src/renderer/components/ft-create-playlist-prompt/ft-create-playlist-prompt.js b/src/renderer/components/ft-create-playlist-prompt/ft-create-playlist-prompt.js new file mode 100644 index 0000000000000..a35c622c0483c --- /dev/null +++ b/src/renderer/components/ft-create-playlist-prompt/ft-create-playlist-prompt.js @@ -0,0 +1,93 @@ +import Vue from 'vue' +import { mapActions } from 'vuex' +import FtFlexBox from '../ft-flex-box/ft-flex-box.vue' +import FtPrompt from '../ft-prompt/ft-prompt.vue' +import FtButton from '../ft-button/ft-button.vue' +import FtInput from '../ft-input/ft-input.vue' +import FtPlaylistSelector from '../ft-playlist-selector/ft-playlist-selector.vue' + +export default Vue.extend({ + name: 'FtCreatePlaylistPrompt', + components: { + FtFlexBox, + FtPrompt, + FtButton, + FtInput, + FtPlaylistSelector + }, + data: function () { + return { + playlistName: '', + playlistAddVideoPromptValues: [ + 'save', + 'cancel' + ], + selectedPlaylists: [] + } + }, + computed: { + allPlaylists: function () { + return this.$store.getters.getAllPlaylists + }, + newPlaylistVideoObject: function () { + return this.$store.getters.getNewPlaylistVideoObject + }, + videoImportLength: function () { + return this.newPlaylistVideoObject.videos.length + } + }, + mounted: function () { + this.playlistName = this.newPlaylistVideoObject.title + }, + methods: { + handleCreatePlaylistPrompt: function (option) { + this.hideCreatePlaylistPrompt() + }, + + createNewPlaylist: function () { + const videosObject = this.videoImportLength > 0 ? this.newPlaylistVideoObject.videos : [] + + const playlistObject = { + playlistName: this.playlistName, + protected: false, + removeOnWatched: false, + description: '', + videos: videosObject + } + + const nameExists = this.allPlaylists.findIndex((playlist) => { + return playlist.playlistName.toLowerCase() === this.playlistName.toLowerCase() + }) + + if (this.playlistName === '') { + this.showToast({ + message: 'Playlist name cannot be empty. Please input a name.' + }) + } else if (nameExists !== -1) { + this.showToast({ + message: 'There is already a playlist with this name. Please pick a different name.' + }) + } else { + try { + this.addPlaylist(playlistObject) + this.showToast({ + message: `Playlist ${this.playlistName} has been successfully created.` + }) + } catch (e) { + this.showToast({ + message: 'There was an issue with creating the playlist.' + }) + console.error(e) + } finally { + this.hideCreatePlaylistPrompt() + } + } + }, + + ...mapActions([ + 'showToast', + 'addPlaylist', + 'hideCreatePlaylistPrompt' + ]) + } +}) diff --git a/src/renderer/components/ft-create-playlist-prompt/ft-create-playlist-prompt.vue b/src/renderer/components/ft-create-playlist-prompt/ft-create-playlist-prompt.vue new file mode 100644 index 0000000000000..7e859b6b8810e --- /dev/null +++ b/src/renderer/components/ft-create-playlist-prompt/ft-create-playlist-prompt.vue @@ -0,0 +1,39 @@ + + +