summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--polygerrit-ui/app/elements/change/gr-file-list/gr-file-list.ts22
-rw-r--r--polygerrit-ui/app/elements/change/gr-file-list/gr-file-list_test.ts35
-rw-r--r--polygerrit-ui/app/elements/edit/gr-edit-file-controls/gr-edit-file-controls.ts19
3 files changed, 62 insertions, 14 deletions
diff --git a/polygerrit-ui/app/elements/change/gr-file-list/gr-file-list.ts b/polygerrit-ui/app/elements/change/gr-file-list/gr-file-list.ts
index dc75a16a18..48e3118447 100644
--- a/polygerrit-ui/app/elements/change/gr-file-list/gr-file-list.ts
+++ b/polygerrit-ui/app/elements/change/gr-file-list/gr-file-list.ts
@@ -1489,7 +1489,11 @@ export class GrFileList extends LitElement {
this.editMode,
() => html`
<gr-edit-file-controls
- class=${this.computeClass('', file.__path)}
+ class=${this.computeClass(
+ '',
+ file.__path,
+ /* showForCommitMessage */ true
+ )}
.filePath=${file.__path}
></gr-edit-file-controls>
`
@@ -2276,11 +2280,17 @@ export class GrFileList extends LitElement {
return delta > 0 ? 'added' : 'removed';
}
- private computeClass(baseClass?: string, path?: string) {
- const classes = [];
- if (baseClass) classes.push(baseClass);
- if (isMagicPath(path)) classes.push('invisible');
- return classes.join(' ');
+ // Private but used in tests.
+ computeClass(baseClass = '', path?: string, showForCommitMessage = false) {
+ const classes = [baseClass];
+ if (
+ !(showForCommitMessage && path === SpecialFilePath.COMMIT_MESSAGE) &&
+ isMagicPath(path)
+ ) {
+ classes.push('invisible');
+ }
+
+ return classes.join(' ').trim();
}
private computePathClass(path: string | undefined) {
diff --git a/polygerrit-ui/app/elements/change/gr-file-list/gr-file-list_test.ts b/polygerrit-ui/app/elements/change/gr-file-list/gr-file-list_test.ts
index 1cfbb83a24..eec829a63f 100644
--- a/polygerrit-ui/app/elements/change/gr-file-list/gr-file-list_test.ts
+++ b/polygerrit-ui/app/elements/change/gr-file-list/gr-file-list_test.ts
@@ -39,6 +39,7 @@ import {
import {
createDefaultDiffPrefs,
DiffViewMode,
+ SpecialFilePath,
} from '../../../constants/constants';
import {
assertIsDefined,
@@ -2259,11 +2260,41 @@ suite('gr-file-list tests', () => {
element.editMode = true;
await element.updateComplete;
- // Commit message should not have edit controls.
+ // Commit message can have edit controls.
const editControls = Array.from(
queryAll(element, '.row:not(.header-row)')
).map(row => row.querySelector('gr-edit-file-controls'));
- assert.isTrue(editControls[0]!.classList.contains('invisible'));
+ assert.isFalse(editControls[0]!.classList.contains('invisible'));
+ });
+ });
+
+ suite('computeClass', () => {
+ test('works', () => {
+ assert.equal(
+ element.computeClass(
+ '',
+ SpecialFilePath.MERGE_LIST,
+ /* showForCommitMessage */ true
+ ),
+ 'invisible'
+ );
+ assert.equal(
+ element.computeClass(
+ '',
+ SpecialFilePath.COMMIT_MESSAGE,
+ /* showForCommitMessage */ true
+ ),
+ ''
+ );
+ assert.equal(
+ element.computeClass(
+ '',
+ SpecialFilePath.COMMIT_MESSAGE,
+ /* showForCommitMessage */ false
+ ),
+ 'invisible'
+ );
+ assert.equal(element.computeClass('', 'file.java'), '');
});
});
});
diff --git a/polygerrit-ui/app/elements/edit/gr-edit-file-controls/gr-edit-file-controls.ts b/polygerrit-ui/app/elements/edit/gr-edit-file-controls/gr-edit-file-controls.ts
index 7e49a1201c..e343a0172a 100644
--- a/polygerrit-ui/app/elements/edit/gr-edit-file-controls/gr-edit-file-controls.ts
+++ b/polygerrit-ui/app/elements/edit/gr-edit-file-controls/gr-edit-file-controls.ts
@@ -11,6 +11,7 @@ import {LitElement, css, html} from 'lit';
import {customElement, property} from 'lit/decorators.js';
import {fire} from '../../../utils/event-util';
import {DropdownLink} from '../../../types/common';
+import {SpecialFilePath} from '../../../constants/constants';
interface EditAction {
label: string;
@@ -76,12 +77,18 @@ export class GrEditFileControls extends LitElement {
_computeFileActions(actions: EditAction[]): DropdownLink[] {
// TODO(kaspern): conditionally disable some actions based on file status.
- return actions.map(action => {
- return {
- name: action.label,
- id: action.id,
- };
- });
+ return actions
+ .filter(
+ action =>
+ this.filePath !== SpecialFilePath.COMMIT_MESSAGE ||
+ action.label === GrEditConstants.Actions.OPEN.label
+ )
+ .map(action => {
+ return {
+ name: action.label,
+ id: action.id,
+ };
+ });
}
}