Use the REST API in the web interface for editing projects

[?]
Oct 3, 2013, 3:23 PM
DAPOSS44WRFQZ7XUWSMYCCORY4POKD42DGAIXMGP4ZRBOEPNNRGAC

Dependencies

  • [2] 6LTPI6B2
  • [3] 6Q2JPSWG Fix lazy tab loading
  • [4] D7PL2VWU Move more actions from the top bar
  • [5] BV7V5RGN Allow only project owners to delete projects / jobsets
  • [6] H66SHOS7 Fix and clean up editing project settings
  • [7] JY7BXXOP Split viewing and editing a project
  • [8] A6XVP6FE Make the hide/unhide actions a checkbox in the project settings
  • [9] QTFVCDIF added hide feature for project/jobset
  • [10] M6UBWKN2 Fix project/jobset deletion
  • [11] 225GEK4N After editing a project/jobset, redirect back to the config tab
  • [12] LZVO64YG Merge in the first bits of the API work
  • [13] MJ4RWQ3T Add links to the project/jobset edit pages in the logical place
  • [14] UWVMQIAC * Refactoring.
  • [15] ODNCGFQ5 * Improved the navigation bar: don't include all projects (since that
  • [16] LZO3C2KI * Hack around those SQLite timeouts: just retry the transaction.
  • [17] 3PNG7NIB Remove trailing whitespace
  • [18] 2VBQRQ2Q Fix some XML well-formedness problems
  • [19] K22TMPH5 Make the info tables less compressed
  • [20] ZRRPBEI4 Make jobset deletion consistent with project deletion
  • [21] FPK5LF53 * Put the project-related actions in a separate controller. Put the
  • [22] JARRBLZD Bootstrapify the Hydra forms (except the project and jobset edit pages)
  • [*] 7YBYT2LQ
  • [*] ZI535LI6 * hydra: 'new' UI for project/jobset/job/build
  • [*] W6DC6K4I * Happy Javascript hacking.
  • [*] 2P7VNAAC Move common Javascript code into a separate file

