Skip to content
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

Starred messages #294

Draft
wants to merge 12 commits into
base: main
Choose a base branch
from
41 changes: 24 additions & 17 deletions bootstrapping-lambda/local/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -10,32 +10,39 @@
<a href="?expandPinboard=true"
>Expand pinboard via query param <code>?expandPinboard=true</code></a
>
<h4>
Open Pinboard via query param (for workflow/pinboard ID
<code>65299</code>)
</h4>
<ul>
<li>
<a href="?pinboardId=65299">?pinboardId=65299</a>
</li>
<li>
<a href="?pinboardId=65299&pinboardItemId=2885"
>?pinboardId=65299&pinboardItemId=2885</a
>
</li>
<li>
<a href="?"><em>REMOVE QUERY PARAM</em></a>
</li>
</ul>
<h3>Pinboard pre-selection</h3>
<ul>
<h4>via query param (for workflow/pinboard ID <code>14748</code>)</h4>
<ul>
<li>
<a href="?pinboardId=14748">?pinboardId=14748</a>
</li>
<li>
<a href="?pinboardId=14748&pinboardItemId=1667"
>?pinboardId=14748&pinboardItemId=1667</a
>
</li>
<li>
<a href="?"><em>REMOVE QUERY PARAM</em></a>
</li>
</ul>

<h4>
via hidden element (for composer ID
<code>54f2d2fee4b011581586e710</code>)
<code>649975868f08c7d8da8802ff</code>)
</h4>
<button id="btn-add-preselection">Add pinboard pre-selection</button>
<button id="btn-remove-preselection">
Remove pinboard pre-selection
</button>

<h5>Starred messages (requires pinboard pre-selection)</h5>
<div style="max-width: 710px">
<pinboard-starred-messages></pinboard-starred-messages>
</div>

<h4>via hidden element (for invalid/untracked composer ID)</h4>
<button id="btn-add-invalid-preselection">
Add pinboard INVALID pre-selection
Expand Down Expand Up @@ -119,7 +126,7 @@ <h4>presented after 1 second</h4>

