Files
azuredatastudio/extensions/machine-learning/src/views/externalLanguages/languagesTable.ts
nasc17 b472539646 Switch withProperties to be withProps (#16380)
* Transition to withProps in arc

* Transition to withProps inputbox

* Transition to withProps in checkbox

* Transition to withProps text

* Transition to withProps in declarative table

* Transition to withProps hyperlink

* Transition to withProps in button

* Transition to withProps radiobutton

* Transition to withProps in input

* Transition to withProps button

* Transition to withProps in text

* Transition to withProps image

* Transition to withProps declare table

* Transition to withProps in table

* Transition to withProps radio button

* Transition to withProps in image

* Transition to withProps radio button

* Transition to withProps in commit

* Transition to withProps div cont

* Transition to withProps in comp

* Transition to withProps radio card

* Transition to withProps in comp icon

* Transition to withProps card

* Transition to withProps list
2021-07-21 11:12:47 -07:00

166 lines
4.7 KiB
TypeScript

/*---------------------------------------------------------------------------------------------
* Copyright (c) Microsoft Corporation. All rights reserved.
* Licensed under the Source EULA. See License.txt in the project root for license information.
*--------------------------------------------------------------------------------------------*/
import * as azdata from 'azdata';
import * as constants from '../../common/constants';
import * as mssql from '../../../../mssql';
import { LanguageViewBase } from './languageViewBase';
import { ApiWrapper } from '../../common/apiWrapper';
export class LanguagesTable extends LanguageViewBase {
private _table: azdata.DeclarativeTableComponent;
/**
*
*/
constructor(apiWrapper: ApiWrapper, private _modelBuilder: azdata.ModelBuilder, parent: LanguageViewBase) {
super(apiWrapper, parent.root, parent);
this._table = _modelBuilder.declarativeTable()
.withProps(
{
columns: [
{ // Name
displayName: constants.extLangLanguageName,
ariaLabel: constants.extLangLanguageName,
valueType: azdata.DeclarativeDataType.string,
isReadOnly: true,
width: 100,
headerCssStyles: {
...constants.cssStyles.tableHeader
},
rowCssStyles: {
...constants.cssStyles.tableRow
},
},
{ // Platform
displayName: constants.extLangLanguagePlatform,
ariaLabel: constants.extLangLanguagePlatform,
valueType: azdata.DeclarativeDataType.string,
isReadOnly: true,
width: 150,
headerCssStyles: {
...constants.cssStyles.tableHeader
},
rowCssStyles: {
...constants.cssStyles.tableRow
},
},
{ // Created Date
displayName: constants.extLangLanguageCreatedDate,
ariaLabel: constants.extLangLanguageCreatedDate,
valueType: azdata.DeclarativeDataType.string,
isReadOnly: true,
width: 150,
headerCssStyles: {
...constants.cssStyles.tableHeader
},
rowCssStyles: {
...constants.cssStyles.tableRow
},
},
{ // Action
displayName: '',
valueType: azdata.DeclarativeDataType.component,
isReadOnly: true,
width: 50,
headerCssStyles: {
...constants.cssStyles.tableHeader
},
rowCssStyles: {
...constants.cssStyles.tableRow
},
},
{ // Action
displayName: '',
valueType: azdata.DeclarativeDataType.component,
isReadOnly: true,
width: 50,
headerCssStyles: {
...constants.cssStyles.tableHeader
},
rowCssStyles: {
...constants.cssStyles.tableRow
},
}
],
data: [],
ariaLabel: constants.mlsConfigTitle
})
.component();
}
public get table(): azdata.DeclarativeTableComponent {
return this._table;
}
public async loadData(): Promise<void> {
let languages: mssql.ExternalLanguage[] | undefined;
languages = await this.listLanguages();
let tableData: azdata.DeclarativeTableCellValue[][] = [];
if (languages) {
languages.forEach(language => {
if (!language.contents || language.contents.length === 0) {
language.contents.push(this.createNewContent());
}
tableData = tableData.concat(language.contents.map(content => this.createTableRow(language, content)));
});
}
this._table.dataValues = tableData;
}
private createTableRow(language: mssql.ExternalLanguage, content: mssql.ExternalLanguageContent): azdata.DeclarativeTableCellValue[] {
if (this._modelBuilder) {
let dropLanguageButton = this._modelBuilder.button().withProps({
label: '',
title: constants.deleteTitle,
iconPath: {
dark: this.asAbsolutePath('images/dark/delete_inverse.svg'),
light: this.asAbsolutePath('images/light/delete.svg')
},
width: 15,
height: 15
}).component();
dropLanguageButton.onDidClick(async () => {
await this.deleteLanguage({
language: language,
content: content,
newLang: false
});
});
let editLanguageButton = this._modelBuilder.button().withProps({
label: '',
title: constants.editTitle,
iconPath: {
dark: this.asAbsolutePath('images/dark/edit_inverse.svg'),
light: this.asAbsolutePath('images/light/edit.svg')
},
width: 15,
height: 15
}).component();
editLanguageButton.onDidClick(() => {
this.onEditLanguage({
language: language,
content: content,
newLang: false
});
});
return [{ value: language.name }, { value: content.platform || '' }, { value: language.createdDate || '' }, { value: dropLanguageButton }, { value: editLanguageButton }];
}
return [];
}
public async reset(): Promise<void> {
await this.loadData();
}
}