PolyGerrit: Add support for project command
* This adds a new page called Project Command accessed by navigating to <url>/projects/<project>,commands * This supports creating a change through the new dialog (though note you can't edit any files, will have to switch to gwtui to do that) * Supports creating the change as a private and wip or one or the other. * Supports the Run GC button allowing you to run gc on projects. Feature: Issue 5232 Change-Id: Ibd3507c0fdb84303c8a978e3ea87f251582b13e8
This commit is contained in:
@@ -29,10 +29,11 @@ limitations under the License.
|
||||
<link rel="import" href="../gr-admin-group-list/gr-admin-group-list.html">
|
||||
<link rel="import" href="../gr-admin-project-list/gr-admin-project-list.html">
|
||||
<link rel="import" href="../gr-group/gr-group.html">
|
||||
<link rel="import" href="../gr-group-audit-log/gr-group-audit-log.html">
|
||||
<link rel="import" href="../gr-group-members/gr-group-members.html">
|
||||
<link rel="import" href="../gr-plugin-list/gr-plugin-list.html">
|
||||
<link rel="import" href="../gr-project/gr-project.html">
|
||||
<link rel="import" href="../gr-group-audit-log/gr-group-audit-log.html">
|
||||
<link rel="import" href="../gr-project-commands/gr-project-commands.html">
|
||||
<link rel="import" href="../gr-project-detail-list/gr-project-detail-list.html">
|
||||
|
||||
<dom-module id="gr-admin-view">
|
||||
@@ -120,6 +121,12 @@ limitations under the License.
|
||||
class="table"></gr-group-audit-log>
|
||||
</main>
|
||||
</template>
|
||||
<template is="dom-if" if="[[_showProjectCommands]]" restamp="true">
|
||||
<main>
|
||||
<gr-project-commands
|
||||
project="[[params.project]]"></gr-project-commands>
|
||||
</main>
|
||||
</template>
|
||||
<template is="dom-if" if="[[params.placeholder]]" restamp="true">
|
||||
<gr-placeholder title="Admin" path="[[path]]"></gr-placeholder>
|
||||
</template>
|
||||
|
||||
@@ -64,6 +64,7 @@
|
||||
_showGroupAuditLog: Boolean,
|
||||
_showGroupList: Boolean,
|
||||
_showGroupMembers: Boolean,
|
||||
_showProjectCommands: Boolean,
|
||||
_showProjectMain: Boolean,
|
||||
_showProjectList: Boolean,
|
||||
_showProjectDetailList: Boolean,
|
||||
@@ -109,6 +110,13 @@
|
||||
view: 'gr-project',
|
||||
url: `/admin/projects/${this.encodeURL(this._projectName, true)}`,
|
||||
children: [{
|
||||
name: 'Commands',
|
||||
detailType: 'commands',
|
||||
view: 'gr-project-commands',
|
||||
url: `/admin/projects/` +
|
||||
`${this.encodeURL(this._projectName, true)},commands`,
|
||||
},
|
||||
{
|
||||
name: 'Branches',
|
||||
detailType: 'branches',
|
||||
view: 'gr-project-detail-list',
|
||||
@@ -171,6 +179,8 @@
|
||||
this.set('_showGroupAuditLog', params.adminView === 'gr-group-audit-log');
|
||||
this.set('_showGroupList', params.adminView === 'gr-admin-group-list');
|
||||
this.set('_showGroupMembers', params.adminView === 'gr-group-members');
|
||||
this.set('_showProjectCommands',
|
||||
params.adminView === 'gr-project-commands');
|
||||
this.set('_showProjectMain', params.adminView === 'gr-project');
|
||||
this.set('_showProjectList',
|
||||
params.adminView === 'gr-admin-project-list');
|
||||
|
||||
@@ -0,0 +1,108 @@
|
||||
<!--
|
||||
Copyright (C) 2017 The Android Open Source Project
|
||||
|
||||
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.
|
||||
-->
|
||||
|
||||
<link rel="import" href="../../../bower_components/iron-autogrow-textarea/iron-autogrow-textarea.html">
|
||||
<link rel="import" href="../../../bower_components/iron-input/iron-input.html">
|
||||
<link rel="import" href="../../../bower_components/polymer/polymer.html">
|
||||
<link rel="import" href="../../../behaviors/base-url-behavior/base-url-behavior.html">
|
||||
<link rel="import" href="../../../behaviors/gr-url-encoding-behavior.html">
|
||||
<link rel="import" href="../../../styles/gr-form-styles.html">
|
||||
<link rel="import" href="../../../styles/shared-styles.html">
|
||||
<link rel="import" href="../../core/gr-navigation/gr-navigation.html">
|
||||
<link rel="import" href="../../shared/gr-autocomplete/gr-autocomplete.html">
|
||||
<link rel="import" href="../../shared/gr-button/gr-button.html">
|
||||
<link rel="import" href="../../shared/gr-confirm-dialog/gr-confirm-dialog.html">
|
||||
<link rel="import" href="../../shared/gr-rest-api-interface/gr-rest-api-interface.html">
|
||||
<link rel="import" href="../../shared/gr-select/gr-select.html">
|
||||
|
||||
<dom-module id="gr-create-change-dialog">
|
||||
<template>
|
||||
<style include="shared-styles"></style>
|
||||
<style include="gr-form-styles">
|
||||
:host {
|
||||
display: inline-block;
|
||||
}
|
||||
input {
|
||||
width: 25em;
|
||||
}
|
||||
gr-autocomplete {
|
||||
border: none;
|
||||
float: right;
|
||||
--gr-autocomplete: {
|
||||
border: 1px solid #d1d2d3;
|
||||
border-radius: 2px;
|
||||
font-size: 1em;
|
||||
height: 2em;
|
||||
padding: 0 .15em;
|
||||
width: 20em;
|
||||
}
|
||||
}
|
||||
</style>
|
||||
<div class="gr-form-styles">
|
||||
<div id="form">
|
||||
<section>
|
||||
<span class="title">Select branch for new change</span>
|
||||
<span class="value">
|
||||
<gr-autocomplete
|
||||
id="branchInput"
|
||||
text="{{branch}}"
|
||||
query="[[_query]]"
|
||||
placeholder="Destination branch">
|
||||
</gr-autocomplete>
|
||||
</span>
|
||||
</section>
|
||||
<section>
|
||||
<span class="title">Enter topic for new change (optional)</span>
|
||||
<input
|
||||
is="iron-input"
|
||||
id="tagNameInput"
|
||||
bind-value="{{topic}}">
|
||||
</section>
|
||||
<section>
|
||||
<span class="title">Description</span>
|
||||
<iron-autogrow-textarea
|
||||
id="messageInput"
|
||||
class="message"
|
||||
autocomplete="on"
|
||||
rows="4"
|
||||
max-rows="15"
|
||||
bind-value="{{subject}}"
|
||||
placeholder="Insert the description of the change.">
|
||||
</iron-autogrow-textarea>
|
||||
</section>
|
||||
<section>
|
||||
<span class="title">Options</span>
|
||||
<section>
|
||||
<label for="privateChangeCheckBox">Private Change</label>
|
||||
<input
|
||||
type="checkbox"
|
||||
id="privateChangeCheckBox"
|
||||
checked$="{{checkedPrivate}}"
|
||||
hidden$="[[_serverConfig.change.private_by_default]]">
|
||||
</section>
|
||||
<section>
|
||||
<label for="wipChangeCheckBox">WIP Change</label>
|
||||
<input
|
||||
type="checkbox"
|
||||
id="wipChangeCheckBox">
|
||||
</section>
|
||||
</section>
|
||||
</div>
|
||||
</div>
|
||||
<gr-rest-api-interface id="restAPI"></gr-rest-api-interface>
|
||||
</template>
|
||||
<script src="gr-create-change-dialog.js"></script>
|
||||
</dom-module>
|
||||
@@ -0,0 +1,102 @@
|
||||
// Copyright (C) 2017 The Android Open Source Project
|
||||
//
|
||||
// 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.
|
||||
(function() {
|
||||
'use strict';
|
||||
|
||||
const SUGGESTIONS_LIMIT = 15;
|
||||
const REF_PREFIX = 'refs/heads/';
|
||||
|
||||
Polymer({
|
||||
is: 'gr-create-change-dialog',
|
||||
|
||||
properties: {
|
||||
projectName: String,
|
||||
branch: String,
|
||||
/** @type {?} */
|
||||
_serverConfig: Object,
|
||||
subject: String,
|
||||
topic: String,
|
||||
_query: {
|
||||
type: Function,
|
||||
value() {
|
||||
return this._getProjectBranchesSuggestions.bind(this);
|
||||
},
|
||||
},
|
||||
checkedPrivate: {
|
||||
type: Boolean,
|
||||
value: true,
|
||||
},
|
||||
canCreate: {
|
||||
type: Boolean,
|
||||
notify: true,
|
||||
value: false,
|
||||
},
|
||||
},
|
||||
|
||||
behaviors: [
|
||||
Gerrit.BaseUrlBehavior,
|
||||
Gerrit.URLEncodingBehavior,
|
||||
],
|
||||
|
||||
attached() {
|
||||
this.$.restAPI.getConfig().then(config => {
|
||||
this._serverConfig = config;
|
||||
});
|
||||
},
|
||||
|
||||
observers: [
|
||||
'_allowCreate(branch, subject)',
|
||||
],
|
||||
|
||||
_allowCreate(branch, subject) {
|
||||
this.canCreate = !!branch && !!subject;
|
||||
},
|
||||
|
||||
handleCreateChange() {
|
||||
const isPrivate = this.$.privateChangeCheckBox.checked;
|
||||
const isWip = this.$.wipChangeCheckBox.checked;
|
||||
return this.$.restAPI.createChange(this.projectName, this.branch,
|
||||
this.subject, this.topic, isPrivate, isWip)
|
||||
.then(changeCreated => {
|
||||
if (!changeCreated) {
|
||||
return;
|
||||
}
|
||||
Gerrit.Nav.navigateToChange(changeCreated);
|
||||
});
|
||||
},
|
||||
|
||||
_getProjectBranchesSuggestions(input) {
|
||||
if (input.startsWith(REF_PREFIX)) {
|
||||
input = input.substring(REF_PREFIX.length);
|
||||
}
|
||||
return this.$.restAPI.getProjectBranches(
|
||||
input, this.projectName, SUGGESTIONS_LIMIT).then(response => {
|
||||
const branches = [];
|
||||
let branch;
|
||||
for (const key in response) {
|
||||
if (!response.hasOwnProperty(key)) { continue; }
|
||||
if (response[key].ref.startsWith('refs/heads/')) {
|
||||
branch = response[key].ref.substring('refs/heads/'.length);
|
||||
} else {
|
||||
branch = response[key].ref;
|
||||
}
|
||||
branches.push({
|
||||
name: branch,
|
||||
});
|
||||
}
|
||||
return branches;
|
||||
});
|
||||
},
|
||||
});
|
||||
})();
|
||||
@@ -0,0 +1,117 @@
|
||||
<!DOCTYPE html>
|
||||
<!--
|
||||
Copyright (C) 2017 The Android Open Source Project
|
||||
|
||||
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.
|
||||
-->
|
||||
|
||||
<meta name="viewport" content="width=device-width, minimum-scale=1.0, initial-scale=1.0, user-scalable=yes">
|
||||
<title>gr-create-change-dialog</title>
|
||||
|
||||
<script src="../../../bower_components/webcomponentsjs/webcomponents-lite.min.js"></script>
|
||||
<script src="../../../bower_components/web-component-tester/browser.js"></script>
|
||||
<link rel="import" href="../../../test/common-test-setup.html"/>
|
||||
<link rel="import" href="gr-create-change-dialog.html">
|
||||
|
||||
<script>void(0);</script>
|
||||
|
||||
<test-fixture id="basic">
|
||||
<template>
|
||||
<gr-create-change-dialog></gr-create-change-dialog>
|
||||
</template>
|
||||
</test-fixture>
|
||||
|
||||
<script>
|
||||
suite('gr-create-change-dialog tests', () => {
|
||||
let element;
|
||||
let sandbox;
|
||||
|
||||
setup(() => {
|
||||
sandbox = sinon.sandbox.create();
|
||||
stub('gr-rest-api-interface', {
|
||||
getLoggedIn() { return Promise.resolve(true); },
|
||||
getProjectBranches(input) {
|
||||
if (input.startsWith('test')) {
|
||||
return Promise.resolve([
|
||||
{
|
||||
ref: 'refs/heads/test-branch',
|
||||
revision: '67ebf73496383c6777035e374d2d664009e2aa5c',
|
||||
can_delete: true,
|
||||
},
|
||||
]);
|
||||
} else {
|
||||
return Promise.resolve({});
|
||||
}
|
||||
},
|
||||
});
|
||||
element = fixture('basic');
|
||||
element.projectName = 'test-project';
|
||||
element._serverConfig = {
|
||||
change: {},
|
||||
};
|
||||
});
|
||||
|
||||
teardown(() => {
|
||||
sandbox.restore();
|
||||
});
|
||||
|
||||
test('new change created', () => {
|
||||
const configInputObj = {
|
||||
branch: 'test-branch',
|
||||
topic: 'test-topic',
|
||||
subject: 'first change created with polygerrit ui',
|
||||
is_private: true,
|
||||
work_in_progress: false,
|
||||
project: element.projectName,
|
||||
};
|
||||
|
||||
const saveStub = sandbox.stub(element.$.restAPI,
|
||||
'createChange', () => {
|
||||
return Promise.resolve({});
|
||||
});
|
||||
|
||||
element.project = element.projectName;
|
||||
element.branch = 'test-branch';
|
||||
element.topic = 'test-topic';
|
||||
element.subject = 'first change created with polygerrit ui';
|
||||
element.is_private = true;
|
||||
element.work_in_progress = false;
|
||||
|
||||
element.$.branchInput.bindValue = configInputObj.branch;
|
||||
element.$.tagNameInput.bindValue = configInputObj.topic;
|
||||
element.$.messageInput.bindValue = configInputObj.subject;
|
||||
element.$.privateChangeCheckBox.checked = configInputObj.is_private;
|
||||
element.$.wipChangeCheckBox.checked =
|
||||
configInputObj.work_in_progress;
|
||||
|
||||
element.handleCreateChange().then(() => {
|
||||
assert.isTrue(saveStub.lastCall.calledWithExactly(configInputObj));
|
||||
});
|
||||
});
|
||||
|
||||
test('_getProjectBranchesSuggestions empty', done => {
|
||||
element._getProjectBranchesSuggestions('nonexistent').then(branches => {
|
||||
assert.equal(branches.length, 0);
|
||||
done();
|
||||
});
|
||||
});
|
||||
|
||||
test('_getProjectBranchesSuggestions non-empty', done => {
|
||||
element._getProjectBranchesSuggestions('test-branch').then(branches => {
|
||||
assert.equal(branches.length, 1);
|
||||
assert.equal(branches[0].name, 'test-branch');
|
||||
done();
|
||||
});
|
||||
});
|
||||
});
|
||||
</script>
|
||||
@@ -0,0 +1,92 @@
|
||||
<!--
|
||||
Copyright (C) 2017 The Android Open Source Project
|
||||
|
||||
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.
|
||||
-->
|
||||
|
||||
<link rel="import" href="../../../bower_components/polymer/polymer.html">
|
||||
<link rel="import" href="../../../bower_components/iron-autogrow-textarea/iron-autogrow-textarea.html">
|
||||
<link rel="import" href="../../../bower_components/iron-input/iron-input.html">
|
||||
<link rel="import" href="../../../styles/gr-form-styles.html">
|
||||
<link rel="import" href="../../../styles/shared-styles.html">
|
||||
<link rel="import" href="../../shared/gr-confirm-dialog/gr-confirm-dialog.html">
|
||||
<link rel="import" href="../../shared/gr-overlay/gr-overlay.html">
|
||||
<link rel="import" href="../../shared/gr-rest-api-interface/gr-rest-api-interface.html">
|
||||
<link rel="import" href="../gr-create-change-dialog/gr-create-change-dialog.html">
|
||||
|
||||
<dom-module id="gr-project-commands">
|
||||
<template>
|
||||
<style include="shared-styles">
|
||||
main {
|
||||
margin: 2em 1em;
|
||||
}
|
||||
.loading {
|
||||
display: none;
|
||||
}
|
||||
#loading.loading {
|
||||
display: block;
|
||||
}
|
||||
#loading:not(.loading) {
|
||||
display: none;
|
||||
}
|
||||
</style>
|
||||
<style include="gr-form-styles"></style>
|
||||
<main class="gr-form-styles read-only">
|
||||
<h1 id="Title">Project Commands</h1>
|
||||
<div id="loading" class$="[[_computeLoadingClass(_loading)]]">Loading...</div>
|
||||
<div id="loadedContent" class$="[[_computeLoadingClass(_loading)]]">
|
||||
<h2 id="options">Command</h2>
|
||||
<div id="form">
|
||||
<fieldset>
|
||||
<h3 id="createChange">Create Change</h3>
|
||||
<fieldset>
|
||||
<gr-button id="createNewChange" on-tap="_createNewChange">
|
||||
Create Change
|
||||
</gr-button>
|
||||
</fieldset>
|
||||
<h3 id="runGC" hidden$="[[!_projectConfig.actions.gc.enabled]]">
|
||||
Run GC
|
||||
</h3>
|
||||
<fieldset>
|
||||
<gr-button
|
||||
on-tap="_handleRunningGC"
|
||||
hidden$="[[!_projectConfig.actions.gc.enabled]]">
|
||||
Run GC
|
||||
</gr-button>
|
||||
</fieldset>
|
||||
</fieldset>
|
||||
</div>
|
||||
</div>
|
||||
</main>
|
||||
<gr-overlay id="createChangeOverlay" with-backdrop>
|
||||
<gr-confirm-dialog
|
||||
id="createChangeDialog"
|
||||
confirm-label="Create"
|
||||
disabled="[[!_canCreate]]"
|
||||
on-confirm="_handleCreateChange"
|
||||
on-cancel="_handleCloseCreateChange">
|
||||
<div class="header">
|
||||
Create Change
|
||||
</div>
|
||||
<div class="main">
|
||||
<gr-create-change-dialog
|
||||
id="createNewChangeModal"
|
||||
can-create="{{_canCreate}}"
|
||||
project-name="[[project]]"></gr-create-change-dialog>
|
||||
</div>
|
||||
</gr-confirm-dialog>
|
||||
</gr-overlay>
|
||||
<gr-rest-api-interface id="restAPI"></gr-rest-api-interface>
|
||||
</template>
|
||||
<script src="gr-project-commands.js"></script>
|
||||
</dom-module>
|
||||
@@ -0,0 +1,80 @@
|
||||
// Copyright (C) 2017 The Android Open Source Project
|
||||
//
|
||||
// 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.
|
||||
(function() {
|
||||
'use strict';
|
||||
|
||||
const GC_MESSAGE = 'Garbage collection completed successfully.';
|
||||
|
||||
Polymer({
|
||||
is: 'gr-project-commands',
|
||||
|
||||
properties: {
|
||||
params: Object,
|
||||
project: String,
|
||||
_loading: {
|
||||
type: Boolean,
|
||||
value: true,
|
||||
},
|
||||
/** @type {?} */
|
||||
_projectConfig: Object,
|
||||
_canCreate: Boolean,
|
||||
},
|
||||
|
||||
attached() {
|
||||
this._loadProject();
|
||||
|
||||
this.fire('title-change', {title: 'Project Commands'});
|
||||
},
|
||||
|
||||
_loadProject() {
|
||||
if (!this.project) { return Promise.resolve(); }
|
||||
|
||||
return this.$.restAPI.getProjectConfig(this.project).then(
|
||||
config => {
|
||||
this._projectConfig = config;
|
||||
this._loading = false;
|
||||
});
|
||||
},
|
||||
|
||||
_computeLoadingClass(loading) {
|
||||
return loading ? 'loading' : '';
|
||||
},
|
||||
|
||||
_isLoading() {
|
||||
return this._loading || this._loading === undefined;
|
||||
},
|
||||
|
||||
_handleRunningGC() {
|
||||
return this.$.restAPI.runProjectGC(this.project).then(response => {
|
||||
if (response.status === 200) {
|
||||
this.dispatchEvent(new CustomEvent('show-alert',
|
||||
{detail: {message: GC_MESSAGE}, bubbles: true}));
|
||||
}
|
||||
});
|
||||
},
|
||||
|
||||
_createNewChange() {
|
||||
this.$.createChangeOverlay.open();
|
||||
},
|
||||
|
||||
_handleCreateChange() {
|
||||
this.$.createNewChangeModal.handleCreateChange();
|
||||
this._handleCloseCreateChange();
|
||||
},
|
||||
|
||||
_handleCloseCreateChange() {
|
||||
this.$.createChangeOverlay.close();
|
||||
},
|
||||
});
|
||||
})();
|
||||
@@ -0,0 +1,69 @@
|
||||
<!DOCTYPE html>
|
||||
<!--
|
||||
Copyright (C) 2017 The Android Open Source Project
|
||||
|
||||
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.
|
||||
-->
|
||||
|
||||
<meta name="viewport" content="width=device-width, minimum-scale=1.0, initial-scale=1.0, user-scalable=yes">
|
||||
<title>gr-project-commands</title>
|
||||
|
||||
<script src="../../../bower_components/page/page.js"></script>
|
||||
<script src="../../../bower_components/webcomponentsjs/webcomponents-lite.min.js"></script>
|
||||
<script src="../../../bower_components/web-component-tester/browser.js"></script>
|
||||
<link rel="import" href="../../../test/common-test-setup.html"/>
|
||||
<link rel="import" href="gr-project-commands.html">
|
||||
|
||||
<script>void(0);</script>
|
||||
|
||||
<test-fixture id="basic">
|
||||
<template>
|
||||
<gr-project-commands></gr-project-commands>
|
||||
</template>
|
||||
</test-fixture>
|
||||
|
||||
<script>
|
||||
suite('gr-project-commands tests', () => {
|
||||
let element;
|
||||
let sandbox;
|
||||
|
||||
setup(() => {
|
||||
sandbox = sinon.sandbox.create();
|
||||
element = fixture('basic');
|
||||
});
|
||||
|
||||
teardown(() => {
|
||||
sandbox.restore();
|
||||
});
|
||||
|
||||
suite('create new change dialog', () => {
|
||||
test('_createNewChange opens modal', () => {
|
||||
const openStub = sandbox.stub(element.$.createChangeOverlay, 'open');
|
||||
element._createNewChange();
|
||||
assert.isTrue(openStub.called);
|
||||
});
|
||||
|
||||
test('_handleCreateChange called when confirm fired', () => {
|
||||
sandbox.stub(element, '_handleCreateChange');
|
||||
element.$.createChangeDialog.fire('confirm');
|
||||
assert.isTrue(element._handleCreateChange.called);
|
||||
});
|
||||
|
||||
test('_handleCloseCreateChange called when cancel fired', () => {
|
||||
sandbox.stub(element, '_handleCloseCreateChange');
|
||||
element.$.createChangeDialog.fire('cancel');
|
||||
assert.isTrue(element._handleCloseCreateChange.called);
|
||||
});
|
||||
});
|
||||
});
|
||||
</script>
|
||||
@@ -237,6 +237,22 @@
|
||||
});
|
||||
});
|
||||
|
||||
// Matches /admin/projects/<project>,commands.
|
||||
page(/^\/admin\/projects\/(.+),commands$/, loadUser, data => {
|
||||
restAPI.getLoggedIn().then(loggedIn => {
|
||||
if (loggedIn) {
|
||||
app.params = {
|
||||
view: Gerrit.Nav.View.ADMIN,
|
||||
adminView: 'gr-project-commands',
|
||||
detailType: 'commands',
|
||||
project: data.params[0],
|
||||
};
|
||||
} else {
|
||||
redirectToLogin(data.canonicalPath);
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
// Matches /admin/projects/<project>,branches[,<offset>].
|
||||
page(/^\/admin\/projects\/(.+),branches(,(.+))?$/, loadUser, data => {
|
||||
app.params = {
|
||||
|
||||
@@ -217,6 +217,15 @@
|
||||
opt_errFn, opt_ctx);
|
||||
},
|
||||
|
||||
runProjectGC(project, opt_errFn, opt_ctx) {
|
||||
if (!project) {
|
||||
return '';
|
||||
}
|
||||
const encodeName = encodeURIComponent(project);
|
||||
return this.send('POST', `/projects/${encodeName}/gc`, '',
|
||||
opt_errFn, opt_ctx);
|
||||
},
|
||||
|
||||
/**
|
||||
* @param {?Object} config
|
||||
* @param {function(?Response, string=)=} opt_errFn
|
||||
@@ -1175,6 +1184,22 @@
|
||||
});
|
||||
},
|
||||
|
||||
/**
|
||||
* @param {!string} project
|
||||
* @param {!string} branch
|
||||
* @param {!string} subject
|
||||
* @param {!string} topic
|
||||
* @param {!boolean} isPrivate
|
||||
* @param {!boolean} workInProgress
|
||||
*/
|
||||
createChange(project, branch, subject, topic, isPrivate,
|
||||
workInProgress) {
|
||||
return this.send('POST', '/changes/',
|
||||
{project, branch, subject, topic, is_private: isPrivate,
|
||||
work_in_progress: workInProgress})
|
||||
.then(response => this.getResponseObject(response));
|
||||
},
|
||||
|
||||
getFileInChangeEdit(changeNum, path) {
|
||||
const e = '/edit/' + encodeURIComponent(path);
|
||||
return this.getChangeURLAndSend(changeNum, 'GET', null, e);
|
||||
|
||||
@@ -34,6 +34,7 @@ limitations under the License.
|
||||
'admin/gr-admin-project-list/gr-admin-project-list_test.html',
|
||||
'admin/gr-admin-view/gr-admin-view_test.html',
|
||||
'admin/gr-confirm-delete-item-dialog/gr-confirm-delete-item-dialog_test.html',
|
||||
'admin/gr-create-change-dialog/gr-create-change-dialog_test.html',
|
||||
'admin/gr-create-group-dialog/gr-create-group-dialog_test.html',
|
||||
'admin/gr-create-pointer-dialog/gr-create-pointer-dialog_test.html',
|
||||
'admin/gr-create-project-dialog/gr-create-project-dialog_test.html',
|
||||
@@ -43,6 +44,7 @@ limitations under the License.
|
||||
'admin/gr-permission/gr-permission_test.html',
|
||||
'admin/gr-plugin-list/gr-plugin-list_test.html',
|
||||
'admin/gr-project/gr-project_test.html',
|
||||
'admin/gr-project-commands/gr-project-commands_test.html',
|
||||
'admin/gr-project-detail-list/gr-project-detail-list_test.html',
|
||||
'admin/gr-rule-editor/gr-rule-editor_test.html',
|
||||
'change-list/gr-change-list-item/gr-change-list-item_test.html',
|
||||
|
||||
Reference in New Issue
Block a user