How to custom a dashboard table action's request url

asked 2015-11-25 09:27:35 -0500

liaozd gravatar image

I am changing the layout of dashboard > identity > projects, move the ModifyQuotas button from the row_actions to the table_actions, the original ModifyQuotas code is:

# horizon/openstack_dashboard/dashboards/identity/projects/tables.py
class ModifyQuotas(tables.LinkAction):
    name = "quotas"
    verbose_name = _("Modify Quotas")
    url = "horizon:identity:projects:update"
    classes = ("ajax-modal",)
    icon = "pencil"
    policy_rules = (('compute', "compute_extension:quotas:update"),)

    def get_link_url(self, project):
        step = 'update_quotas'
        base_url = reverse(self.url, args=[project.id])
        param = urlencode({"step": step})
        return "?".join([base_url, param])
....
row_actions = (UpdateMembersLink, UpdateGroupsLink, UpdateProject,
               UsageLink, ModifyQuotas, DeleteTenantsAction,
               RescopeTokenToProject)
table_actions = (TenantFilterAction, CreateProject,
                 DeleteTenantsAction)

And I change code to like this:

class ModifyQuotas(tables.LinkAction):
    name = "quotas"
    verbose_name = _("Modify Quotas")
    url = "horizon:identity:projects:update"
    classes = ("action-ajax-modal", "action-btn", "action-single",)
    icon = "pencil"
    policy_rules = (('compute', "compute_extension:quotas:update"),)
    table_actions_tag = "action_link"
    ....
    row_actions = (UpdateMembersLink, UpdateGroupsLink, UpdateProject,
                   UsageLink, DeleteTenantsAction,
                   RescopeTokenToProject)
    table_actions = (TenantFilterAction, CreateProject, ModifyQuotas,
                     DeleteTenantsAction)

The problem is, after I change it, the url should not be rendered for each row, so I take off def get_link_url(self, project). So the button is corresponded for the row I select. When I click, it should go to the 3rd tab of the url = "horizon:identity:projects:update", but for now, the default tab opened is the first one (update project), how can I do that?

edit retag flag offensive close merge delete