Skip to content

Commit

Permalink
Add example extension
Browse files Browse the repository at this point in the history
  • Loading branch information
nathandf committed Oct 4, 2024
1 parent 0c3503a commit 5c79b5a
Show file tree
Hide file tree
Showing 11 changed files with 199 additions and 0 deletions.
2 changes: 2 additions & 0 deletions packages/example-extension/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
dist
node_modules
2 changes: 2 additions & 0 deletions packages/example-extension/.npmignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
node_modules
tasks.ts
1 change: 1 addition & 0 deletions packages/example-extension/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
# tapisui-extension-icicle
35 changes: 35 additions & 0 deletions packages/example-extension/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
{
"name": "<YOUR_PACKAGE_NAME>",
"version": "<YOUR_PACKAGE_VERIONS>",
"description": "",
"main": "./dist/index.js",
"typings": "./dist/index.d.ts",
"types": "./dist/index.d.ts",
"scripts": {
"clean": "rm -rf dist",
"test": "echo \"Error: no test specified\" && exit 1",
"push": "npm run build && npm publish --access public",
"copy-files": "copyfiles -u 1 \"src/styles/**/*\" \"src/fonts/**/*\" \"src/**/*.scss\" \"src/index.css\" \"src/**/*.css\" \"src/**/*.module.css\" dist/",
"build": "npm run clean && npx tsc --build ./tsconfig.json && npm run copy-files"
},
"keywords": [
"typescript",
"tapisui"
],
"author": "<YOUR_NAME>",
"license": "MIT",
"dependencies": {
"@tapis/tapis-typescript": "^0.0.51",
"@tapis/tapisui-extensions-core": "file:../tapisui-extensions-core",
"@tapis/tapisui-common": "file:../tapisui-common",
"@tapis/tapisui-hooks": "file:../tapisui-hooks",
"copyfiles": "^2.4.1",
"react": "^18.3.1"
},
"devDependencies": {
"@types/node": "^18.19.33",
"typescript": "^4.9.5",
"@tapis/tapisui-extension-devtools": "file:../tapisui-extension-devtools",
"sass": "^1.77.6"
}
}
14 changes: 14 additions & 0 deletions packages/example-extension/src/declaration.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
declare module '*.module.scss' {
const content: { [className: string]: string };
export default content;
}

declare module '*.module.css' {
const content: { [className: string]: string };
export default content;
}

declare module '*.css' {
const content: { [className: string]: string };
export default content;
}
48 changes: 48 additions & 0 deletions packages/example-extension/src/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
import {
createExtension,
EnumTapisCoreService,
} from '@tapis/tapisui-extensions-core';
import { MyNewPage } from './pages';

const extension = createExtension({
allowMultiTenant: false,
authentication: {
password: true,
implicit: {
authorizationPath: 'https://icicleai.tapis.io/v3/oauth2/authorize',
clientId: 'tapisui-implicit-client',
redirectURI: 'https://icicleai.tapis.io/tapis-ui/#/oauth2',
responseType: 'token',
},
},
removeServices: [EnumTapisCoreService.Apps],
mainSidebarServices: [
'systems',
'apps',
'jobs',
'files',
'workflows',
'pods',
'ml-hub',
'my-new-page',
],
authMethods: ['implicit', 'password'],
logo: {
filePath: './logo_icicle.png',
text: 'MY EXTENSION',
},
icon: {
filePath: './icon_icicle.png',
text: 'MY EXTENSION',
},
});

// Registering a new service will add
extension.registerService({
id: 'my-new-page',
sidebarDisplayName: 'My New Page',
iconName: 'simulation',
component: MyNewPage,
});

export { extension };
20 changes: 20 additions & 0 deletions packages/example-extension/src/pages/MyNewPage/MyNewPage.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
import { Component } from '@tapis/tapisui-extensions-core';

export const MyNewPage: Component = () => {
return (
<div
style={{
width: '100%',
height: '100%',
display: 'flex',
flexDirection: 'column',
overflow: 'hidden',
}}
>
<h1>My new page</h1>
<p>Hello from my new page!</p>
</div>
);
};

export default MyNewPage;
1 change: 1 addition & 0 deletions packages/example-extension/src/pages/MyNewPage/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export { default as MyNewPage } from './MyNewPage';
1 change: 1 addition & 0 deletions packages/example-extension/src/pages/index.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export { MyNewPage } from './MyNewPage';
48 changes: 48 additions & 0 deletions packages/example-extension/src/tasks.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
import { Workflows } from '@tapis/tapis-typescript';

export const tasks: Array<Workflows.Task> = [
{
id: 'django-search',
type: Workflows.EnumTaskType.Function,
execution_profile: {
flavor: Workflows.EnumTaskFlavor.C1med,
},
input: {
OBJECT: {
type: Workflows.EnumTaskIOType.String,
description: 'Django search parameter - object',
required: false,
value_from: {
args: 'OBJECT',
},
},
PREDICATE: {
type: Workflows.EnumTaskIOType.String,
description: 'Django search parameter - predicate',
required: false,
value_from: {
args: 'PREDICATE',
},
},
API_HOST: {
type: Workflows.EnumTaskIOType.String,
description: 'Django API host url',
required: false,
value_from: {
args: 'API_HOST',
},
},
},
installer: Workflows.EnumInstaller.Pip,
packages: ['pandas==2.1.4', 'requests'],
runtime: Workflows.EnumRuntimeEnvironment.Python39,
entrypoint: 'icicle-task-templates/task-templates/django_search.py',
git_repositories: [
{
url: 'https://github.com/ICICLE-ai/tapisui-extension-icicle.git',
branch: 'main',
directory: 'icicle-task-templates',
},
],
},
];
27 changes: 27 additions & 0 deletions packages/example-extension/tsconfig.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
{
"compilerOptions": {
"jsx": "react-jsx",
"declaration": true,
"target": "esnext",
"module": "esnext",
"moduleResolution": "node",
"skipLibCheck": true,
"noFallthroughCasesInSwitch": true,
"outDir": "dist",
"lib": ["dom", "esnext", "dom.iterable"],
"types": ["node"],
"typeRoots": ["./types", "node_modules/@types"],
"incremental": true,
"esModuleInterop": true // required or pages won't import
// "baseUrl": "src",
// "allowJs": true,
// // "allowSyntheticDefaultImports": true,
// "strict": false,
// "forceConsistentCasingInFileNames": true,
// "resolveJsonModule": true,
// "isolatedModules": true,
// "noEmit": false,
},
"include": ["src"],
"exclude": ["node_modules", "dist", "bundle.ts", "tasks.ts"]
}

0 comments on commit 5c79b5a

Please sign in to comment.