[assist] Fix js exception on missing database/table in the right assist
@@ -24,6 +24,7 @@ import componentUtils from 'ko/components/componentUtils';
import dataCatalog from 'catalog/dataCatalog';
import huePubSub from 'utils/huePubSub';
import I18n from 'utils/i18n';
+import DataCatalogEntry from 'catalog/dataCatalogEntry';
const TEMPLATE =
ASSIST_TABLE_TEMPLATES +
@@ -82,7 +83,7 @@ const TEMPLATE =
<i class="hue-warning fa fa-fw muted valign-middle fa-warning"></i>
<!-- ko with: catalogEntry -->
<!-- ko if: typeof reload !== 'undefined' -->
- <span data-bind="text: getDisplayName()"></span> <a class="inactive-action" href="javascript: void(0);" data-bind="click: reload"><i class="fa fa-refresh" data-bind="css: { 'fa-spin': reloading }"></i></a>
+ <span data-bind="text: getDisplayName(true)"></span> <a class="inactive-action" href="javascript: void(0);" data-bind="click: reload"><i class="fa fa-refresh" data-bind="css: { 'fa-spin': reloading }"></i></a>
<!-- /ko -->
<!-- /ko -->
</span>
@@ -467,17 +468,15 @@ class AssistEditorContextPanel {
});
if (!found) {
- const missingEntry = new AssistDbEntry(
- {
+ const catalogEntry = new DataCatalogEntry({
path: [dbEntry.catalogEntry.name, tableName],
- name: tableName,
- isTableOrView: () => true,
- getType: () => 'table',
- hasPossibleChildren: () => true,
- getSourceMeta: () => $.Deferred().resolve({ notFound: true }).promise(),
- getDisplayName: () => dbEntry.catalogEntry.name + '.' + tableName,
- reloading: ko.observable(false),
- reload: function () {
+ dataCatalog: dbEntry.catalogEntry.dataCatalog,
+ namespace: dbEntry.catalogEntry.namespace,
+ compute: dbEntry.catalogEntry.namespace
+ });
+
+ catalogEntry.reloading = ko.observable(false);
+ catalogEntry.reload = function () {
const self = this;
if (self.reloading()) {
return;
@@ -502,9 +501,7 @@ class AssistEditorContextPanel {
let clearPromise;
// Clear the database first if it exists without cascade
const hasDb = dbEntries.some(dbEntry => {
- if (
- dbEntry.name.toLowerCase() === self.path[0].toLowerCase()
- ) {
+ if (dbEntry.name.toLowerCase() === self.path[0].toLowerCase()) {
clearPromise = dbEntry.clearCache({
invalidate: 'invalidate',
cascade: false
@@ -530,8 +527,10 @@ class AssistEditorContextPanel {
.fail(() => {
self.reloading(false);
});
- }
- },
+ };
+
+ const missingEntry = new AssistDbEntry(
+ catalogEntry,
dbEntry,
assistDbSource,
this.filter,
