Skip to content

Commit

Permalink
Merge branch 'develop' into wip/procrat/home-button-6399
Browse files Browse the repository at this point in the history
* develop:
  Build nightlies every day. (#6681)
  Force `newDashboard` default on the CI-built packages. (#6680)
  Verify ascribed types of parameters really exist (#6584)
  SuggestionBuilder needs to send ascribedType of constructor parameters (#6655)
  Improvements to the Table visualization. (#6653)
  Removing flush (#6670)
  Improving widgets for take/drop (#6641)
  disable authentication and newDashboard by default (#6664)
  Add COOP+COEP+CORP headers (#6646)
  • Loading branch information
Procrat committed May 15, 2023
2 parents 5a86e4a + 1c89430 commit 030cbe7
Show file tree
Hide file tree
Showing 64 changed files with 1,076 additions and 197 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/nightly.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
name: Nightly Release
on:
schedule:
- cron: 0 2 * * 2-6
- cron: 0 2 * * *
workflow_dispatch: {}
jobs:
promote-nightly:
Expand Down
14 changes: 7 additions & 7 deletions app/gui/view/documentation/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,29 +17,27 @@
//!
//! [`Tailwind CSS`]: https://tailwindcss.com/
#![recursion_limit = "1024"]
// === Features ===
#![feature(drain_filter)]
#![feature(option_result_contains)]
// === Standard Linter Configuration ===
#![deny(non_ascii_idents)]
#![warn(unsafe_code)]
#![allow(clippy::bool_to_int_with_if)]
#![allow(clippy::let_and_return)]
// === Non-Standard Linter Configuration ===
#![warn(missing_copy_implementations)]
#![warn(missing_debug_implementations)]
#![warn(missing_docs)]
#![warn(trivial_casts)]
#![warn(trivial_numeric_casts)]
#![warn(unsafe_code)]
#![warn(unused_import_braces)]
#![warn(unused_qualifications)]
#![recursion_limit = "1024"]

use ensogl::prelude::*;
use ensogl::system::web::traits::*;

use graph_editor::component::visualization;
use ide_view_graph_editor as graph_editor;

use enso_frp as frp;
use enso_suggestion_database::documentation_ir::EntryDocumentation;
use ensogl::animation::physics::inertia::Spring;
Expand All @@ -55,16 +53,18 @@ use ensogl::Animation;
use ensogl_component::shadow;
use ensogl_derive_theme::FromTheme;
use ensogl_hardcoded_theme::application::component_browser::documentation as theme;
use graph_editor::component::visualization;
use ide_view_graph_editor as graph_editor;
use web::HtmlElement;
use web::JsCast;

pub mod html;


// ==============
// === Export ===
// ==============

pub mod html;

pub use visualization::container::overlay;


Expand Down
2 changes: 1 addition & 1 deletion app/gui/view/examples/text-grid-visualization/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ fn init(app: &Application) {
font_tag.set_attribute_or_warn("rel", "stylesheet");
font_tag.set_attribute_or_warn("media", "screen");
font_tag.set_attribute_or_warn("type", "text/css");
font_tag.set_attribute_or_warn("href", "https://fontlibrary.org/face/dejavu-sans-mono");
font_tag.set_attribute_or_warn("href", "https://fonts.cdnfonts.com/css/dejavu-sans-mono");

web::document
.head()
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/** Heatmap Visualization. */
// TODO refactor this to avoid loading on startup. See issue #985 .
loadScript('https://d3js.org/d3.v4.min.js')
loadStyle('https://fontlibrary.org/face/dejavu-sans-mono')
loadStyle('https://fonts.cdnfonts.com/css/dejavu-sans-mono')

/**
* A d3.js heatmap visualization.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
*/
function loadScript(url, onload) {
let script = document.createElement('script')
script.crossOrigin = 'anonymous'
script.onload = onload
script.src = url

Expand All @@ -14,6 +15,7 @@ function loadScript(url, onload) {
*/
function loadStyle(url, onload) {
let style = document.createElement('link')
style.crossOrigin = 'anonymous'
style.onload = onload
style.href = url
style.rel = 'stylesheet'
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/** Histogram Visualization. */
// TODO refactor this to avoid loading on startup. See issue #985 .
loadScript('https://d3js.org/d3.v4.min.js')
loadStyle('https://fontlibrary.org/face/dejavu-sans-mono')
loadStyle('https://fonts.cdnfonts.com/css/dejavu-sans-mono')

let shortcuts = {
zoomIn: e => (e.ctrlKey || e.metaKey) && e.key === 'z',
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/** ScatterPlot Visualization. */
// TODO refactor this to avoid loading on startup. See issue #985 .
loadScript('https://d3js.org/d3.v4.min.js')
loadStyle('https://fontlibrary.org/face/dejavu-sans-mono')
loadStyle('https://fonts.cdnfonts.com/css/dejavu-sans-mono')

let shortcuts = {
zoomIn: e => (e.ctrlKey || e.metaKey) && e.key === 'z',
Expand Down
150 changes: 133 additions & 17 deletions app/gui/view/graph-editor/src/builtin/visualization/java_script/table.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,19 @@ class TableVisualization extends Visualization {

constructor(data) {
super(data)
this.setPreprocessor('Standard.Visualization.Table.Visualization', 'prepare_visualization')
this.setRowLimitAndPage(1000, 0)
}

setRowLimitAndPage(row_limit, page) {
if (this.row_limit !== row_limit || this.page !== page) {
this.row_limit = row_limit
this.page = page
this.setPreprocessor(
'Standard.Visualization.Table.Visualization',
'prepare_visualization',
this.row_limit.toString()
)
}
}

onDataReceived(data) {
Expand Down Expand Up @@ -79,21 +91,46 @@ class TableVisualization extends Visualization {
return content
}

function cellRenderer(params) {
if (params.value === null) {
return '<span style="color:grey; font-style: italic;">Nothing</span>'
} else if (params.value === undefined) {
return ''
} else if (params.value === '') {
return '<span style="color:grey; font-style: italic;">Empty</span>'
}
return params.value.toString()
}

if (!this.tabElem) {
while (this.dom.firstChild) {
this.dom.removeChild(this.dom.lastChild)
}

const style =
'.ag-theme-alpine { --ag-grid-size: 3px; --ag-list-item-height: 20px; display: inline; }'
'.ag-theme-alpine { --ag-grid-size: 3px; --ag-list-item-height: 20px; display: inline; }\n' +
'.vis-status-bar { height: 20x; background-color: white; font-size:14px; white-space:nowrap; padding: 0 5px; overflow:hidden; border-radius: 16px }\n' +
'.vis-status-bar > button { width: 12px; margin: 0 2px; display: none }\n' +
'.vis-tbl-grid { height: calc(100% - 20px); width: 100%; }\n'
const styleElem = document.createElement('style')
styleElem.innerHTML = style
this.dom.appendChild(styleElem)

const statusElem = document.createElement('div')
statusElem.setAttributeNS(null, 'id', 'vis-tbl-status')
statusElem.setAttributeNS(null, 'class', 'vis-status-bar')
this.dom.appendChild(statusElem)
this.statusElem = statusElem

const gridElem = document.createElement('div')
gridElem.setAttributeNS(null, 'id', 'vis-tbl-grid')
gridElem.className = 'vis-tbl-grid'
this.dom.appendChild(gridElem)

const tabElem = document.createElement('div')
tabElem.setAttributeNS(null, 'id', 'vis-tbl-view')
tabElem.setAttributeNS(null, 'class', 'scrollable ag-theme-alpine')
this.dom.appendChild(tabElem)
gridElem.appendChild(tabElem)
this.tabElem = tabElem

this.agGridOptions = {
Expand All @@ -106,6 +143,7 @@ class TableVisualization extends Visualization {
resizable: true,
minWidth: 25,
headerValueGetter: params => params.colDef.field,
cellRenderer: cellRenderer,
},
onColumnResized: e => this.lockColumnSize(e),
}
Expand Down Expand Up @@ -198,28 +236,106 @@ class TableVisualization extends Visualization {
dataTruncated = parsedData.all_rows_count !== rowData.length
}

// If the table contains more rows than an upper limit, the engine will send only some of all rows.
// Update Status Bar
this.updateStatusBarControls(
parsedData.all_rows_count === undefined ? 1 : parsedData.all_rows_count,
dataTruncated
)

// If data is truncated, we cannot rely on sorting/filtering so will disable.
// A pinned row is added to tell the user the row count and that filter/sort is disabled.
const col_span = '__COL_SPAN__'
if (dataTruncated) {
columnDefs[0].colSpan = p => p.data[col_span] || 1
}
this.agGridOptions.defaultColDef.filter = !dataTruncated
this.agGridOptions.defaultColDef.sortable = !dataTruncated
this.agGridOptions.api.setColumnDefs(columnDefs)
if (dataTruncated) {
const field = columnDefs[0].field
const extraRow = {
[field]: `Showing ${rowData.length} of ${parsedData.all_rows_count} rows. Sorting and filtering disabled.`,
[col_span]: columnDefs.length,
}
this.agGridOptions.api.setPinnedTopRowData([extraRow])
}
this.agGridOptions.api.setRowData(rowData)
this.updateTableSize(this.dom.getAttributeNS(null, 'width'))
}

makeOption(value, label) {
const optionElem = document.createElement('option')
optionElem.value = value
optionElem.appendChild(document.createTextNode(label))
return optionElem
}

makeButton(label, onclick) {
const buttonElem = document.createElement('button')
buttonElem.name = label
buttonElem.appendChild(document.createTextNode(label))
buttonElem.addEventListener('click', onclick)
return buttonElem
}

// Updates the status bar to reflect the current row limit and page, shown at top of the visualization.
// - Creates the row dropdown and page buttons.
// - Updated the row counts and filter available options.
updateStatusBarControls(all_rows_count, dataTruncated) {
const pageLimit = Math.ceil(all_rows_count / this.row_limit)
if (this.page > pageLimit) {
this.page = pageLimit
}

if (this.statusElem.childElementCount === 0) {
this.statusElem.appendChild(
this.makeButton('«', () => this.setRowLimitAndPage(this.row_limit, 0))
)
this.statusElem.appendChild(
this.makeButton('‹', () => this.setRowLimitAndPage(this.row_limit, this.page - 1))
)

const selectElem = document.createElement('select')
selectElem.name = 'row-limit'
selectElem.addEventListener('change', e => {
this.setRowLimitAndPage(e.target.value, this.page)
})
this.statusElem.appendChild(selectElem)

const rowCountSpanElem = document.createElement('span')
this.statusElem.appendChild(rowCountSpanElem)

this.statusElem.appendChild(
this.makeButton('›', () => this.setRowLimitAndPage(this.row_limit, this.page + 1))
)
this.statusElem.appendChild(
this.makeButton('»', () => this.setRowLimitAndPage(this.row_limit, pageLimit - 1))
)
}

// Enable/Disable Page buttons
this.statusElem.children.namedItem('«').disabled = this.page === 0
this.statusElem.children.namedItem('‹').disabled = this.page === 0
this.statusElem.children.namedItem('›').disabled = this.page === pageLimit - 1
this.statusElem.children.namedItem('»').disabled = this.page === pageLimit - 1

// Update row limit dropdown and row count
const rowCountElem = this.statusElem.getElementsByTagName('span')[0]
const rowLimitElem = this.statusElem.children.namedItem('row-limit')
if (all_rows_count > 1000) {
rowLimitElem.style.display = 'inline-block'
const rowCounts = [1000, 2500, 5000, 10000, 25000, 50000, 100000].filter(
r => r <= all_rows_count
)
if (
all_rows_count < rowCounts[rowCounts.length - 1] &&
rowCounts.indexOf(all_rows_count) === -1
) {
rowCounts.push(all_rows_count)
}
rowLimitElem.innerHTML = ''
rowCounts.forEach(r => {
const option = this.makeOption(r, r.toString())
rowLimitElem.appendChild(option)
})
rowLimitElem.value = this.row_limit

rowCountElem.innerHTML = dataTruncated
? ` of ${all_rows_count} rows (Sorting/Filtering disabled).`
: ` rows.`
} else {
rowLimitElem.style.display = 'none'
rowCountElem.innerHTML = all_rows_count === 1 ? '1 row.' : `${all_rows_count} rows.`
}
}

updateTableSize(clientWidth) {
// Check the grid has been initialised and return if not.
if (!this.agGridOptions) {
Expand Down
4 changes: 4 additions & 0 deletions app/ide-desktop/lib/client/src/bin/server.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import * as mime from 'mime-types'
import * as portfinder from 'portfinder'
import createServer from 'create-servers'

import * as common from 'enso-common'
import * as contentConfig from 'enso-content-config'

import * as paths from '../paths'
Expand Down Expand Up @@ -105,6 +106,9 @@ export class Server {
resource === '/preload.cjs.map'
? `${paths.APP_PATH}${resource}`
: `${this.config.dir}${resource}`
for (const [header, value] of common.COOP_COEP_CORP_HEADERS) {
response.setHeader(header, value)
}
fs.readFile(resourceFile, (err, data) => {
if (err) {
logger.error(`Resource '${resource}' not found.`)
Expand Down
13 changes: 12 additions & 1 deletion app/ide-desktop/lib/common/src/index.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
/** @file This module contains metadata about the product and distribution.
/** @file This module contains metadata about the product and distribution,
* and various other constants that are needed in multiple sibling packages.
*
* Code in this package is used by two or more sibling packages of this package. The code is defined
* here when it is not possible for a sibling package to own that code without introducing a
Expand All @@ -12,3 +13,13 @@ export const DEEP_LINK_SCHEME = 'enso'

/** Name of the product. */
export const PRODUCT_NAME = 'Enso'

/** COOP, COEP, and CORP headers: https://web.dev/coop-coep/
*
* These are required to increase the resolution of `performance.now()` timers,
* making profiling a lot more accurate and consistent. */
export const COOP_COEP_CORP_HEADERS: [header: string, value: string][] = [
['Cross-Origin-Embedder-Policy', 'require-corp'],
['Cross-Origin-Opener-Policy', 'same-origin'],
['Cross-Origin-Resource-Policy', 'same-origin'],
]
4 changes: 2 additions & 2 deletions app/ide-desktop/lib/content-config/src/config.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"options": {
"authentication": {
"value": true,
"value": false,
"description": "Determines whether user authentication is enabled. This option is always true when executed in the cloud."
},
"dataCollection": {
Expand Down Expand Up @@ -121,7 +121,7 @@
"primary": false
},
"newDashboard": {
"value": true,
"value": false,
"description": "Determines whether the new dashboard with cloud integration is enabled."
},
"profiling": {
Expand Down
6 changes: 5 additions & 1 deletion app/ide-desktop/lib/content/esbuild-config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,11 @@ import esbuildPluginYaml from 'esbuild-plugin-yaml'
import * as utils from '../../utils'
import BUILD_INFO from '../../build.json' assert { type: 'json' }

export const THIS_PATH = pathModule.resolve(pathModule.dirname(url.fileURLToPath(import.meta.url)))
// =================
// === Constants ===
// =================

const THIS_PATH = pathModule.resolve(pathModule.dirname(url.fileURLToPath(import.meta.url)))

// =============================
// === Environment variables ===
Expand Down
Loading

0 comments on commit 030cbe7

Please sign in to comment.