Skip to content

Commit

Permalink
ci: add flyte-api plugin package (#490)
Browse files Browse the repository at this point in the history
Signed-off-by: Nastya <55718143+anrusina@users.noreply.github.com>
  • Loading branch information
anrusina committed May 19, 2022
1 parent 1191ec4 commit 95aa4b0
Show file tree
Hide file tree
Showing 15 changed files with 165 additions and 9 deletions.
1 change: 1 addition & 0 deletions .storybook/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ module.exports = {
'@flyteconsole/locale': path.resolve(__dirname, '../packages/basics/locale/src'),
'@flyteconsole/ui-atoms': path.resolve(__dirname, '../packages/composites/ui-atoms/src'),
'@flyteconsole/components': path.resolve(__dirname, '../packages/plugins/components/src'),
'@flyteconsole/flyte-api': path.resolve(__dirname, '../packages/plugins/flyte-api/src'),
};

return config;
Expand Down
8 changes: 4 additions & 4 deletions jest.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,10 @@ module.exports = {

setupFilesAfterEnv: ['./script/test/jest-setup.ts'],
projects: [
'<rootDir>/packages/basics/locale',
'<rootDir>/packages/composites/ui-atoms',
'<rootDir>/packages/plugins/components',
'<rootDir>/packages/zapp/console',
'<rootDir>/packages/basics/*',
'<rootDir>/packages/composites/*',
'<rootDir>/packages/plugins/*',
'<rootDir>/packages/zapp/*',
],

coverageDirectory: '<rootDir>/.coverage',
Expand Down
1 change: 1 addition & 0 deletions packages/plugins/flyte-api/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
This is a flyte-API package for flyteconsole plugin system
6 changes: 6 additions & 0 deletions packages/plugins/flyte-api/jest.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
/** @type {import('ts-jest/dist/types').InitialOptionsTsJest} */
const sharedConfig = require('../../../script/test/jest.base.js');

module.exports = {
...sharedConfig,
};
35 changes: 35 additions & 0 deletions packages/plugins/flyte-api/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
{
"name": "@flyteconsole/flyte-api",
"version": "0.0.1-rc.1",
"description": "FlyteConsole plugin to allow access FlyteAPI",
"main": "./dist/index.js",
"module": "./lib/esm/index.js",
"types": "./lib/esm/index.d.ts",
"license": "Apache-2.0",
"private": false,
"publishConfig": {
"access": "public",
"registry": "https://registry.npmjs.org/"
},
"scripts": {
"build": "yarn build:esm && yarn build:cjs",
"build:esm": "tsc --module esnext --outDir lib/esm --project ./tsconfig.build.json",
"build:cjs": "tsc --project ./tsconfig.build.json",
"test": "NODE_ENV=test jest"
},
"dependencies": {
"@material-ui/core": "^4.0.0",
"@material-ui/icons": "^4.0.0",
"classnames": "^2.3.1"
},
"peerDependencies": {
"react": "^16.13.1",
"react-dom": "^16.13.1"
},
"devDependencies": {
"@types/react": "^16.9.34",
"@types/react-dom": "^16.9.7",
"react": "^16.13.1",
"react-dom": "^16.13.1"
}
}
41 changes: 41 additions & 0 deletions packages/plugins/flyte-api/src/Sample/index.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
import * as React from 'react';
import { AppBar, Toolbar, IconButton, makeStyles, Theme } from '@material-ui/core';
import MenuIcon from '@material-ui/icons/Menu';

const useStyles = makeStyles((theme: Theme) => ({
spacer: {
flexGrow: 1,
},
menuButton: {
marginRight: theme.spacing(2),
},
}));

export interface SampleComponentProps {
useCustomContent?: boolean; // rename to show that it is a backNavigation
className?: string;
}

/** Contains all content in the top navbar of the application. */
export const SampleComponent = (props: SampleComponentProps) => {
const styles = useStyles();

return (
<AppBar
color="secondary"
elevation={0}
id="navbar"
position="fixed"
className={props.className as string}
>
<Toolbar>
<div className={styles.spacer} />
{' Sample Text '}
<div className={styles.spacer} />
<IconButton edge="start" className={styles.menuButton} color="inherit" aria-label="menu">
<MenuIcon />
</IconButton>
</Toolbar>
</AppBar>
);
};
34 changes: 34 additions & 0 deletions packages/plugins/flyte-api/src/Sample/sample.stories.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
import * as React from 'react';
import { ComponentStory, ComponentMeta } from '@storybook/react';
import { makeStyles, Theme } from '@material-ui/core/styles';

import { SampleComponent } from '.';

export default {
title: 'Flyte-API/Sample',
component: SampleComponent,
} as ComponentMeta<typeof SampleComponent>;

const useStyles = makeStyles((_theme: Theme) => ({
updatedOne: {
backgroundColor: 'lightblue',
color: 'black',
},
updatedTwo: {
backgroundColor: 'black',
color: 'yellow',
},
}));

const Template: ComponentStory<typeof SampleComponent> = () => <SampleComponent />;
export const Primary = Template.bind({});

export const Secondary: ComponentStory<typeof SampleComponent> = () => {
const styles = useStyles();
return <SampleComponent className={styles.updatedOne} />;
};

export const Tertiary: ComponentStory<typeof SampleComponent> = () => {
const styles = useStyles();
return <SampleComponent className={styles.updatedTwo} />;
};
11 changes: 11 additions & 0 deletions packages/plugins/flyte-api/src/Sample/sample.test.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
import * as React from 'react';
import { render, screen } from '@testing-library/react';
import { SampleComponent } from './index';

describe('add function', () => {
it('SampleComponent is rendered contains correct text', () => {
render(<SampleComponent />);
const text = screen.getByText('Sample Text');
expect(text).toBeInTheDocument();
});
});
1 change: 1 addition & 0 deletions packages/plugins/flyte-api/src/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export { SampleComponent } from './Sample';
16 changes: 16 additions & 0 deletions packages/plugins/flyte-api/tsconfig.build.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
{
"extends": "./tsconfig.json",
"exclude": [
// files excluded from the build, we can not put it inro default tsconfig
// as it will screw VSCode IntelliSence
"**/test",
"**/mocks",
"**/__mocks__",
"**/__stories__",
"**/*.spec.*",
"**/*.test.*",
"**/*.mock.*",
"**/*.stories.*"
],
"references": []
}
9 changes: 9 additions & 0 deletions packages/plugins/flyte-api/tsconfig.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
{
"extends": "../../../tsconfig.base.json",
"compilerOptions": {
"rootDir": "./src",
"outDir": "./dist"
},
"references": [],
"include": ["src/**/*"]
}
2 changes: 0 additions & 2 deletions packages/zapp/console/src/routes/NavBarRouter.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import { NavBar } from 'components/Navigation/NavBar';
// import { NavBar as NewNavBar } from '@flyteconsole/components';
import * as React from 'react';
import { Route, Switch } from 'react-router-dom';
import { Routes } from './routes';
Expand All @@ -11,7 +10,6 @@ export const NavBarRouter: React.FC<{}> = () => (
<>
<Switch>
<Route path={Routes.ExecutionDetails.path} component={CustomNavBar} />
{/* <Route component={NewNavBar} /> */}
<Route component={NavBar} />
</Switch>
</>
Expand Down
3 changes: 2 additions & 1 deletion packages/zapp/console/tsconfig.build.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
"references": [
{ "path": "../../basics/locale/tsconfig.build.json" },
{ "path": "../../composites/ui-atoms/tsconfig.build.json" },
{ "path": "../../plugins/components/tsconfig.build.json" }
{ "path": "../../plugins/components/tsconfig.build.json" },
{ "path": "../../plugins/flyte-api/tsconfig.build.json" }
]
}
3 changes: 2 additions & 1 deletion packages/zapp/console/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,8 @@
"references": [
{ "path": "../../basics/locale" },
{ "path": "../../composites/ui-atoms" },
{ "path": "../../plugins/components" }
{ "path": "../../plugins/components" },
{ "path": "../../plugins/flyte-api" }
],
"include": ["src/**/*"]
}
3 changes: 2 additions & 1 deletion packages/zapp/console/webpack.common.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
import chalk from 'chalk';
import * as path from 'path';
import * as webpack from 'webpack';
import { processEnv as env, ASSETS_PATH as publicPath, processEnv } from './env';
import { processEnv as env, ASSETS_PATH as publicPath } from './env';

const { StatsWriterPlugin } = require('webpack-stats-plugin');
const FavIconWebpackPlugin = require('favicons-webpack-plugin');
Expand Down Expand Up @@ -95,6 +95,7 @@ const resolve = {
'@flyteconsole/locale': path.resolve(__dirname, '../../basics/locale/src'),
'@flyteconsole/ui-atoms': path.resolve(__dirname, '../../composites/ui-atoms/src'),
'@flyteconsole/components': path.resolve(__dirname, '../../plugins/components/src'),
'@flyteconsole/flyte-api': path.resolve(__dirname, '../../plugins/flyte-api/src'),
},
};

Expand Down

0 comments on commit 95aa4b0

Please sign in to comment.