mirror of
https://github.com/ckaczor/azuredatastudio.git
synced 2026-02-17 02:51:36 -05:00
Adding flag to hide refresh button in dashboards. (#18964)
This commit is contained in:
@@ -145,6 +145,7 @@
|
|||||||
"dark": "./images/migration.svg"
|
"dark": "./images/migration.svg"
|
||||||
},
|
},
|
||||||
"when": "connectionProvider == 'MSSQL' && !mssql:iscloud && mssql:engineedition != 8",
|
"when": "connectionProvider == 'MSSQL' && !mssql:iscloud && mssql:engineedition != 8",
|
||||||
|
"hideRefreshTask": true,
|
||||||
"container": {
|
"container": {
|
||||||
"grid-container": [
|
"grid-container": [
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -70,6 +70,7 @@ export interface IDashboardTabContrib {
|
|||||||
isHomeTab?: boolean;
|
isHomeTab?: boolean;
|
||||||
group?: string;
|
group?: string;
|
||||||
icon?: IUserFriendlyIcon;
|
icon?: IUserFriendlyIcon;
|
||||||
|
hideRefreshTask?: boolean;
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface IInsightTypeContrib {
|
export interface IInsightTypeContrib {
|
||||||
|
|||||||
@@ -83,7 +83,11 @@ export abstract class DashboardPage extends AngularDisposable implements IConfig
|
|||||||
// tslint:disable:no-unused-variable
|
// tslint:disable:no-unused-variable
|
||||||
private readonly homeTabTitle: string = nls.localize('home', "Home");
|
private readonly homeTabTitle: string = nls.localize('home', "Home");
|
||||||
private readonly homeTabId: string = 'homeTab';
|
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>();
|
private tabContents = new Map<string, string>();
|
||||||
|
|
||||||
static tabName = new RawContextKey<string>('tabName', undefined);
|
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;
|
return tasks;
|
||||||
}
|
}
|
||||||
@@ -219,8 +219,8 @@ export abstract class DashboardPage extends AngularDisposable implements IConfig
|
|||||||
const toolbarTasks = this.tabToolbarActionsConfig.get(tabId);
|
const toolbarTasks = this.tabToolbarActionsConfig.get(tabId);
|
||||||
let tasks = TaskRegistry.getTasks();
|
let tasks = TaskRegistry.getTasks();
|
||||||
let content = [];
|
let content = [];
|
||||||
if (types.isArray(toolbarTasks) && toolbarTasks.length > 0) {
|
if (types.isArray(toolbarTasks.actions) && toolbarTasks.actions.length > 0) {
|
||||||
tasks = toolbarTasks.map(i => {
|
tasks = toolbarTasks.actions.map(i => {
|
||||||
if (types.isString(i)) {
|
if (types.isString(i)) {
|
||||||
if (tasks.some(x => x === i)) {
|
if (tasks.some(x => x === i)) {
|
||||||
return i;
|
return i;
|
||||||
@@ -239,12 +239,29 @@ export abstract class DashboardPage extends AngularDisposable implements IConfig
|
|||||||
|
|
||||||
// get extension actions contributed to the page's toolbar
|
// get extension actions contributed to the page's toolbar
|
||||||
const contributedTasks = this.getContributedTasks(tabId);
|
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);
|
content.push(...contributedTasks);
|
||||||
|
|
||||||
|
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(() => {
|
const refreshAction = new RefreshWidgetAction(() => {
|
||||||
this.refresh();
|
this.refresh();
|
||||||
}, this);
|
}, this);
|
||||||
content.push({ action: refreshAction });
|
content.push({ action: refreshAction });
|
||||||
|
}
|
||||||
return content;
|
return content;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -263,11 +280,6 @@ export abstract class DashboardPage extends AngularDisposable implements IConfig
|
|||||||
content.push({ action: a });
|
content.push({ action: a });
|
||||||
});
|
});
|
||||||
|
|
||||||
if (content.length > 0) {
|
|
||||||
let separator: HTMLElement = Taskbar.createTaskbarSeparator();
|
|
||||||
content.push({ element: separator });
|
|
||||||
}
|
|
||||||
|
|
||||||
return content;
|
return content;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -442,7 +454,7 @@ export abstract class DashboardPage extends AngularDisposable implements IConfig
|
|||||||
configs = cb.apply(this, [configs]);
|
configs = cb.apply(this, [configs]);
|
||||||
});
|
});
|
||||||
|
|
||||||
this.processTasksWidgets(configs, value.id);
|
this.processTasksWidgets(configs, value.id, value.hideRefreshTask);
|
||||||
|
|
||||||
if (key === WIDGETS_CONTAINER) {
|
if (key === WIDGETS_CONTAINER) {
|
||||||
return { id: value.id, title: value.title, container: { 'widgets-container': configs }, alwaysShow: value.alwaysShow, iconClass: value.iconClass };
|
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 widgets widgets
|
||||||
* @param tabId tab id
|
* @param tabId tab id
|
||||||
*/
|
*/
|
||||||
private processTasksWidgets(widgets: WidgetConfig[], tabId: string): void {
|
private processTasksWidgets(widgets: WidgetConfig[], tabId: string, hideRefreshTask?: boolean): void {
|
||||||
let index;
|
let index;
|
||||||
const allTasks = [];
|
const allTasks = [];
|
||||||
// do this in a while loop since there might be multiple tasks widgets in a tab
|
// 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);
|
widgets.splice(index, 1);
|
||||||
}
|
}
|
||||||
} while (index !== -1);
|
} while (index !== -1);
|
||||||
this.tabToolbarActionsConfig.set(tabId, allTasks);
|
this.tabToolbarActionsConfig.set(tabId, {
|
||||||
|
actions: allTasks,
|
||||||
|
hideRefreshTask: hideRefreshTask
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
protected getContentType(tab: TabConfig): string {
|
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."),
|
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'
|
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: {
|
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"),
|
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: [{
|
anyOf: [{
|
||||||
@@ -101,7 +105,7 @@ const tabContributionSchema: IJSONSchema = {
|
|||||||
ExtensionsRegistry.registerExtensionPoint<IDashboardTabContrib | IDashboardTabContrib[]>({ extensionPoint: 'dashboard.tabs', jsonSchema: tabContributionSchema }).setHandler(extensions => {
|
ExtensionsRegistry.registerExtensionPoint<IDashboardTabContrib | IDashboardTabContrib[]>({ extensionPoint: 'dashboard.tabs', jsonSchema: tabContributionSchema }).setHandler(extensions => {
|
||||||
|
|
||||||
function handleTab(tab: IDashboardTabContrib, extension: IExtensionPointUser<any>) {
|
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 always show is not specified, set it to true by default.
|
||||||
if (!types.isBoolean(alwaysShow)) {
|
if (!types.isBoolean(alwaysShow)) {
|
||||||
@@ -155,7 +159,7 @@ ExtensionsRegistry.registerExtensionPoint<IDashboardTabContrib | IDashboardTabCo
|
|||||||
iconClass = createCSSRuleForIcon(icon, extension);
|
iconClass = createCSSRuleForIcon(icon, extension);
|
||||||
}
|
}
|
||||||
if (result) {
|
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;
|
canClose: boolean;
|
||||||
actions?: Array<Action>;
|
actions?: Array<Action>;
|
||||||
type?: TabType;
|
type?: TabType;
|
||||||
|
hideRefreshTask?: boolean;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -15,6 +15,7 @@ export interface IDashboardTab {
|
|||||||
isHomeTab?: boolean;
|
isHomeTab?: boolean;
|
||||||
group?: string;
|
group?: string;
|
||||||
iconClass?: string;
|
iconClass?: string;
|
||||||
|
hideRefreshTask?: boolean;
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface IDashboardTabGroup {
|
export interface IDashboardTabGroup {
|
||||||
|
|||||||
Reference in New Issue
Block a user