mirror of
https://github.com/ckaczor/azuredatastudio.git
synced 2026-01-19 09:35:36 -05:00
Adding flag to hide refresh button in dashboards. (#18964)
This commit is contained in:
@@ -83,7 +83,11 @@ export abstract class DashboardPage extends AngularDisposable implements IConfig
|
||||
// tslint:disable:no-unused-variable
|
||||
private readonly homeTabTitle: string = nls.localize('home', "Home");
|
||||
private readonly homeTabId: string = 'homeTab';
|
||||
private tabToolbarActionsConfig = new Map<string, any[]>();
|
||||
private tabToolbarActionsConfig = new Map<string, {
|
||||
actions: any[],
|
||||
hideRefreshTask: boolean
|
||||
}>();
|
||||
|
||||
private tabContents = new Map<string, string>();
|
||||
|
||||
static tabName = new RawContextKey<string>('tabName', undefined);
|
||||
@@ -190,10 +194,6 @@ export abstract class DashboardPage extends AngularDisposable implements IConfig
|
||||
}
|
||||
});
|
||||
|
||||
if (primary.length > 0) {
|
||||
let separator: HTMLElement = Taskbar.createTaskbarSeparator();
|
||||
tasks.push({ element: separator });
|
||||
}
|
||||
}
|
||||
return tasks;
|
||||
}
|
||||
@@ -219,8 +219,8 @@ export abstract class DashboardPage extends AngularDisposable implements IConfig
|
||||
const toolbarTasks = this.tabToolbarActionsConfig.get(tabId);
|
||||
let tasks = TaskRegistry.getTasks();
|
||||
let content = [];
|
||||
if (types.isArray(toolbarTasks) && toolbarTasks.length > 0) {
|
||||
tasks = toolbarTasks.map(i => {
|
||||
if (types.isArray(toolbarTasks.actions) && toolbarTasks.actions.length > 0) {
|
||||
tasks = toolbarTasks.actions.map(i => {
|
||||
if (types.isString(i)) {
|
||||
if (tasks.some(x => x === i)) {
|
||||
return i;
|
||||
@@ -239,12 +239,29 @@ export abstract class DashboardPage extends AngularDisposable implements IConfig
|
||||
|
||||
// get extension actions contributed to the page's toolbar
|
||||
const contributedTasks = this.getContributedTasks(tabId);
|
||||
if (content.length > 0 && contributedTasks.length > 0) {
|
||||
/**
|
||||
* Adding the separator before adding contributed tasks if there other
|
||||
* toolbar tasks already present in the toolbar
|
||||
*/
|
||||
const separator: HTMLElement = Taskbar.createTaskbarSeparator();
|
||||
content.push({ element: separator });
|
||||
}
|
||||
content.push(...contributedTasks);
|
||||
|
||||
const refreshAction = new RefreshWidgetAction(() => {
|
||||
this.refresh();
|
||||
}, this);
|
||||
content.push({ action: refreshAction });
|
||||
if (!toolbarTasks.hideRefreshTask) {
|
||||
/**
|
||||
* Adding the separator only when there are other actions present on the task
|
||||
*/
|
||||
if (content.length > 0) {
|
||||
const separator: HTMLElement = Taskbar.createTaskbarSeparator();
|
||||
content.push({ element: separator });
|
||||
}
|
||||
const refreshAction = new RefreshWidgetAction(() => {
|
||||
this.refresh();
|
||||
}, this);
|
||||
content.push({ action: refreshAction });
|
||||
}
|
||||
return content;
|
||||
}
|
||||
|
||||
@@ -263,11 +280,6 @@ export abstract class DashboardPage extends AngularDisposable implements IConfig
|
||||
content.push({ action: a });
|
||||
});
|
||||
|
||||
if (content.length > 0) {
|
||||
let separator: HTMLElement = Taskbar.createTaskbarSeparator();
|
||||
content.push({ element: separator });
|
||||
}
|
||||
|
||||
return content;
|
||||
}
|
||||
|
||||
@@ -442,7 +454,7 @@ export abstract class DashboardPage extends AngularDisposable implements IConfig
|
||||
configs = cb.apply(this, [configs]);
|
||||
});
|
||||
|
||||
this.processTasksWidgets(configs, value.id);
|
||||
this.processTasksWidgets(configs, value.id, value.hideRefreshTask);
|
||||
|
||||
if (key === WIDGETS_CONTAINER) {
|
||||
return { id: value.id, title: value.title, container: { 'widgets-container': configs }, alwaysShow: value.alwaysShow, iconClass: value.iconClass };
|
||||
@@ -459,7 +471,7 @@ export abstract class DashboardPage extends AngularDisposable implements IConfig
|
||||
* @param widgets widgets
|
||||
* @param tabId tab id
|
||||
*/
|
||||
private processTasksWidgets(widgets: WidgetConfig[], tabId: string): void {
|
||||
private processTasksWidgets(widgets: WidgetConfig[], tabId: string, hideRefreshTask?: boolean): void {
|
||||
let index;
|
||||
const allTasks = [];
|
||||
// do this in a while loop since there might be multiple tasks widgets in a tab
|
||||
@@ -473,7 +485,10 @@ export abstract class DashboardPage extends AngularDisposable implements IConfig
|
||||
widgets.splice(index, 1);
|
||||
}
|
||||
} while (index !== -1);
|
||||
this.tabToolbarActionsConfig.set(tabId, allTasks);
|
||||
this.tabToolbarActionsConfig.set(tabId, {
|
||||
actions: allTasks,
|
||||
hideRefreshTask: hideRefreshTask
|
||||
});
|
||||
}
|
||||
|
||||
protected getContentType(tab: TabConfig): string {
|
||||
|
||||
@@ -65,6 +65,10 @@ const tabSchema: IJSONSchema = {
|
||||
description: localize('azdata.extension.contributes.dashboard.tab.group', "The unique identifier of the group this tab belongs to, value for home group: home."),
|
||||
type: 'string'
|
||||
},
|
||||
hideRefreshTask: {
|
||||
description: localize('azdata.extension.contributes.dashboard.tab.hideRefreshTask', "Flag used to show/hide refresh button in toolbar. By default, the value is false"),
|
||||
type: 'boolean'
|
||||
},
|
||||
icon: {
|
||||
description: localize('dazdata.extension.contributes.dashboard.tab.icon', "(Optional) Icon which is used to represent this tab in the UI. Either a file path or a themeable configuration"),
|
||||
anyOf: [{
|
||||
@@ -101,7 +105,7 @@ const tabContributionSchema: IJSONSchema = {
|
||||
ExtensionsRegistry.registerExtensionPoint<IDashboardTabContrib | IDashboardTabContrib[]>({ extensionPoint: 'dashboard.tabs', jsonSchema: tabContributionSchema }).setHandler(extensions => {
|
||||
|
||||
function handleTab(tab: IDashboardTabContrib, extension: IExtensionPointUser<any>) {
|
||||
let { description, container, provider, title, when, id, alwaysShow, isHomeTab, group, icon } = tab;
|
||||
let { description, container, provider, title, when, id, alwaysShow, isHomeTab, group, icon, hideRefreshTask } = tab;
|
||||
|
||||
// If always show is not specified, set it to true by default.
|
||||
if (!types.isBoolean(alwaysShow)) {
|
||||
@@ -155,7 +159,7 @@ ExtensionsRegistry.registerExtensionPoint<IDashboardTabContrib | IDashboardTabCo
|
||||
iconClass = createCSSRuleForIcon(icon, extension);
|
||||
}
|
||||
if (result) {
|
||||
registerTab({ description, title, container, provider, when, id, alwaysShow, publisher, isHomeTab, group, iconClass });
|
||||
registerTab({ description, title, container, provider, when, id, alwaysShow, publisher, isHomeTab, group, iconClass, hideRefreshTask });
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -45,6 +45,7 @@ export interface TabConfig extends IDashboardTab {
|
||||
canClose: boolean;
|
||||
actions?: Array<Action>;
|
||||
type?: TabType;
|
||||
hideRefreshTask?: boolean;
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -15,6 +15,7 @@ export interface IDashboardTab {
|
||||
isHomeTab?: boolean;
|
||||
group?: string;
|
||||
iconClass?: string;
|
||||
hideRefreshTask?: boolean;
|
||||
}
|
||||
|
||||
export interface IDashboardTabGroup {
|
||||
|
||||
Reference in New Issue
Block a user