import {
AdaptableButton,
AdaptableOptions,
CustomToolbarButtonContext,
DashboardButtonContext,
DataUpdateConfig,
} from '@adaptabletools/adaptable';
import {rowData, WebFramework} from './rowData';
export function updateReact(): WebFramework {
return {
id: 10270250,
name: 'react',
full_name: 'facebook/react',
html_url: 'https://github.com/facebook/react',
description:
'A declarative, efficient, and flexible JavaScript library for building user interfaces.',
created_at: new Date('2013-05-24T16:15:54').toDateString(),
updated_at: new Date(Date.now()).toDateString(),
pushed_at: new Date('2021-12-19T14:34:59').toDateString(),
homepage: 'https://reactjs.org',
github_stars: 201548,
language: 'JavaScript',
forks_count: 36403,
open_issues_count: 920,
license: 'MIT License',
topics: ['declarative', 'frontend', 'javascript', 'library', 'react', 'ui'],
github_watchers: 6527,
has_projects: true,
has_wiki: true,
has_pages: true,
closed_issues_count: 10326,
open_pr_count: 249,
closed_pr_count: 11408,
week_issue_change: 5,
};
}
export function updateAngular(): WebFramework {
return {
id: 24195339,
name: 'angular',
full_name: 'angular/angular',
html_url: 'https://github.com/angular/angular',
description: 'The modern web developer’s platform',
created_at: new Date('2014-09-18T16:12:01').toDateString(),
updated_at: new Date(Date.now()).toDateString(),
pushed_at: new Date('2021-12-19T21:54:01').toDateString(),
homepage: 'https://angular.io',
github_stars: 69651,
language: 'TypeScript',
forks_count: 20569,
open_issues_count: 1889,
license: 'MIT License',
topics: [
'angular',
'javascript',
'pwa',
'typescript',
'web',
'web-framework',
'web-performance',
],
github_watchers: 5026,
has_projects: true,
has_wiki: false,
has_pages: false,
closed_issues_count: 21706,
open_pr_count: 159,
closed_pr_count: 20052,
week_issue_change: 12,
};
}
export const adaptableOptions: AdaptableOptions<WebFramework> = {
primaryKey: 'id',
adaptableId: 'Updating Grid Rows',
dashboardOptions: {
customToolbars: [
{
name: 'ButtonToolbar',
title: 'Buttons',
toolbarButtons: [
{
label: 'Update React',
onClick: (
_button: AdaptableButton<CustomToolbarButtonContext>,
context: CustomToolbarButtonContext
) => {
const react: WebFramework = updateReact();
const dataUpdateConfig: DataUpdateConfig = {
runAsync: true,
addIndex: 0,
};
context.adaptableApi.gridApi.updateGridData(
[react],
dataUpdateConfig
);
},
buttonStyle: {
tone: 'info',
variant: 'text',
},
disabled: () => false,
},
{
label: 'Update Angular',
onClick: (
_button: AdaptableButton<CustomToolbarButtonContext>,
context: CustomToolbarButtonContext
) => {
const angular: WebFramework = updateAngular();
const dataUpdateConfig: DataUpdateConfig = {
runAsync: true,
};
context.adaptableApi.gridApi.updateGridData(
[angular],
dataUpdateConfig
);
},
buttonStyle: {
tone: 'warning',
variant: 'text',
},
disabled: () => false,
},
],
},
],
},
initialState: {
Theme: {CurrentTheme: 'dark'},
Dashboard: {
PinnedToolbars: ['ButtonToolbar'],
},
Layout: {
CurrentLayout: 'Standard Layout',
Layouts: [
{
TableColumns: [
'name',
'language',
'github_stars',
'github_watchers',
'updated_at',
'license',
'created_at',
'has_wiki',
'pushed_at',
'description',
'open_issues_count',
'closed_issues_count',
'open_pr_count',
'closed_pr_count',
'has_projects',
'has_pages',
'week_issue_change',
],
Name: 'Standard Layout',
AutoSizeColumns: true,
},
],
},
FlashingCell: {
FlashingCellDefinitions: [
{
Name: 'Flashing_Cell_Any_Change',
Rule: {
BooleanExpression: 'ANY_CHANGE()',
},
Scope: {
All: true,
},
},
],
},
},
};