Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update all plugin to wanted version Button #1456

Merged
merged 1 commit into from
Jun 5, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
3 changes: 2 additions & 1 deletion packages/@vue/cli-ui/locales/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -267,7 +267,8 @@
"project-plugins": {
"title": "Project plugins",
"button": "Add plugin",
"heading": "Installed plugins"
"heading": "Installed plugins",
"update-all": "Update all plugins"
},
"project-plugins-add": {
"title": "Add a plugin",
Expand Down
32 changes: 31 additions & 1 deletion packages/@vue/cli-ui/src/graphql-api/connectors/plugins.js
Original file line number Diff line number Diff line change
Expand Up @@ -350,7 +350,7 @@ async function initPrompts (id, context) {
await prompts.start()
}

function update (id, context) {
function update (id, context, notify = true) {
return progress.wrap('plugin-update', context, async setProgress => {
setProgress({
status: 'plugin-update',
Expand All @@ -361,15 +361,44 @@ function update (id, context) {
const { current, wanted } = await getVersion(plugin, context)
await updatePackage(cwd.get(), getCommand(), null, id)
resetPluginApi(context)

logs.add({
message: `Plugin ${id} updated from ${current} to ${wanted}`,
type: 'info'
}, context)

if (notify) {
notifier.notify({
title: `Plugin updated`,
message: `Plugin ${id} was successfully updated`,
icon: path.resolve(__dirname, '../../assets/done.png')
})
}

currentPluginId = null
return findOne(id)
})
}

async function updateAll (context) {
const plugins = await list(cwd.get(), context)
let updatedPlugins = []
for (const plugin of plugins) {
const version = await getVersion(plugin, context)
if (version.current !== version.wanted) {
updatedPlugins.push(await update(plugin.id, context, false))
}
}

notifier.notify({
title: `Plugins updated`,
message: `${updatedPlugins.length} plugin(s) were successfully updated`,
icon: path.resolve(__dirname, '../../assets/done.png')
})

return updatedPlugins
}

function getApi () {
return pluginApi
}
Expand Down Expand Up @@ -424,6 +453,7 @@ module.exports = {
install,
uninstall,
update,
updateAll,
runInvoke,
resetPluginApi,
getApi,
Expand Down
4 changes: 3 additions & 1 deletion packages/@vue/cli-ui/src/graphql-api/schema/plugin.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ extend type Mutation {
pluginFinishInstall: PluginInstallation
pluginUpdate (id: ID!): Plugin
pluginActionCall (id: ID!, params: JSON): PluginActionResult
pluginsUpdate: [Plugin]
}

extend type Subscription {
Expand Down Expand Up @@ -80,7 +81,8 @@ exports.resolvers = {
pluginInvoke: (root, { id }, context) => plugins.runInvoke(id, context),
pluginFinishInstall: (root, args, context) => plugins.finishInstall(context),
pluginUpdate: (root, { id }, context) => plugins.update(id, context),
pluginActionCall: (root, args, context) => plugins.callAction(args, context)
pluginActionCall: (root, args, context) => plugins.callAction(args, context),
pluginsUpdate: (root, args, context) => plugins.updateAll(context)
},

Subscription: {
Expand Down
10 changes: 10 additions & 0 deletions packages/@vue/cli-ui/src/graphql/pluginsUpdate.gql
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
#import "./versionFragment.gql"

mutation pluginsUpdate {
pluginsUpdate {
id
version {
...version
}
}
}
24 changes: 24 additions & 0 deletions packages/@vue/cli-ui/src/views/ProjectPlugins.vue
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,20 @@
:to="{ name: 'project-plugins-add' }"
data-testid="add-plugin"
/>

<VueDropdown>
<VueButton
slot="trigger"
icon-left="more_vert"
class="icon-button flat round"
/>

<VueDropdownButton
icon-left="file_download"
:label="$t('views.project-plugins.update-all')"
@click="updateAll()"
/>
</VueDropdown>
</template>

<ApolloQuery
Expand Down Expand Up @@ -43,13 +57,23 @@
</template>

<script>
import PLUGINS_UPDATE from '../graphql/pluginsUpdate.gql'

export default {
name: 'ProjectPlugins',

metaInfo () {
return {
title: this.$t('views.project-plugins.title')
}
},

methods: {
updateAll () {
return this.$apollo.mutate({
mutation: PLUGINS_UPDATE
})
}
}
}
</script>
Expand Down