Skip to content

Commit

Permalink
Remove people preview link implementation
Browse files Browse the repository at this point in the history
  • Loading branch information
pierrick committed Jan 24, 2024
1 parent f495026 commit 65bbbab
Show file tree
Hide file tree
Showing 11 changed files with 3 additions and 250 deletions.
34 changes: 0 additions & 34 deletions apps-script/3p-resources/3p-resources.gs
Original file line number Diff line number Diff line change
Expand Up @@ -72,40 +72,6 @@ function parseQuery(url) {
}

// [END add_ons_case_preview_link]
// [START add_ons_people_preview_link]

/**
* Entry point for an employee profile link preview
*
* @param {!Object} event The event object.
* @return {!Card} The resulting preview link card.
*/
function peopleLinkPreview(event) {

// If the event object URL matches a specified pattern for employee profile links.
if (event.docs.matchedUrl.url) {

// Builds a preview card with an employee's name, title, email, and profile photo.
const userHeader = CardService.newCardHeader().setTitle("Rosario Cruz");
const userImage = CardService.newImage()
.setImageUrl("https://developers.google.com/workspace/add-ons/images/employee-profile.png");
const userInfo = CardService.newDecoratedText()
.setText("rosario@example.com")
.setBottomLabel("Case Manager")
.setIcon(CardService.Icon.EMAIL);
const userSection = CardService.newCardSection()
.addWidget(userImage)
.addWidget(userInfo);

// Returns the card. Uses the text from the card's header for the title of the smart chip.
return CardService.newCardBuilder()
.setHeader(userHeader)
.addSection(userSection)
.build();
}
}

// [END add_ons_people_preview_link]
// [END add_ons_preview_link]

// [START add_ons_3p_resources]
Expand Down
14 changes: 0 additions & 14 deletions apps-script/3p-resources/appsscript.json
Original file line number Diff line number Diff line change
Expand Up @@ -36,20 +36,6 @@
"es": "Caso de soporte"
},
"logoUrl": "https://developers.google.com/workspace/add-ons/images/support-icon.png"
},
{
"runFunction": "peopleLinkPreview",
"patterns": [
{
"hostPattern": "example.com",
"pathPrefix": "people"
}
],
"labelText": "People",
"localizedLabelText": {
"es": "Personas"
},
"logoUrl": "https://developers.google.com/workspace/add-ons/images/person-icon.png"
}
],
"createActionTriggers": [
Expand Down
2 changes: 1 addition & 1 deletion java/3p-resources/README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Third-Party Resources

The solution is made of two Cloud Functions, one for the two link preview triggers and
The solution is made of two Cloud Functions, one for the link preview trigger and
one for the third-party resource create action trigger.
To learn about writing Cloud Functions,
see the documentation: https://cloud.google.com/functions/docs/writing.
Expand Down
14 changes: 0 additions & 14 deletions java/3p-resources/deployment.json
Original file line number Diff line number Diff line change
Expand Up @@ -33,20 +33,6 @@
"es": "Caso de soporte"
},
"logoUrl": "https://developers.google.com/workspace/add-ons/images/support-icon.png"
},
{
"runFunction": "$URL1",
"patterns": [
{
"hostPattern": "example.com",
"pathPrefix": "people"
}
],
"labelText": "People",
"localizedLabelText": {
"es": "Personas"
},
"logoUrl": "https://developers.google.com/workspace/add-ons/images/person-icon.png"
}
],
"createActionTriggers": [
Expand Down
63 changes: 0 additions & 63 deletions java/3p-resources/src/main/java/CreateLinkPreview.java
Original file line number Diff line number Diff line change
Expand Up @@ -52,11 +52,6 @@ public void service(HttpRequest request, HttpResponse response) throws Exception
response.getWriter().write(gson.toJson(caseLinkPreview(parsedURL)));
return;
}

if (parsedURL.getPath().startsWith("/people/")) {
response.getWriter().write(gson.toJson(peopleLinkPreview()));
return;
}
}

response.getWriter().write("{}");
Expand Down Expand Up @@ -116,64 +111,6 @@ JsonObject caseLinkPreview(URL url) throws UnsupportedEncodingException {
}

// [END add_ons_case_preview_link]
// [START add_ons_people_preview_link]

/**
* An employee profile link preview.
*
* @return The resulting preview link card.
*/
JsonObject peopleLinkPreview() {
// Builds a preview card with an employee's name, title, email, and profile photo.
// Uses the text from the card's header for the title of the smart chip.
JsonObject cardHeader = new JsonObject();
cardHeader.add("title", new JsonPrimitive("Rosario Cruz"));

JsonObject image = new JsonObject();
image.add("imageUrl", new JsonPrimitive("https://developers.google.com/workspace/add-ons/images/employee-profile.png"));

JsonObject imageWidget = new JsonObject();
imageWidget.add("image", image);

JsonObject startIcon = new JsonObject();
startIcon.add("knownIcon", new JsonPrimitive("EMAIL"));

JsonObject decoratedText = new JsonObject();
decoratedText.add("startIcon", startIcon);
decoratedText.add("text", new JsonPrimitive("rosario@example.com"));
decoratedText.add("bottomLabel", new JsonPrimitive("Case Manager"));

JsonObject decoratedTextWidget = new JsonObject();
decoratedTextWidget.add("decoratedText", decoratedText);

JsonArray widgets = new JsonArray();
widgets.add(imageWidget);
widgets.add(decoratedTextWidget);

JsonObject section = new JsonObject();
section.add("widgets", widgets);

JsonArray sections = new JsonArray();
sections.add(section);

JsonObject previewCard = new JsonObject();
previewCard.add("header", cardHeader);
previewCard.add("sections", sections);

JsonObject linkPreview = new JsonObject();
linkPreview.add("title", new JsonPrimitive("Rosario Cruz"));
linkPreview.add("previewCard", previewCard);

JsonObject action = new JsonObject();
action.add("linkPreview", linkPreview);

JsonObject renderActions = new JsonObject();
renderActions.add("action", action);

return renderActions;
}

