-
Notifications
You must be signed in to change notification settings - Fork 97
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Remove people preview link implementation
- Loading branch information
pierrick
committed
Jan 24, 2024
1 parent
f495026
commit 65bbbab
Showing
11 changed files
with
3 additions
and
250 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 |
---|---|---|
|
@@ -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("[email protected]") | ||
.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] | ||
|
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
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 |
---|---|---|
|
@@ -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("{}"); | ||
|
@@ -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("[email protected]")); | ||
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] |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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()); | ||
} | ||
} | ||
} | ||
}; | ||
|
@@ -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: "[email protected]", | ||
bottomLabel: "Case Manager" | ||
} | ||
} | ||
] | ||
}] | ||
} | ||
} | ||
} | ||
}; | ||
} | ||
|
||
// [END add_ons_people_preview_link] | ||
// [END add_ons_preview_link] | ||
|
||
// [START add_ons_3p_resources] | ||
|
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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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 {} | ||
|
||
|
||
|
@@ -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": "[email protected]", | ||
"bottomLabel": "Case Manager", | ||
} | ||
}, | ||
] | ||
}], | ||
} | ||
} | ||
} | ||
} | ||
|
||
|
||
# [END add_ons_people_preview_link] | ||
# [END add_ons_preview_link] |
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