Change contents

  • edit in src/lib/Hydra/Controller/Project.pm at line 3
    [7.1283]
    [7.1283]
    use utf8;
  • edit in src/lib/Hydra/Controller/Project.pm at line 55
    [7.17085]
    [7.17085]
  • replacement in src/lib/Hydra/Controller/Project.pm at line 60
    [7.17197][7.17197:17437]()
    if ($c->req->looks_like_browser) {
    $c->res->redirect($c->uri_for($self->action_for("project"), [$c->stash->{project}->name]) . "#tabs-configuration");
    } else {
    $self->status_no_content($c);
    }
    [7.17197]
    [6.543]
    my $uri = $c->uri_for($self->action_for("project"), [$c->stash->{project}->name]) . "#tabs-configuration";
    $self->status_ok($c, entity => { redirect => "$uri" });
  • replacement in src/lib/Hydra/Controller/Project.pm at line 74
    [7.18913][6.562:659]()
    { name => ".tmp.$$." . int(rand(100000)), displayname => "", owner => $owner });
    [7.18913]
    [7.19002]
    { name => ".tmp", displayname => "", owner => $owner });
  • replacement in src/lib/Hydra/Controller/Project.pm at line 79
    [7.19135][7.19135:19459]()
    if ($c->req->looks_like_browser) {
    $c->res->redirect($uri . "#tabs-configuration");
    } else {
    $self->status_created(
    $c,
    location => "$uri",
    entity => { name => $project->name, uri => "$uri", type => "project" }
    );
    }
    [7.19135]
    [7.19459]
    $self->status_created($c,
    location => "$uri",
    entity => { name => $project->name, uri => "$uri", redirect => "$uri", type => "project" });
  • replacement in src/lib/Hydra/Controller/Project.pm at line 85
    [7.19468][7.19468:19523]()
    sub edit : Chained('projectChain') PathPart Args(0) {
    [7.19468]
    [7.1995]
    sub project_DELETE {
  • replacement in src/lib/Hydra/Controller/Project.pm at line 90
    [7.2076][7.0:47](),[7.47][7.2118:2145](),[7.2118][7.2118:2145]()
    $c->stash->{template} = 'edit-project.tt';
    $c->stash->{edit} = 1;
    [7.2076]
    [7.2145]
    txn_do($c->model('DB')->schema, sub {
    $c->stash->{project}->jobsetevals->delete_all;
    $c->stash->{project}->builds->delete_all;
    $c->stash->{project}->delete;
    });
    my $uri = $c->res->redirect($c->uri_for("/"));
    $self->status_ok($c, entity => { redirect => "$uri" });
  • replacement in src/lib/Hydra/Controller/Project.pm at line 101
    [7.2149][7.19524:19580]()
    sub submit : Chained('projectChain') PathPart Args(0) {
    [7.2149]
    [7.2200]
    sub edit : Chained('projectChain') PathPart Args(0) {
  • edit in src/lib/Hydra/Controller/Project.pm at line 104
    [7.833][7.4631:4652]()
    requirePost($c);
  • edit in src/lib/Hydra/Controller/Project.pm at line 105
    [5.103][5.103:104](),[5.104][7.230:291](),[7.2217][7.230:291](),[7.291][7.211:424](),[7.424][7.292:344](),[7.740][7.292:344](),[7.344][7.785:791](),[7.785][7.785:791]()
    if (($c->request->params->{submit} // "") eq "delete") {
    txn_do($c->model('DB')->schema, sub {
    $c->stash->{project}->jobsetevals->delete_all;
    $c->stash->{project}->builds->delete_all;
    $c->stash->{project}->delete;
    });
    return $c->res->redirect($c->uri_for("/"));
    }
  • replacement in src/lib/Hydra/Controller/Project.pm at line 106
    [7.19858][7.19858:19886]()
    project_PUT($self, $c);
    [7.792]
    [7.884]
    $c->stash->{template} = 'edit-project.tt';
    $c->stash->{edit} = 1;
  • edit in src/lib/Hydra/Controller/Project.pm at line 132
    [7.3096][2.40:93](),[2.93][7.3148:3173](),[7.3148][7.3148:3173](),[7.2233][7.19953:19981](),[7.19981][7.4769:4773](),[7.3745][7.4769:4773]()
    sub create_submit : Path('/create-project/submit') {
    my ($self, $c) = @_;
    project_PUT($self, $c);
    }
  • replacement in src/lib/Hydra/Controller/Project.pm at line 164
    [6.841][6.841:938]()
    error($c, "Invalid project name ‘$projectName’.") if $projectName !~ /^$projectNameRE$/;
    [6.841]
    [7.2242]
    error($c, "Invalid project identifier ‘$projectName’.") if $projectName !~ /^$projectNameRE$/;
  • replacement in src/lib/Hydra/Controller/Project.pm at line 166
    [7.2243][6.939:1034]()
    error($c, "Cannot rename project to ‘$projectName’ since that name is already taken.")
    [7.2243]
    [6.1034]
    error($c, "Cannot rename project to ‘$projectName’ since that identifier is already taken.")
  • replacement in src/root/edit-project.tt at line 4
    [7.137][7.137:316]()
    <form class="form-horizontal" action="[% IF create %][% c.uri_for('/create-project/submit') %][% ELSE %][% c.uri_for('/project' project.name 'submit') %][% END %]" method="post">
    [7.137]
    [7.316]
    <form class="form-horizontal">
  • replacement in src/root/edit-project.tt at line 57
    [7.2173][7.2173:2226]()
    <button type="submit" class="btn btn-primary">
    [7.2173]
    [7.2226]
    <button id="submit-project" type="submit" class="btn btn-primary">
  • edit in src/root/edit-project.tt at line 60
    [7.2330][7.1870:1886](),[7.1870][7.1870:1886](),[7.1886][7.2331:2553]()
    </button>
    [% IF !create %]
    <button id="delete-project" type="submit" class="btn btn-danger" name="submit" value="delete">
    <i class="icon-trash icon-white"></i>
    Delete this project
    </button>
  • replacement in src/root/edit-project.tt at line 61
    [7.2593][7.2593:2720]()
    $("#delete-project").click(function() {
    return confirm("Are you sure you want to delete this project?");
    [7.2593]
    [7.2720]
    $("#submit-project").click(function() {
    requestJSON({
    [% IF create %]
    url: "[% c.uri_for('/project' '.new') %]",
    [% ELSE %]
    url: "[% c.uri_for('/project' project.name) %]",
    [% END %]
    data: $(this).parents("form").serialize(),
    type: 'PUT',
    success: function(data) {
    window.location = data.redirect;
    },
    });
    return false;
  • replacement in src/root/edit-project.tt at line 77
    [7.2752][7.2752:2768]()
    [% END %]
    [7.2752]
    [7.2768]
    </button>
  • replacement in src/root/project.tt at line 12
    [4.1536][4.1536:1642]()
    [% INCLUDE menuItem uri = c.uri_for('/project' project.name 'edit') title="Edit configuration" %]
    [4.1536]
    [4.1642]
    <li><a href="[% c.uri_for('/project' project.name 'edit') %]"><i class="icon-edit icon-black"></i> Edit configuration</a></li>
    <li><a href="javascript:deleteProject()"><i class="icon-trash icon-black"></i> Delete this project</a></li>
  • edit in src/root/project.tt at line 98
    [7.465][7.133:253](),[7.5769][7.133:253]()
    <a class="btn pull-right" href="[% c.uri_for('/project' project.name "edit") %]"><i class="icon-edit"></i> Edit</a>
  • edit in src/root/project.tt at line 188
    [25.30705]
    [26.5229]
    <script>
    function deleteProject() {
    bootbox.confirm(
    'Are you sure you want to delete this project?',
    function(c) {
    if (!c) return;
    redirectJSON({
    url: "[% c.uri_for('/project' project.name) %]",
    type: 'DELETE'
    });
    });
    };
    </script>
  • edit in src/root/static/js/common.js at line 90
    [3.642]
    [3.642]
    }
    var requestJSON = function(args) {
    args.dataType = 'json';
    args.error = function(data) {
    json = {};
    try {
    if (data.responseText)
    json = $.parseJSON(data.responseText);
    } catch (err) {
    }
    if (json.error)
    bootbox.alert(json.error);
    else if (data.responseText)
    bootbox.alert("Server error: " + data.responseText);
    else
    bootbox.alert("Unknown server error!");
    };
    return $.ajax(args);
  • edit in src/root/static/js/common.js at line 110
    [3.644]
    var redirectJSON = function(args) {
    args.success = function(data) {
    window.location = data.redirect;
    };
    return requestJSON(args);
    }