diff --git a/react/javascript/simple-embed/.eslintrc.js b/react/javascript/simple-embed/.eslintrc.js new file mode 100644 index 0000000..a1bcd9c --- /dev/null +++ b/react/javascript/simple-embed/.eslintrc.js @@ -0,0 +1,39 @@ +module.exports = { + env: { + browser: true, + es2021: true, + 'jest/globals': true, + }, + extends: [ + 'eslint:recommended', + 'standard', + 'plugin:jest-dom/recommended', + 'plugin:prettier/recommended', + 'plugin:react/recommended', + 'plugin:testing-library/react', + 'prettier', + '@looker/eslint-config/license-header', + ], + parserOptions: { + ecmaFeatures: { + jsx: true, + }, + ecmaVersion: 12, + sourceType: 'module', + }, + plugins: [ + 'react', + 'jest', + 'jest-dom', + 'prettier', + 'react-hooks', + 'sort-keys-fix', + 'testing-library', + ], + rules: {}, + settings: { + react: { + version: 'detect', + }, + }, +} diff --git a/react/javascript/simple-embed/.gitignore b/react/javascript/simple-embed/.gitignore new file mode 100644 index 0000000..773ed0a --- /dev/null +++ b/react/javascript/simple-embed/.gitignore @@ -0,0 +1,7 @@ +node_modules +dist +!dist/index.js +.cache +.vscode +.env +.eslintcache \ No newline at end of file diff --git a/react/javascript/simple-embed/.node-version b/react/javascript/simple-embed/.node-version new file mode 100644 index 0000000..47c0a98 --- /dev/null +++ b/react/javascript/simple-embed/.node-version @@ -0,0 +1 @@ +12.13.0 diff --git a/react/javascript/simple-embed/.nvmrc b/react/javascript/simple-embed/.nvmrc new file mode 100644 index 0000000..48082f7 --- /dev/null +++ b/react/javascript/simple-embed/.nvmrc @@ -0,0 +1 @@ +12 diff --git a/react/javascript/simple-embed/.prettierrc.json b/react/javascript/simple-embed/.prettierrc.json new file mode 100644 index 0000000..36301bc --- /dev/null +++ b/react/javascript/simple-embed/.prettierrc.json @@ -0,0 +1,5 @@ +{ + "semi": false, + "singleQuote": true, + "trailingComma": "es5" +} diff --git a/react/javascript/simple-embed/LICENSE b/react/javascript/simple-embed/LICENSE new file mode 100644 index 0000000..b97ac8b --- /dev/null +++ b/react/javascript/simple-embed/LICENSE @@ -0,0 +1,21 @@ +The MIT License (MIT) + +Copyright (c) 2020 Looker Data Sciences, Inc. + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in +all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +THE SOFTWARE. diff --git a/react/javascript/simple-embed/README.md b/react/javascript/simple-embed/README.md new file mode 100644 index 0000000..99f1089 --- /dev/null +++ b/react/javascript/simple-embed/README.md @@ -0,0 +1 @@ +# todo \ No newline at end of file diff --git a/react/javascript/simple-embed/babel.config.js b/react/javascript/simple-embed/babel.config.js new file mode 100644 index 0000000..6a28636 --- /dev/null +++ b/react/javascript/simple-embed/babel.config.js @@ -0,0 +1,60 @@ +/* + * The MIT License (MIT) + * + * Copyright (c) 2019 Looker Data Sciences, Inc. + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ + +module.exports = (api) => { + const isTest = api.env('test') + api.cache(true) + + return { + presets: [ + [ + '@babel/env', + { + targets: { + esmodules: true, + }, + modules: isTest ? 'auto' : false, + }, + ], + [ + '@babel/preset-react', + { + development: process.env.BABEL_ENV !== 'build', + }, + ], + ], + env: { + build: { + ignore: ['**/*.test.js', '**/*.test.jsx', '__snapshots__', '__tests__'], + }, + }, + ignore: ['node_modules'], + plugins: [ + '@babel/plugin-proposal-class-properties', + '@babel/plugin-proposal-object-rest-spread', + '@babel/plugin-transform-runtime', + 'babel-plugin-styled-components', + ], + } +} diff --git a/react/javascript/simple-embed/config/license-header.js b/react/javascript/simple-embed/config/license-header.js new file mode 100644 index 0000000..90b9891 --- /dev/null +++ b/react/javascript/simple-embed/config/license-header.js @@ -0,0 +1,23 @@ +/* + * The MIT License (MIT) + * + * Copyright (c) 2021 Looker Data Sciences, Inc. + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ diff --git a/react/javascript/simple-embed/jest.config.js b/react/javascript/simple-embed/jest.config.js new file mode 100644 index 0000000..c34b4a7 --- /dev/null +++ b/react/javascript/simple-embed/jest.config.js @@ -0,0 +1,34 @@ +/* + + MIT License + + Copyright (c) 2021 Looker Data Sciences, Inc. + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to deal + in the Software without restriction, including without limitation the rights + to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in all + copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + SOFTWARE. + + */ + +module.exports = { + automock: false, + moduleDirectories: ['./node_modules'], + moduleFileExtensions: ['js', 'jsx', 'json'], + restoreMocks: true, + testPathIgnorePatterns: [], + globals: {}, +} diff --git a/react/javascript/simple-embed/manifest.lkml b/react/javascript/simple-embed/manifest.lkml new file mode 100644 index 0000000..6a01ad5 --- /dev/null +++ b/react/javascript/simple-embed/manifest.lkml @@ -0,0 +1,9 @@ +project_name: "simple-embed" + +application: simple-embed { + label: "Simple Embed" + url: "http://localhost:8080/bundle.js" + entitlements: { + use_embeds: yes + } +} diff --git a/react/javascript/simple-embed/package.json b/react/javascript/simple-embed/package.json new file mode 100644 index 0000000..605ad07 --- /dev/null +++ b/react/javascript/simple-embed/package.json @@ -0,0 +1,102 @@ +{ + "name": "helloworld-js", + "version": "0.1.0", + "description": "Looker Extension Hello World JavaScript Demo", + "main": "dist/bundle.js", + "scripts": { + "analyze": "export ANALYZE_MODE=static && yarn build", + "build": "export BABEL_ENV=build && webpack --config webpack.prod.js", + "clean": "rm -rf dist", + "develop": "webpack serve --hot --port 8080 --disable-host-check --config webpack.develop.js", + "prebuild": "yarn clean", + "lint:es": "eslint 'src/**/*.js{,x}' --cache", + "lint:es:fix": "eslint 'src/**/*.js{,x}' --cache --fix", + "test": "jest" + }, + "author": "Looker", + "license": "MIT", + "engines": { + "node": ">=12" + }, + "dependencies": { + "@looker/components": "^1.1.6", + "@looker/embed-sdk": "^1.6.0", + "@looker/extension-sdk": "^21.4.5", + "@looker/extension-sdk-react": "^21.4.5", + "@looker/icons": "1.1.5", + "@looker/sdk": "^21.4.3", + "@looker/sdk-rtl": "^21.0.12", + "@styled-icons/material": "10.28.0", + "@styled-icons/material-outlined": "10.28.0", + "@styled-icons/material-rounded": "10.28.0", + "react": "^16.14.0", + "react-dom": "^16.14.0", + "react-is": "^16.13.1", + "react-router-dom": "^5.1.2", + "styled-components": "^5.2.1" + }, + "devDependencies": { + "@babel/cli": "^7.12.10", + "@babel/core": "^7.12.10", + "@babel/plugin-proposal-class-properties": "^7.12.1", + "@babel/plugin-proposal-object-rest-spread": "^7.12.1", + "@babel/plugin-transform-react-jsx": "^7.12.10", + "@babel/plugin-transform-runtime": "^7.12.10", + "@babel/preset-env": "^7.12.10", + "@babel/preset-react": "^7.12.10", + "@babel/runtime": "^7.12.5", + "@looker/components-test-utils": "^1.1.5", + "@looker/eslint-config": "^0.10.4", + "@looker/prettier-config": "^0.10.4", + "@testing-library/jest-dom": "^5.11.6", + "@testing-library/react": "^11.2.2", + "@testing-library/user-event": "^12.6.0", + "babel-loader": "^8.2.2", + "babel-preset-nano-react-app": "^0.1.0", + "dotenv": "^8.2.0", + "eslint": "^7.22.0", + "eslint-config-prettier": "^8.3.0", + "eslint-config-standard": "^16.0.2", + "eslint-plugin-jest": "^24.3.6", + "eslint-import-resolver-webpack": "^0.12.1", + "eslint-plugin-header": "^3.0.0", + "eslint-plugin-import": "^2.22.1", + "eslint-plugin-jest-dom": "^3.8.1", + "eslint-plugin-mdx": "^1.6.8", + "eslint-plugin-node": "^11.1.0", + "eslint-plugin-prettier": "^3.1.3", + "eslint-plugin-promise": "^4.3.1", + "eslint-plugin-react": "^7.22.0", + "eslint-plugin-react-hooks": "^4.2.0", + "eslint-plugin-testing-library": "^4.2.0", + "prettier": "^2.1.1", + "jest": "^26.6.3", + "jest-junit": "^12.0.0", + "jest-styled-components": "^7.0.3", + "react-test-renderer": "^17.0.1", + "react-hot-loader": "^4.12.20", + "webpack": "^5.10.0", + "webpack-bundle-analyzer": "^4.2.0", + "webpack-cli": "^4.2.0", + "webpack-dev-server": "^3.10.3" + }, + "babel": { + "presets": [ + "nano-react-app" + ], + "plugins": [ + [ + "@babel/plugin-proposal-class-properties", + { + "loose": true + } + ], + [ + "@babel/plugin-transform-react-jsx", + { + "pragmaFrag": "React.Fragment" + } + ] + ] + } +} diff --git a/react/javascript/simple-embed/src/App.js b/react/javascript/simple-embed/src/App.js new file mode 100644 index 0000000..0004a12 --- /dev/null +++ b/react/javascript/simple-embed/src/App.js @@ -0,0 +1,36 @@ +/* + * The MIT License (MIT) + * + * Copyright (c) 2021 Looker Data Sciences, Inc. + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ + +import React from 'react' +import SimpleEmbed from './SimpleEmbed' +import { ExtensionProvider } from '@looker/extension-sdk-react' +import { hot } from 'react-hot-loader/root' + +export const App = hot(() => { + return ( + + + + ) +}) diff --git a/react/javascript/simple-embed/src/SimpleEmbed.js b/react/javascript/simple-embed/src/SimpleEmbed.js new file mode 100644 index 0000000..77d244c --- /dev/null +++ b/react/javascript/simple-embed/src/SimpleEmbed.js @@ -0,0 +1,84 @@ +/* + * The MIT License (MIT) + * + * Copyright (c) 2021 Looker Data Sciences, Inc. + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ + +import { ComponentsProvider, Flex, InputText, Label, Select, Space, Text, Tooltip } from '@looker/components' +import { ChartBar, DashboardFile, Explore } from '@looker/icons' +import React, { useState } from 'react' +import Embed from './components/Embed' + +const SimpleEmbed = () => { + const [content_id, setContentId] = useState('1'); + const [content_type, setContentType] = useState('dashboard'); + + return ( + <> + + + + + + + Looker Extension Framework: Simple Embed + + + + + +