Skip to content

Brynryans/seven guis #59

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Draft
wants to merge 2 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .envrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
if has nix; then
use nix
fi
6 changes: 6 additions & 0 deletions react/typescript/seven-guis-ts/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
node_modules
dist
.cache
.vscode
.env
.eslintcache
5 changes: 5 additions & 0 deletions react/typescript/seven-guis-ts/.prettierrc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"semi": false,
"singleQuote": true,
"trailingComma": "es5"
}
94 changes: 94 additions & 0 deletions react/typescript/seven-guis-ts/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,94 @@
# Seven GUIs demo

Demonstrates use of Looker components.

Inspired by [7Guis Programming Benchmark](https://eugenkiss.github.io/7guis/tasks)

## Getting Started for Development

1. Clone the Looker extension examples repo.

```
# cd ~/ Optional, your user directory is usually a good place to git clone to.
git clone git@github.com:looker-open-source/extension-examples.git
```

2. Navigate (`cd`) to the example directory on your system

```
cd extension-examples/react/typescript/seven-guis-ts
```

3. Install the dependencies with [Yarn](https://yarnpkg.com/).

```
yarn install
```

4. Start the development server

```
yarn develop
```

The extension is now running and serving the JavaScript locally at http://localhost:8080/bundle.js.

5. Log in to Looker and create a new project.

This is found under **Develop** => **Manage LookML Projects** => **New LookML Project**.

Select "Blank Project" as your "Starting Point". This will create a new project with no files.

1. The extension folder has a `manifest.lkml` file.

Either drag & upload this file into your Looker project, or create a `manifest.lkml` with the same content. Change the `id`, `label`, or `url` as needed.

```
project_name: "seven-guis-ts"

application: seven-guis-ts {
label: "Seven Guis"
url: "http://localhost:8080/bundle.js"
entitlements: {
use_form_submit: yes
}
}
```

6. Create a `model` LookML file in your project. The name doesn't matter but the convention is to name it the same as the project, in this case, seven-guis-ts.

- Add a connection in this model.
- [Configure the model you created](https://docs.looker.com/data-modeling/getting-started/create-projects#configuring_a_model) so that it has access to the selected connection.
We do this because Looker permissions data access via models— In order to grant / limit access to an extension, it must be associated with a model.

8. Connect the project to Git. This can be done in multiple ways:

- Create a new repository on GitHub or a similar service, and follow the instructions to [connect your project to Git](https://docs.looker.com/data-modeling/getting-started/setting-up-git-connection)
- A simpler but less powerful approach is to set up git with the "Bare" repository option which does not require connecting to an external Git Service.

9. Commit the changes and deploy them to production through the Project UI.

10. Reload the page and click the `Browse` dropdown menu. You will see the extension in the list.

- The extension will load the JavaScript from the `url` provided in the `application` definition. By default, this is http://localhost:8080/bundle.js. If you change the port your server runs on in the package.json, you will need to also update it in the manifest.lkml.
- Refreshing the extension page will bring in any new code changes from the extension template, although some changes will hot reload.

## Deployment

The process above describes how to run the extension for development. Once you're done developing and ready to deploy, the production version of the extension may be deployed as follows:

1. In the extension project directory build the extension by running `yarn build`.
2. Drag and drop the generated `dist/bundle.js` file into the Looker project interface
3. Modify the `manifest.lkml` to use `file` instead of `url`:

```
project_name: "seven-guis-ts"

application: seven-guis-ts {
label: "Seven Guis"
url: "http://localhost:8080/bundle.js"
entitlements: {
use_form_submit: yes
}
}
```
68 changes: 68 additions & 0 deletions react/typescript/seven-guis-ts/babel.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
/*
* 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) => {
api.cache(true)

return {
presets: [
[
'@babel/env',
{
targets: {
esmodules: true,
},
modules: false,
},
],
[
'@babel/preset-react',
{
development: process.env.BABEL_ENV !== 'build',
},
],
'@babel/preset-typescript',
],
env: {
build: {
ignore: [
'**/*.d.ts',
'**/*.test.js',
'**/*.test.jsx',
'**/*.test.ts',
'**/*.test.tsx',
'__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',
],
}
}
23 changes: 23 additions & 0 deletions react/typescript/seven-guis-ts/config/license-header.js
Original file line number Diff line number Diff line change
@@ -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.
*/
59 changes: 59 additions & 0 deletions react/typescript/seven-guis-ts/jest.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
/*

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.

*/

const excludeNodeModuleExcept = require('babel-loader-exclude-node-modules-except')

// Our own modules are built as esm to allow for tree shaking.
const ownModules = [
'@looker/components-test-utils',
'@looker/components',
'@looker/icons',
'@looker/design-tokens',
]

const excludeNodeModulesExceptRegExp = excludeNodeModuleExcept([...ownModules])

module.exports = {
automock: false,
moduleDirectories: ['./node_modules', './packages'],
moduleFileExtensions: ['js', 'jsx', 'ts', 'tsx', 'json', 'node'],
moduleNameMapper: {},
restoreMocks: true,
testMatch: ['**/?(*.)(spec|test).(ts|js)?(x)'],
transform: {
'^.+\\.(js|jsx|ts|tsx)$': 'ts-jest',
},
transformIgnorePatterns: [
excludeNodeModulesExceptRegExp.toString().slice(1, -2),
],
testPathIgnorePatterns: [],
globals: {
'ts-jest': {
isolatedModules: true,
diagnostics: false,
},
},
}
9 changes: 9 additions & 0 deletions react/typescript/seven-guis-ts/manifest.lkml
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
project_name: "seven-guis-ts"

application: seven-guis-ts {
label: "Seven Guis"
url: "http://localhost:8080/bundle.js"
entitlements: {
use_form_submit: yes
}
}
Loading