Dev/brih/feature/switch ads to portal context (#18963)

* Add CodeQL Analysis workflow (#10195)

* Add CodeQL Analysis workflow

* Fix path

* dashboard refactor

* update version, readme, minor ui changes

* fix merge issue

* Revert "Add CodeQL Analysis workflow (#10195)"

This reverts commit fe98d586cd75be4758ac544649bb4983accf4acd.

* fix context switching issue

* fix resource id parsing error and mi api version

* mv refresh btn, rm autorefresh, align cards

* remove missed autorefresh code

* improve error handling and messages

* fix typos

* remove duplicate/unnecessary  _populate* calls

* change clear configuration button text

* remove confusing watermark text

* add stale account handling

Co-authored-by: Justin Hutchings <jhutchings1@users.noreply.github.com>
This commit is contained in:
brian-harris
2022-04-12 16:26:40 -07:00
committed by GitHub
parent d98a421035
commit 3a0ac7279a
30 changed files with 2163 additions and 1701 deletions

View File

@@ -5,15 +5,17 @@
import * as azdata from 'azdata';
import * as vscode from 'vscode';
import { MigrationContext, MigrationLocalStorage } from '../models/migrationLocalStorage';
import { logError, TelemetryViews } from '../telemtery';
import * as loc from '../constants/strings';
import { IconPath, IconPathHelper } from '../constants/iconPathHelper';
import { MigrationStatusDialog } from '../dialog/migrationStatus/migrationStatusDialog';
import { AdsMigrationStatus } from '../dialog/migrationStatus/migrationStatusDialogModel';
import { filterMigrations, SupportedAutoRefreshIntervals } from '../api/utils';
import { filterMigrations } from '../api/utils';
import * as styles from '../constants/styles';
import * as nls from 'vscode-nls';
import { SelectMigrationServiceDialog } from '../dialog/selectMigrationService/selectMigrationServiceDialog';
import { DatabaseMigration } from '../api/azure';
import { getCurrentMigrations, getSelectedServiceStatus, isServiceContextValid, MigrationLocalStorage } from '../models/migrationLocalStorage';
const localize = nls.loadMessageBundle();
interface IActionMetadata {
@@ -25,7 +27,12 @@ interface IActionMetadata {
}
const maxWidth = 800;
const refreshFrequency: SupportedAutoRefreshIntervals = 180000;
const BUTTON_CSS = {
'font-size': '13px',
'line-height': '18px',
'margin': '4px 0',
'text-align': 'left',
};
interface StatusCard {
container: azdata.DivContainer;
@@ -37,39 +44,33 @@ interface StatusCard {
export class DashboardWidget {
private _context: vscode.ExtensionContext;
private _migrationStatusCardsContainer!: azdata.FlexContainer;
private _migrationStatusCardLoadingContainer!: azdata.LoadingComponent;
private _view!: azdata.ModelView;
private _inProgressMigrationButton!: StatusCard;
private _inProgressWarningMigrationButton!: StatusCard;
private _allMigrationButton!: StatusCard;
private _successfulMigrationButton!: StatusCard;
private _failedMigrationButton!: StatusCard;
private _completingMigrationButton!: StatusCard;
private _notStartedMigrationCard!: StatusCard;
private _migrationStatusMap: Map<string, MigrationContext[]> = new Map();
private _viewAllMigrationsButton!: azdata.ButtonComponent;
private _selectServiceText!: azdata.TextComponent;
private _serviceContextButton!: azdata.ButtonComponent;
private _refreshButton!: azdata.ButtonComponent;
private _autoRefreshHandle!: NodeJS.Timeout;
private _disposables: vscode.Disposable[] = [];
private isRefreshing: boolean = false;
public onDialogClosed = async (): Promise<void> => {
const label = await getSelectedServiceStatus();
this._serviceContextButton.label = label;
this._serviceContextButton.title = label;
await this.refreshMigrations();
};
constructor(context: vscode.ExtensionContext) {
this._context = context;
}
private async getCurrentMigrations(): Promise<MigrationContext[]> {
const connectionId = (await azdata.connection.getCurrentConnection()).connectionId;
return this._migrationStatusMap.get(connectionId)!;
}
private async setCurrentMigrations(migrations: MigrationContext[]): Promise<void> {
const connectionId = (await azdata.connection.getCurrentConnection()).connectionId;
this._migrationStatusMap.set(connectionId, migrations);
}
public register(): void {
azdata.ui.registerModelViewProvider('migration.dashboard', async (view) => {
this._view = view;
@@ -82,7 +83,10 @@ export class DashboardWidget {
const header = this.createHeader(view);
// Files need to have the vscode-file scheme to be loaded by ADS
const watermarkUri = vscode.Uri.file(<string>IconPathHelper.migrationDashboardHeaderBackground.light).with({ scheme: 'vscode-file' });
const watermarkUri = vscode.Uri
.file(<string>IconPathHelper.migrationDashboardHeaderBackground.light)
.with({ scheme: 'vscode-file' });
container.addItem(header, {
CSSStyles: {
'background-image': `
@@ -107,11 +111,11 @@ export class DashboardWidget {
'margin': '0 24px'
}
});
this._disposables.push(this._view.onClosed(e => {
clearInterval(this._autoRefreshHandle);
this._disposables.forEach(
d => { try { d.dispose(); } catch { } });
}));
this._disposables.push(
this._view.onClosed(e => {
this._disposables.forEach(
d => { try { d.dispose(); } catch { } });
}));
await view.initializeModel(container);
await this.refreshMigrations();
@@ -119,8 +123,6 @@ export class DashboardWidget {
}
private createHeader(view: azdata.ModelView): azdata.FlexContainer {
this.setAutoRefresh(refreshFrequency);
const header = view.modelBuilder.flexContainer().withLayout({
flexFlow: 'column',
width: maxWidth,
@@ -229,95 +231,71 @@ export class DashboardWidget {
'transition': 'all .5s ease',
}
}).component();
this._disposables.push(buttonContainer.onDidClick(async () => {
if (taskMetaData.command) {
await vscode.commands.executeCommand(taskMetaData.command);
}
}));
this._disposables.push(
buttonContainer.onDidClick(async () => {
if (taskMetaData.command) {
await vscode.commands.executeCommand(taskMetaData.command);
}
}));
return view.modelBuilder.divContainer().withItems([buttonContainer]).component();
}
private setAutoRefresh(interval: SupportedAutoRefreshIntervals): void {
const classVariable = this;
clearInterval(this._autoRefreshHandle);
if (interval !== -1) {
this._autoRefreshHandle = setInterval(async function () { await classVariable.refreshMigrations(); }, interval);
}
}
private async refreshMigrations(): Promise<void> {
public async refreshMigrations(): Promise<void> {
if (this.isRefreshing) {
return;
}
this.isRefreshing = true;
this._viewAllMigrationsButton.enabled = false;
this._migrationStatusCardLoadingContainer.loading = true;
let migrations: DatabaseMigration[] = [];
try {
await this.setCurrentMigrations(await this.getMigrations());
const migrations = await this.getCurrentMigrations();
const inProgressMigrations = filterMigrations(migrations, AdsMigrationStatus.ONGOING);
let warningCount = 0;
for (let i = 0; i < inProgressMigrations.length; i++) {
if (
inProgressMigrations[i].asyncOperationResult?.error?.message ||
inProgressMigrations[i].migrationContext.properties.migrationFailureError?.message ||
inProgressMigrations[i].migrationContext.properties.migrationStatusDetails?.fileUploadBlockingErrors ||
inProgressMigrations[i].migrationContext.properties.migrationStatusDetails?.restoreBlockingReason
) {
warningCount += 1;
}
}
if (warningCount > 0) {
this._inProgressWarningMigrationButton.warningText!.value = loc.MIGRATION_INPROGRESS_WARNING(warningCount);
this._inProgressMigrationButton.container.display = 'none';
this._inProgressWarningMigrationButton.container.display = '';
} else {
this._inProgressMigrationButton.container.display = '';
this._inProgressWarningMigrationButton.container.display = 'none';
}
this._inProgressMigrationButton.count.value = inProgressMigrations.length.toString();
this._inProgressWarningMigrationButton.count.value = inProgressMigrations.length.toString();
const successfulMigration = filterMigrations(migrations, AdsMigrationStatus.SUCCEEDED);
this._successfulMigrationButton.count.value = successfulMigration.length.toString();
const failedMigrations = filterMigrations(migrations, AdsMigrationStatus.FAILED);
const failedCount = failedMigrations.length;
if (failedCount > 0) {
this._failedMigrationButton.container.display = '';
this._failedMigrationButton.count.value = failedCount.toString();
} else {
this._failedMigrationButton.container.display = 'none';
}
const completingCutoverMigrations = filterMigrations(migrations, AdsMigrationStatus.COMPLETING);
const cutoverCount = completingCutoverMigrations.length;
if (cutoverCount > 0) {
this._completingMigrationButton.container.display = '';
this._completingMigrationButton.count.value = cutoverCount.toString();
} else {
this._completingMigrationButton.container.display = 'none';
}
} catch (error) {
logError(TelemetryViews.SqlServerDashboard, 'RefreshgMigrationFailed', error);
} finally {
this.isRefreshing = false;
this._migrationStatusCardLoadingContainer.loading = false;
this._viewAllMigrationsButton.enabled = true;
migrations = await getCurrentMigrations();
} catch (e) {
logError(TelemetryViews.SqlServerDashboard, 'RefreshgMigrationFailed', e);
void vscode.window.showErrorMessage(loc.DASHBOARD_REFRESH_MIGRATIONS(e.message));
}
const inProgressMigrations = filterMigrations(migrations, AdsMigrationStatus.ONGOING);
let warningCount = 0;
for (let i = 0; i < inProgressMigrations.length; i++) {
if (inProgressMigrations[i].properties.migrationFailureError?.message ||
inProgressMigrations[i].properties.migrationStatusDetails?.fileUploadBlockingErrors ||
inProgressMigrations[i].properties.migrationStatusDetails?.restoreBlockingReason) {
warningCount += 1;
}
}
if (warningCount > 0) {
this._inProgressWarningMigrationButton.warningText!.value = loc.MIGRATION_INPROGRESS_WARNING(warningCount);
this._inProgressMigrationButton.container.display = 'none';
this._inProgressWarningMigrationButton.container.display = '';
} else {
this._inProgressMigrationButton.container.display = '';
this._inProgressWarningMigrationButton.container.display = 'none';
}
this._inProgressMigrationButton.count.value = inProgressMigrations.length.toString();
this._inProgressWarningMigrationButton.count.value = inProgressMigrations.length.toString();
this._updateStatusCard(migrations, this._successfulMigrationButton, AdsMigrationStatus.SUCCEEDED, true);
this._updateStatusCard(migrations, this._failedMigrationButton, AdsMigrationStatus.FAILED);
this._updateStatusCard(migrations, this._completingMigrationButton, AdsMigrationStatus.COMPLETING);
this._updateStatusCard(migrations, this._allMigrationButton, AdsMigrationStatus.ALL, true);
await this._updateSummaryStatus();
this.isRefreshing = false;
this._migrationStatusCardLoadingContainer.loading = false;
}
private async getMigrations(): Promise<MigrationContext[]> {
const currentConnection = (await azdata.connection.getCurrentConnection());
return await MigrationLocalStorage.getMigrationsBySourceConnections(currentConnection, true);
private _updateStatusCard(
migrations: DatabaseMigration[],
card: StatusCard,
status: AdsMigrationStatus,
show?: boolean): void {
const list = filterMigrations(migrations, status);
const count = list?.length || 0;
card.container.display = count > 0 || show ? '' : 'none';
card.count.value = count.toString();
}
private createStatusCard(
cardIconPath: IconPath,
cardTitle: string,
@@ -334,26 +312,27 @@ export class DashboardWidget {
}
}).component();
const statusIcon = this._view.modelBuilder.image().withProps({
iconPath: cardIconPath!.light,
iconHeight: 24,
iconWidth: 24,
height: 32,
CSSStyles: {
'margin': '0 8px'
}
}).component();
const statusIcon = this._view.modelBuilder.image()
.withProps({
iconPath: cardIconPath!.light,
iconHeight: 24,
iconWidth: 24,
height: 32,
CSSStyles: { 'margin': '0 8px' }
}).component();
const textContainer = this._view.modelBuilder.flexContainer().withLayout({
flexFlow: 'column'
}).component();
const textContainer = this._view.modelBuilder.flexContainer()
.withLayout({ flexFlow: 'column' })
.component();
const cardTitleText = this._view.modelBuilder.text().withProps({ value: cardTitle }).withProps({
CSSStyles: {
...styles.SECTION_HEADER_CSS,
'width': '240px'
}
}).component();
const cardTitleText = this._view.modelBuilder.text()
.withProps({ value: cardTitle })
.withProps({
CSSStyles: {
...styles.SECTION_HEADER_CSS,
'width': '240px',
}
}).component();
textContainer.addItem(cardTitleText);
const cardCount = this._view.modelBuilder.text().withProps({
@@ -368,32 +347,31 @@ export class DashboardWidget {
let warningContainer;
let warningText;
if (hasSubtext) {
const warningIcon = this._view.modelBuilder.image().withProps({
iconPath: IconPathHelper.warning,
iconWidth: 12,
iconHeight: 12,
width: 12,
height: 18
}).component();
const warningIcon = this._view.modelBuilder.image()
.withProps({
iconPath: IconPathHelper.warning,
iconWidth: 12,
iconHeight: 12,
width: 12,
height: 18,
}).component();
const warningDescription = '';
warningText = this._view.modelBuilder.text().withProps({ value: warningDescription }).withProps({
CSSStyles: {
...styles.BODY_CSS,
'padding-left': '8px',
}
}).component();
warningText = this._view.modelBuilder.text().withProps({ value: warningDescription })
.withProps({
CSSStyles: {
...styles.BODY_CSS,
'padding-left': '8px',
}
}).component();
warningContainer = this._view.modelBuilder.flexContainer().withItems([
warningIcon,
warningText
], {
flex: '0 0 auto'
}).withProps({
CSSStyles: {
'align-items': 'center'
}
}).component();
warningContainer = this._view.modelBuilder.flexContainer()
.withItems(
[warningIcon, warningText],
{ flex: '0 0 auto' })
.withProps({
CSSStyles: { 'align-items': 'center' }
}).component();
textContainer.addItem(warningContainer);
}
@@ -452,255 +430,243 @@ export class DashboardWidget {
const statusContainer = view.modelBuilder.flexContainer().withLayout({
flexFlow: 'column',
width: '400px',
height: '360px',
height: '385px',
justifyContent: 'flex-start',
}).withProps({
CSSStyles: {
'border': '1px solid rgba(0, 0, 0, 0.1)',
'padding': '16px'
'padding': '10px',
}
}).component();
const statusContainerTitle = view.modelBuilder.text().withProps({
value: loc.DATABASE_MIGRATION_STATUS,
CSSStyles: {
...styles.SECTION_HEADER_CSS
}
}).component();
const statusContainerTitle = view.modelBuilder.text()
.withProps({
value: loc.DATABASE_MIGRATION_STATUS,
width: '100%',
CSSStyles: { ...styles.SECTION_HEADER_CSS }
}).component();
this._viewAllMigrationsButton = view.modelBuilder.hyperlink().withProps({
label: loc.VIEW_ALL,
url: '',
CSSStyles: {
...styles.BODY_CSS
}
}).component();
this._refreshButton = view.modelBuilder.button()
.withProps({
label: loc.REFRESH,
iconPath: IconPathHelper.refresh,
iconHeight: 16,
iconWidth: 16,
width: 70,
CSSStyles: { 'float': 'right' }
}).component();
this._disposables.push(this._viewAllMigrationsButton.onDidClick(async (e) => {
const migrationStatus = await this.getCurrentMigrations();
new MigrationStatusDialog(this._context, migrationStatus ? migrationStatus : await this.getMigrations(), AdsMigrationStatus.ALL).initialize();
}));
const refreshButton = view.modelBuilder.hyperlink().withProps({
label: loc.REFRESH,
url: '',
ariaRole: 'button',
CSSStyles: {
...styles.BODY_CSS,
'text-align': 'right',
}
}).component();
this._disposables.push(refreshButton.onDidClick(async (e) => {
refreshButton.enabled = false;
await this.refreshMigrations();
refreshButton.enabled = true;
}));
const buttonContainer = view.modelBuilder.flexContainer().withLayout({
justifyContent: 'flex-end',
}).component();
buttonContainer.addItem(this._viewAllMigrationsButton, {
CSSStyles: {
'padding-right': '8px',
'border-right': '1px solid',
}
});
buttonContainer.addItem(refreshButton, {
CSSStyles: {
'padding-left': '8px',
}
});
const addAccountImage = view.modelBuilder.image().withProps({
iconPath: IconPathHelper.addAzureAccount,
iconHeight: 100,
iconWidth: 100,
width: 96,
height: 96,
CSSStyles: {
'opacity': '50%',
'margin': '15% auto 10% auto',
'filter': 'drop-shadow(0px 4px 4px rgba(0, 0, 0, 0.25))',
'display': 'none'
}
}).component();
const addAccountText = view.modelBuilder.text().withProps({
value: loc.ADD_ACCOUNT_MESSAGE,
width: 198,
height: 34,
CSSStyles: {
...styles.NOTE_CSS,
'margin': 'auto',
'text-align': 'center',
'display': 'none'
}
}).component();
const addAccountButton = view.modelBuilder.button().withProps({
label: loc.ADD_ACCOUNT,
width: '100px',
enabled: true,
CSSStyles: {
'margin': '5% 40%',
'display': 'none'
}
}).component();
this._disposables.push(addAccountButton.onDidClick(async (e) => {
await vscode.commands.executeCommand('workbench.actions.modal.linkedAccount');
addAccountButton.enabled = false;
let accounts = await azdata.accounts.getAllAccounts();
if (accounts.length !== 0) {
await addAccountImage.updateCssStyles({
'display': 'none'
});
await addAccountText.updateCssStyles({
'display': 'none'
});
await addAccountButton.updateCssStyles({
'display': 'none'
});
await this._migrationStatusCardsContainer.updateCssStyles({ 'visibility': 'visible' });
await this._viewAllMigrationsButton.updateCssStyles({ 'visibility': 'visible' });
}
await this.refreshMigrations();
}));
const header = view.modelBuilder.flexContainer().withItems(
[
const statusHeadingContainer = view.modelBuilder.flexContainer()
.withItems([
statusContainerTitle,
buttonContainer
]
).withLayout({
flexFlow: 'row',
alignItems: 'center'
}).component();
this._refreshButton,
]).withLayout({
alignContent: 'center',
alignItems: 'center',
flexFlow: 'row',
}).component();
this._migrationStatusCardsContainer = view.modelBuilder.flexContainer().withLayout({ flexFlow: 'column' }).component();
this._disposables.push(
this._refreshButton.onDidClick(async (e) => {
this._refreshButton.enabled = false;
await this.refreshMigrations();
this._refreshButton.enabled = true;
}));
let accounts = await azdata.accounts.getAllAccounts();
const buttonContainer = view.modelBuilder.flexContainer()
.withProps({
CSSStyles: {
'justify-content': 'left',
'align-iems': 'center',
},
})
.component();
if (accounts.length === 0) {
await addAccountImage.updateCssStyles({
'display': 'block'
});
await addAccountText.updateCssStyles({
'display': 'block'
});
await addAccountButton.updateCssStyles({
'display': 'block'
});
await this._migrationStatusCardsContainer.updateCssStyles({ 'visibility': 'hidden' });
await this._viewAllMigrationsButton.updateCssStyles({ 'visibility': 'hidden' });
}
buttonContainer.addItem(
await this.createServiceSelector(this._view));
this._selectServiceText = view.modelBuilder.text()
.withProps({
value: loc.SELECT_SERVICE_MESSAGE,
CSSStyles: {
'font-size': '12px',
'margin': '10px',
'font-weight': '350',
'text-align': 'center',
'display': 'none'
}
}).component();
const header = view.modelBuilder.flexContainer()
.withItems([statusHeadingContainer, buttonContainer])
.withLayout({ flexFlow: 'column', })
.component();
this._migrationStatusCardsContainer = view.modelBuilder.flexContainer()
.withLayout({
flexFlow: 'column',
height: '272px',
})
.withProps({ CSSStyles: { 'overflow': 'hidden auto' } })
.component();
await this._updateSummaryStatus();
// in progress
this._inProgressMigrationButton = this.createStatusCard(
IconPathHelper.inProgressMigration,
loc.MIGRATION_IN_PROGRESS
);
this._disposables.push(this._inProgressMigrationButton.container.onDidClick(async (e) => {
const dialog = new MigrationStatusDialog(this._context, await this.getCurrentMigrations(), AdsMigrationStatus.ONGOING);
dialog.initialize();
}));
loc.MIGRATION_IN_PROGRESS);
this._disposables.push(
this._inProgressMigrationButton.container.onDidClick(async (e) => {
const dialog = new MigrationStatusDialog(
this._context,
AdsMigrationStatus.ONGOING,
this.onDialogClosed);
await dialog.initialize();
}));
this._migrationStatusCardsContainer.addItem(
this._inProgressMigrationButton.container
);
this._inProgressMigrationButton.container,
{ flex: '0 0 auto' });
// in progress warning
this._inProgressWarningMigrationButton = this.createStatusCard(
IconPathHelper.inProgressMigration,
loc.MIGRATION_IN_PROGRESS,
true
);
this._disposables.push(this._inProgressWarningMigrationButton.container.onDidClick(async (e) => {
const dialog = new MigrationStatusDialog(this._context, await this.getCurrentMigrations(), AdsMigrationStatus.ONGOING);
dialog.initialize();
}));
true);
this._disposables.push(
this._inProgressWarningMigrationButton.container.onDidClick(async (e) => {
const dialog = new MigrationStatusDialog(
this._context,
AdsMigrationStatus.ONGOING,
this.onDialogClosed);
await dialog.initialize();
}));
this._migrationStatusCardsContainer.addItem(
this._inProgressWarningMigrationButton.container
);
this._inProgressWarningMigrationButton.container,
{ flex: '0 0 auto' });
// successful
this._successfulMigrationButton = this.createStatusCard(
IconPathHelper.completedMigration,
loc.MIGRATION_COMPLETED
);
this._disposables.push(this._successfulMigrationButton.container.onDidClick(async (e) => {
const dialog = new MigrationStatusDialog(this._context, await this.getCurrentMigrations(), AdsMigrationStatus.SUCCEEDED);
dialog.initialize();
}));
loc.MIGRATION_COMPLETED);
this._disposables.push(
this._successfulMigrationButton.container.onDidClick(async (e) => {
const dialog = new MigrationStatusDialog(
this._context,
AdsMigrationStatus.SUCCEEDED,
this.onDialogClosed);
await dialog.initialize();
}));
this._migrationStatusCardsContainer.addItem(
this._successfulMigrationButton.container
);
this._successfulMigrationButton.container,
{ flex: '0 0 auto' });
// completing
this._completingMigrationButton = this.createStatusCard(
IconPathHelper.completingCutover,
loc.MIGRATION_CUTOVER_CARD
);
this._disposables.push(this._completingMigrationButton.container.onDidClick(async (e) => {
const dialog = new MigrationStatusDialog(this._context, await this.getCurrentMigrations(), AdsMigrationStatus.COMPLETING);
dialog.initialize();
}));
loc.MIGRATION_CUTOVER_CARD);
this._disposables.push(
this._completingMigrationButton.container.onDidClick(async (e) => {
const dialog = new MigrationStatusDialog(
this._context,
AdsMigrationStatus.COMPLETING,
this.onDialogClosed);
await dialog.initialize();
}));
this._migrationStatusCardsContainer.addItem(
this._completingMigrationButton.container
);
this._completingMigrationButton.container,
{ flex: '0 0 auto' });
// failed
this._failedMigrationButton = this.createStatusCard(
IconPathHelper.error,
loc.MIGRATION_FAILED
);
this._disposables.push(this._failedMigrationButton.container.onDidClick(async (e) => {
const dialog = new MigrationStatusDialog(this._context, await this.getCurrentMigrations(), AdsMigrationStatus.FAILED);
dialog.initialize();
}));
loc.MIGRATION_FAILED);
this._disposables.push(
this._failedMigrationButton.container.onDidClick(async (e) => {
const dialog = new MigrationStatusDialog(
this._context,
AdsMigrationStatus.FAILED,
this.onDialogClosed);
await dialog.initialize();
}));
this._migrationStatusCardsContainer.addItem(
this._failedMigrationButton.container
);
this._failedMigrationButton.container,
{ flex: '0 0 auto' });
this._notStartedMigrationCard = this.createStatusCard(
IconPathHelper.notStartedMigration,
loc.MIGRATION_NOT_STARTED
);
this._disposables.push(this._notStartedMigrationCard.container.onDidClick((e) => {
void vscode.window.showInformationMessage('Feature coming soon');
}));
// all migrations
this._allMigrationButton = this.createStatusCard(
IconPathHelper.view,
loc.VIEW_ALL);
this._disposables.push(
this._allMigrationButton.container.onDidClick(async (e) => {
const dialog = new MigrationStatusDialog(
this._context,
AdsMigrationStatus.ALL,
this.onDialogClosed);
await dialog.initialize();
}));
this._migrationStatusCardsContainer.addItem(
this._allMigrationButton.container,
{ flex: '0 0 auto' });
this._migrationStatusCardLoadingContainer = view.modelBuilder.loadingComponent().withItem(this._migrationStatusCardsContainer).component();
statusContainer.addItem(
header, {
CSSStyles: {
'margin-bottom': '16px'
}
}
);
statusContainer.addItem(addAccountImage, {});
statusContainer.addItem(addAccountText, {});
statusContainer.addItem(addAccountButton, {});
this._migrationStatusCardLoadingContainer = view.modelBuilder.loadingComponent()
.withItem(this._migrationStatusCardsContainer)
.component();
statusContainer.addItem(header, { CSSStyles: { 'margin-bottom': '10px' } });
statusContainer.addItem(this._selectServiceText, {});
statusContainer.addItem(this._migrationStatusCardLoadingContainer, {});
return statusContainer;
}
private async _updateSummaryStatus(): Promise<void> {
const serviceContext = await MigrationLocalStorage.getMigrationServiceContext();
const isContextValid = isServiceContextValid(serviceContext);
await this._selectServiceText.updateCssStyles({ 'display': isContextValid ? 'none' : 'block' });
await this._migrationStatusCardsContainer.updateCssStyles({ 'visibility': isContextValid ? 'visible' : 'hidden' });
this._refreshButton.enabled = isContextValid;
}
private async createServiceSelector(view: azdata.ModelView): Promise<azdata.Component> {
const serviceContextLabel = await getSelectedServiceStatus();
this._serviceContextButton = view.modelBuilder.button()
.withProps({
iconPath: IconPathHelper.sqlMigrationService,
iconHeight: 22,
iconWidth: 22,
label: serviceContextLabel,
title: serviceContextLabel,
description: loc.MIGRATION_SERVICE_DESCRIPTION,
buttonType: azdata.ButtonType.Informational,
width: 375,
CSSStyles: { ...BUTTON_CSS },
})
.component();
this._disposables.push(
this._serviceContextButton.onDidClick(async () => {
const dialog = new SelectMigrationServiceDialog(this.onDialogClosed);
await dialog.initialize();
}));
return this._serviceContextButton;
}
private createVideoLinks(view: azdata.ModelView): azdata.Component {
const linksContainer = view.modelBuilder.flexContainer().withLayout({
flexFlow: 'column',
width: '400px',
height: '360px',
justifyContent: 'flex-start',
}).withProps({
CSSStyles: {
'border': '1px solid rgba(0, 0, 0, 0.1)',
'padding': '16px',
'overflow': 'scroll',
}
}).component();
const linksContainer = view.modelBuilder.flexContainer()
.withLayout({
flexFlow: 'column',
width: '440px',
height: '385px',
justifyContent: 'flex-start',
}).withProps({
CSSStyles: {
'border': '1px solid rgba(0, 0, 0, 0.1)',
'padding': '10px',
'overflow': 'scroll',
}
}).component();
const titleComponent = view.modelBuilder.text().withProps({
value: loc.HELP_TITLE,
CSSStyles: {
@@ -809,11 +775,12 @@ export class DashboardWidget {
...styles.BODY_CSS
}
}).component();
this._disposables.push(video1Container.onDidClick(async () => {
if (linkMetaData.link) {
await vscode.env.openExternal(vscode.Uri.parse(linkMetaData.link));
}
}));
this._disposables.push(
video1Container.onDidClick(async () => {
if (linkMetaData.link) {
await vscode.env.openExternal(vscode.Uri.parse(linkMetaData.link));
}
}));
videosContainer.addItem(video1Container, {
CSSStyles: {
'background-image': `url(${vscode.Uri.file(<string>linkMetaData.iconPath?.light)})`,