Skip to content

Commit

Permalink
Merge branch 'main' into dependabot/github_actions/actions/checkout-4
Browse files Browse the repository at this point in the history
  • Loading branch information
Gustav-Eikaas authored Apr 29, 2024
2 parents 5d51426 + b16e935 commit b91dcba
Show file tree
Hide file tree
Showing 31 changed files with 3,606 additions and 2,358 deletions.
4 changes: 2 additions & 2 deletions .github/actions/pnpm-setup/action.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,12 @@ runs:
steps:
- uses: pnpm/action-setup@v2.2.4
with:
version: 8.0.0
version: 9.0.5

- name: Setup Node.js environment
uses: actions/setup-node@v4
with:
node-version: 18
node-version: 20
cache: 'pnpm'

- name: Install dependencies
Expand Down
4 changes: 2 additions & 2 deletions .github/helpers/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@
"dependencies": {
"@actions/core": "^1.10.1",
"@actions/github": "^6.0.0",
"commander": "^11.1.0",
"commander": "^12.0.0",
"markdown-table": "^3.0.3",
"tsx": "^4.6.2"
"tsx": "^4.7.1"
}
}
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -52,3 +52,5 @@ testem.log
Thumbs.db

.turbo

*.tsbuildinfo
2 changes: 1 addition & 1 deletion Contribution.md → CONTRIBUTING.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Contributions
# Contributing

## Table of content

