How to use the horizon.tables.LinkAction function in horizon

To help you get started, we’ve selected a few horizon examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github intel / virtual-storage-manager / source / vsm-dashboard / vsm_dashboard / dashboards / vsm / openstackconnect / tables.py View on Github external
return True

class DelOpenstackEndpointAction(tables.DeleteAction):
    data_type_singular = ("IP")
    data_type_plural = ("IPs")
    classes = ("btn-delopenstackip",)

    # TODO delete openstack endpoint
    def allowed(self, request, datum):
        return False

    def delete(self, request, obj_id):
        LOG.info("CEPH_LOG DELOPENSTACKIP: DELETE %s" % obj_id)
        vsmapi.del_appnode(request, obj_id)

class EditOpenstackEndpointAction(tables.LinkAction):
    name = "edit openstack endpoint"
    verbose_name = _("Edit")
    url = "horizon:vsm:openstackconnect:update"
    classes = ("ajax-modal", "btn-primary")

    def allowed(self, request, datum):
        return len([x for x in vsmapi.pool_usages(request) if x.attach_status=="success"]) == 0

class ListOpenstackEndpointTable(tables.DataTable):

    id = tables.Column("id", verbose_name=_("ID"), classes=("ip_list",), hidden=True)
    os_tenant_name = tables.Column("os_tenant_name", verbose_name=_("Tenant Name"))
    os_username = tables.Column("os_username", verbose_name=_("UserName"))
    os_password = tables.Column("os_password", verbose_name=_("Password"), hidden=True)
    os_auth_url = tables.Column("os_auth_url", verbose_name=_("Auth Url"))
    os_region_name = tables.Column("os_region_name", verbose_name=_("Region Name"))
github openstack / horizon / openstack_dashboard / dashboards / project / firewalls / tables.py View on Github external
return base_url


class UpdatePolicyLink(policy.PolicyTargetMixin, tables.LinkAction):
    name = "updatepolicy"
    verbose_name = _("Edit Policy")
    classes = ("ajax-modal", "btn-update",)
    policy_rules = (("network", "update_firewall_policy"),)

    def get_link_url(self, policy):
        base_url = reverse("horizon:project:firewalls:updatepolicy",
                           kwargs={'policy_id': policy.id})
        return base_url


class UpdateFirewallLink(policy.PolicyTargetMixin, tables.LinkAction):
    name = "updatefirewall"
    verbose_name = _("Edit Firewall")
    classes = ("ajax-modal", "btn-update",)
    policy_rules = (("network", "update_firewall"),)

    def get_link_url(self, firewall):
        base_url = reverse("horizon:project:firewalls:updatefirewall",
                           kwargs={'firewall_id': firewall.id})
        return base_url

    def allowed(self, request, firewall):
        if firewall.status in ("PENDING_CREATE",
                               "PENDING_UPDATE",
                               "PENDING_DELETE"):
            return False
        return True
github openstack / horizon / openstack_dashboard / dashboards / identity / mappings / tables.py View on Github external
from horizon import tables

from openstack_dashboard import api


class CreateMappingLink(tables.LinkAction):
    name = "create"
    verbose_name = _("Create Mapping")
    url = "horizon:identity:mappings:create"
    classes = ("ajax-modal",)
    icon = "plus"
    policy_rules = (("identity", "identity:create_mapping"),)


class EditMappingLink(tables.LinkAction):
    name = "edit"
    verbose_name = _("Edit")
    url = "horizon:identity:mappings:update"
    classes = ("ajax-modal",)
    icon = "pencil"
    policy_rules = (("identity", "identity:update_mapping"),)


class DeleteMappingsAction(tables.DeleteAction):
    @staticmethod
    def action_present(count):
        return ungettext_lazy(
            u"Delete Mapping",
            u"Delete Mappings",
            count
        )
github openstack / solum-dashboard / solumdashboard / assemblies / tables.py View on Github external
def action_past(count):
        return ungettext_lazy(
            u"Scheduled deletion of Assembly",
            u"Scheduled deletion of Assemblies",
            count
        )

    def allowed(self, request, template):
        return True

    def action(self, request, assembly_id):
        solum = solumclient(request)
        solum.assemblies.delete(assembly_id=assembly_id)


class ViewAssembly(tables.LinkAction):
    name = "view"
    verbose_name = _("View")
    url = "horizon:solum:assemblies:detail"
    classes = ("btn-edit",)


class AssembliesTable(tables.DataTable):
    uuid = tables.Column('uuid', verbose_name=_('UUID'),
                         link=("horizon:solum:assemblies:detail"))
    name = tables.Column('name', verbose_name=_('Name'))
    application = tables.Column('application', verbose_name=_('Application'),
                                link=("horizon:solum:applications:detail"))
    description = tables.Column('description', verbose_name=_('Description'))

    def get_object_id(self, app):
        return app.uuid
github openstack / manila-ui / manila_ui / dashboards / project / shares / tables.py View on Github external
if not shares_allowed:
            if "disabled" not in self.classes:
                self.classes = [c for c in self.classes] + ['disabled']
                self.verbose_name = format_lazy(
                    '{verbose_name} {quota_exceeded}',
                    verbose_name=self.verbose_name,
                    quota_exceeded=_("(Quota exceeded)"))
        else:
            self.verbose_name = _("Create Share")
            classes = [c for c in self.classes if c != "disabled"]
            self.classes = classes

        return True


