Add status to invitation
Signed-off-by: Sacha Al Himdani <sacha@getprobo.com>
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
/**
|
||||
* @generated SignedSource<<df47e943d9509dbbe4d7cf9498941171>>
|
||||
* @generated SignedSource<<8c0884f06c22c11239816cecf638ebbd>>
|
||||
* @lightSyntaxTransform
|
||||
* @nogrep
|
||||
*/
|
||||
@@ -489,6 +489,13 @@ return {
|
||||
(v5/*: any*/),
|
||||
(v11/*: any*/),
|
||||
(v12/*: any*/),
|
||||
{
|
||||
"alias": null,
|
||||
"args": null,
|
||||
"kind": "ScalarField",
|
||||
"name": "status",
|
||||
"storageKey": null
|
||||
},
|
||||
{
|
||||
"alias": null,
|
||||
"args": null,
|
||||
@@ -536,12 +543,12 @@ return {
|
||||
]
|
||||
},
|
||||
"params": {
|
||||
"cacheID": "eb300e10b8aec548831c1610ea7bc0ec",
|
||||
"cacheID": "1f03968306005615bd5d2f70342db661",
|
||||
"id": null,
|
||||
"metadata": {},
|
||||
"name": "OrganizationGraph_ViewQuery",
|
||||
"operationKind": "query",
|
||||
"text": "query OrganizationGraph_ViewQuery(\n $organizationId: ID!\n) {\n node(id: $organizationId) {\n __typename\n ... on Organization {\n id\n name\n ...SettingsPageFragment\n ...SettingsPageMembershipsFragment\n ...SettingsPageInvitationsFragment\n }\n id\n }\n}\n\nfragment SettingsPageFragment on Organization {\n id\n name\n logoUrl\n horizontalLogoUrl\n description\n websiteUrl\n email\n headquarterAddress\n customDomain {\n id\n domain\n sslStatus\n dnsRecords {\n type\n name\n value\n ttl\n purpose\n }\n createdAt\n updatedAt\n sslExpiresAt\n }\n createdAt\n updatedAt\n connectors(first: 100) {\n edges {\n node {\n id\n name\n type\n createdAt\n }\n }\n }\n}\n\nfragment SettingsPageInvitationsFragment on Organization {\n invitations(first: 20, orderBy: {direction: ASC, field: CREATED_AT}) {\n totalCount\n edges {\n node {\n id\n email\n fullName\n role\n expiresAt\n acceptedAt\n createdAt\n __typename\n }\n cursor\n }\n pageInfo {\n endCursor\n hasNextPage\n hasPreviousPage\n startCursor\n }\n }\n id\n}\n\nfragment SettingsPageMembershipsFragment on Organization {\n memberships(first: 20, orderBy: {direction: ASC, field: CREATED_AT}) {\n totalCount\n edges {\n node {\n id\n fullName\n emailAddress\n role\n createdAt\n __typename\n }\n cursor\n }\n pageInfo {\n endCursor\n hasNextPage\n hasPreviousPage\n startCursor\n }\n }\n id\n}\n"
|
||||
"text": "query OrganizationGraph_ViewQuery(\n $organizationId: ID!\n) {\n node(id: $organizationId) {\n __typename\n ... on Organization {\n id\n name\n ...SettingsPageFragment\n ...SettingsPageMembershipsFragment\n ...SettingsPageInvitationsFragment\n }\n id\n }\n}\n\nfragment SettingsPageFragment on Organization {\n id\n name\n logoUrl\n horizontalLogoUrl\n description\n websiteUrl\n email\n headquarterAddress\n customDomain {\n id\n domain\n sslStatus\n dnsRecords {\n type\n name\n value\n ttl\n purpose\n }\n createdAt\n updatedAt\n sslExpiresAt\n }\n createdAt\n updatedAt\n connectors(first: 100) {\n edges {\n node {\n id\n name\n type\n createdAt\n }\n }\n }\n}\n\nfragment SettingsPageInvitationsFragment on Organization {\n invitations(first: 20, orderBy: {direction: ASC, field: CREATED_AT}) {\n totalCount\n edges {\n node {\n id\n email\n fullName\n role\n status\n expiresAt\n acceptedAt\n createdAt\n __typename\n }\n cursor\n }\n pageInfo {\n endCursor\n hasNextPage\n hasPreviousPage\n startCursor\n }\n }\n id\n}\n\nfragment SettingsPageMembershipsFragment on Organization {\n memberships(first: 20, orderBy: {direction: ASC, field: CREATED_AT}) {\n totalCount\n edges {\n node {\n id\n fullName\n emailAddress\n role\n createdAt\n __typename\n }\n cursor\n }\n pageInfo {\n endCursor\n hasNextPage\n hasPreviousPage\n startCursor\n }\n }\n id\n}\n"
|
||||
}
|
||||
};
|
||||
})();
|
||||
|
||||
@@ -87,7 +87,7 @@ const OrganizationSelectorFragment = graphql`
|
||||
endCursor
|
||||
}
|
||||
}
|
||||
invitations(first: 1, filter: {onlyPending: true}) {
|
||||
invitations(first: 1, filter: {status: PENDING}) {
|
||||
totalCount
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/**
|
||||
* @generated SignedSource<<7288534d3b5e852c463af820a9001298>>
|
||||
* @generated SignedSource<<dedda437f17ae35a28c1cdc28ed21a62>>
|
||||
* @lightSyntaxTransform
|
||||
* @nogrep
|
||||
*/
|
||||
@@ -215,7 +215,7 @@ return {
|
||||
"kind": "Literal",
|
||||
"name": "filter",
|
||||
"value": {
|
||||
"onlyPending": true
|
||||
"status": "PENDING"
|
||||
}
|
||||
},
|
||||
{
|
||||
@@ -237,7 +237,7 @@ return {
|
||||
"storageKey": null
|
||||
}
|
||||
],
|
||||
"storageKey": "invitations(filter:{\"onlyPending\":true},first:1)"
|
||||
"storageKey": "invitations(filter:{\"status\":\"PENDING\"},first:1)"
|
||||
},
|
||||
(v4/*: any*/)
|
||||
],
|
||||
@@ -246,16 +246,16 @@ return {
|
||||
]
|
||||
},
|
||||
"params": {
|
||||
"cacheID": "77f3fbbca18dda24151bff9901c54626",
|
||||
"cacheID": "dbf01211a1e8b22f1d74fa9c2171231d",
|
||||
"id": null,
|
||||
"metadata": {},
|
||||
"name": "MainLayoutOrganizationSelectorPaginationQuery",
|
||||
"operationKind": "query",
|
||||
"text": "query MainLayoutOrganizationSelectorPaginationQuery(\n $after: CursorKey\n $first: Int = 25\n) {\n viewer {\n ...MainLayout_OrganizationSelector_viewer_2HEEH6\n id\n }\n}\n\nfragment MainLayout_OrganizationSelector_viewer_2HEEH6 on Viewer {\n organizations(first: $first, after: $after, orderBy: {field: NAME, direction: ASC}) {\n edges {\n node {\n id\n name\n logoUrl\n __typename\n }\n cursor\n }\n pageInfo {\n hasNextPage\n endCursor\n }\n }\n invitations(first: 1, filter: {onlyPending: true}) {\n totalCount\n }\n}\n"
|
||||
"text": "query MainLayoutOrganizationSelectorPaginationQuery(\n $after: CursorKey\n $first: Int = 25\n) {\n viewer {\n ...MainLayout_OrganizationSelector_viewer_2HEEH6\n id\n }\n}\n\nfragment MainLayout_OrganizationSelector_viewer_2HEEH6 on Viewer {\n organizations(first: $first, after: $after, orderBy: {field: NAME, direction: ASC}) {\n edges {\n node {\n id\n name\n logoUrl\n __typename\n }\n cursor\n }\n pageInfo {\n hasNextPage\n endCursor\n }\n }\n invitations(first: 1, filter: {status: PENDING}) {\n totalCount\n }\n}\n"
|
||||
}
|
||||
};
|
||||
})();
|
||||
|
||||
(node as any).hash = "99a5cdcce2542bc7fba01d32bbd4648b";
|
||||
(node as any).hash = "d1491a8228d455e2491724c03c7c30c1";
|
||||
|
||||
export default node;
|
||||
|
||||
@@ -27,7 +27,7 @@ const OrganizationsPageQuery = graphql`
|
||||
}
|
||||
}
|
||||
}
|
||||
invitations(first: 1000, orderBy: {field: CREATED_AT, direction: DESC}, filter: {onlyPending: true}) @connection(key: "OrganizationsPage_invitations") {
|
||||
invitations(first: 1000, orderBy: {field: CREATED_AT, direction: DESC}, filter: {status: PENDING}) @connection(key: "OrganizationsPage_invitations") {
|
||||
__id
|
||||
edges {
|
||||
node {
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/**
|
||||
* @generated SignedSource<<c25588b7506704dd23d9c8be8672f9ef>>
|
||||
* @generated SignedSource<<fd6d397e513dc681f055a502fa93a6b4>>
|
||||
* @lightSyntaxTransform
|
||||
* @nogrep
|
||||
*/
|
||||
@@ -162,7 +162,7 @@ v8 = {
|
||||
"kind": "Literal",
|
||||
"name": "filter",
|
||||
"value": {
|
||||
"onlyPending": true
|
||||
"status": "PENDING"
|
||||
}
|
||||
},
|
||||
v9 = {
|
||||
@@ -309,7 +309,7 @@ return {
|
||||
"name": "__OrganizationsPage_invitations_connection",
|
||||
"plural": false,
|
||||
"selections": (v10/*: any*/),
|
||||
"storageKey": "__OrganizationsPage_invitations_connection(filter:{\"onlyPending\":true},orderBy:{\"direction\":\"DESC\",\"field\":\"CREATED_AT\"})"
|
||||
"storageKey": "__OrganizationsPage_invitations_connection(filter:{\"status\":\"PENDING\"},orderBy:{\"direction\":\"DESC\",\"field\":\"CREATED_AT\"})"
|
||||
}
|
||||
],
|
||||
"storageKey": null
|
||||
@@ -361,7 +361,7 @@ return {
|
||||
"name": "invitations",
|
||||
"plural": false,
|
||||
"selections": (v10/*: any*/),
|
||||
"storageKey": "invitations(filter:{\"onlyPending\":true},first:1000,orderBy:{\"direction\":\"DESC\",\"field\":\"CREATED_AT\"})"
|
||||
"storageKey": "invitations(filter:{\"status\":\"PENDING\"},first:1000,orderBy:{\"direction\":\"DESC\",\"field\":\"CREATED_AT\"})"
|
||||
},
|
||||
{
|
||||
"alias": null,
|
||||
@@ -382,7 +382,7 @@ return {
|
||||
]
|
||||
},
|
||||
"params": {
|
||||
"cacheID": "5675b3eb7810ef04bf531d7bf988c86c",
|
||||
"cacheID": "f8cd83b9b7ce0e1b43adc7aec05198bb",
|
||||
"id": null,
|
||||
"metadata": {
|
||||
"connection": [
|
||||
@@ -408,11 +408,11 @@ return {
|
||||
},
|
||||
"name": "OrganizationsPageQuery",
|
||||
"operationKind": "query",
|
||||
"text": "query OrganizationsPageQuery {\n viewer {\n organizations(first: 1000, orderBy: {field: NAME, direction: ASC}) {\n edges {\n node {\n id\n name\n logoUrl\n __typename\n }\n cursor\n }\n pageInfo {\n endCursor\n hasNextPage\n }\n }\n invitations(first: 1000, orderBy: {field: CREATED_AT, direction: DESC}, filter: {onlyPending: true}) {\n edges {\n node {\n id\n email\n fullName\n role\n expiresAt\n acceptedAt\n createdAt\n organization {\n id\n name\n }\n __typename\n }\n cursor\n }\n pageInfo {\n endCursor\n hasNextPage\n }\n }\n id\n }\n}\n"
|
||||
"text": "query OrganizationsPageQuery {\n viewer {\n organizations(first: 1000, orderBy: {field: NAME, direction: ASC}) {\n edges {\n node {\n id\n name\n logoUrl\n __typename\n }\n cursor\n }\n pageInfo {\n endCursor\n hasNextPage\n }\n }\n invitations(first: 1000, orderBy: {field: CREATED_AT, direction: DESC}, filter: {status: PENDING}) {\n edges {\n node {\n id\n email\n fullName\n role\n expiresAt\n acceptedAt\n createdAt\n organization {\n id\n name\n }\n __typename\n }\n cursor\n }\n pageInfo {\n endCursor\n hasNextPage\n }\n }\n id\n }\n}\n"
|
||||
}
|
||||
};
|
||||
})();
|
||||
|
||||
(node as any).hash = "a548f9c3a434e12c079fb2ff651822d2";
|
||||
(node as any).hash = "d1957c93062d07020dc978b0f62bdf41";
|
||||
|
||||
export default node;
|
||||
|
||||
@@ -169,6 +169,7 @@ const paginatedInvitationsFragment = graphql`
|
||||
email
|
||||
fullName
|
||||
role
|
||||
status
|
||||
expiresAt
|
||||
acceptedAt
|
||||
createdAt
|
||||
@@ -836,9 +837,6 @@ function InvitationRow(props: {
|
||||
}
|
||||
);
|
||||
|
||||
const isExpired = new Date() > new Date(props.invitation.expiresAt);
|
||||
const isAccepted = !!props.invitation.acceptedAt;
|
||||
|
||||
const onDelete = () => {
|
||||
confirm(
|
||||
() => {
|
||||
@@ -874,9 +872,9 @@ function InvitationRow(props: {
|
||||
</Td>
|
||||
<Td>{new Date(props.invitation.createdAt).toLocaleDateString()}</Td>
|
||||
<Td>
|
||||
{isAccepted ? (
|
||||
{props.invitation.status === "ACCEPTED" ? (
|
||||
<Badge variant="success">{__("Accepted")}</Badge>
|
||||
) : isExpired ? (
|
||||
) : props.invitation.status === "EXPIRED" ? (
|
||||
<Badge variant="danger">{__("Expired")}</Badge>
|
||||
) : (
|
||||
<Badge variant="warning">{__("Pending")}</Badge>
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/**
|
||||
* @generated SignedSource<<9b6812ed468b85a1d3a8684ed1c3ad6f>>
|
||||
* @generated SignedSource<<33365519d19ebac5b95ae4c54652d49d>>
|
||||
* @lightSyntaxTransform
|
||||
* @nogrep
|
||||
*/
|
||||
@@ -243,6 +243,13 @@ return {
|
||||
"name": "role",
|
||||
"storageKey": null
|
||||
},
|
||||
{
|
||||
"alias": null,
|
||||
"args": null,
|
||||
"kind": "ScalarField",
|
||||
"name": "status",
|
||||
"storageKey": null
|
||||
},
|
||||
{
|
||||
"alias": null,
|
||||
"args": null,
|
||||
@@ -353,16 +360,16 @@ return {
|
||||
]
|
||||
},
|
||||
"params": {
|
||||
"cacheID": "d1ad09b7e16875a4fc09c5e8dc7e3b7e",
|
||||
"cacheID": "0aa692d4815ddc0a17f76209ea0a5c4f",
|
||||
"id": null,
|
||||
"metadata": {},
|
||||
"name": "SettingsInvitationsRefetchQuery",
|
||||
"operationKind": "query",
|
||||
"text": "query SettingsInvitationsRefetchQuery(\n $after: CursorKey = null\n $before: CursorKey = null\n $first: Int = 20\n $last: Int = null\n $order: InvitationOrder = {direction: ASC, field: CREATED_AT}\n $id: ID!\n) {\n node(id: $id) {\n __typename\n ...SettingsPageInvitationsFragment_16fISc\n id\n }\n}\n\nfragment SettingsPageInvitationsFragment_16fISc on Organization {\n invitations(first: $first, after: $after, last: $last, before: $before, orderBy: $order) {\n totalCount\n edges {\n node {\n id\n email\n fullName\n role\n expiresAt\n acceptedAt\n createdAt\n __typename\n }\n cursor\n }\n pageInfo {\n endCursor\n hasNextPage\n hasPreviousPage\n startCursor\n }\n }\n id\n}\n"
|
||||
"text": "query SettingsInvitationsRefetchQuery(\n $after: CursorKey = null\n $before: CursorKey = null\n $first: Int = 20\n $last: Int = null\n $order: InvitationOrder = {direction: ASC, field: CREATED_AT}\n $id: ID!\n) {\n node(id: $id) {\n __typename\n ...SettingsPageInvitationsFragment_16fISc\n id\n }\n}\n\nfragment SettingsPageInvitationsFragment_16fISc on Organization {\n invitations(first: $first, after: $after, last: $last, before: $before, orderBy: $order) {\n totalCount\n edges {\n node {\n id\n email\n fullName\n role\n status\n expiresAt\n acceptedAt\n createdAt\n __typename\n }\n cursor\n }\n pageInfo {\n endCursor\n hasNextPage\n hasPreviousPage\n startCursor\n }\n }\n id\n}\n"
|
||||
}
|
||||
};
|
||||
})();
|
||||
|
||||
(node as any).hash = "d971d93653991efde284ed2b87068698";
|
||||
(node as any).hash = "f9a1ec38579cea21312ba0a20bb7394a";
|
||||
|
||||
export default node;
|
||||
|
||||
@@ -29,14 +29,15 @@ import (
|
||||
|
||||
type (
|
||||
Invitation struct {
|
||||
ID gid.GID `db:"id"`
|
||||
OrganizationID gid.GID `db:"organization_id"`
|
||||
Email string `db:"email"`
|
||||
FullName string `db:"full_name"`
|
||||
Role string `db:"role"`
|
||||
ExpiresAt time.Time `db:"expires_at"`
|
||||
AcceptedAt *time.Time `db:"accepted_at"`
|
||||
CreatedAt time.Time `db:"created_at"`
|
||||
ID gid.GID `db:"id"`
|
||||
OrganizationID gid.GID `db:"organization_id"`
|
||||
Email string `db:"email"`
|
||||
FullName string `db:"full_name"`
|
||||
Role string `db:"role"`
|
||||
Status InvitationStatus `db:"status"`
|
||||
ExpiresAt time.Time `db:"expires_at"`
|
||||
AcceptedAt *time.Time `db:"accepted_at"`
|
||||
CreatedAt time.Time `db:"created_at"`
|
||||
}
|
||||
|
||||
Invitations []*Invitation
|
||||
@@ -116,7 +117,20 @@ func (i *Invitation) LoadByID(
|
||||
id gid.GID,
|
||||
) error {
|
||||
query := `
|
||||
SELECT id, organization_id, email, full_name, role, expires_at, accepted_at, created_at
|
||||
SELECT
|
||||
id,
|
||||
organization_id,
|
||||
email,
|
||||
full_name,
|
||||
role,
|
||||
CASE
|
||||
WHEN accepted_at IS NOT NULL THEN 'ACCEPTED'
|
||||
WHEN expires_at < NOW() THEN 'EXPIRED'
|
||||
ELSE 'PENDING'
|
||||
END as status,
|
||||
expires_at,
|
||||
accepted_at,
|
||||
created_at
|
||||
FROM authz_invitations
|
||||
WHERE id = @id AND %s
|
||||
`
|
||||
@@ -207,7 +221,20 @@ func (i *Invitations) LoadByEmail(
|
||||
filter *InvitationFilter,
|
||||
) error {
|
||||
query := `
|
||||
SELECT id, organization_id, email, full_name, role, expires_at, accepted_at, created_at
|
||||
SELECT
|
||||
id,
|
||||
organization_id,
|
||||
email,
|
||||
full_name,
|
||||
role,
|
||||
CASE
|
||||
WHEN accepted_at IS NOT NULL THEN 'ACCEPTED'
|
||||
WHEN expires_at < NOW() THEN 'EXPIRED'
|
||||
ELSE 'PENDING'
|
||||
END as status,
|
||||
expires_at,
|
||||
accepted_at,
|
||||
created_at
|
||||
FROM authz_invitations
|
||||
WHERE email = @email
|
||||
AND %s
|
||||
@@ -244,7 +271,20 @@ func (i *Invitations) LoadByOrganizationID(
|
||||
cursor *page.Cursor[InvitationOrderField],
|
||||
) error {
|
||||
query := `
|
||||
SELECT id, organization_id, email, full_name, role, expires_at, accepted_at, created_at
|
||||
SELECT
|
||||
id,
|
||||
organization_id,
|
||||
email,
|
||||
full_name,
|
||||
role,
|
||||
CASE
|
||||
WHEN accepted_at IS NOT NULL THEN 'ACCEPTED'
|
||||
WHEN expires_at < NOW() THEN 'EXPIRED'
|
||||
ELSE 'PENDING'
|
||||
END as status,
|
||||
expires_at,
|
||||
accepted_at,
|
||||
created_at
|
||||
FROM authz_invitations
|
||||
WHERE organization_id = @organization_id AND %s
|
||||
AND %s
|
||||
|
||||
@@ -20,19 +20,19 @@ import (
|
||||
|
||||
type (
|
||||
InvitationFilter struct {
|
||||
onlyPending *bool
|
||||
status *InvitationStatus
|
||||
}
|
||||
)
|
||||
|
||||
func NewInvitationFilter(onlyPending *bool) *InvitationFilter {
|
||||
func NewInvitationFilter(status *InvitationStatus) *InvitationFilter {
|
||||
return &InvitationFilter{
|
||||
onlyPending: onlyPending,
|
||||
status: status,
|
||||
}
|
||||
}
|
||||
|
||||
func (f *InvitationFilter) SQLArguments() pgx.NamedArgs {
|
||||
return pgx.NamedArgs{
|
||||
"only_pending": f.onlyPending,
|
||||
"status": f.status,
|
||||
}
|
||||
}
|
||||
|
||||
@@ -40,10 +40,13 @@ func (f *InvitationFilter) SQLFragment() string {
|
||||
return `
|
||||
(
|
||||
CASE
|
||||
WHEN @only_pending::boolean IS NOT NULL AND @only_pending::boolean = true THEN
|
||||
(accepted_at IS NULL AND expires_at > NOW())
|
||||
WHEN @status::text IS NOT NULL THEN
|
||||
(CASE
|
||||
WHEN accepted_at IS NOT NULL THEN 'ACCEPTED'
|
||||
WHEN expires_at < NOW() THEN 'EXPIRED'
|
||||
ELSE 'PENDING'
|
||||
END) = @status::text
|
||||
ELSE TRUE
|
||||
END
|
||||
)`
|
||||
}
|
||||
|
||||
|
||||
60
pkg/coredata/invitation_status.go
Normal file
60
pkg/coredata/invitation_status.go
Normal file
@@ -0,0 +1,60 @@
|
||||
// Copyright (c) 2025 Probo Inc <hello@getprobo.com>.
|
||||
//
|
||||
// Permission to use, copy, modify, and/or distribute this software for any
|
||||
// purpose with or without fee is hereby granted, provided that the above
|
||||
// copyright notice and this permission notice appear in all copies.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
|
||||
// REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
|
||||
// AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
|
||||
// INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
|
||||
// LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
|
||||
// OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
|
||||
// PERFORMANCE OF THIS SOFTWARE.
|
||||
|
||||
package coredata
|
||||
|
||||
import (
|
||||
"database/sql/driver"
|
||||
"fmt"
|
||||
)
|
||||
|
||||
type InvitationStatus string
|
||||
|
||||
const (
|
||||
InvitationStatusPending InvitationStatus = "PENDING"
|
||||
InvitationStatusAccepted InvitationStatus = "ACCEPTED"
|
||||
InvitationStatusExpired InvitationStatus = "EXPIRED"
|
||||
)
|
||||
|
||||
func (tcv InvitationStatus) String() string {
|
||||
return string(tcv)
|
||||
}
|
||||
|
||||
func (tcv *InvitationStatus) Scan(value any) error {
|
||||
var s string
|
||||
switch v := value.(type) {
|
||||
case string:
|
||||
s = v
|
||||
case []byte:
|
||||
s = string(v)
|
||||
default:
|
||||
return fmt.Errorf("unsupported type for TrustCenterVisibility: %T", value)
|
||||
}
|
||||
|
||||
switch s {
|
||||
case "PENDING":
|
||||
*tcv = InvitationStatusPending
|
||||
case "ACCEPTED":
|
||||
*tcv = InvitationStatusAccepted
|
||||
case "EXPIRED":
|
||||
*tcv = InvitationStatusExpired
|
||||
default:
|
||||
return fmt.Errorf("invalid InvitationStatus value: %q", s)
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func (tcv InvitationStatus) Value() (driver.Value, error) {
|
||||
return tcv.String(), nil
|
||||
}
|
||||
@@ -92,6 +92,16 @@ enum PeopleKind
|
||||
)
|
||||
}
|
||||
|
||||
enum InvitationStatus
|
||||
@goModel(model: "github.com/getprobo/probo/pkg/coredata.InvitationStatus") {
|
||||
PENDING
|
||||
@goEnum(value: "github.com/getprobo/probo/pkg/coredata.InvitationStatusPending")
|
||||
ACCEPTED
|
||||
@goEnum(value: "github.com/getprobo/probo/pkg/coredata.InvitationStatusAccepted")
|
||||
EXPIRED
|
||||
@goEnum(value: "github.com/getprobo/probo/pkg/coredata.InvitationStatusExpired")
|
||||
}
|
||||
|
||||
enum DocumentStatus
|
||||
@goModel(model: "github.com/getprobo/probo/pkg/coredata.DocumentStatus") {
|
||||
DRAFT
|
||||
@@ -1466,7 +1476,7 @@ input InvitationOrder {
|
||||
}
|
||||
|
||||
input InvitationFilter {
|
||||
onlyPending: Boolean
|
||||
status: InvitationStatus
|
||||
}
|
||||
|
||||
input DocumentVersionFilter {
|
||||
@@ -1759,6 +1769,7 @@ type Invitation implements Node {
|
||||
email: String!
|
||||
fullName: String!
|
||||
role: String!
|
||||
status: InvitationStatus!
|
||||
expiresAt: Datetime!
|
||||
acceptedAt: Datetime
|
||||
createdAt: Datetime!
|
||||
|
||||
@@ -771,6 +771,7 @@ type ComplexityRoot struct {
|
||||
ID func(childComplexity int) int
|
||||
Organization func(childComplexity int) int
|
||||
Role func(childComplexity int) int
|
||||
Status func(childComplexity int) int
|
||||
}
|
||||
|
||||
InvitationConnection struct {
|
||||
@@ -4171,6 +4172,13 @@ func (e *executableSchema) Complexity(ctx context.Context, typeName, field strin
|
||||
|
||||
return e.complexity.Invitation.Role(childComplexity), true
|
||||
|
||||
case "Invitation.status":
|
||||
if e.complexity.Invitation.Status == nil {
|
||||
break
|
||||
}
|
||||
|
||||
return e.complexity.Invitation.Status(childComplexity), true
|
||||
|
||||
case "InvitationConnection.edges":
|
||||
if e.complexity.InvitationConnection.Edges == nil {
|
||||
break
|
||||
@@ -9134,6 +9142,16 @@ enum PeopleKind
|
||||
)
|
||||
}
|
||||
|
||||
enum InvitationStatus
|
||||
@goModel(model: "github.com/getprobo/probo/pkg/coredata.InvitationStatus") {
|
||||
PENDING
|
||||
@goEnum(value: "github.com/getprobo/probo/pkg/coredata.InvitationStatusPending")
|
||||
ACCEPTED
|
||||
@goEnum(value: "github.com/getprobo/probo/pkg/coredata.InvitationStatusAccepted")
|
||||
EXPIRED
|
||||
@goEnum(value: "github.com/getprobo/probo/pkg/coredata.InvitationStatusExpired")
|
||||
}
|
||||
|
||||
enum DocumentStatus
|
||||
@goModel(model: "github.com/getprobo/probo/pkg/coredata.DocumentStatus") {
|
||||
DRAFT
|
||||
@@ -10508,7 +10526,7 @@ input InvitationOrder {
|
||||
}
|
||||
|
||||
input InvitationFilter {
|
||||
onlyPending: Boolean
|
||||
status: InvitationStatus
|
||||
}
|
||||
|
||||
input DocumentVersionFilter {
|
||||
@@ -10801,6 +10819,7 @@ type Invitation implements Node {
|
||||
email: String!
|
||||
fullName: String!
|
||||
role: String!
|
||||
status: InvitationStatus!
|
||||
expiresAt: Datetime!
|
||||
acceptedAt: Datetime
|
||||
createdAt: Datetime!
|
||||
@@ -21778,6 +21797,8 @@ func (ec *executionContext) fieldContext_AcceptInvitationPayload_invitation(_ co
|
||||
return ec.fieldContext_Invitation_fullName(ctx, field)
|
||||
case "role":
|
||||
return ec.fieldContext_Invitation_role(ctx, field)
|
||||
case "status":
|
||||
return ec.fieldContext_Invitation_status(ctx, field)
|
||||
case "expiresAt":
|
||||
return ec.fieldContext_Invitation_expiresAt(ctx, field)
|
||||
case "acceptedAt":
|
||||
@@ -36420,6 +36441,50 @@ func (ec *executionContext) fieldContext_Invitation_role(_ context.Context, fiel
|
||||
return fc, nil
|
||||
}
|
||||
|
||||
func (ec *executionContext) _Invitation_status(ctx context.Context, field graphql.CollectedField, obj *types.Invitation) (ret graphql.Marshaler) {
|
||||
fc, err := ec.fieldContext_Invitation_status(ctx, field)
|
||||
if err != nil {
|
||||
return graphql.Null
|
||||
}
|
||||
ctx = graphql.WithFieldContext(ctx, fc)
|
||||
defer func() {
|
||||
if r := recover(); r != nil {
|
||||
ec.Error(ctx, ec.Recover(ctx, r))
|
||||
ret = graphql.Null
|
||||
}
|
||||
}()
|
||||
resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (any, error) {
|
||||
ctx = rctx // use context from middleware stack in children
|
||||
return obj.Status, nil
|
||||
})
|
||||
if err != nil {
|
||||
ec.Error(ctx, err)
|
||||
return graphql.Null
|
||||
}
|
||||
if resTmp == nil {
|
||||
if !graphql.HasFieldError(ctx, fc) {
|
||||
ec.Errorf(ctx, "must not be null")
|
||||
}
|
||||
return graphql.Null
|
||||
}
|
||||
res := resTmp.(coredata.InvitationStatus)
|
||||
fc.Result = res
|
||||
return ec.marshalNInvitationStatus2githubᚗcomᚋgetproboᚋproboᚋpkgᚋcoredataᚐInvitationStatus(ctx, field.Selections, res)
|
||||
}
|
||||
|
||||
func (ec *executionContext) fieldContext_Invitation_status(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) {
|
||||
fc = &graphql.FieldContext{
|
||||
Object: "Invitation",
|
||||
Field: field,
|
||||
IsMethod: false,
|
||||
IsResolver: false,
|
||||
Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) {
|
||||
return nil, errors.New("field of type InvitationStatus does not have child fields")
|
||||
},
|
||||
}
|
||||
return fc, nil
|
||||
}
|
||||
|
||||
func (ec *executionContext) _Invitation_expiresAt(ctx context.Context, field graphql.CollectedField, obj *types.Invitation) (ret graphql.Marshaler) {
|
||||
fc, err := ec.fieldContext_Invitation_expiresAt(ctx, field)
|
||||
if err != nil {
|
||||
@@ -36896,6 +36961,8 @@ func (ec *executionContext) fieldContext_InvitationEdge_node(_ context.Context,
|
||||
return ec.fieldContext_Invitation_fullName(ctx, field)
|
||||
case "role":
|
||||
return ec.fieldContext_Invitation_role(ctx, field)
|
||||
case "status":
|
||||
return ec.fieldContext_Invitation_status(ctx, field)
|
||||
case "expiresAt":
|
||||
return ec.fieldContext_Invitation_expiresAt(ctx, field)
|
||||
case "acceptedAt":
|
||||
@@ -72048,20 +72115,20 @@ func (ec *executionContext) unmarshalInputInvitationFilter(ctx context.Context,
|
||||
asMap[k] = v
|
||||
}
|
||||
|
||||
fieldsInOrder := [...]string{"onlyPending"}
|
||||
fieldsInOrder := [...]string{"status"}
|
||||
for _, k := range fieldsInOrder {
|
||||
v, ok := asMap[k]
|
||||
if !ok {
|
||||
continue
|
||||
}
|
||||
switch k {
|
||||
case "onlyPending":
|
||||
ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("onlyPending"))
|
||||
data, err := ec.unmarshalOBoolean2ᚖbool(ctx, v)
|
||||
case "status":
|
||||
ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("status"))
|
||||
data, err := ec.unmarshalOInvitationStatus2ᚖgithubᚗcomᚋgetproboᚋproboᚋpkgᚋcoredataᚐInvitationStatus(ctx, v)
|
||||
if err != nil {
|
||||
return it, err
|
||||
}
|
||||
it.OnlyPending = data
|
||||
it.Status = data
|
||||
}
|
||||
}
|
||||
|
||||
@@ -82256,6 +82323,11 @@ func (ec *executionContext) _Invitation(ctx context.Context, sel ast.SelectionSe
|
||||
if out.Values[i] == graphql.Null {
|
||||
atomic.AddUint32(&out.Invalids, 1)
|
||||
}
|
||||
case "status":
|
||||
out.Values[i] = ec._Invitation_status(ctx, field, obj)
|
||||
if out.Values[i] == graphql.Null {
|
||||
atomic.AddUint32(&out.Invalids, 1)
|
||||
}
|
||||
case "expiresAt":
|
||||
out.Values[i] = ec._Invitation_expiresAt(ctx, field, obj)
|
||||
if out.Values[i] == graphql.Null {
|
||||
@@ -96418,6 +96490,36 @@ var (
|
||||
}
|
||||
)
|
||||
|
||||
func (ec *executionContext) unmarshalNInvitationStatus2githubᚗcomᚋgetproboᚋproboᚋpkgᚋcoredataᚐInvitationStatus(ctx context.Context, v any) (coredata.InvitationStatus, error) {
|
||||
tmp, err := graphql.UnmarshalString(v)
|
||||
res := unmarshalNInvitationStatus2githubᚗcomᚋgetproboᚋproboᚋpkgᚋcoredataᚐInvitationStatus[tmp]
|
||||
return res, graphql.ErrorOnPath(ctx, err)
|
||||
}
|
||||
|
||||
func (ec *executionContext) marshalNInvitationStatus2githubᚗcomᚋgetproboᚋproboᚋpkgᚋcoredataᚐInvitationStatus(ctx context.Context, sel ast.SelectionSet, v coredata.InvitationStatus) graphql.Marshaler {
|
||||
_ = sel
|
||||
res := graphql.MarshalString(marshalNInvitationStatus2githubᚗcomᚋgetproboᚋproboᚋpkgᚋcoredataᚐInvitationStatus[v])
|
||||
if res == graphql.Null {
|
||||
if !graphql.HasFieldError(ctx, graphql.GetFieldContext(ctx)) {
|
||||
ec.Errorf(ctx, "the requested element is null which the schema does not allow")
|
||||
}
|
||||
}
|
||||
return res
|
||||
}
|
||||
|
||||
var (
|
||||
unmarshalNInvitationStatus2githubᚗcomᚋgetproboᚋproboᚋpkgᚋcoredataᚐInvitationStatus = map[string]coredata.InvitationStatus{
|
||||
"PENDING": coredata.InvitationStatusPending,
|
||||
"ACCEPTED": coredata.InvitationStatusAccepted,
|
||||
"EXPIRED": coredata.InvitationStatusExpired,
|
||||
}
|
||||
marshalNInvitationStatus2githubᚗcomᚋgetproboᚋproboᚋpkgᚋcoredataᚐInvitationStatus = map[coredata.InvitationStatus]string{
|
||||
coredata.InvitationStatusPending: "PENDING",
|
||||
coredata.InvitationStatusAccepted: "ACCEPTED",
|
||||
coredata.InvitationStatusExpired: "EXPIRED",
|
||||
}
|
||||
)
|
||||
|
||||
func (ec *executionContext) unmarshalNInviteUserInput2githubᚗcomᚋgetproboᚋproboᚋpkgᚋserverᚋapiᚋconsoleᚋv1ᚋtypesᚐInviteUserInput(ctx context.Context, v any) (types.InviteUserInput, error) {
|
||||
res, err := ec.unmarshalInputInviteUserInput(ctx, v)
|
||||
return res, graphql.ErrorOnPath(ctx, err)
|
||||
@@ -101250,6 +101352,38 @@ func (ec *executionContext) unmarshalOInvitationOrder2ᚖgithubᚗcomᚋgetprobo
|
||||
return &res, graphql.ErrorOnPath(ctx, err)
|
||||
}
|
||||
|
||||
func (ec *executionContext) unmarshalOInvitationStatus2ᚖgithubᚗcomᚋgetproboᚋproboᚋpkgᚋcoredataᚐInvitationStatus(ctx context.Context, v any) (*coredata.InvitationStatus, error) {
|
||||
if v == nil {
|
||||
return nil, nil
|
||||
}
|
||||
tmp, err := graphql.UnmarshalString(v)
|
||||
res := unmarshalOInvitationStatus2ᚖgithubᚗcomᚋgetproboᚋproboᚋpkgᚋcoredataᚐInvitationStatus[tmp]
|
||||
return &res, graphql.ErrorOnPath(ctx, err)
|
||||
}
|
||||
|
||||
func (ec *executionContext) marshalOInvitationStatus2ᚖgithubᚗcomᚋgetproboᚋproboᚋpkgᚋcoredataᚐInvitationStatus(ctx context.Context, sel ast.SelectionSet, v *coredata.InvitationStatus) graphql.Marshaler {
|
||||
if v == nil {
|
||||
return graphql.Null
|
||||
}
|
||||
_ = sel
|
||||
_ = ctx
|
||||
res := graphql.MarshalString(marshalOInvitationStatus2ᚖgithubᚗcomᚋgetproboᚋproboᚋpkgᚋcoredataᚐInvitationStatus[*v])
|
||||
return res
|
||||
}
|
||||
|
||||
var (
|
||||
unmarshalOInvitationStatus2ᚖgithubᚗcomᚋgetproboᚋproboᚋpkgᚋcoredataᚐInvitationStatus = map[string]coredata.InvitationStatus{
|
||||
"PENDING": coredata.InvitationStatusPending,
|
||||
"ACCEPTED": coredata.InvitationStatusAccepted,
|
||||
"EXPIRED": coredata.InvitationStatusExpired,
|
||||
}
|
||||
marshalOInvitationStatus2ᚖgithubᚗcomᚋgetproboᚋproboᚋpkgᚋcoredataᚐInvitationStatus = map[coredata.InvitationStatus]string{
|
||||
coredata.InvitationStatusPending: "PENDING",
|
||||
coredata.InvitationStatusAccepted: "ACCEPTED",
|
||||
coredata.InvitationStatusExpired: "EXPIRED",
|
||||
}
|
||||
)
|
||||
|
||||
func (ec *executionContext) marshalOMeasure2ᚖgithubᚗcomᚋgetproboᚋproboᚋpkgᚋserverᚋapiᚋconsoleᚋv1ᚋtypesᚐMeasure(ctx context.Context, sel ast.SelectionSet, v *types.Measure) graphql.Marshaler {
|
||||
if v == nil {
|
||||
return graphql.Null
|
||||
|
||||
@@ -1208,14 +1208,15 @@ type ImportMeasurePayload struct {
|
||||
}
|
||||
|
||||
type Invitation struct {
|
||||
ID gid.GID `json:"id"`
|
||||
Email string `json:"email"`
|
||||
FullName string `json:"fullName"`
|
||||
Role string `json:"role"`
|
||||
ExpiresAt time.Time `json:"expiresAt"`
|
||||
AcceptedAt *time.Time `json:"acceptedAt,omitempty"`
|
||||
CreatedAt time.Time `json:"createdAt"`
|
||||
Organization *Organization `json:"organization"`
|
||||
ID gid.GID `json:"id"`
|
||||
Email string `json:"email"`
|
||||
FullName string `json:"fullName"`
|
||||
Role string `json:"role"`
|
||||
Status coredata.InvitationStatus `json:"status"`
|
||||
ExpiresAt time.Time `json:"expiresAt"`
|
||||
AcceptedAt *time.Time `json:"acceptedAt,omitempty"`
|
||||
CreatedAt time.Time `json:"createdAt"`
|
||||
Organization *Organization `json:"organization"`
|
||||
}
|
||||
|
||||
func (Invitation) IsNode() {}
|
||||
@@ -1227,7 +1228,7 @@ type InvitationEdge struct {
|
||||
}
|
||||
|
||||
type InvitationFilter struct {
|
||||
OnlyPending *bool `json:"onlyPending,omitempty"`
|
||||
Status *coredata.InvitationStatus `json:"status,omitempty"`
|
||||
}
|
||||
|
||||
type InvitationOrder struct {
|
||||
|
||||
@@ -919,7 +919,7 @@ func (r *invitationConnectionResolver) TotalCount(ctx context.Context, obj *type
|
||||
|
||||
invitationFilter := coredata.NewInvitationFilter(nil)
|
||||
if obj.Filter != nil {
|
||||
invitationFilter = coredata.NewInvitationFilter(obj.Filter.OnlyPending)
|
||||
invitationFilter = coredata.NewInvitationFilter(obj.Filter.Status)
|
||||
}
|
||||
|
||||
count, err := r.authzSvc.CountUserInvitations(ctx, user.EmailAddress, invitationFilter)
|
||||
@@ -5353,7 +5353,7 @@ func (r *viewerResolver) Invitations(ctx context.Context, obj *types.Viewer, fir
|
||||
|
||||
invitationFilter := coredata.NewInvitationFilter(nil)
|
||||
if filter != nil {
|
||||
invitationFilter = coredata.NewInvitationFilter(filter.OnlyPending)
|
||||
invitationFilter = coredata.NewInvitationFilter(filter.Status)
|
||||
}
|
||||
|
||||
invitations, err := r.authzSvc.GetUserInvitations(ctx, user.EmailAddress, cursor, invitationFilter)
|
||||
|
||||
Reference in New Issue
Block a user