diff --git a/packages/client/src/pages/Profile/Section/Body/sub-components/authorized-apps/styled-authorized-apps.ts b/packages/client/src/pages/Profile/Section/Body/sub-components/authorized-apps/AuthorizedApps.styled.ts similarity index 100% rename from packages/client/src/pages/Profile/Section/Body/sub-components/authorized-apps/styled-authorized-apps.ts rename to packages/client/src/pages/Profile/Section/Body/sub-components/authorized-apps/AuthorizedApps.styled.ts diff --git a/packages/client/src/pages/Profile/Section/Body/sub-components/authorized-apps/AuthorizedApps.types.ts b/packages/client/src/pages/Profile/Section/Body/sub-components/authorized-apps/AuthorizedApps.types.ts new file mode 100644 index 0000000000..661d7aa0bb --- /dev/null +++ b/packages/client/src/pages/Profile/Section/Body/sub-components/authorized-apps/AuthorizedApps.types.ts @@ -0,0 +1,33 @@ +import { IClientProps } from "@docspace/shared/utils/oauth/interfaces"; + +import { DeviceUnionType } from "SRC_DIR/Hooks/useViewEffect"; +import { ViewAsType } from "SRC_DIR/store/OAuthStore"; + +export interface AuthorizedAppsProps { + consents?: IClientProps[]; + fetchConsents?: () => Promise; + + viewAs: ViewAsType; + setViewAs: (value: string) => void; + + currentDeviceType: DeviceUnionType; + + infoDialogVisible: boolean; + fetchScopes?: () => Promise; + + revokeDialogVisible: boolean; + setRevokeDialogVisible: (value: boolean) => void; + selection: string[]; + bufferSelection: IClientProps; + revokeClient: (value: string[]) => Promise; +} + +export interface RevokeDialogProps { + visible: boolean; + + onClose: () => void; + selection: string[]; + bufferSelection: IClientProps; + onRevoke: (value: string[]) => Promise; + currentDeviceType: DeviceUnionType; +} diff --git a/packages/client/src/pages/Profile/Section/Body/sub-components/authorized-apps/index.tsx b/packages/client/src/pages/Profile/Section/Body/sub-components/authorized-apps/index.tsx index 849f7d8702..a6a89a3e90 100644 --- a/packages/client/src/pages/Profile/Section/Body/sub-components/authorized-apps/index.tsx +++ b/packages/client/src/pages/Profile/Section/Body/sub-components/authorized-apps/index.tsx @@ -2,49 +2,22 @@ import React from "react"; import { inject, observer } from "mobx-react"; import { useTranslation } from "react-i18next"; -import { IClientProps } from "@docspace/shared/utils/oauth/interfaces"; - -//@ts-ignore -import { DeviceUnionType } from "SRC_DIR/Hooks/useViewEffect"; -//@ts-ignore -import useViewEffect from "SRC_DIR/Hooks/useViewEffect"; - import { Consumer } from "@docspace/shared/utils/context"; import { Text } from "@docspace/shared/components/text"; import { SettingsStore } from "@docspace/shared/store/SettingsStore"; -//@ts-ignore + +import useViewEffect from "SRC_DIR/Hooks/useViewEffect"; import OAuthStore from "SRC_DIR/store/OAuthStore"; -//@ts-ignore -import { ViewAsType } from "SRC_DIR/store/OAuthStore"; -//@ts-ignore import InfoDialog from "SRC_DIR/pages/PortalSettings/categories/developer-tools/OAuth/sub-components/InfoDialog"; -import { StyledContainer } from "./styled-authorized-apps"; +import { StyledContainer } from "./AuthorizedApps.styled"; +import { AuthorizedAppsProps } from "./AuthorizedApps.types"; import TableView from "./sub-components/TableView"; import RowView from "./sub-components/RowView"; import RevokeDialog from "./sub-components/RevokeDialog"; import EmptyScreen from "./sub-components/EmptyScreen"; -interface AuthorizedAppsProps { - consents?: IClientProps[]; - fetchConsents?: () => Promise; - - viewAs: ViewAsType; - setViewAs: (value: ViewAsType) => void; - - currentDeviceType: DeviceUnionType; - - infoDialogVisible: boolean; - fetchScopes?: () => Promise; - - revokeDialogVisible: boolean; - setRevokeDialogVisible: (value: boolean) => void; - selection: string[]; - bufferSelection: IClientProps; - revokeClient: (value: string[]) => Promise; -} - const AuthorizedApps = ({ consents, fetchConsents, @@ -64,13 +37,13 @@ const AuthorizedApps = ({ const getConsentList = React.useCallback(async () => { fetchScopes?.(); await fetchConsents?.(); - }, []); + }, [fetchConsents, fetchScopes]); React.useEffect(() => { - if (!!consents?.length) return; + if (consents?.length) return; getConsentList(); - }, []); + }, [consents?.length, getConsentList]); useViewEffect({ view: viewAs, @@ -82,26 +55,24 @@ const AuthorizedApps = ({ {consents && consents?.length > 0 ? ( <> - + {t("ProfileDescription")} - {(context) => ( - <> - {viewAs === "table" ? ( - - ) : ( - - )} - - )} + {(context) => + viewAs === "table" ? ( + + ) : ( + + ) + } ) : ( @@ -163,5 +134,5 @@ export default inject( bufferSelection, revokeClient, }; - } + }, )(observer(AuthorizedApps)); diff --git a/packages/client/src/pages/Profile/Section/Body/sub-components/authorized-apps/sub-components/RevokeDialog.tsx b/packages/client/src/pages/Profile/Section/Body/sub-components/authorized-apps/sub-components/RevokeDialog.tsx index e4e969db00..44c9954881 100644 --- a/packages/client/src/pages/Profile/Section/Body/sub-components/authorized-apps/sub-components/RevokeDialog.tsx +++ b/packages/client/src/pages/Profile/Section/Body/sub-components/authorized-apps/sub-components/RevokeDialog.tsx @@ -8,19 +8,7 @@ import { import { Text } from "@docspace/shared/components/text"; import { Button, ButtonSize } from "@docspace/shared/components/button"; -// @ts-ignore -import { DeviceUnionType } from "SRC_DIR/Hooks/useViewEffect"; -import { IClientProps } from "@docspace/shared/utils/oauth/interfaces"; - -interface RevokeDialogProps { - visible: boolean; - - onClose: () => void; - selection: string[]; - bufferSelection: IClientProps; - onRevoke: (value: string[]) => Promise; - currentDeviceType: DeviceUnionType; -} +import { RevokeDialogProps } from "../AuthorizedApps.types"; const RevokeDialog = ({ visible, @@ -57,7 +45,10 @@ const RevokeDialog = ({ ); const onRevokeAction = async () => { + if (isRequestRunning) return; + setIsRequestRunning(true); + if (isGroup) { await onRevoke(selection); } else { diff --git a/packages/client/src/pages/Profile/Section/Body/sub-components/authorized-apps/sub-components/RowView/Row.tsx b/packages/client/src/pages/Profile/Section/Body/sub-components/authorized-apps/sub-components/RowView/Row.tsx index e127b20712..3717c783f2 100644 --- a/packages/client/src/pages/Profile/Section/Body/sub-components/authorized-apps/sub-components/RowView/Row.tsx +++ b/packages/client/src/pages/Profile/Section/Body/sub-components/authorized-apps/sub-components/RowView/Row.tsx @@ -1,4 +1,3 @@ -import { useNavigate } from "react-router-dom"; import { useTranslation } from "react-i18next"; import { Row } from "@docspace/shared/components/row"; @@ -10,45 +9,40 @@ export const OAuthRow = (props: RowProps) => { const { item, sectionWidth, - changeClientStatus, + isChecked, inProgress, getContextMenuItems, setSelection, } = props; - const navigate = useNavigate(); const { t } = useTranslation(["OAuth", "Common", "Files"]); const contextOptions = getContextMenuItems?.(t, item, false, false) || []; const element = ( - {"App + App logo ); return ( - <> - setSelection && setSelection(item.clientId)} + onRowClick={() => {}} + > + setSelection && setSelection(item.clientId)} - onRowClick={() => {}} - > - - - + setSelection={setSelection} + /> + ); }; - -export default OAuthRow; diff --git a/packages/client/src/pages/Profile/Section/Body/sub-components/authorized-apps/sub-components/RowView/RowContent.tsx b/packages/client/src/pages/Profile/Section/Body/sub-components/authorized-apps/sub-components/RowView/RowContent.tsx index eb8546465b..341fed5fd4 100644 --- a/packages/client/src/pages/Profile/Section/Body/sub-components/authorized-apps/sub-components/RowView/RowContent.tsx +++ b/packages/client/src/pages/Profile/Section/Body/sub-components/authorized-apps/sub-components/RowView/RowContent.tsx @@ -36,7 +36,7 @@ export const RowContent = ({ sectionWidth, item }: RowContentProps) => { - <> + {null} ); }; diff --git a/packages/client/src/pages/Profile/Section/Body/sub-components/authorized-apps/sub-components/RowView/RowView.types.ts b/packages/client/src/pages/Profile/Section/Body/sub-components/authorized-apps/sub-components/RowView/RowView.types.ts index fa694a0825..ba0a448d21 100644 --- a/packages/client/src/pages/Profile/Section/Body/sub-components/authorized-apps/sub-components/RowView/RowView.types.ts +++ b/packages/client/src/pages/Profile/Section/Body/sub-components/authorized-apps/sub-components/RowView/RowView.types.ts @@ -12,7 +12,7 @@ export interface RowViewProps { t: TTranslation, item: IClientProps, isInfo: boolean, - isSettings: boolean + isSettings: boolean, ) => ContextMenuModel[]; activeClients?: string[]; hasNextPage?: boolean; @@ -30,7 +30,7 @@ export interface RowProps { t: TTranslation, item: IClientProps, isInfo: boolean, - isSettings: boolean + isSettings: boolean, ) => ContextMenuModel[]; setSelection?: (clientId: string) => void; changeClientStatus?: (clientId: string, status: boolean) => Promise; diff --git a/packages/client/src/pages/Profile/Section/Body/sub-components/authorized-apps/sub-components/RowView/index.tsx b/packages/client/src/pages/Profile/Section/Body/sub-components/authorized-apps/sub-components/RowView/index.tsx index b30441142b..0ec89e4f75 100644 --- a/packages/client/src/pages/Profile/Section/Body/sub-components/authorized-apps/sub-components/RowView/index.tsx +++ b/packages/client/src/pages/Profile/Section/Body/sub-components/authorized-apps/sub-components/RowView/index.tsx @@ -1,11 +1,9 @@ import React from "react"; import { inject, observer } from "mobx-react"; -import { isMobile } from "react-device-detect"; -//@ts-ignore import { OAuthStoreProps } from "SRC_DIR/store/OAuthStore"; -import OAuthRow from "./Row"; +import { OAuthRow } from "./Row"; import { RowViewProps } from "./RowView.types"; import { StyledRowContainer } from "./RowView.styled"; @@ -30,7 +28,7 @@ const RowView = (props: RowViewProps) => { async ({ startIndex }: { startIndex: number; stopIndex: number }) => { await fetchNextClients?.(startIndex); }, - [] + [fetchNextClients], ); return ( @@ -59,32 +57,30 @@ const RowView = (props: RowViewProps) => { ); }; -export default inject( - ({ oauthStore }: { auth: any; oauthStore: OAuthStoreProps }) => { - const { - viewAs, - setViewAs, - selection, - setSelection, - changeClientStatus, - getContextMenuItems, - activeClients, - hasNextPage, - itemCount, - fetchNextClients, - } = oauthStore; +export default inject(({ oauthStore }: { oauthStore: OAuthStoreProps }) => { + const { + viewAs, + setViewAs, + selection, + setSelection, + changeClientStatus, + getContextMenuItems, + activeClients, + hasNextPage, + itemCount, + fetchNextClients, + } = oauthStore; - return { - viewAs, - setViewAs, - changeClientStatus, - selection, - setSelection, - activeClients, - getContextMenuItems, - hasNextPage, - itemCount, - fetchNextClients, - }; - } -)(observer(RowView)); + return { + viewAs, + setViewAs, + changeClientStatus, + selection, + setSelection, + activeClients, + getContextMenuItems, + hasNextPage, + itemCount, + fetchNextClients, + }; +})(observer(RowView)); diff --git a/packages/client/src/pages/Profile/Section/Body/sub-components/authorized-apps/sub-components/TableView/Row.tsx b/packages/client/src/pages/Profile/Section/Body/sub-components/authorized-apps/sub-components/TableView/Row.tsx index 3f406e23b8..86c2506632 100644 --- a/packages/client/src/pages/Profile/Section/Body/sub-components/authorized-apps/sub-components/TableView/Row.tsx +++ b/packages/client/src/pages/Profile/Section/Body/sub-components/authorized-apps/sub-components/TableView/Row.tsx @@ -35,53 +35,51 @@ const Row = (props: RowProps) => { getContextMenuItems ? getContextMenuItems(t, item, false, false) : []; return ( - <> - - - - - + + + + + - - + + - - {item.websiteUrl} - - - + {item.websiteUrl} + + + - - - {modifiedDate} - - - - - + + + {modifiedDate} + + + + ); }; diff --git a/packages/client/src/pages/Profile/Section/Body/sub-components/authorized-apps/sub-components/TableView/TableView.types.ts b/packages/client/src/pages/Profile/Section/Body/sub-components/authorized-apps/sub-components/TableView/TableView.types.ts index d048eea0dc..6a5bda66f8 100644 --- a/packages/client/src/pages/Profile/Section/Body/sub-components/authorized-apps/sub-components/TableView/TableView.types.ts +++ b/packages/client/src/pages/Profile/Section/Body/sub-components/authorized-apps/sub-components/TableView/TableView.types.ts @@ -13,7 +13,7 @@ export interface TableViewProps { t: TTranslation, item: IClientProps, isInfo: boolean, - isSettings: boolean + isSettings: boolean, ) => ContextMenuModel[]; bufferSelection?: IClientProps | null; activeClients?: string[]; @@ -38,7 +38,7 @@ export interface RowProps { t: TTranslation, item: IClientProps, isInfo: boolean, - isSettings: boolean + isSettings: boolean, ) => ContextMenuModel[]; setSelection?: (clientId: string) => void; changeClientStatus?: (clientId: string, status: boolean) => Promise; diff --git a/packages/client/src/pages/Profile/Section/Body/sub-components/authorized-apps/sub-components/TableView/columns/name.tsx b/packages/client/src/pages/Profile/Section/Body/sub-components/authorized-apps/sub-components/TableView/columns/name.tsx index ac5633d496..9f2693854d 100644 --- a/packages/client/src/pages/Profile/Section/Body/sub-components/authorized-apps/sub-components/TableView/columns/name.tsx +++ b/packages/client/src/pages/Profile/Section/Body/sub-components/authorized-apps/sub-components/TableView/columns/name.tsx @@ -41,7 +41,7 @@ const NameCell = ({ setSelection, }: NameCellProps) => { const onChange = () => { - setSelection && setSelection(clientId); + setSelection?.(clientId); }; return ( @@ -56,7 +56,7 @@ const NameCell = ({
- {icon && } + {icon && }
{ await fetchNextClients?.(startIndex); }, - [], + [fetchNextClients], ); return (