class EditShare(tables.LinkAction):
    name = "edit"
    verbose_name = _("Edit Share")
    url = "horizon:project:shares:update"
    classes = ("ajax-modal", "btn-create")
    policy_rules = (("share", "share:update"),)

    def get_policy_target(self, request, datum=None):
        project_id = None
        if datum:
            project_id = getattr(datum, "os-share-tenant-attr:tenant_id", None)
        return {"project_id": project_id}

    def allowed(self, request, share=None):
        return share.status in ("available", "in-use")
github openstack / mistral-dashboard / mistraldashboard / workflows / tables.py View on Github external
from horizon import tables
from horizon.utils import filters

from mistraldashboard import api


class CreateWorkflow(tables.LinkAction):
    name = "create"
    verbose_name = _("Create Workflow")
    url = "horizon:mistral:workflows:select_definition"
    classes = ("ajax-modal",)
    icon = "plus"


class UpdateWorkflow(tables.LinkAction):
    name = "update"
    verbose_name = _("Update Workflow")
    url = "horizon:mistral:workflows:change_definition"
    classes = ("ajax-modal",)
    icon = "pencil"


class DeleteWorkflow(tables.DeleteAction):
    @staticmethod
    def action_present(count):
        return ungettext_lazy(
            u"Delete Workflow",
            u"Delete Workflows",
            count
        )
github openstack / horizon / openstack_dashboard / dashboards / identity / roles / tables.py View on Github external
#
#    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.

from django.utils.translation import ugettext_lazy as _
from django.utils.translation import ungettext_lazy

from horizon import tables

from openstack_dashboard import api


class CreateRoleLink(tables.LinkAction):
    name = "create"
    verbose_name = _("Create Role")
    url = "horizon:identity:roles:create"
    classes = ("ajax-modal",)
    icon = "plus"
    policy_rules = (("identity", "identity:create_role"),)

    def allowed(self, request, role):
        return api.keystone.keystone_can_edit_role()


class EditRoleLink(tables.LinkAction):
    name = "edit"
    verbose_name = _("Edit")
    url = "horizon:identity:roles:update"
    classes = ("ajax-modal",)
github openstack / neutron-vpnaas-dashboard / neutron_vpnaas_dashboard / dashboards / project / vpn / tables.py View on Github external
url = "horizon:project:vpn:addvpnservice"
    classes = ("ajax-modal",)
    icon = "plus"
    policy_rules = (("network", "create_vpnservice"),)


class AddEndpointGroupLink(tables.LinkAction):
    name = "addendpointgroup"
    verbose_name = _("Add Endpoint Group")
    url = "horizon:project:vpn:addendpointgroup"
    classes = ("ajax-modal",)
    icon = "plus"
    policy_rules = (("network", "create_endpointgroup"),)


class AddIPsecSiteConnectionLink(tables.LinkAction):
    name = "addipsecsiteconnection"
    verbose_name = _("Add IPsec Site Connection")
    url = "horizon:project:vpn:addipsecsiteconnection"
    classes = ("ajax-modal",)
    icon = "plus"
    policy_rules = (("network", "create_ipsec_site_connection"),)


class DeleteVPNServiceLink(policy.PolicyTargetMixin, tables.DeleteAction):
    name = "deletevpnservice"
    policy_rules = (("network", "delete_vpnservice"),)

    @staticmethod
    def action_present(count):
        return ungettext_lazy(
            u"Delete VPN Service",
github openstack / murano / dashboard / windc / tables.py View on Github external
class CreateService(tables.LinkAction):
    name = 'CreateService'
    verbose_name = _('Create Service')
    url = 'horizon:project:windc:create'
    classes = ('btn-launch', 'ajax-modal')

    def allowed(self, request, datum):
        return True

    def action(self, request, service):
        api.windc.services_create(request, service)


class CreateDataCenter(tables.LinkAction):
    name = 'CreateDataCenter'
    verbose_name = _('Create Windows Data Center')
    url = 'horizon:project:windc:create_dc'
    classes = ('btn-launch', 'ajax-modal')

    def allowed(self, request, datum):
        return True

    def action(self, request, datacenter):
        api.windc.datacenters_create(request, datacenter)


class DeleteDataCenter(tables.BatchAction):
    name = 'delete'
    action_present = _('Delete')
    action_past = _('Delete')
github openstack / solum-dashboard / solumdashboard / applications / tables.py View on Github external
from horizon.utils import filters

from solumclient.v1 import app as cli_app

from solumdashboard.api.client import client as solumclient
from solumdashboard.applications import tabs


class CreateApplication(tables.LinkAction):
    name = "create"
    verbose_name = _("New Application")
    url = "horizon:solum:applications:create"
    classes = ("btn-launch", "ajax-modal")


class ScaleApplication(tables.LinkAction):
    name = "scale"
    verbose_name = _("Scale Application")
    url = "horizon:solum:applications:scale"
    classes = ("btn-launch", "ajax-modal")


class UpdateApplication(tables.LinkAction):
    name = "update"
    verbose_name = _("Update Application")
    url = "horizon:solum:applications:update"
    classes = ("btn-launch", "ajax-modal")


class LaunchApplication(tables.LinkAction):
    name = "build-and-deploy"
    verbose_name = _("Build and Deploy Application")