Skip to content

Commit

Permalink
Pull request #3: rename tree component
Browse files Browse the repository at this point in the history
Merge in TNG/ash-tree from rename_tree_component to main

* commit '5f46f1c8c757e1895be8290b42da0507b5dbb408':
  Remove a couple of leftover react-tree and react-one-tree references
  rename tree component
  • Loading branch information
benedikt-richter committed Dec 15, 2023
2 parents aad7c20 + 5f46f1c commit aef2a56
Show file tree
Hide file tree
Showing 28 changed files with 59 additions and 62 deletions.
2 changes: 1 addition & 1 deletion .eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ module.exports = {
},
ecmaVersion: 2018,
sourceType: 'module',
project: ['tsconfig.json', 'react-one-tree/tsconfig.json'],
project: ['tsconfig.json', 'ash-tree/tsconfig.json'],
},
parser: '@typescript-eslint/parser',
extends: [
Expand Down
11 changes: 5 additions & 6 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,14 @@
# SPDX-License-Identifier: Apache-2.0

# dependencies
/react-one-tree/node_modules
/react-one-tree/build
/ash-tree/node_modules
/ash-tree/build
/node_modules


# testing
/coverage
/react-one-tree/coverage
/ash-tree/coverage

# production
/build
Expand All @@ -32,7 +32,6 @@ yarn-error.log*

.idea
/.vscode
/react-tree.iml
/test-app.iml
/react-one-tree.iml
/react-one-tree/notices
/ash-tree.iml
/ash-tree/notices
2 changes: 1 addition & 1 deletion .reuse/dep5
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
Format: https://www.debian.org/doc/packaging-manuals/copyright-format/1.0/
Source: https://github.com/benedikt-richter/react-tree
Source: https://bitbucket.int.tngtech.com/projects/TNG/repos/ash-tree/browse

Files: NOTICE
*.json
Expand Down
2 changes: 1 addition & 1 deletion CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ This package is a React component written in TypeScript. The only further depend
react-window. The repo ist structured on two levels:
1. the root directory contains the developing package.json, including all scripts, dev dependencies and testing app
dependencies,
2. the react-one-tree directory contains the source code of the virtualized tree component and its package.json,
2. the ash-tree directory contains the source code of the virtualized tree component and its package.json,
including no dev dependencies and meant to be distributed with the package.

Prettier is used as a code formatter, eslint as a linter.
Expand Down
2 changes: 1 addition & 1 deletion NOTICE
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
React Virtualized Tree
Ash Tree
Copyright 2020-2023 Benedikt Richter [email protected]
Copyright 2020-2023 Leslie Lazzarino [email protected]
Copyright 2020-2023 Meta Platforms, Inc. and its affiliates
Expand Down
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ fit the needs of the user. It is not meant to be a full-fledged file explorer, b

## API

The package exposes the React component **ReactOneTree** with the following API:
The package exposes the React component **AshTree** with the following API:

* nodes: The nodes of the tree
* It is a recursive data structure that allows to define the nodes of the tree and their relations.
Expand All @@ -39,7 +39,7 @@ It is produced by the following code (we omitted some unimportant details; for d


```
import { ReactOneTreeExport as ReactOneTree } from 'react-one-tree';
import { AshTreeExport as AshTree } from 'ash-tree';
function BasicTree(): ReactElement {
Expand All @@ -60,7 +60,7 @@ function BasicTree(): ReactElement {
}
return (
<ReactOneTree
<AshTree
expandedPaths={expandedPaths}
isFileWithChildren={(path: string): boolean => Boolean(path)}
onSelect={handleSelect}
Expand Down
File renamed without changes.
4 changes: 2 additions & 2 deletions react-one-tree/package.json → ash-tree/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "react-one-tree",
"description": "React One Tree.",
"name": "ash-tree",
"description": "React Ash Tree.",
"license": "Apache-2.0",
"version": "0.1.0",
"private": true,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,12 @@ import {
NumberOfDisplayedNodesForTree,
TreeNodeStyle,
} from './types';
import { ReactOneTreeNode, ReactOneTreeNodeData } from './ReactOneTreeNode';
import { AshTreeNode, AshTreeNodeData } from './AshTreeNode';
import { getTreeNodeProps } from './utils/get-tree-node-props';

const DEFAULT_MAX_TREE_DISPLAYED_NODES = 5;

interface ReactOneTreeProps {
interface AshTreeProps {
nodes: NodesForTree;
getTreeNodeLabel: (
nodeName: string,
Expand All @@ -41,9 +41,9 @@ interface ReactOneTreeProps {
breakpoints?: Set<string>;
}

export function ReactOneTree(props: ReactOneTreeProps): ReactElement | null {
export function AshTree(props: AshTreeProps): ReactElement | null {
// eslint-disable-next-line testing-library/render-result-naming-convention
const treeNodeProps: Array<ReactOneTreeNodeData> = getTreeNodeProps(
const treeNodeProps: Array<AshTreeNodeData> = getTreeNodeProps(
props.nodes,
'',
props.expandedPaths,
Expand Down Expand Up @@ -77,7 +77,7 @@ export function ReactOneTree(props: ReactOneTreeProps): ReactElement | null {
max={maxListLength}
cardVerticalDistance={props.cardHeight}
getListItem={(index: number): ReactElement => (
<ReactOneTreeNode
<AshTreeNode
{...{
...treeNodeProps[index],
expandedNodeIcon: props.expandedNodeIcon,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import { isChildOfSelected, isSelected } from './utils/get-tree-node-props';
const INDENT_PER_DEPTH_LEVEL = 12;
const SIMPLE_NODE_EXTRA_INDENT = 28;

export interface ReactOneTreeNodeData {
export interface AshTreeNodeData {
path: string;
nodeName: string;
node: NodesForTree | 1;
Expand All @@ -34,9 +34,7 @@ export interface ReactOneTreeNodeData {
nodeHeight: number;
}

export function ReactOneTreeNode(
props: ReactOneTreeNodeData,
): ReactElement | null {
export function AshTreeNode(props: AshTreeNodeData): ReactElement | null {
const marginRight =
((props.path.match(/\//g) || []).length - 1) * INDENT_PER_DEPTH_LEVEL +
(!props.isExpandable ? SIMPLE_NODE_EXTRA_INDENT : 0);
Expand Down
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
// SPDX-License-Identifier: Apache-2.0

import React, { ReactElement } from 'react';
import { ReactOneTree } from '../ReactOneTree';
import { AshTree } from '../AshTree';
import { render, screen } from '@testing-library/react';
import { NodesForTree, PathPredicateForTree } from '../types';

Expand Down Expand Up @@ -37,7 +37,7 @@ export function renderVirtualizedTree(
const mockOnSelect = jest.fn();
const mockOnToggle = jest.fn();
render(
<ReactOneTree
<AshTree
expandedPaths={expandedPaths}
isFileWithChildren={isFileWithChildren}
onSelect={mockOnSelect}
Expand Down
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

import React, { ReactElement } from 'react';
import { PathPredicateForTree, NodesForTree } from '../types';
import { ReactOneTreeNodeData } from '../ReactOneTreeNode';
import { AshTreeNodeData } from '../AshTreeNode';

export function getTreeNodeProps(
nodes: NodesForTree,
Expand All @@ -23,12 +23,12 @@ export function getTreeNodeProps(
path: string,
) => ReactElement,
cardHeight: number,
): Array<ReactOneTreeNodeData> {
): Array<AshTreeNodeData> {
const sortedNodeNames: Array<string> = Object.keys(nodes).sort(
getSortFunction(nodes, isFileWithChildren, parentPath),
);

let treeNodes: Array<ReactOneTreeNodeData> = [];
let treeNodes: Array<AshTreeNodeData> = [];

for (const nodeName of sortedNodeNames) {
const node = nodes[nodeName];
Expand Down
13 changes: 13 additions & 0 deletions ash-tree/src/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
// SPDX-FileCopyrightText: TNG Technology Consulting GmbH <https://www.tngtech.com>
// SPDX-FileCopyrightText: Leslie Lazzarino <[email protected]>
// SPDX-FileCopyrightText: Benedikt Richter <[email protected]>
//
// SPDX-License-Identifier: Apache-2.0

import { AshTree as AshTreeComponent } from './AshTree/AshTree';
import { NodesForTree as NodesForTreeType } from './AshTree/types';
import './AshTree/styles.css';

export const AshTree = AshTreeComponent;

export type NodesForAshTree = NodesForTreeType;
File renamed without changes.
File renamed without changes.
16 changes: 8 additions & 8 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
"react": "^18.2.0",
"react-dom": "^18.2.0",
"react-scripts": "5.0.1",
"react-one-tree": "link:./react-one-tree/build/",
"ash-tree": "link:./ash-tree/build/",
"web-vitals": "^3.3.2"
},
"devDependencies": {
Expand Down Expand Up @@ -48,23 +48,23 @@
"setup": "yarn install && yarn build-package && yarn install",
"update-package": "yarn build-package && yarn install",
"start": "yarn update-package && react-scripts start",
"build-package": "cd react-one-tree && yarn install && tsc && cp ./src/ReactOneTree/styles.css ./build/src/ReactOneTree/styles.css && cd .. && yarn generate-notice",
"build-package": "cd ash-tree && yarn install && tsc && cp ./src/AshTree/styles.css ./build/src/AshTree/styles.css && cd .. && yarn generate-notice",
"test-no-update": "yarn test-package-no-build && yarn test-app-no-update && yarn test-performance-no-update",
"test": "yarn update-package && yarn test-package-no-build && yarn test-app-no-update && yarn test-performance-no-update",
"test-package-no-build": "cd react-one-tree && jest --coverage && cd ..",
"test-package": "cd react-one-tree && tsc && jest --coverage && cd ..",
"test-package-no-build": "cd ash-tree && jest --coverage && cd ..",
"test-package": "cd ash-tree && tsc && jest --coverage && cd ..",
"test-app-no-update": "react-scripts test --testPathIgnorePatterns=performance.test.tsx --watchAll=false",
"test-app": "yarn update-package && yarn test-app-no-update",
"lint": "eslint -c .eslintrc.js \"react-one-tree/src/**/*.{ts,tsx}\" --fix && eslint -c .eslintrc.js \"src/**/*.{ts,tsx}\" --fix",
"minify-and-size": "esbuild react-one-tree/build/src/index.js --bundle --outfile=minified-bundle.js && gzip-size minified-bundle.js && rm minified-bundle.js && rm minified-bundle.css",
"lint": "eslint -c .eslintrc.js \"ash-tree/src/**/*.{ts,tsx}\" --fix && eslint -c .eslintrc.js \"src/**/*.{ts,tsx}\" --fix",
"minify-and-size": "esbuild ash-tree/build/src/index.js --bundle --outfile=minified-bundle.js && gzip-size minified-bundle.js && rm minified-bundle.js && rm minified-bundle.css",
"test-performance-no-update": "react-scripts test --testMatch='**/performance.test.tsx' --watchAll=false",
"test-performance": "yarn update-package && yarn test-performance-no-update",
"ci": "yarn setup && yarn lint && yarn test-no-update && yarn minify-and-size",
"test-compile": "tsc -p ./",
"prepare": "husky install",
"generate-notice": "run-script-os",
"generate-notice:linux:darwin": "cd react-one-tree && mkdir -p notices && yarn licenses generate-disclaimer --ignore-platform --production > notices/notices.txt && cd ..",
"generate-notice:win32": "cd react-one-tree && IF NOT EXIST notices mkdir notices && yarn licenses generate-disclaimer --ignore-platform --production > notices/notices.txt && cd .."
"generate-notice:linux:darwin": "cd ash-tree && mkdir -p notices && yarn licenses generate-disclaimer --ignore-platform --production > notices/notices.txt && cd ..",
"generate-notice:win32": "cd ash-tree && IF NOT EXIST notices mkdir notices && yarn licenses generate-disclaimer --ignore-platform --production > notices/notices.txt && cd .."
},
"eslintConfig": {
"extends": [
Expand Down
13 changes: 0 additions & 13 deletions react-one-tree/src/index.ts

This file was deleted.

4 changes: 2 additions & 2 deletions src/Components/BasicTree/BasicTree.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
import React, { ReactElement, useState } from 'react';
import '../../styles.css';
import { testNodes } from '../shared';
import { ReactOneTree } from 'react-one-tree';
import { AshTree } from 'ash-tree';

export function BasicTree(): ReactElement {
const [selectedPath, setSelectedPath] = useState<string>('/');
Expand Down Expand Up @@ -42,7 +42,7 @@ export function BasicTree(): ReactElement {
return (
<div className="tree-box">
<h1>Basic Tree</h1>
<ReactOneTree
<AshTree
expandedPaths={expandedPaths}
isFileWithChildren={(path: string): boolean => Boolean(path)}
onSelect={handleSelect}
Expand Down
4 changes: 2 additions & 2 deletions src/Components/FancyTree/FancyTree.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import React, { ReactElement, useState } from 'react';
import '../../styles.css';
import { getFancyTreeItemLabel } from './FancyTreeItemLabel';
import { testNodes } from '../shared';
import { ReactOneTree } from 'react-one-tree';
import { AshTree } from 'ash-tree';

export function FancyTree(): ReactElement {
const [selectedPath, setSelectedPath] = useState<string>('/');
Expand Down Expand Up @@ -43,7 +43,7 @@ export function FancyTree(): ReactElement {
return (
<div className="tree-box">
<h1>Fancy Tree</h1>
<ReactOneTree
<AshTree
expandedPaths={expandedPaths}
isFileWithChildren={(path: string): boolean => Boolean(path)}
onSelect={handleSelect}
Expand Down
4 changes: 2 additions & 2 deletions src/Components/FancyTree/FancyTreeItemLabel.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,11 @@ import React, { ReactElement } from 'react';
import MuiBox from '@mui/material/Box';
import MuiTypography from '@mui/material/Typography';
import { DirectoryIcon, FileIcon } from './FancyTreeIcons';
import { NodesForReactOneTree } from 'react-one-tree';
import { NodesForAshTree } from 'ash-tree';

export function getFancyTreeItemLabel(
nodeName: string,
node: NodesForReactOneTree | 1,
node: NodesForAshTree | 1,
// eslint-disable-next-line @typescript-eslint/no-unused-vars
nodePath: string,
): ReactElement {
Expand Down
4 changes: 2 additions & 2 deletions src/Components/shared.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@
//
// SPDX-License-Identifier: Apache-2.0

import { NodesForReactOneTree } from 'react-one-tree';
import { NodesForAshTree } from 'ash-tree';

export const testNodes: NodesForReactOneTree = {
export const testNodes: NodesForAshTree = {
'': {
thirdParty: {
'package_01.tr.gz': 1,
Expand Down
8 changes: 4 additions & 4 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -3405,6 +3405,10 @@ asap@~2.0.6:
resolved "https://registry.yarnpkg.com/asap/-/asap-2.0.6.tgz#e50347611d7e690943208bbdafebcbc2fb866d46"
integrity sha512-BSHWgDSAiKs50o2Re8ppvp3seVHXSRM44cdSsT9FfNEUUZLOGWVCsiWaRPWM1Znn+mqZ1OfVZ3z3DWEzSp7hRA==

"ash-tree@link:./ash-tree/build":
version "0.0.0"
uid ""

ast-types-flow@^0.0.7:
version "0.0.7"
resolved "https://registry.yarnpkg.com/ast-types-flow/-/ast-types-flow-0.0.7.tgz#f70b735c6bca1a5c9c22d982c3e39e7feba3bdad"
Expand Down Expand Up @@ -9230,10 +9234,6 @@ react-is@^18.0.0, react-is@^18.2.0:
resolved "https://registry.yarnpkg.com/react-is/-/react-is-18.2.0.tgz#199431eeaaa2e09f86427efbb4f1473edb47609b"
integrity sha512-xWGDIW6x921xtzPkhiULtthJHoJvBbF3q26fzloPCK0hsvxtPVelvftw3zjbHWSkR2km9Z+4uxbDDK/6Zw9B8w==

"react-one-tree@link:./react-one-tree/build":
version "0.0.0"
uid ""

react-refresh@^0.11.0:
version "0.11.0"
resolved "https://registry.yarnpkg.com/react-refresh/-/react-refresh-0.11.0.tgz#77198b944733f0f1f1a90e791de4541f9f074046"
Expand Down

0 comments on commit aef2a56

Please sign in to comment.