// [END add_ons_people_preview_link]
}

// [END add_ons_preview_link]
2 changes: 1 addition & 1 deletion node/3p-resources/README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Third-Party Resources

The solution is made of two Cloud Functions, one for the two link preview triggers and
The solution is made of two Cloud Functions, one for the link preview trigger and
one for the third-party resource create action trigger.
To learn about writing Cloud Functions,
see the documentation: https://cloud.google.com/functions/docs/writing.
Expand Down
14 changes: 0 additions & 14 deletions node/3p-resources/deployment.json
Original file line number Diff line number Diff line change
Expand Up @@ -33,20 +33,6 @@
"es": "Caso de soporte"
},
"logoUrl": "https://developers.google.com/workspace/add-ons/images/support-icon.png"
},
{
"runFunction": "$URL1",
"patterns": [
{
"hostPattern": "example.com",
"pathPrefix": "people"
}
],
"labelText": "People",
"localizedLabelText": {
"es": "Personas"
},
"logoUrl": "https://developers.google.com/workspace/add-ons/images/person-icon.png"
}
],
"createActionTriggers": [
Expand Down
47 changes: 0 additions & 47 deletions node/3p-resources/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,10 +31,6 @@ exports.createLinkPreview = (req, res) => {
if (parsedUrl.pathname.startsWith('/support/cases/')) {
return res.json(caseLinkPreview(parsedUrl));
}

if (parsedUrl.pathname.startsWith('/people/')) {
return res.json(peopleLinkPreview());
}
}
}
};
Expand Down Expand Up @@ -75,49 +71,6 @@ function caseLinkPreview(url) {
}

// [END add_ons_case_preview_link]
// [START add_ons_people_preview_link]

/**
* An employee profile link preview.
*
* @param {!URL} url The event object.
* @return {!Card} The resulting preview link card.
*/
function peopleLinkPreview() {
// Builds a preview card with an employee's name, title, email, and profile photo.
// Uses the text from the card's header for the title of the smart chip.
return {
action: {
linkPreview: {
title: "Rosario Cruz",
previewCard: {
header: {
title: "Rosario Cruz"
},
sections: [{
widgets: [
{
image: {
imageUrl: 'https://developers.google.com/workspace/add-ons/images/employee-profile.png'
}
}, {
decoratedText: {
startIcon: {
knownIcon: "EMAIL"
},
text: "rosario@example.com",
bottomLabel: "Case Manager"
}
}
]
}]
}
}
}
};
}

// [END add_ons_people_preview_link]
// [END add_ons_preview_link]

// [START add_ons_3p_resources]
Expand Down
2 changes: 1 addition & 1 deletion python/3p-resources/README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Third-Party Resources

The solution is made of two Cloud Functions, one for the two link preview triggers and
The solution is made of two Cloud Functions, one for the link preview trigger and
one for the third-party resource create action trigger.
To learn about writing Cloud Functions,
see the documentation: https://cloud.google.com/functions/docs/writing.
Expand Down
47 changes: 0 additions & 47 deletions python/3p-resources/create_link_preview/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,9 +37,6 @@ def create_link_preview(req: flask.Request):
if parsed_url.path.startswith("/support/cases/"):
return case_link_preview(parsed_url)

if parsed_url.path.startswith("/people/"):
return people_link_preview()

return {}


Expand Down Expand Up @@ -80,48 +77,4 @@ def case_link_preview(url):


# [END add_ons_case_preview_link]
# [START add_ons_people_preview_link]


def people_link_preview():
"""An employee profile link preview.
Returns:
A people link preview card.
"""

# Builds a preview card with an employee's name, title, email, and profile photo.
# Uses the text from the card's header for the title of the smart chip.
return {
"action": {
"linkPreview": {
"title": "Rosario Cruz",
"previewCard": {
"header": {
"title": "Rosario Cruz"
},
"sections": [{
"widgets": [
{
"image": {
"imageUrl": "https://developers.google.com/workspace/add-ons/images/employee-profile.png"
}
},
{
"decoratedText": {
"startIcon": {
"knownIcon": "EMAIL"
},
"text": "rosario@example.com",
"bottomLabel": "Case Manager",
}
},
]
}],
}
}
}
}


# [END add_ons_people_preview_link]
# [END add_ons_preview_link]
14 changes: 0 additions & 14 deletions python/3p-resources/deployment.json
Original file line number Diff line number Diff line change
Expand Up @@ -33,20 +33,6 @@
"es": "Caso de soporte"
},
"logoUrl": "https://developers.google.com/workspace/add-ons/images/support-icon.png"
},
{
"runFunction": "$URL1",
"patterns": [
{
"hostPattern": "example.com",
"pathPrefix": "people"
}
],
"labelText": "People",
"localizedLabelText": {
"es": "Personas"
},
"logoUrl": "https://developers.google.com/workspace/add-ons/images/person-icon.png"
}
],
"createActionTriggers": [
Expand Down

0 comments on commit 65bbbab

Please sign in to comment.