Skip to content

Commit

Permalink
Merge pull request #2937 from evidence-dev/release-2024-12-19
Browse files Browse the repository at this point in the history
Release release-2024-12-19
  • Loading branch information
kwongz authored Dec 19, 2024
2 parents 3fbcedf + 76b5a68 commit 5824e6c
Show file tree
Hide file tree
Showing 97 changed files with 3,143 additions and 2,423 deletions.
5 changes: 5 additions & 0 deletions .changeset/cold-trains-visit.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@evidence-dev/core-components': patch
---

Feature: DateInput - supports single and ranged calendar date inputs
5 changes: 5 additions & 0 deletions .changeset/dirty-worms-sniff.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@evidence-dev/core-components': patch
---

fix ssr'd defaultValue usage with DateRange
5 changes: 5 additions & 0 deletions .changeset/funny-mayflies-refuse.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@evidence-dev/core-components': patch
---

fixed datatable wraptitle alignment issue
5 changes: 5 additions & 0 deletions .changeset/fuzzy-zebras-give.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@evidence-dev/core-components': patch
---

USMap and Column default colorScale is default
5 changes: 5 additions & 0 deletions .changeset/hip-pumas-jam.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@evidence-dev/core-components': patch
---

Add lightLogo and darkLogo props to EvidenceDefaultLayout to show different custom logos in light/dark mode
5 changes: 5 additions & 0 deletions .changeset/khaki-coats-talk.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@evidence-dev/core-components': patch
---

Improvments to ErrorChart
5 changes: 5 additions & 0 deletions .changeset/lazy-days-cheer.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@evidence-dev/core-components': patch
---

Adds a 'Last 365 days' option to defaultValues
5 changes: 5 additions & 0 deletions .changeset/lucky-walls-scream.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@evidence-dev/core-components': patch
---

Sparkline tooltip theming
6 changes: 6 additions & 0 deletions .changeset/witty-apples-taste.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
---
'@evidence-dev/sdk': patch
'@evidence-dev/core-components': patch
---

Upgrade nanoid to 5.0.9
1 change: 1 addition & 0 deletions .github/workflows/changesets.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ on:
branches: [next]
paths:
- 'packages/**'
- '!packages/extension/**'
- 'sites/example-project/**'

jobs:
Expand Down
4 changes: 4 additions & 0 deletions e2e/basic/evidence.config.yaml
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
appearance:
default: system
switcher: true

plugins:
components:
# This loads all of evidence's core charts and UI components
Expand Down
10 changes: 10 additions & 0 deletions e2e/basic/pages/+layout.svelte
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
<script>
import '@evidence-dev/tailwind/fonts.css';
import '../app.css';
import { EvidenceDefaultLayout } from '@evidence-dev/core-components';
export let data;
</script>

<EvidenceDefaultLayout lightLogo="/lightLogo.png" darkLogo="/darkLogo.png" {data}>
<slot slot="content" />
</EvidenceDefaultLayout>
Binary file added e2e/basic/static/darkLogo.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added e2e/basic/static/lightLogo.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
15 changes: 14 additions & 1 deletion e2e/basic/tests/tests.spec.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
// @ts-check
import { test, expect } from '@playwright/test';
import { waitForPageToLoad } from '../../test-utils';
import { getLogo, switchAppearance, waitForPageToLoad } from '../../test-utils';

