-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #15 from HubSpot/UIE-public-beta-update
React getting started project
- Loading branch information
Showing
16 changed files
with
199 additions
and
137 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,20 +1,28 @@ | ||
{ | ||
"components": [ | ||
{ "path": "components/app-crm-card-middle", "label": "App (CRM card - middle panel)", "insertPath": "./"}, | ||
{ "path": "components/app-crm-card-side", "label": "App (CRM card - side panel)", "insertPath": "./"} | ||
], | ||
"projects": [ | ||
{ | ||
"name": "no-template", | ||
"label": "No template", | ||
"path": "projects/no-template", | ||
"insertPath": "./" | ||
}, | ||
{ | ||
"name": "getting-started", | ||
"label": "Getting started", | ||
"path": "projects/getting-started-template", | ||
"insertPath": "./" | ||
} | ||
] | ||
"components": [ | ||
{ | ||
"path": "components/app-crm-card-middle", | ||
"label": "App (CRM card - middle panel)", | ||
"insertPath": "./" | ||
}, | ||
{ | ||
"path": "components/app-crm-card-side", | ||
"label": "App (CRM card - side panel)", | ||
"insertPath": "./" | ||
} | ||
], | ||
"projects": [ | ||
{ | ||
"name": "getting-started", | ||
"label": "Use CRM getting started project", | ||
"path": "projects/getting-started-template", | ||
"insertPath": "./" | ||
}, | ||
{ | ||
"name": "no-template", | ||
"label": "No, start from scratch", | ||
"path": "projects/no-template", | ||
"insertPath": "./" | ||
} | ||
] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
MIT License | ||
|
||
Copyright (c) 2023 HubSpot | ||
|
||
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. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,16 +1,17 @@ | ||
# getting-started-project-template | ||
# HubSpot Getting Started Project Template | ||
|
||
This is the Getting Started project for HubSpot developer projects. This repo contains code that is intended to help developers to get up and running with developer projects quickly and easily. | ||
This is the Getting Started project for HubSpot developer projects. It contains a private app, a CRM card written in React, and a serverless function that the CRM card is able to interact with. This code is intended to help developers get up and running with developer projects quickly and easily. | ||
|
||
## Requirements | ||
|
||
There are a few things that must be set up before you can make use of this getting started project. | ||
|
||
- You must have an active HubSpot account. | ||
- You must have the [HubSpot CLI](https://www.npmjs.com/package/@hubspot/cli) installed and set up. | ||
- You must have access to developer projects (developer projects are currently [in public beta under "CRM Development Tools"](https://app.hubspot.com/l/whats-new/betas)). | ||
|
||
## Usage | ||
The HubSpot CLI is configured to pull from the latest release of this project. To get started, run the following CLI command in your terminal: | ||
|
||
`hs project create` | ||
The HubSpot CLI enables you to run this project locally so that you may test and iterate quickly. Getting started is simple, just run this HubSpot CLI command in your project directory and follow the prompts: | ||
|
||
The CLI should walk you throug the rest of the setup flow. | ||
`hs project dev` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,5 @@ | ||
{ | ||
"name": "getting-started-template", | ||
"name": "Get Started Project", | ||
"srcDir": "src", | ||
"platformVersion": "2023.1" | ||
} |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
{ | ||
"name": "hubspot-get-started-project", | ||
"version": "0.1.0", | ||
"description": "Basic example of a UI Extension built with HubSpot's React developer tools", | ||
"scripts": { | ||
"postinstall": "cd ./src/app/extensions/ && npm install; cd ../app.functions && npm install", | ||
"build": "npm run build --prefix ./src/app/extensions/" | ||
}, | ||
"author": "HubSpot", | ||
"license": "MIT" | ||
} |
82 changes: 0 additions & 82 deletions
82
projects/getting-started-template/src/app/app.functions/example-card.js
This file was deleted.
Oops, something went wrong.
11 changes: 11 additions & 0 deletions
11
projects/getting-started-template/src/app/app.functions/example-function.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
exports.main = (context = {}, sendResponse) => { | ||
const { text } = context.parameters; | ||
|
||
const response = `This is coming from a serverless function! You entered: ${text}`; | ||
|
||
try { | ||
sendResponse(response); | ||
} catch (error) { | ||
sendResponse(error); | ||
} | ||
}; |
13 changes: 4 additions & 9 deletions
13
projects/getting-started-template/src/app/app.functions/package.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
16 changes: 0 additions & 16 deletions
16
projects/getting-started-template/src/app/example-card.json
This file was deleted.
Oops, something went wrong.
76 changes: 76 additions & 0 deletions
76
projects/getting-started-template/src/app/extensions/Example.jsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,76 @@ | ||
import React, { useState } from "react"; | ||
import { | ||
Divider, | ||
Link, | ||
Button, | ||
Text, | ||
Input, | ||
Flex, | ||
hubspot, | ||
} from "@hubspot/ui-extensions"; | ||
|
||
// Define the extension to be run within the Hubspot CRM | ||
hubspot.extend(({ context, runServerlessFunction, actions }) => ( | ||
<Extension | ||
context={context} | ||
runServerless={runServerlessFunction} | ||
sendAlert={actions.addAlert} | ||
/> | ||
)); | ||
|
||
// Define the Extension component, taking in runServerless, context, & sendAlert as props | ||
const Extension = ({ context, runServerless, sendAlert }) => { | ||
const [text, setText] = useState(""); | ||
|
||
// Call serverless function to execute with parameters. | ||
// The `myFunc` function name is configured inside `serverless.json` | ||
const handleClick = () => { | ||
runServerless({ name: "myFunc", parameters: { text: text } }).then((resp) => | ||
sendAlert({ message: resp.response }) | ||
); | ||
}; | ||
|
||
return ( | ||
<> | ||
<Text> | ||
<Text format={{ fontWeight: "bold" }}> | ||
Your first UI extension is ready! | ||
</Text> | ||
Congratulations, {context.user.firstName}! You just deployed your first | ||
HubSpot UI extension. This example demonstrates how you would send | ||
parameters from your React frontend to the serverless function and get a | ||
response back. | ||
</Text> | ||
<Flex direction="row" align="end" gap="small"> | ||
<Input name="text" label="Send" onInput={(t) => setText(t)} /> | ||
<Button type="submit" onClick={handleClick}> | ||
Click me | ||
</Button> | ||
</Flex> | ||
<Divider /> | ||
<Text> | ||
What now? Explore all available{" "} | ||
<Link href="https://developers.hubspot.com/docs/platform/ui-extension-components"> | ||
UI components | ||
</Link> | ||
, get an overview of{" "} | ||
<Link href="https://developers.hubspot.com/docs/platform/ui-extensions-overview"> | ||
UI extensions | ||
</Link> | ||
, learn how to{" "} | ||
<Link href="https://developers.hubspot.com/docs/platform/create-ui-extensions"> | ||
add a new custom card | ||
</Link> | ||
, jump right in with our{" "} | ||
<Link href="https://developers.hubspot.com/docs/platform/ui-extensions-quickstart"> | ||
Quickstart Guide | ||
</Link> | ||
, or check out our{" "} | ||
<Link href="https://github.com/HubSpot/ui-extensions-react-examples"> | ||
code Samples | ||
</Link> | ||
. | ||
</Text> | ||
</> | ||
); | ||
}; |
12 changes: 12 additions & 0 deletions
12
projects/getting-started-template/src/app/extensions/example-card.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
{ | ||
"type": "crm-card", | ||
"data": { | ||
"title": "Example Card", | ||
"uid": "get_started_card", | ||
"location": "crm.record.tab", | ||
"module": { | ||
"file": "Example.jsx" | ||
}, | ||
"objectTypes": [{ "name": "contacts" }] | ||
} | ||
} |
10 changes: 10 additions & 0 deletions
10
projects/getting-started-template/src/app/extensions/package.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
{ | ||
"name": "hubspot-example-extension", | ||
"version": "0.1.0", | ||
"author": "HubSpot", | ||
"license": "MIT", | ||
"dependencies": { | ||
"@hubspot/ui-extensions": "latest", | ||
"react": "^18.2.0" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,5 @@ | ||
{ | ||
"name": "no-template", | ||
"name": "Empty Project", | ||
"srcDir": "src", | ||
"platformVersion": "2023.1" | ||
} |