/* * Copyright 2015 Mirantis, Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); you may * not use this file except in compliance with the License. You may obtain * a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the * License for the specific language governing permissions and limitations * under the License. **/ import $ from 'jquery'; import _ from 'underscore'; import i18n from 'i18n'; import React from 'react'; import utils from 'utils'; import models from 'models'; import {Tooltip} from 'views/controls'; var PluginsPage = React.createClass({ statics: { title: i18n('plugins_page.title'), navbarActiveElement: 'plugins', breadcrumbsPath: [['home', '#'], 'plugins'], fetchData() { var releases = app.releases; var plugins = new models.Plugins(); var availableVersions = {}; return $.when( plugins.fetch() .then(() => { return $.when(...plugins.map((plugin) => { var links = new models.PluginLinks(); links.url = _.result(plugin, 'url') + '/links'; plugin.set({links: links}); return links.fetch(); })); }), releases.fetch({cache: true}) .then(() => { releases.each((release) => { availableVersions[ release.get('operating_system').toLowerCase() + '-' + release.get('version') ] = true; }); }) ) .then(() => ({plugins, availableVersions})); } }, getDefaultProps() { return { details: [ 'version', 'description', 'homepage', 'authors', 'licenses', 'releases', 'links' ] }; }, processPluginData(plugin, attribute) { var data = plugin.get(attribute); if (attribute === 'releases') { return _.map(_.groupBy(data, 'os'), (osReleases, osName) =>