test('has title', async ({ page }) => {
await page.goto('/');
Expand All @@ -15,3 +15,16 @@ test('has hidden sidebar', async ({ page }) => {

await expect(page.getByRole('button', { name: 'Open sidebar' })).toBeVisible();
});

test('shows different logo in light and dark mode', async ({ page }) => {
await page.goto('/');
await waitForPageToLoad(page);

await switchAppearance(page, 'light');
let logo = await getLogo(page);
await expect(logo).toHaveAttribute('src', '/lightLogo.png');

await switchAppearance(page, 'dark');
logo = await getLogo(page);
await expect(logo).toHaveAttribute('src', '/darkLogo.png');
});
8 changes: 8 additions & 0 deletions e2e/test-utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -126,3 +126,11 @@ export const switchAppearance = async (page, appearance) => {
await closeKebabMenu(page);
}
};

/**
* @param {import('@playwright/test').Page} page
* @returns {Promise<import('@playwright/test').Locator>}
*/
export const getLogo = async (page) =>
// We render multiple logos and show/hide them in light/dark mode accordingly, so we need to get just the visible one here
page.getByAltText('Home', { exact: true }).locator('visible=true');
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@
"get-port": "^7.1.0",
"git-remote-origin-url": "4.0.0",
"http-proxy": "^1.18.1",
"nanoid": "^5.0.4",
"nanoid": "^5.0.9",
"node-fetch": "^3.3.2",
"npm-run-all": "^4.1.5",
"open": "^9.1.0",
Expand Down Expand Up @@ -113,4 +113,4 @@
}
},
"packageManager": "[email protected]+sha512.499434c9d8fdd1a2794ebf4552b3b25c0a633abcee5bb15e7b5de90f32f47b513aca98cd5cfd001c31f0db454bc3804edccd578501e4ca293a6816166bbd9f81"
}
}
14 changes: 6 additions & 8 deletions packages/extension/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,11 @@
"title": "Getting Started Walkthrough",
"category": "Evidence"
},
{
"command": "evidence.addCustomLayout",
"title": "Add Custom Layout",
"category": "Evidence"
},
{
"command": "evidence.insertColumnName",
"title": "Insert",
Expand Down Expand Up @@ -122,12 +127,6 @@
"category": "Evidence",
"enablement": "evidence.hasProject"
},
{
"command": "evidence.migrateProjectToUSQL",
"title": "Migrate Project to USQL",
"category": "Evidence",
"enablement": "evidence.hasProject"
},
{
"command": "evidence.startServer",
"title": "Start Evidence Server",
Expand Down Expand Up @@ -505,8 +504,7 @@
"explorer": [
{
"id": "schemaView",
"name": "Evidence Schema View",
"when": "evidence.isNonLegacyProject"
"name": "Evidence Schema View"
}
]
}
Expand Down
14 changes: 4 additions & 10 deletions packages/extension/src/commands/commands.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,17 +5,11 @@ import { installDependencies, updateDependencies, buildProject, buildProjectStri

import { runSources } from './sources';

import {
createNewProject,
openIndex,
openWalkthrough,
copyProject,
migrateProjectToUSQL
} from './project';
import { createNewProject, openIndex, openWalkthrough, copyProject } from './project';
import { createProjectFromTemplate } from './template';
import { startServer, stopServer } from './server';
import { preview } from './preview';
import { createTemplatedPageFromQuery } from './documents';
import { createTemplatedPageFromQuery, addCustomLayout } from './documents';
import { openSettingsFile, viewExtensionSettings, viewAppSettings } from './settings';
import { clearCache } from './cache';
import { showOutput } from '../output';
Expand Down Expand Up @@ -55,8 +49,8 @@ export const enum Commands {
RunSources = 'evidence.runSources',
ShowOutput = 'evidence.showOutput',
OpenIndex = 'evidence.openIndex',
MigrateProjectToUSQL = 'evidence.migrateProjectToUSQL',
OpenEvidenceWalkthrough = 'evidence.openWalkthrough',
AddCustomLayout = 'evidence.addCustomLayout',
CreateTemplatedPageFromQuery = 'evidence.createTemplatedPageFromQuery',
OpenSimpleBrowser = 'simpleBrowser.api.open'
}
Expand Down Expand Up @@ -89,8 +83,8 @@ export function registerCommands(context: ExtensionContext) {
registerCommand(Commands.RunSources, runSources);
registerCommand(Commands.ShowOutput, showOutput);
registerCommand(Commands.OpenIndex, openIndex);
registerCommand(Commands.MigrateProjectToUSQL, migrateProjectToUSQL);
registerCommand(Commands.OpenEvidenceWalkthrough, openWalkthrough);
registerCommand(Commands.AddCustomLayout, addCustomLayout);
registerCommand(Commands.CreateTemplatedPageFromQuery, createTemplatedPageFromQuery);
}

Expand Down
83 changes: 69 additions & 14 deletions packages/extension/src/commands/documents.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { workspace, window, Uri } from 'vscode';
import * as fs from 'fs';
import * as path from 'path';
import { telemetryService } from '../extension';
import { isUSQL, getPackageJsonFolder } from '../utils/jsonUtils';
import { getPackageJsonFolder } from '../utils/jsonUtils';

function capitalizeWords(str: string) {
return str
Expand All @@ -18,12 +18,10 @@ export async function createTemplatedPageFromQuery() {
if (
!activeEditor ||
!activeEditor.document.fileName.endsWith('.sql') ||
!activeEditor.document.fileName.includes(
(await isUSQL()) ? `${path.sep}queries${path.sep}` : `${path.sep}sources${path.sep}`
)
!activeEditor.document.fileName.includes(`${path.sep}queries${path.sep}`)
) {
window.showWarningMessage(
`This command can only be run from within a .sql file in your ${(await isUSQL()) ? 'queries' : 'sources'} folder`,
`This command can only be run from within a .sql file in your 'queries' folder`,
{ modal: true }
);
telemetryService?.sendEvent('createTemplatedPageSqlWarning');
Expand Down Expand Up @@ -55,20 +53,77 @@ export async function createTemplatedPageFromQuery() {
const indexPath = path.join(newFolderPath, 'index.md');
const columnFilePath = path.join(newFolderPath, `[${columnName}].md`);

const legacyIndexContent = `---\ntitle: ${capitalizeWords(sqlFileName)}\nsources:\n - ${sqlFileName}: ${sqlFileName}.sql\n---\n\nClick on an item to see more detail\n\n\n\`\`\`sql ${sqlFileName}_with_link\nselect *, '/${sqlFileName}/' || ${columnName} as link\nfrom \$\{${sqlFileName}\}\n\`\`\`\n\n<DataTable data={${sqlFileName}_with_link} link=link/>\n`;
const usqlIndexContent = `---\ntitle: ${capitalizeWords(sqlFileName)}\nqueries:\n - ${sqlFileName}: ${sqlFileName}.sql\n---\n\nClick on an item to see more detail\n\n\n\`\`\`sql ${sqlFileName}_with_link\nselect *, '/${sqlFileName}/' || ${columnName} as link\nfrom \$\{${sqlFileName}\}\n\`\`\`\n\n<DataTable data={${sqlFileName}_with_link} link=link/>\n`;
const legacyColumnFileContent = `---\nsources:\n - ${sqlFileName}: ${sqlFileName}.sql\n---\n\n# {$page.params.${columnName}}\n\n<DataTable data={${sqlFileName}.filter(d => d.${columnName} === $page.params.${columnName})}/>\n`;
const usqlColumnFileContent = `---\nqueries:\n - ${sqlFileName}: ${sqlFileName}.sql\n---\n\n# {params.${columnName}}\n\n\`\`\`sql ${sqlFileName}_filtered\nselect * from \$\{${sqlFileName}\}\nwhere ${columnName} = '\$\{params.${columnName}\}'\n\`\`\`\n\n<DataTable data={${sqlFileName}_filtered}/>\n`;
const indexContent = `---\ntitle: ${capitalizeWords(sqlFileName)}\nqueries:\n - ${sqlFileName}: ${sqlFileName}.sql\n---\n\nClick on an item to see more detail\n\n\n\`\`\`sql ${sqlFileName}_with_link\nselect *, '/${sqlFileName}/' || ${columnName} as link\nfrom \$\{${sqlFileName}\}\n\`\`\`\n\n<DataTable data={${sqlFileName}_with_link} link=link/>\n`;
const columnFileContent = `---\nqueries:\n - ${sqlFileName}: ${sqlFileName}.sql\n---\n\n# {params.${columnName}}\n\n\`\`\`sql ${sqlFileName}_filtered\nselect * from \$\{${sqlFileName}\}\nwhere ${columnName} = '\$\{params.${columnName}\}'\n\`\`\`\n\n<DataTable data={${sqlFileName}_filtered}/>\n`;

fs.writeFileSync(indexPath, (await isUSQL()) ? usqlIndexContent : legacyIndexContent);
fs.writeFileSync(
columnFilePath,
(await isUSQL()) ? usqlColumnFileContent : legacyColumnFileContent
);
fs.writeFileSync(indexPath, indexContent);
fs.writeFileSync(columnFilePath, columnFileContent);

// Open the templated markdown file
const columnFileUri = Uri.file(columnFilePath);
const document = await workspace.openTextDocument(columnFileUri);
await window.showTextDocument(document);
telemetryService?.sendEvent('templatedPageCreated');
}

export async function addCustomLayout() {
telemetryService?.sendEvent('addCustomLayout');

// Get the workspace folder and ensure it is open
const workspaceFolders = workspace.workspaceFolders;
if (!workspaceFolders) {
window.showErrorMessage('No workspace folder is open.');
return;
}

// Define the source and destination paths
const workspaceRoot = workspaceFolders[0].uri.fsPath;
const packageJsonFolder = await getPackageJsonFolder();
const projectRoot = path.join(workspaceRoot, packageJsonFolder ?? '');

const sourceFilePath = path.join(
projectRoot,
'.evidence',
'template',
'src',
'pages',
'+layout.svelte'
);
const destinationFolderPath = path.join(projectRoot, 'pages');
const destinationFilePath = path.join(destinationFolderPath, '+layout.svelte');

// Check if the source file exists
if (!fs.existsSync(sourceFilePath)) {
window.showErrorMessage(
`Layout template file not found in ${sourceFilePath}. Run the server to populate this file.`
);
return;
}

// Check if the destination file already exists
if (fs.existsSync(destinationFilePath)) {
const overwrite = await window.showWarningMessage(
`The file ${destinationFilePath} already exists. Do you want to overwrite it?`,
{ modal: true },
'Yes',
'No'
);
if (overwrite !== 'Yes') {
window.showInformationMessage('Custom layout addition cancelled');
return;
}
}

// Ensure the destination folder exists
fs.mkdirSync(destinationFolderPath, { recursive: true });

// Copy the layout file to the destination
try {
fs.copyFileSync(sourceFilePath, destinationFilePath);
window.showInformationMessage(`Custom layout added successfully at: ${destinationFilePath}`);
telemetryService?.sendEvent('customLayoutAdded');
} catch (error) {
console.error(error);
window.showErrorMessage('Failed to add custom layout.');
}
}
Loading

0 comments on commit 5824e6c

Please sign in to comment.