diff --git a/frontend/src/components/CompatSessionList.tsx b/frontend/src/components/CompatSessionList.tsx deleted file mode 100644 index 96c7a9e5..00000000 --- a/frontend/src/components/CompatSessionList.tsx +++ /dev/null @@ -1,158 +0,0 @@ -// Copyright 2022 The Matrix.org Foundation C.I.C. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -import { atom, useAtom, useAtomValue, useSetAtom } from "jotai"; -import { atomFamily } from "jotai/utils"; -import { atomWithQuery } from "jotai-urql"; -import { useTransition } from "react"; - -import { mapQueryAtom } from "../atoms"; -import { graphql } from "../gql"; -import { SessionState, PageInfo } from "../gql/graphql"; -import { - atomForCurrentPagination, - atomWithPagination, - FIRST_PAGE, - Pagination, -} from "../pagination"; -import { isOk, unwrap, unwrapOk } from "../result"; - -import BlockList from "./BlockList"; -import CompatSession from "./CompatSession"; -import PaginationControls from "./PaginationControls"; -import { Title } from "./Typography"; - -const QUERY = graphql(/* GraphQL */ ` - query CompatSessionList( - $userId: ID! - $state: SessionState - $first: Int - $after: String - $last: Int - $before: String - ) { - user(id: $userId) { - id - compatSessions( - first: $first - after: $after - last: $last - before: $before - state: $state - ) { - edges { - node { - id - ...CompatSession_session - } - } - - totalCount - pageInfo { - hasNextPage - hasPreviousPage - startCursor - endCursor - } - } - } - } -`); - -const currentPaginationAtom = atomForCurrentPagination(); -const filterAtom = atom(SessionState.Active); - -const compatSessionListFamily = atomFamily((userId: string) => { - const compatSessionListQuery = atomWithQuery({ - query: QUERY, - getVariables: (get) => ({ - userId, - state: get(filterAtom), - ...get(currentPaginationAtom), - }), - }); - - const compatSessionList = mapQueryAtom( - compatSessionListQuery, - (data) => data.user?.compatSessions || null, - ); - - return compatSessionList; -}); - -const pageInfoFamily = atomFamily((userId: string) => { - const pageInfoAtom = atom(async (get): Promise => { - const result = await get(compatSessionListFamily(userId)); - return (isOk(result) && unwrapOk(result)?.pageInfo) || null; - }); - - return pageInfoAtom; -}); - -const paginationFamily = atomFamily((userId: string) => { - const paginationAtom = atomWithPagination( - currentPaginationAtom, - pageInfoFamily(userId), - ); - return paginationAtom; -}); - -const CompatSessionList: React.FC<{ userId: string }> = ({ userId }) => { - const [pending, startTransition] = useTransition(); - const result = useAtomValue(compatSessionListFamily(userId)); - const setPagination = useSetAtom(currentPaginationAtom); - const [prevPage, nextPage] = useAtomValue(paginationFamily(userId)); - const [filter, setFilter] = useAtom(filterAtom); - - const compatSessionList = unwrap(result); - if (compatSessionList === null) return <>Failed to load sessions.; - - const paginate = (pagination: Pagination): void => { - startTransition(() => { - setPagination(pagination); - }); - }; - - const toggleFilter = (): void => { - startTransition(() => { - setPagination(FIRST_PAGE); - setFilter(filter === SessionState.Active ? null : SessionState.Active); - }); - }; - - return ( - - Regular apps - - paginate(prevPage) : null} - onNext={nextPage ? (): void => paginate(nextPage) : null} - count={compatSessionList.totalCount} - disabled={pending} - /> - {compatSessionList.edges.map((n) => ( - - ))} - - ); -}; - -export default CompatSessionList; diff --git a/frontend/src/components/OAuth2SessionList.tsx b/frontend/src/components/OAuth2SessionList.tsx deleted file mode 100644 index 9503acfa..00000000 --- a/frontend/src/components/OAuth2SessionList.tsx +++ /dev/null @@ -1,163 +0,0 @@ -// Copyright 2022 The Matrix.org Foundation C.I.C. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -import { atom, useAtom, useAtomValue, useSetAtom } from "jotai"; -import { atomFamily } from "jotai/utils"; -import { atomWithQuery } from "jotai-urql"; -import { useTransition } from "react"; - -import { mapQueryAtom } from "../atoms"; -import { graphql } from "../gql"; -import { SessionState, PageInfo } from "../gql/graphql"; -import { - atomForCurrentPagination, - atomWithPagination, - FIRST_PAGE, - Pagination, -} from "../pagination"; -import { isOk, unwrap, unwrapOk } from "../result"; - -import BlockList from "./BlockList"; -import OAuth2Session from "./OAuth2Session"; -import PaginationControls from "./PaginationControls"; -import { Title } from "./Typography"; - -const QUERY = graphql(/* GraphQL */ ` - query OAuth2SessionListQuery( - $userId: ID! - $state: SessionState - $first: Int - $after: String - $last: Int - $before: String - ) { - user(id: $userId) { - id - oauth2Sessions( - state: $state - first: $first - after: $after - last: $last - before: $before - ) { - edges { - cursor - node { - id - ...OAuth2Session_session - } - } - - totalCount - pageInfo { - hasNextPage - hasPreviousPage - startCursor - endCursor - } - } - } - } -`); - -const currentPaginationAtom = atomForCurrentPagination(); -const filterAtom = atom(SessionState.Active); - -const oauth2SessionListFamily = atomFamily((userId: string) => { - const oauth2SessionListQuery = atomWithQuery({ - query: QUERY, - getVariables: (get) => ({ - userId, - state: get(filterAtom), - ...get(currentPaginationAtom), - }), - }); - - const oauth2SessionList = mapQueryAtom( - oauth2SessionListQuery, - (data) => data.user?.oauth2Sessions || null, - ); - - return oauth2SessionList; -}); - -const pageInfoFamily = atomFamily((userId: string) => { - const pageInfoAtom = atom(async (get): Promise => { - const result = await get(oauth2SessionListFamily(userId)); - return (isOk(result) && unwrapOk(result)?.pageInfo) || null; - }); - - return pageInfoAtom; -}); - -const paginationFamily = atomFamily((userId: string) => { - const paginationAtom = atomWithPagination( - currentPaginationAtom, - pageInfoFamily(userId), - ); - return paginationAtom; -}); - -type Props = { - userId: string; -}; - -const OAuth2SessionList: React.FC = ({ userId }) => { - const [pending, startTransition] = useTransition(); - const result = useAtomValue(oauth2SessionListFamily(userId)); - const setPagination = useSetAtom(currentPaginationAtom); - const [prevPage, nextPage] = useAtomValue(paginationFamily(userId)); - const [filter, setFilter] = useAtom(filterAtom); - - const oauth2Sessions = unwrap(result); - if (oauth2Sessions === null) return <>Failed to load sessions.; - - const paginate = (pagination: Pagination): void => { - startTransition(() => { - setPagination(pagination); - }); - }; - - const toggleFilter = (): void => { - startTransition(() => { - setPagination(FIRST_PAGE); - setFilter(filter === SessionState.Active ? null : SessionState.Active); - }); - }; - - return ( - - New apps: - - paginate(prevPage) : null} - onNext={nextPage ? (): void => paginate(nextPage) : null} - count={oauth2Sessions.totalCount} - disabled={pending} - /> - {oauth2Sessions.edges.map((n) => ( - - ))} - - ); -}; - -export default OAuth2SessionList; diff --git a/frontend/src/gql/gql.ts b/frontend/src/gql/gql.ts index 0c26edcf..7ec36255 100644 --- a/frontend/src/gql/gql.ts +++ b/frontend/src/gql/gql.ts @@ -29,14 +29,10 @@ const documents = { types.CompatSession_SessionFragmentDoc, "\n mutation EndCompatSession($id: ID!) {\n endCompatSession(input: { compatSessionId: $id }) {\n status\n compatSession {\n id\n finishedAt\n }\n }\n }\n": types.EndCompatSessionDocument, - "\n query CompatSessionList(\n $userId: ID!\n $state: SessionState\n $first: Int\n $after: String\n $last: Int\n $before: String\n ) {\n user(id: $userId) {\n id\n compatSessions(\n first: $first\n after: $after\n last: $last\n before: $before\n state: $state\n ) {\n edges {\n node {\n id\n ...CompatSession_session\n }\n }\n\n totalCount\n pageInfo {\n hasNextPage\n hasPreviousPage\n startCursor\n endCursor\n }\n }\n }\n }\n": - types.CompatSessionListDocument, "\n fragment OAuth2Session_session on Oauth2Session {\n id\n scope\n createdAt\n finishedAt\n client {\n id\n clientId\n clientName\n clientUri\n logoUri\n }\n }\n": types.OAuth2Session_SessionFragmentDoc, "\n mutation EndOAuth2Session($id: ID!) {\n endOauth2Session(input: { oauth2SessionId: $id }) {\n status\n oauth2Session {\n id\n ...OAuth2Session_session\n }\n }\n }\n": types.EndOAuth2SessionDocument, - "\n query OAuth2SessionListQuery(\n $userId: ID!\n $state: SessionState\n $first: Int\n $after: String\n $last: Int\n $before: String\n ) {\n user(id: $userId) {\n id\n oauth2Sessions(\n state: $state\n first: $first\n after: $after\n last: $last\n before: $before\n ) {\n edges {\n cursor\n node {\n id\n ...OAuth2Session_session\n }\n }\n\n totalCount\n pageInfo {\n hasNextPage\n hasPreviousPage\n startCursor\n endCursor\n }\n }\n }\n }\n": - types.OAuth2SessionListQueryDocument, "\n query SessionQuery($userId: ID!, $deviceId: String!) {\n session(userId: $userId, deviceId: $deviceId) {\n __typename\n ...CompatSession_session\n ...OAuth2Session_session\n }\n }\n": types.SessionQueryDocument, "\n fragment UnverifiedEmailAlert on User {\n id\n unverifiedEmails: emails(first: 0, state: PENDING) {\n totalCount\n }\n }\n": @@ -141,12 +137,6 @@ export function graphql( export function graphql( source: "\n mutation EndCompatSession($id: ID!) {\n endCompatSession(input: { compatSessionId: $id }) {\n status\n compatSession {\n id\n finishedAt\n }\n }\n }\n", ): (typeof documents)["\n mutation EndCompatSession($id: ID!) {\n endCompatSession(input: { compatSessionId: $id }) {\n status\n compatSession {\n id\n finishedAt\n }\n }\n }\n"]; -/** - * The graphql function is used to parse GraphQL queries into a document that can be used by GraphQL clients. - */ -export function graphql( - source: "\n query CompatSessionList(\n $userId: ID!\n $state: SessionState\n $first: Int\n $after: String\n $last: Int\n $before: String\n ) {\n user(id: $userId) {\n id\n compatSessions(\n first: $first\n after: $after\n last: $last\n before: $before\n state: $state\n ) {\n edges {\n node {\n id\n ...CompatSession_session\n }\n }\n\n totalCount\n pageInfo {\n hasNextPage\n hasPreviousPage\n startCursor\n endCursor\n }\n }\n }\n }\n", -): (typeof documents)["\n query CompatSessionList(\n $userId: ID!\n $state: SessionState\n $first: Int\n $after: String\n $last: Int\n $before: String\n ) {\n user(id: $userId) {\n id\n compatSessions(\n first: $first\n after: $after\n last: $last\n before: $before\n state: $state\n ) {\n edges {\n node {\n id\n ...CompatSession_session\n }\n }\n\n totalCount\n pageInfo {\n hasNextPage\n hasPreviousPage\n startCursor\n endCursor\n }\n }\n }\n }\n"]; /** * The graphql function is used to parse GraphQL queries into a document that can be used by GraphQL clients. */ @@ -159,12 +149,6 @@ export function graphql( export function graphql( source: "\n mutation EndOAuth2Session($id: ID!) {\n endOauth2Session(input: { oauth2SessionId: $id }) {\n status\n oauth2Session {\n id\n ...OAuth2Session_session\n }\n }\n }\n", ): (typeof documents)["\n mutation EndOAuth2Session($id: ID!) {\n endOauth2Session(input: { oauth2SessionId: $id }) {\n status\n oauth2Session {\n id\n ...OAuth2Session_session\n }\n }\n }\n"]; -/** - * The graphql function is used to parse GraphQL queries into a document that can be used by GraphQL clients. - */ -export function graphql( - source: "\n query OAuth2SessionListQuery(\n $userId: ID!\n $state: SessionState\n $first: Int\n $after: String\n $last: Int\n $before: String\n ) {\n user(id: $userId) {\n id\n oauth2Sessions(\n state: $state\n first: $first\n after: $after\n last: $last\n before: $before\n ) {\n edges {\n cursor\n node {\n id\n ...OAuth2Session_session\n }\n }\n\n totalCount\n pageInfo {\n hasNextPage\n hasPreviousPage\n startCursor\n endCursor\n }\n }\n }\n }\n", -): (typeof documents)["\n query OAuth2SessionListQuery(\n $userId: ID!\n $state: SessionState\n $first: Int\n $after: String\n $last: Int\n $before: String\n ) {\n user(id: $userId) {\n id\n oauth2Sessions(\n state: $state\n first: $first\n after: $after\n last: $last\n before: $before\n ) {\n edges {\n cursor\n node {\n id\n ...OAuth2Session_session\n }\n }\n\n totalCount\n pageInfo {\n hasNextPage\n hasPreviousPage\n startCursor\n endCursor\n }\n }\n }\n }\n"]; /** * The graphql function is used to parse GraphQL queries into a document that can be used by GraphQL clients. */ diff --git a/frontend/src/gql/graphql.ts b/frontend/src/gql/graphql.ts index c471b040..61bf77d9 100644 --- a/frontend/src/gql/graphql.ts +++ b/frontend/src/gql/graphql.ts @@ -1191,42 +1191,6 @@ export type EndCompatSessionMutation = { }; }; -export type CompatSessionListQueryVariables = Exact<{ - userId: Scalars["ID"]["input"]; - state?: InputMaybe; - first?: InputMaybe; - after?: InputMaybe; - last?: InputMaybe; - before?: InputMaybe; -}>; - -export type CompatSessionListQuery = { - __typename?: "Query"; - user?: { - __typename?: "User"; - id: string; - compatSessions: { - __typename?: "CompatSessionConnection"; - totalCount: number; - edges: Array<{ - __typename?: "CompatSessionEdge"; - node: { __typename?: "CompatSession"; id: string } & { - " $fragmentRefs"?: { - CompatSession_SessionFragment: CompatSession_SessionFragment; - }; - }; - }>; - pageInfo: { - __typename?: "PageInfo"; - hasNextPage: boolean; - hasPreviousPage: boolean; - startCursor?: string | null; - endCursor?: string | null; - }; - }; - } | null; -}; - export type OAuth2Session_SessionFragment = { __typename?: "Oauth2Session"; id: string; @@ -1262,43 +1226,6 @@ export type EndOAuth2SessionMutation = { }; }; -export type OAuth2SessionListQueryQueryVariables = Exact<{ - userId: Scalars["ID"]["input"]; - state?: InputMaybe; - first?: InputMaybe; - after?: InputMaybe; - last?: InputMaybe; - before?: InputMaybe; -}>; - -export type OAuth2SessionListQueryQuery = { - __typename?: "Query"; - user?: { - __typename?: "User"; - id: string; - oauth2Sessions: { - __typename?: "Oauth2SessionConnection"; - totalCount: number; - edges: Array<{ - __typename?: "Oauth2SessionEdge"; - cursor: string; - node: { __typename?: "Oauth2Session"; id: string } & { - " $fragmentRefs"?: { - OAuth2Session_SessionFragment: OAuth2Session_SessionFragment; - }; - }; - }>; - pageInfo: { - __typename?: "PageInfo"; - hasNextPage: boolean; - hasPreviousPage: boolean; - startCursor?: string | null; - endCursor?: string | null; - }; - }; - } | null; -}; - export type SessionQueryQueryVariables = Exact<{ userId: Scalars["ID"]["input"]; deviceId: Scalars["String"]["input"]; @@ -2458,234 +2385,6 @@ export const EndCompatSessionDocument = { EndCompatSessionMutation, EndCompatSessionMutationVariables >; -export const CompatSessionListDocument = { - kind: "Document", - definitions: [ - { - kind: "OperationDefinition", - operation: "query", - name: { kind: "Name", value: "CompatSessionList" }, - variableDefinitions: [ - { - kind: "VariableDefinition", - variable: { - kind: "Variable", - name: { kind: "Name", value: "userId" }, - }, - type: { - kind: "NonNullType", - type: { kind: "NamedType", name: { kind: "Name", value: "ID" } }, - }, - }, - { - kind: "VariableDefinition", - variable: { - kind: "Variable", - name: { kind: "Name", value: "state" }, - }, - type: { - kind: "NamedType", - name: { kind: "Name", value: "SessionState" }, - }, - }, - { - kind: "VariableDefinition", - variable: { - kind: "Variable", - name: { kind: "Name", value: "first" }, - }, - type: { kind: "NamedType", name: { kind: "Name", value: "Int" } }, - }, - { - kind: "VariableDefinition", - variable: { - kind: "Variable", - name: { kind: "Name", value: "after" }, - }, - type: { kind: "NamedType", name: { kind: "Name", value: "String" } }, - }, - { - kind: "VariableDefinition", - variable: { kind: "Variable", name: { kind: "Name", value: "last" } }, - type: { kind: "NamedType", name: { kind: "Name", value: "Int" } }, - }, - { - kind: "VariableDefinition", - variable: { - kind: "Variable", - name: { kind: "Name", value: "before" }, - }, - type: { kind: "NamedType", name: { kind: "Name", value: "String" } }, - }, - ], - selectionSet: { - kind: "SelectionSet", - selections: [ - { - kind: "Field", - name: { kind: "Name", value: "user" }, - arguments: [ - { - kind: "Argument", - name: { kind: "Name", value: "id" }, - value: { - kind: "Variable", - name: { kind: "Name", value: "userId" }, - }, - }, - ], - selectionSet: { - kind: "SelectionSet", - selections: [ - { kind: "Field", name: { kind: "Name", value: "id" } }, - { - kind: "Field", - name: { kind: "Name", value: "compatSessions" }, - arguments: [ - { - kind: "Argument", - name: { kind: "Name", value: "first" }, - value: { - kind: "Variable", - name: { kind: "Name", value: "first" }, - }, - }, - { - kind: "Argument", - name: { kind: "Name", value: "after" }, - value: { - kind: "Variable", - name: { kind: "Name", value: "after" }, - }, - }, - { - kind: "Argument", - name: { kind: "Name", value: "last" }, - value: { - kind: "Variable", - name: { kind: "Name", value: "last" }, - }, - }, - { - kind: "Argument", - name: { kind: "Name", value: "before" }, - value: { - kind: "Variable", - name: { kind: "Name", value: "before" }, - }, - }, - { - kind: "Argument", - name: { kind: "Name", value: "state" }, - value: { - kind: "Variable", - name: { kind: "Name", value: "state" }, - }, - }, - ], - selectionSet: { - kind: "SelectionSet", - selections: [ - { - kind: "Field", - name: { kind: "Name", value: "edges" }, - selectionSet: { - kind: "SelectionSet", - selections: [ - { - kind: "Field", - name: { kind: "Name", value: "node" }, - selectionSet: { - kind: "SelectionSet", - selections: [ - { - kind: "Field", - name: { kind: "Name", value: "id" }, - }, - { - kind: "FragmentSpread", - name: { - kind: "Name", - value: "CompatSession_session", - }, - }, - ], - }, - }, - ], - }, - }, - { - kind: "Field", - name: { kind: "Name", value: "totalCount" }, - }, - { - kind: "Field", - name: { kind: "Name", value: "pageInfo" }, - selectionSet: { - kind: "SelectionSet", - selections: [ - { - kind: "Field", - name: { kind: "Name", value: "hasNextPage" }, - }, - { - kind: "Field", - name: { kind: "Name", value: "hasPreviousPage" }, - }, - { - kind: "Field", - name: { kind: "Name", value: "startCursor" }, - }, - { - kind: "Field", - name: { kind: "Name", value: "endCursor" }, - }, - ], - }, - }, - ], - }, - }, - ], - }, - }, - ], - }, - }, - { - kind: "FragmentDefinition", - name: { kind: "Name", value: "CompatSession_session" }, - typeCondition: { - kind: "NamedType", - name: { kind: "Name", value: "CompatSession" }, - }, - selectionSet: { - kind: "SelectionSet", - selections: [ - { kind: "Field", name: { kind: "Name", value: "id" } }, - { kind: "Field", name: { kind: "Name", value: "createdAt" } }, - { kind: "Field", name: { kind: "Name", value: "deviceId" } }, - { kind: "Field", name: { kind: "Name", value: "finishedAt" } }, - { - kind: "Field", - name: { kind: "Name", value: "ssoLogin" }, - selectionSet: { - kind: "SelectionSet", - selections: [ - { kind: "Field", name: { kind: "Name", value: "id" } }, - { kind: "Field", name: { kind: "Name", value: "redirectUri" } }, - ], - }, - }, - ], - }, - }, - ], -} as unknown as DocumentNode< - CompatSessionListQuery, - CompatSessionListQueryVariables ->; export const EndOAuth2SessionDocument = { kind: "Document", definitions: [ @@ -2788,241 +2487,6 @@ export const EndOAuth2SessionDocument = { EndOAuth2SessionMutation, EndOAuth2SessionMutationVariables >; -export const OAuth2SessionListQueryDocument = { - kind: "Document", - definitions: [ - { - kind: "OperationDefinition", - operation: "query", - name: { kind: "Name", value: "OAuth2SessionListQuery" }, - variableDefinitions: [ - { - kind: "VariableDefinition", - variable: { - kind: "Variable", - name: { kind: "Name", value: "userId" }, - }, - type: { - kind: "NonNullType", - type: { kind: "NamedType", name: { kind: "Name", value: "ID" } }, - }, - }, - { - kind: "VariableDefinition", - variable: { - kind: "Variable", - name: { kind: "Name", value: "state" }, - }, - type: { - kind: "NamedType", - name: { kind: "Name", value: "SessionState" }, - }, - }, - { - kind: "VariableDefinition", - variable: { - kind: "Variable", - name: { kind: "Name", value: "first" }, - }, - type: { kind: "NamedType", name: { kind: "Name", value: "Int" } }, - }, - { - kind: "VariableDefinition", - variable: { - kind: "Variable", - name: { kind: "Name", value: "after" }, - }, - type: { kind: "NamedType", name: { kind: "Name", value: "String" } }, - }, - { - kind: "VariableDefinition", - variable: { kind: "Variable", name: { kind: "Name", value: "last" } }, - type: { kind: "NamedType", name: { kind: "Name", value: "Int" } }, - }, - { - kind: "VariableDefinition", - variable: { - kind: "Variable", - name: { kind: "Name", value: "before" }, - }, - type: { kind: "NamedType", name: { kind: "Name", value: "String" } }, - }, - ], - selectionSet: { - kind: "SelectionSet", - selections: [ - { - kind: "Field", - name: { kind: "Name", value: "user" }, - arguments: [ - { - kind: "Argument", - name: { kind: "Name", value: "id" }, - value: { - kind: "Variable", - name: { kind: "Name", value: "userId" }, - }, - }, - ], - selectionSet: { - kind: "SelectionSet", - selections: [ - { kind: "Field", name: { kind: "Name", value: "id" } }, - { - kind: "Field", - name: { kind: "Name", value: "oauth2Sessions" }, - arguments: [ - { - kind: "Argument", - name: { kind: "Name", value: "state" }, - value: { - kind: "Variable", - name: { kind: "Name", value: "state" }, - }, - }, - { - kind: "Argument", - name: { kind: "Name", value: "first" }, - value: { - kind: "Variable", - name: { kind: "Name", value: "first" }, - }, - }, - { - kind: "Argument", - name: { kind: "Name", value: "after" }, - value: { - kind: "Variable", - name: { kind: "Name", value: "after" }, - }, - }, - { - kind: "Argument", - name: { kind: "Name", value: "last" }, - value: { - kind: "Variable", - name: { kind: "Name", value: "last" }, - }, - }, - { - kind: "Argument", - name: { kind: "Name", value: "before" }, - value: { - kind: "Variable", - name: { kind: "Name", value: "before" }, - }, - }, - ], - selectionSet: { - kind: "SelectionSet", - selections: [ - { - kind: "Field", - name: { kind: "Name", value: "edges" }, - selectionSet: { - kind: "SelectionSet", - selections: [ - { - kind: "Field", - name: { kind: "Name", value: "cursor" }, - }, - { - kind: "Field", - name: { kind: "Name", value: "node" }, - selectionSet: { - kind: "SelectionSet", - selections: [ - { - kind: "Field", - name: { kind: "Name", value: "id" }, - }, - { - kind: "FragmentSpread", - name: { - kind: "Name", - value: "OAuth2Session_session", - }, - }, - ], - }, - }, - ], - }, - }, - { - kind: "Field", - name: { kind: "Name", value: "totalCount" }, - }, - { - kind: "Field", - name: { kind: "Name", value: "pageInfo" }, - selectionSet: { - kind: "SelectionSet", - selections: [ - { - kind: "Field", - name: { kind: "Name", value: "hasNextPage" }, - }, - { - kind: "Field", - name: { kind: "Name", value: "hasPreviousPage" }, - }, - { - kind: "Field", - name: { kind: "Name", value: "startCursor" }, - }, - { - kind: "Field", - name: { kind: "Name", value: "endCursor" }, - }, - ], - }, - }, - ], - }, - }, - ], - }, - }, - ], - }, - }, - { - kind: "FragmentDefinition", - name: { kind: "Name", value: "OAuth2Session_session" }, - typeCondition: { - kind: "NamedType", - name: { kind: "Name", value: "Oauth2Session" }, - }, - selectionSet: { - kind: "SelectionSet", - selections: [ - { kind: "Field", name: { kind: "Name", value: "id" } }, - { kind: "Field", name: { kind: "Name", value: "scope" } }, - { kind: "Field", name: { kind: "Name", value: "createdAt" } }, - { kind: "Field", name: { kind: "Name", value: "finishedAt" } }, - { - kind: "Field", - name: { kind: "Name", value: "client" }, - selectionSet: { - kind: "SelectionSet", - selections: [ - { kind: "Field", name: { kind: "Name", value: "id" } }, - { kind: "Field", name: { kind: "Name", value: "clientId" } }, - { kind: "Field", name: { kind: "Name", value: "clientName" } }, - { kind: "Field", name: { kind: "Name", value: "clientUri" } }, - { kind: "Field", name: { kind: "Name", value: "logoUri" } }, - ], - }, - }, - ], - }, - }, - ], -} as unknown as DocumentNode< - OAuth2SessionListQueryQuery, - OAuth2SessionListQueryQueryVariables ->; export const SessionQueryDocument = { kind: "Document", definitions: [ diff --git a/frontend/src/pages/CompatSessionList.tsx b/frontend/src/pages/CompatSessionList.tsx deleted file mode 100644 index 3b4ab370..00000000 --- a/frontend/src/pages/CompatSessionList.tsx +++ /dev/null @@ -1,38 +0,0 @@ -// Copyright 2023 The Matrix.org Foundation C.I.C. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -import { useAtomValue } from "jotai"; - -import { currentUserIdAtom } from "../atoms"; -import List from "../components/CompatSessionList"; -import ErrorBoundary from "../components/ErrorBoundary"; -import GraphQLError from "../components/GraphQLError"; -import NotLoggedIn from "../components/NotLoggedIn"; -import { isErr, unwrapErr, unwrapOk } from "../result"; - -const CompatSessionList: React.FC = () => { - const result = useAtomValue(currentUserIdAtom); - if (isErr(result)) return ; - - const userId = unwrapOk(result); - if (userId === null) return ; - - return ( - - - - ); -}; - -export default CompatSessionList; diff --git a/frontend/src/pages/OAuth2SessionList.tsx b/frontend/src/pages/OAuth2SessionList.tsx deleted file mode 100644 index c6cc2b9c..00000000 --- a/frontend/src/pages/OAuth2SessionList.tsx +++ /dev/null @@ -1,38 +0,0 @@ -// Copyright 2023 The Matrix.org Foundation C.I.C. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -import { useAtomValue } from "jotai"; - -import { currentUserIdAtom } from "../atoms"; -import ErrorBoundary from "../components/ErrorBoundary"; -import GraphQLError from "../components/GraphQLError"; -import NotLoggedIn from "../components/NotLoggedIn"; -import List from "../components/OAuth2SessionList"; -import { isErr, unwrapErr, unwrapOk } from "../result"; - -const OAuth2SessionList: React.FC = () => { - const result = useAtomValue(currentUserIdAtom); - if (isErr(result)) return ; - - const userId = unwrapOk(result); - if (userId === null) return ; - - return ( - - - - ); -}; - -export default OAuth2SessionList; diff --git a/frontend/src/routing/Router.tsx b/frontend/src/routing/Router.tsx index d4353458..748920c8 100644 --- a/frontend/src/routing/Router.tsx +++ b/frontend/src/routing/Router.tsx @@ -18,9 +18,7 @@ import { useEffect } from "react"; import LoadingSpinner from "../components/LoadingSpinner"; import BrowserSession from "../pages/BrowserSession"; import BrowserSessionList from "../pages/BrowserSessionList"; -import CompatSessionList from "../pages/CompatSessionList"; import OAuth2Client from "../pages/OAuth2Client"; -import OAuth2SessionList from "../pages/OAuth2SessionList"; import Profile from "../pages/Profile"; import SessionDetail from "../pages/SessionDetail"; import SessionsOverview from "../pages/SessionsOverview"; @@ -65,12 +63,8 @@ const Router: React.FC = () => { return ; case "session": return ; - case "oauth2-session-list": - return ; case "browser-session-list": return ; - case "compat-session-list": - return ; case "client": return ; case "browser-session": diff --git a/frontend/src/routing/routes.test.ts b/frontend/src/routing/routes.test.ts index 2b3d16c5..9979c9b0 100644 --- a/frontend/src/routing/routes.test.ts +++ b/frontend/src/routing/routes.test.ts @@ -35,20 +35,6 @@ describe("routes", () => { }); }); - it("returns compat session list for compat-sessions", () => { - const segments: string[] = ["compat-sessions"]; - expect(segmentsToRoute(segments)).toEqual({ - type: "compat-session-list", - }); - }); - - it("returns oauth session list for oauth2-sessions", () => { - const segments: string[] = ["oauth2-sessions"]; - expect(segmentsToRoute(segments)).toEqual({ - type: "oauth2-session-list", - }); - }); - it("returns client detail route correctly", () => { const segments: string[] = ["clients", "client-id"]; expect(segmentsToRoute(segments)).toEqual({ diff --git a/frontend/src/routing/routes.ts b/frontend/src/routing/routes.ts index 8fed53e9..46596dd3 100644 --- a/frontend/src/routing/routes.ts +++ b/frontend/src/routing/routes.ts @@ -31,10 +31,8 @@ type ProfileRoute = Readonly<{ type: "profile" }>; type SessionOverviewRoute = Readonly<{ type: "sessions-overview" }>; type SessionDetailRoute = Readonly<{ type: "session"; id: string }>; type OAuth2ClientRoute = Readonly<{ type: "client"; id: string }>; -type OAuth2SessionList = Readonly<{ type: "oauth2-session-list" }>; type BrowserSessionRoute = Readonly<{ type: "browser-session"; id: string }>; type BrowserSessionListRoute = Readonly<{ type: "browser-session-list" }>; -type CompatSessionListRoute = Readonly<{ type: "compat-session-list" }>; type VerifyEmailRoute = Readonly<{ type: "verify-email"; id: string }>; type UnknownRoute = Readonly<{ type: "unknown"; segments: Segments }>; @@ -43,10 +41,8 @@ export type Route = | SessionDetailRoute | ProfileRoute | OAuth2ClientRoute - | OAuth2SessionList | BrowserSessionRoute | BrowserSessionListRoute - | CompatSessionListRoute | VerifyEmailRoute | UnknownRoute; @@ -75,10 +71,6 @@ export const routeToSegments = (route: Route): Segments => { return ["browser-sessions"]; case "browser-session": return ["browser-sessions", route.id]; - case "oauth2-session-list": - return ["oauth2-sessions"]; - case "compat-session-list": - return ["compat-sessions"]; case "unknown": return route.segments; } @@ -124,14 +116,6 @@ export const segmentsToRoute = (segments: Segments): Route => { return { type: "browser-session-list" }; } - if (matches("oauth2-sessions")) { - return { type: "oauth2-session-list" }; - } - - if (matches("compat-sessions")) { - return { type: "compat-session-list" }; - } - if (matches("emails", P, "verify")) { return { type: "verify-email", id: segments[1] }; }