Merge changes Iffd1de5d,I1992e555
* changes:
GeneralConfig: Include parameter name into warning
Fix removal of inherited global code owners
diff --git a/ui/code-owners-banner.js b/ui/code-owners-banner.js
index a44e258..4e4b07e 100644
--- a/ui/code-owners-banner.js
+++ b/ui/code-owners-banner.js
@@ -133,6 +133,26 @@
banner: {
type: Object,
},
+ /**
+ * This is a temporary property for interop with find-owner plugin.
+ * It stores information about the change and code-owners status for this
+ * change. The possible values for branchState are:
+ * LOADING - branch config are requesting
+ * FAILED - plugin are in failed state (server returned error, etc...)
+ * ENABLED - code-owners is enabled for the change
+ * DISABLED - code-owners is disable for the change
+ *
+ * ENABLED/DISABLED values are different from the pluginStatus.
+ * For merged and abandoned changes the model.pluginStatus value is
+ * always DISABLED, even if code-owners is enabled for a project.
+ */
+ _stateForFindOwnersPlugin: {
+ type: Object,
+ notify: true,
+ computed:
+ '_getStateForFindOwners(model.pluginStatus, model.branchConfig,' +
+ ' change)',
+ },
};
}
@@ -159,6 +179,26 @@
_loadDataAfterStateChanged() {
this.modelLoader.loadPluginStatus();
+ this.modelLoader.loadBranchConfig();
+ }
+
+ _getStateForFindOwners(pluginStatus, branchConfig, change) {
+ if (pluginStatus === undefined || branchConfig === undefined ||
+ change == undefined) {
+ return {
+ branchState: 'LOADING',
+ };
+ }
+ if (pluginStatus.state === PluginState.Failed) {
+ return {
+ change,
+ branchState: 'FAILED',
+ };
+ }
+ return {
+ change,
+ branchState: branchConfig.disabled ? 'DISABLED' : 'ENABLED',
+ };
}
}
diff --git a/ui/owner-status-column.js b/ui/owner-status-column.js
index 31ad654..b3d92fb 100644
--- a/ui/owner-status-column.js
+++ b/ui/owner-status-column.js
@@ -116,6 +116,7 @@
static get properties() {
return {
path: String,
+ oldPath: String,
patchRange: Object,
hidden: {
type: Boolean,
@@ -169,7 +170,7 @@
static get observers() {
return [
- 'computeStatusIcon(model.status, path)',
+ 'computeStatusIcon(model.status, path, oldPath)',
];
}
@@ -178,8 +179,8 @@
this.modelLoader.loadStatus();
}
- computeStatusIcon(modelStatus, path) {
- if ([modelStatus, path].includes(undefined)) return;
+ computeStatusIcon(modelStatus, path, oldPath) {
+ if ([modelStatus, path, oldPath].includes(undefined)) return;
if (MAGIC_FILES.includes(path)) return;
const codeOwnerStatusMap = modelStatus.codeOwnerStatusMap;
@@ -191,10 +192,10 @@
const status = statusItem.status;
let oldPathStatus = null;
- if (statusItem.oldPath) {
- const oldStatusItem = codeOwnerStatusMap.get(statusItem.oldPath);
+ if (oldPath !== path) {
+ const oldStatusItem = codeOwnerStatusMap.get(oldPath);
if (!oldStatusItem) {
- // should not happen
+ this.status = STATUS_CODE.ERROR;
} else {
oldPathStatus = oldStatusItem.status;
}
diff --git a/ui/plugin.js b/ui/plugin.js
index 40bc4e5..124d986 100644
--- a/ui/plugin.js
+++ b/ui/plugin.js
@@ -21,17 +21,41 @@
import {SuggestOwnersTrigger} from './suggest-owners-trigger.js';
import {CodeOwnersBanner, CodeOwnersPluginStatusNotifier} from './code-owners-banner.js';
+// A temporary property for interop with find-owners plugin.
+// It should be set as earlier as possible, so find-owners plugin can check
+// it in Gerrit.install callback.
+window.__gerrit_code_owners_plugin = {
+ state: {
+ // See CodeOwnersPluginStatusNotifier._stateForFindOwnersPlugin for
+ // a list of possible values.
+ branchState: 'LOADING',
+ },
+ stateChanged: new EventTarget(),
+};
+
Gerrit.install(plugin => {
const restApi = plugin.restApi();
const reporting = plugin.reporting();
plugin.registerCustomComponent('banner', CodeOwnersBanner.is);
+ const stateForFindOwnerPluginChanged = evt => {
+ window.__gerrit_code_owners_plugin.state = evt.detail.value;
+ window.__gerrit_code_owners_plugin.stateChanged
+ .dispatchEvent(new CustomEvent('state-changed'));
+ };
+
plugin.registerCustomComponent(
'change-view-integration', CodeOwnersPluginStatusNotifier.is)
.onAttached(view => {
view.restApi = restApi;
view.reporting = reporting;
+ view.addEventListener('_state-for-find-owners-plugin-changed',
+ stateForFindOwnerPluginChanged);
+ })
+ .onDetached(view => {
+ view.removeEventListener('_state-for-find-owners-plugin-changed',
+ stateForFindOwnerPluginChanged);
});
// owner status column / rows for file list