Expand Down
6 changes: 6 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@
[![GitHub issues by-label](https://img.shields.io/github/issues/equinor/fusion-workspace/bug?label=%F0%9F%90%9B%20bug%20issues&color=red)](https://github.com/equinor/fusion-workspace/issues?q=is%3Aissue+is%3Aopen+label%3Abug)
[![GitHub issues](https://img.shields.io/github/issues/equinor/fusion-workspace)](https://github.com/equinor/fusion-workspace/issues)
[![GitHub pull requests](https://img.shields.io/github/issues-pr-raw/equinor/fusion-workspace)](https://github.com/equinor/fusion-workspace/pulls)
![SCM Compliance](https://scm-compliance-api.radix.equinor.com/repos/equinor/fusion-workspace/badge)
![Known Vulnerabilities](https://snyk.io/test/github/equinor/fusion-workspace/badge.svg)

> Fusion Workspace is a library built with a controller-based structure in mind. Core functionality tab navigation, data handling, and allowing you to register controllers that react around page change / config change and data changes.
Expand All @@ -28,3 +30,7 @@ To run a test app go to apps/test-app and run `pnpm dev`. If you make changes to
## Publishing packages

The repository is configured with CI/CD and automatic deployment, to trigger a release update the version in `package.json` of the package you want to release and merge into main.

## Updating package dependencies

To update all package dependencies, use the command `pnpm run bump-deps` to open the interactive pnpm package update prompt in the terminal.
2 changes: 1 addition & 1 deletion apps/test-app/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
"@equinor/workspace-fusion": "workspace:^",
"react": "^18.2.0",
"react-dom": "^18.2.0",
"react-error-boundary": "^3.1.4"
"react-error-boundary": "^4.0.13"
},
"peerDependencies": {
"react-dom": ">= 16.8.0",
Expand Down
4 changes: 2 additions & 2 deletions apps/test-app/src/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ function getFilterMetaData(num_filters: number = 2): any[] {
}

function getKPIData(num_kpis = 5) {
const kpiData = [];
const kpiData: { title: string; value: number }[] = [];

for (let i = 0; i < num_kpis; i++) {
const kpiNameLen = getRandomInt(1, 15);
Expand Down Expand Up @@ -135,7 +135,7 @@ export function App() {
excelExport: async (filterState) =>
new Promise((res, rej) =>
setTimeout(() => {
res();
res(undefined);
}, 2000)
),
}}
Expand Down
23 changes: 12 additions & 11 deletions documentation/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,23 +11,24 @@
"astro": "astro"
},
"dependencies": {
"@algolia/client-search": "^4.13.1",
"@astrojs/mdx": "^0.16.0",
"@astrojs/preact": "^2.0.2",
"@astrojs/react": "^2.0.2",
"@docsearch/css": "^3.3.3",
"@docsearch/react": "^3.3.3",
"@equinor/workspace-fusion": "0.15.0",
"@types/node": "^18.0.0",
"astro": "^2.0.8",
"preact": "^10.12.0",
"@algolia/client-search": "^4.23.2",
"@astrojs/mdx": "^2.2.3",
"@astrojs/preact": "^3.1.2",
"@astrojs/react": "^3.1.0",
"@docsearch/css": "^3.6.0",
"@docsearch/react": "^3.6.0",
"@equinor/workspace-fusion": "workspace:*",
"@types/node": "^20.12.2",
"astro": "^4.5.13",
"preact": "^10.20.1",
"react": "^18.2.0",
"react-dom": "^18.2.0",
"react-is": "^18.2.0",
"react-mermaid3": "^1.0.1",
"styled-components": "^5.3.6"
"styled-components": "^6.1.8"
},
"devDependencies": {
"@types/html-escaper": "^3.0.2",
"@types/react": "^18.0.27",
"@types/react-dom": "^18.0.10",
"html-escaper": "^3.0.3",
Expand Down
9 changes: 6 additions & 3 deletions documentation/src/components/RightSidebar/TableOfContents.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,15 @@ import type { MarkdownHeading } from 'astro';
import type { FunctionalComponent } from 'preact';
import { unescape } from 'html-escaper';
import { useState, useEffect, useRef } from 'preact/hooks';
import type { MouseEventHandler } from 'react';

type ItemOffsets = {
id: string;
topOffset: number;
};

const TableOfContents: FunctionalComponent<{ headings: MarkdownHeading[] }> = ({ headings = [] }) => {
const toc = useRef<HTMLUListElement>();
const toc = useRef<HTMLUListElement>(null);
const onThisPageID = 'on-this-page-heading';
const itemOffsets = useRef<ItemOffsets[]>([]);
const [currentID, setCurrentID] = useState('overview');
Expand Down Expand Up @@ -60,8 +61,10 @@ const TableOfContents: FunctionalComponent<{ headings: MarkdownHeading[] }> = ({
return () => headingsObserver.disconnect();
}, [toc.current]);

const onLinkClick = (e) => {
setCurrentID(e.target.getAttribute('href').replace('#', ''));
const onLinkClick: MouseEventHandler<HTMLAnchorElement> = (e) => {
const element = e.target as HTMLAnchorElement;
const href = element.getAttribute('href')?.replace('#', '');
if (href) setCurrentID(href);
};

return (
Expand Down
12 changes: 8 additions & 4 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,18 +5,19 @@
"type": "module",
"scripts": {
"preinstall": "npx only-allow pnpm",
"first-time-setup": "npm i -g pnpm@8.0.0 turbo && pnpm i",
"first-time-setup": "npm i -g pnpm@9.0.5 turbo && pnpm i",
"build": "turbo run build",
"test": "turbo run test",
"documentation": "pnpx astro dev --root ./documentation",
"shipit": "turbo run build && pnpm -r publish",
"pr-shipit": "turbo run build && pnpm --filter ...[origin/main] pr-release",
"dev": "turbo run dev --filter ./apps/**"
"dev": "turbo run dev --filter ./apps/**",
"bump-deps": "pnpm up --latest --prod --recursive --interactive"
},
"private": true,
"packageManager": "pnpm@8.0.0",
"packageManager": "pnpm@9.0.5",
"dependencies": {
"tslib": "^2.3.0"
"tslib": "^2.6.2"
},
"devDependencies": {
"@changesets/cli": "^2.26.1",
Expand All @@ -28,5 +29,8 @@
"turbo": "^1.9.3",
"typescript": "~5.0.2",
"typescript-plugin-styled-components": "^2.0.0"
},
"engines": {
"node": "20"
}
}
38 changes: 19 additions & 19 deletions packages/ag-grid/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@equinor/workspace-ag-grid",
"version": "2.0.5",
"version": "3.0.0",
"type": "module",
"private": false,
"sideEffects": false,
Expand Down Expand Up @@ -32,25 +32,25 @@
}
},
"dependencies": {
"@ag-grid-community/client-side-row-model": "30.2.1",
"@ag-grid-community/core": "30.2.1",
"@ag-grid-community/react": "30.2.1",
"@ag-grid-enterprise/column-tool-panel": "30.2.1",
"@ag-grid-enterprise/excel-export": "30.2.1",
"@ag-grid-enterprise/filter-tool-panel": "30.2.1",
"@ag-grid-enterprise/master-detail": "30.2.1",
"@ag-grid-enterprise/menu": "30.2.1",
"@ag-grid-enterprise/multi-filter": "30.2.1",
"@ag-grid-enterprise/range-selection": "30.2.1",
"@ag-grid-enterprise/rich-select": "30.2.1",
"@ag-grid-enterprise/row-grouping": "30.2.1",
"@ag-grid-enterprise/server-side-row-model": "30.2.1",
"@ag-grid-enterprise/set-filter": "30.2.1",
"@ag-grid-enterprise/side-bar": "30.2.1",
"@ag-grid-enterprise/status-bar": "30.2.1",
"@ag-grid-community/client-side-row-model": "31.2.0",
"@ag-grid-community/core": "31.2.0",
"@ag-grid-community/react": "31.2.0",
"@ag-grid-enterprise/column-tool-panel": "31.2.0",
"@ag-grid-enterprise/excel-export": "31.2.0",
"@ag-grid-enterprise/filter-tool-panel": "31.2.0",
"@ag-grid-enterprise/master-detail": "31.2.0",
"@ag-grid-enterprise/menu": "31.2.0",
"@ag-grid-enterprise/multi-filter": "31.2.0",
"@ag-grid-enterprise/range-selection": "31.2.0",
"@ag-grid-enterprise/rich-select": "31.2.0",
"@ag-grid-enterprise/row-grouping": "31.2.0",
"@ag-grid-enterprise/server-side-row-model": "31.2.0",
"@ag-grid-enterprise/set-filter": "31.2.0",
"@ag-grid-enterprise/side-bar": "31.2.0",
"@ag-grid-enterprise/status-bar": "31.2.0",
"@equinor/eds-tokens": "^0.9.0",
"@equinor/fusion-react-ag-grid-styles": "^30.2.0",
"@equinor/fusion-react-styles": "^0.6.0",
"@equinor/eds-tokens": "^0.9.0"
"@equinor/fusion-react-styles": "^0.6.2"
},
"peerDependencies": {
"@ag-grid-enterprise/core": "30.2.1",
Expand Down
8 changes: 4 additions & 4 deletions packages/filter/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@equinor/workspace-filter",
"version": "3.0.10",
"version": "4.0.0",
"type": "module",
"sideEffects": false,
"license": "MIT",
Expand Down Expand Up @@ -29,11 +29,11 @@
"@equinor/eds-core-react": "^0.28.0",
"@equinor/eds-icons": "^0.18.0",
"@equinor/eds-tokens": "^0.9.0",
"@tanstack/react-query": "^4.28.0",
"react-error-boundary": "^3.1.4",
"@tanstack/react-query": "^5.28.9",
"react-error-boundary": "^4.0.13",
"react-sortablejs": "^6.1.4",
"react-virtual": "^2.10.4",
"sortablejs": "^1.15.0"
"sortablejs": "^1.15.2"
},
"peerDependencies": {
"react": ">= 16.8.0",
Expand Down
14 changes: 5 additions & 9 deletions packages/filter/src/lib/context/filterContext.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -70,15 +70,11 @@ export const FilterContextWrapper = ({
const [uncheckedValues, setUncheckedValues] = useState<FilterStateGroup[]>(initialState?.uncheckedValues ?? []);
const [filterState, setFilterState] = useState<FilterState>(initialState?.filterState ?? { groups: [], search: '' });

const query = useQuery(
['filter-meta', JSON.stringify(filterState)],
({ signal }): Promise<FilterGroup[]> => dataSource.getFilterMeta(filterState, signal),
{
suspense: false,
useErrorBoundary: false,
keepPreviousData: true,
}
);
const query = useQuery({
queryKey: ['filter-meta', JSON.stringify(filterState)],
queryFn: ({ signal }): Promise<FilterGroup[]> => dataSource.getFilterMeta(filterState, signal),
throwOnError: false,
});

const setFilterStateHandler = (groups: FilterStateGroup[]) =>
setFilterState((s) => {
Expand Down
8 changes: 4 additions & 4 deletions packages/garden/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@equinor/workspace-garden",
"version": "7.0.1",
"version": "8.0.0",
"type": "module",
"sideEffects": false,
"license": "MIT",
Expand Down Expand Up @@ -29,9 +29,9 @@
"@equinor/eds-core-react": "0.28.0",
"@equinor/eds-icons": "^0.18.0",
"@equinor/eds-tokens": "0.9.0",
"@tanstack/react-query": "^4.28.0",
"@tanstack/react-query-devtools": "^4.28.0",
"react-error-boundary": "^3.1.4",
"@tanstack/react-query": "^5.28.9",
"@tanstack/react-query-devtools": "^5.28.10",
"react-error-boundary": "^4.0.13",
"react-virtual": "^2.10.4"
},
"peerDependencies": {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ export const GardenItemContainer = <TData extends Record<PropertyKey, unknown>,

const expand = useExpand();

const isColumnExpanded = !!expand.expandedColumns.find((s) => s === virtualColumn.index);
const isColumnExpanded = expand.expandedColumns.includes(virtualColumn.index);

const {
groupingService: { groupingKeys, timeInterval, dateVariant },
Expand Down
36 changes: 16 additions & 20 deletions packages/garden/src/lib/context/gardenContext.tsx
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
import { PropsWithChildren, createContext, useCallback, useEffect, useState } from 'react';
import { GardenMeta, GetIdentifier } from '../types';
import { UseQueryResult, useQuery } from '@tanstack/react-query';
import { UseSuspenseQueryResult, useSuspenseQuery } from '@tanstack/react-query';
import { GardenDataSource } from '../components';

type GardenState = {
export type GardenState = {
selectionService: SelectionService;
groupingService: GroupingService;
gardenMetaQuery: UseQueryResult<GardenMeta, unknown>;
gardenMetaQuery: ThisType<UseSuspenseQueryResult<GardenMeta, unknown>>;
};

type GroupingService = {
Expand Down Expand Up @@ -34,23 +34,19 @@ export const GardenContextProvider = <T, TContext = undefined>(
context: TContext | undefined;
}>
) => {
const gardenMetaQuery = useQuery(
['garden', ...props.initialGrouping, props.timeInterval, props.dateVariant, props.context],
{
refetchOnWindowFocus: false,
suspense: true,
useErrorBoundary: true,
keepPreviousData: false,
cacheTime: Infinity,
staleTime: Infinity,
queryFn: ({ signal }) =>
props.dataSource.getGardenMeta(
{ groupingKeys: props.initialGrouping, timeInterval: props.timeInterval, dateVariant: props.dateVariant },
props.context as TContext,
signal ?? new AbortSignal()
),
}
);
const gardenMetaQuery = useSuspenseQuery({
queryKey: ['garden', ...props.initialGrouping, props.timeInterval, props.dateVariant, props.context],
queryFn: ({ signal }) => {
return props.dataSource.getGardenMeta(
{ groupingKeys: props.initialGrouping, timeInterval: props.timeInterval, dateVariant: props.dateVariant },
props.context as TContext,
signal ?? new AbortSignal()
);
},
refetchOnWindowFocus: false,
gcTime: Infinity,
staleTime: Infinity,
});

const selectionService = useSelectionService(props.getIdentifier, props.selected);
const groupingService = useGroupingService(props.initialGrouping, props.timeInterval, props.dateVariant);
Expand Down
2 changes: 1 addition & 1 deletion packages/garden/src/lib/hooks/useBlockCache.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ export function useBlockCache<T, TContext = undefined>({
groupingService: { groupingKeys, timeInterval, dateVariant },
} = useGarden();

const blockCache = useQueries({
const blockCache: UseBlockCacheArgs<T, TContext> = useQueries({
queries: blocks.map((block) => ({
/** Unique identifier for blocks, add state here to invalidate query onChange */
queryKey: [...groupingKeys, timeInterval, dateVariant, `x${block.x}`, `y${block.y}`, context, ...hash],
Expand Down
4 changes: 2 additions & 2 deletions packages/garden/src/lib/hooks/useGarden.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { useContext } from 'react';
import { GardenContext } from '../context/gardenContext';
import { GardenContext, GardenState } from '../context/gardenContext';

export function useGarden() {
export function useGarden(): GardenState {
const context = useContext(GardenContext);
if (!context) {
throw new Error('Garden context called outside the provider');
Expand Down
Loading

0 comments on commit b91dcba

Please sign in to comment.