const preSelectPinboardElement =
document.createElement("pinboard-preselect");
preSelectPinboardElement.dataset.composerId = "54f2d2fee4b011581586e710";
preSelectPinboardElement.dataset.composerId = "649975868f08c7d8da8802ff";
document
.getElementById("btn-add-preselection")
.addEventListener("click", () => {
Expand Down
67 changes: 45 additions & 22 deletions cdk/lib/__snapshots__/stack.test.ts.snap
Original file line number Diff line number Diff line change
Expand Up @@ -2268,6 +2268,7 @@ type Mutation {
editItem(itemId: String!, input: EditItemInput!): Item
deleteItem(itemId: String!): Item
claimItem(itemId: String!): Claimed
setIsStarred(itemId: String!, isStarred: Boolean!): Item
seenItem(input: LastItemSeenByUserInput!): LastItemSeenByUser
setWebPushSubscriptionForUser(webPushSubscription: AWSJSON): MyUser
addManuallyOpenedPinboardIds(pinboardId: String!, maybeEmailOverride: String): MyUser
Expand All @@ -2278,7 +2279,7 @@ type Mutation {
type Subscription {
onMutateItem(
pinboardId: String
): Item @aws_subscribe(mutations: [\\"createItem\\", \\"editItem\\", \\"deleteItem\\"])
): Item @aws_subscribe(mutations: [\\"createItem\\", \\"editItem\\", \\"deleteItem\\", \\"setIsStarred\\"])

onClaimItem(
pinboardId: String
Expand Down Expand Up @@ -2313,6 +2314,7 @@ type Item {
relatedItemId: String
editHistory: [AWSDateTime!]
deletedAt: AWSDateTime
isStarred: Boolean!
}

type LastItemSeenByUser {
Expand Down Expand Up @@ -2467,7 +2469,7 @@ type PinboardIdWithItemCounts {
"DataSourceName": "database_bridge_lambda_ds",
"FieldName": "addManuallyOpenedPinboardIds",
"Kind": "UNIT",
"ResponseMappingTemplate": "## schema checksum : aa02bae16942e48366fa36a1cd643d16
"ResponseMappingTemplate": "## schema checksum : b72f387aabaad7462e0e00a8ab981ffc
$util.toJson($ctx.result)",
"TypeName": "Mutation",
},
Expand All @@ -2488,7 +2490,7 @@ $util.toJson($ctx.result)",
"DataSourceName": "database_bridge_lambda_ds",
"FieldName": "claimItem",
"Kind": "UNIT",
"ResponseMappingTemplate": "## schema checksum : aa02bae16942e48366fa36a1cd643d16
"ResponseMappingTemplate": "## schema checksum : b72f387aabaad7462e0e00a8ab981ffc
$util.toJson($ctx.result)",
"TypeName": "Mutation",
},
Expand All @@ -2509,7 +2511,7 @@ $util.toJson($ctx.result)",
"DataSourceName": "database_bridge_lambda_ds",
"FieldName": "createItem",
"Kind": "UNIT",
"ResponseMappingTemplate": "## schema checksum : aa02bae16942e48366fa36a1cd643d16
"ResponseMappingTemplate": "## schema checksum : b72f387aabaad7462e0e00a8ab981ffc
$util.toJson($ctx.result)",
"TypeName": "Mutation",
},
Expand All @@ -2530,7 +2532,7 @@ $util.toJson($ctx.result)",
"DataSourceName": "database_bridge_lambda_ds",
"FieldName": "deleteItem",
"Kind": "UNIT",
"ResponseMappingTemplate": "## schema checksum : aa02bae16942e48366fa36a1cd643d16
"ResponseMappingTemplate": "## schema checksum : b72f387aabaad7462e0e00a8ab981ffc
$util.toJson($ctx.result)",
"TypeName": "Mutation",
},
Expand All @@ -2551,7 +2553,7 @@ $util.toJson($ctx.result)",
"DataSourceName": "database_bridge_lambda_ds",
"FieldName": "editItem",
"Kind": "UNIT",
"ResponseMappingTemplate": "## schema checksum : aa02bae16942e48366fa36a1cd643d16
"ResponseMappingTemplate": "## schema checksum : b72f387aabaad7462e0e00a8ab981ffc
$util.toJson($ctx.result)",
"TypeName": "Mutation",
},
Expand All @@ -2572,7 +2574,7 @@ $util.toJson($ctx.result)",
"DataSourceName": "database_bridge_lambda_ds",
"FieldName": "removeManuallyOpenedPinboardIds",
"Kind": "UNIT",
"ResponseMappingTemplate": "## schema checksum : aa02bae16942e48366fa36a1cd643d16
"ResponseMappingTemplate": "## schema checksum : b72f387aabaad7462e0e00a8ab981ffc
$util.toJson($ctx.result)",
"TypeName": "Mutation",
},
Expand All @@ -2593,7 +2595,28 @@ $util.toJson($ctx.result)",
"DataSourceName": "database_bridge_lambda_ds",
"FieldName": "seenItem",
"Kind": "UNIT",
"ResponseMappingTemplate": "## schema checksum : aa02bae16942e48366fa36a1cd643d16
"ResponseMappingTemplate": "## schema checksum : b72f387aabaad7462e0e00a8ab981ffc
$util.toJson($ctx.result)",
"TypeName": "Mutation",
},
"Type": "AWS::AppSync::Resolver",
},
"pinboardappsyncapidatabasebridgelambdadsMutationsetIsStarredResolver7A053545": Object {
"DependsOn": Array [
"pinboardappsyncapidatabasebridgelambdads970CB9A7",
"pinboardappsyncapiSchema868D9F5B",
],
"Properties": Object {
"ApiId": Object {
"Fn::GetAtt": Array [
"pinboardappsyncapi9D519400",
"ApiId",
],
},
"DataSourceName": "database_bridge_lambda_ds",
"FieldName": "setIsStarred",
"Kind": "UNIT",
"ResponseMappingTemplate": "## schema checksum : b72f387aabaad7462e0e00a8ab981ffc
$util.toJson($ctx.result)",
"TypeName": "Mutation",
},
Expand All @@ -2614,7 +2637,7 @@ $util.toJson($ctx.result)",
"DataSourceName": "database_bridge_lambda_ds",
"FieldName": "setWebPushSubscriptionForUser",
"Kind": "UNIT",
"ResponseMappingTemplate": "## schema checksum : aa02bae16942e48366fa36a1cd643d16
"ResponseMappingTemplate": "## schema checksum : b72f387aabaad7462e0e00a8ab981ffc
$util.toJson($ctx.result)",
"TypeName": "Mutation",
},
Expand All @@ -2635,7 +2658,7 @@ $util.toJson($ctx.result)",
"DataSourceName": "database_bridge_lambda_ds",
"FieldName": "visitTourStep",
"Kind": "UNIT",
"ResponseMappingTemplate": "## schema checksum : aa02bae16942e48366fa36a1cd643d16
"ResponseMappingTemplate": "## schema checksum : b72f387aabaad7462e0e00a8ab981ffc
$util.toJson($ctx.result)",
"TypeName": "Mutation",
},
Expand All @@ -2656,7 +2679,7 @@ $util.toJson($ctx.result)",
"DataSourceName": "database_bridge_lambda_ds",
"FieldName": "getGroupPinboardIds",
"Kind": "UNIT",
"ResponseMappingTemplate": "## schema checksum : aa02bae16942e48366fa36a1cd643d16
"ResponseMappingTemplate": "## schema checksum : b72f387aabaad7462e0e00a8ab981ffc
$util.toJson($ctx.result)",
"TypeName": "Query",
},
Expand All @@ -2677,7 +2700,7 @@ $util.toJson($ctx.result)",
"DataSourceName": "database_bridge_lambda_ds",
"FieldName": "getItemCounts",
"Kind": "UNIT",
"ResponseMappingTemplate": "## schema checksum : aa02bae16942e48366fa36a1cd643d16
"ResponseMappingTemplate": "## schema checksum : b72f387aabaad7462e0e00a8ab981ffc
$util.toJson($ctx.result)",
"TypeName": "Query",
},
Expand All @@ -2698,7 +2721,7 @@ $util.toJson($ctx.result)",
"DataSourceName": "database_bridge_lambda_ds",
"FieldName": "getMyUser",
"Kind": "UNIT",
"ResponseMappingTemplate": "## schema checksum : aa02bae16942e48366fa36a1cd643d16
"ResponseMappingTemplate": "## schema checksum : b72f387aabaad7462e0e00a8ab981ffc
$util.toJson($ctx.result)",
"TypeName": "Query",
},
Expand All @@ -2719,7 +2742,7 @@ $util.toJson($ctx.result)",
"DataSourceName": "database_bridge_lambda_ds",
"FieldName": "getUsers",
"Kind": "UNIT",
"ResponseMappingTemplate": "## schema checksum : aa02bae16942e48366fa36a1cd643d16
"ResponseMappingTemplate": "## schema checksum : b72f387aabaad7462e0e00a8ab981ffc
$util.toJson($ctx.result)",
"TypeName": "Query",
},
Expand All @@ -2740,7 +2763,7 @@ $util.toJson($ctx.result)",
"DataSourceName": "database_bridge_lambda_ds",
"FieldName": "listItems",
"Kind": "UNIT",
"ResponseMappingTemplate": "## schema checksum : aa02bae16942e48366fa36a1cd643d16
"ResponseMappingTemplate": "## schema checksum : b72f387aabaad7462e0e00a8ab981ffc
$util.toJson($ctx.result)",
"TypeName": "Query",
},
Expand All @@ -2761,7 +2784,7 @@ $util.toJson($ctx.result)",
"DataSourceName": "database_bridge_lambda_ds",
"FieldName": "listLastItemSeenByUsers",
"Kind": "UNIT",
"ResponseMappingTemplate": "## schema checksum : aa02bae16942e48366fa36a1cd643d16
"ResponseMappingTemplate": "## schema checksum : b72f387aabaad7462e0e00a8ab981ffc
$util.toJson($ctx.result)",
"TypeName": "Query",
},
Expand All @@ -2782,7 +2805,7 @@ $util.toJson($ctx.result)",
"DataSourceName": "database_bridge_lambda_ds",
"FieldName": "searchMentionableUsers",
"Kind": "UNIT",
"ResponseMappingTemplate": "## schema checksum : aa02bae16942e48366fa36a1cd643d16
"ResponseMappingTemplate": "## schema checksum : b72f387aabaad7462e0e00a8ab981ffc
$util.toJson($ctx.result)",
"TypeName": "Query",
},
Expand Down Expand Up @@ -2907,7 +2930,7 @@ $util.toJson($ctx.result)",
"DataSourceName": "grid_bridge_lambda_ds",
"FieldName": "asGridPayload",
"Kind": "UNIT",
"ResponseMappingTemplate": "## schema checksum : aa02bae16942e48366fa36a1cd643d16
"ResponseMappingTemplate": "## schema checksum : b72f387aabaad7462e0e00a8ab981ffc
$util.toJson($ctx.result)",
"TypeName": "Query",
},
Expand All @@ -2928,7 +2951,7 @@ $util.toJson($ctx.result)",
"DataSourceName": "grid_bridge_lambda_ds",
"FieldName": "getGridSearchSummary",
"Kind": "UNIT",
"ResponseMappingTemplate": "## schema checksum : aa02bae16942e48366fa36a1cd643d16
"ResponseMappingTemplate": "## schema checksum : b72f387aabaad7462e0e00a8ab981ffc
$util.toJson($ctx.result)",
"TypeName": "Query",
},
Expand Down Expand Up @@ -3053,7 +3076,7 @@ $util.toJson($ctx.result)",
"DataSourceName": "workflow_bridge_lambda_ds",
"FieldName": "getPinboardByComposerId",
"Kind": "UNIT",
"ResponseMappingTemplate": "## schema checksum : aa02bae16942e48366fa36a1cd643d16
"ResponseMappingTemplate": "## schema checksum : b72f387aabaad7462e0e00a8ab981ffc
$util.toJson($ctx.result)",
"TypeName": "Query",
},
Expand All @@ -3074,7 +3097,7 @@ $util.toJson($ctx.result)",
"DataSourceName": "workflow_bridge_lambda_ds",
"FieldName": "getPinboardsByIds",
"Kind": "UNIT",
"ResponseMappingTemplate": "## schema checksum : aa02bae16942e48366fa36a1cd643d16
"ResponseMappingTemplate": "## schema checksum : b72f387aabaad7462e0e00a8ab981ffc
$util.toJson($ctx.result)",
"TypeName": "Query",
},
Expand All @@ -3095,7 +3118,7 @@ $util.toJson($ctx.result)",
"DataSourceName": "workflow_bridge_lambda_ds",
"FieldName": "listPinboards",
"Kind": "UNIT",
"ResponseMappingTemplate": "## schema checksum : aa02bae16942e48366fa36a1cd643d16
"ResponseMappingTemplate": "## schema checksum : b72f387aabaad7462e0e00a8ab981ffc
$util.toJson($ctx.result)",
"TypeName": "Query",
},
Expand Down
9 changes: 9 additions & 0 deletions client/gql.ts
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,7 @@ const itemReturnFields = `
relatedItemId
editHistory
deletedAt
isStarred
`;

// TODO: consider updating the resolver (cdk/stack.ts) to use a Query with a secondary index (if performance degrades when we have lots of items)
Expand Down Expand Up @@ -241,6 +242,14 @@ export const gqlOnClaimItem = (pinboardId: string) => gql`
}
`;

export const gqlSetIsStarred = gql`
mutation SetIsStarred($itemId: String!, $isStarred: Boolean!) {
setIsStarred(itemId: $itemId, isStarred: $isStarred) {
${itemReturnFields}
}
}
`;

const gridBadgeFields = `
text
color
Expand Down
Loading