synapse-react-client
Version:
[](https://travis-ci.com/Sage-Bionetworks/Synapse-React-Client) [](https://badge.fury.io/js/synaps
86 lines (85 loc) • 4.22 kB
TypeScript
/**
* To be reworked so that HasAccess component doesn't need to request file handle information
* because that information can be obtained in the parent component
*
* For example in SynapseTable.tsx, the variable "fileEntityHandle" is available
* for each row Synapse id to store file handle information.
* If the row Synapse id doesn't return a file handle, "fileEntityHandle" will contain
* an object { success:boolean = false , message:string }
* If the row Synapse id returns a file handle, "fileEntityHandle" will contain
* an object { success:boolean = true, data: {fileEntity, fileHandle} }
*
* To set up "fileEntityHandle", the parent component should import "FileEntityHandleQueryWrapper"
* and pass a callback function to "FileEntityHandleQueryWrapper" so that once the file handle information
* is returned, the success for failure result can be saved in the parent state.
* See SynapseTable.tsx as an example.
*/
import { IconProp } from '@fortawesome/fontawesome-svg-core';
import * as React from 'react';
import { FileHandle, RestrictionInformationResponse, AccessRequirement } from '../utils/synapseTypes/';
import { AccessRequirementListProps } from './access_requirement_list/AccessRequirementList';
export declare type HasAccessProps = {
onHide?: () => void;
fileHandle?: FileHandle;
entityId: string;
isInDownloadList?: boolean;
entityVersionNumber?: string;
forceSamePage?: boolean;
set_arPropsFromHasAccess?: (props: AccessRequirementListProps) => void;
className?: string;
};
declare type HasAccessState = {
restrictionInformation?: RestrictionInformationResponse;
fileHandleDownloadType?: FileHandleDownloadTypeEnum;
displayAccessRequirement: boolean;
accessRequirements?: Array<AccessRequirement>;
isGettingRestrictionInformation: boolean;
isGettingEntityInformation: boolean;
errorOnGetRestrictionInformation: boolean;
};
export declare const GIGABYTE_SIZE: number;
export declare enum FileHandleDownloadTypeEnum {
ExternalCloudFile = "ExternalCloudFile",
ExternalFileLink = "ExternalFileLink",
TooLarge = "TooLarge",
Accessible = "Accessible",
AccessBlockedByRestriction = "AccessBlockedByRestriction",
AccessBlockedByACL = "AccessBlockedByACL",
AccessBlockedToAnonymous = "AccessBlockedToAnonymous",
NoFileHandle = "NoFileHandle"
}
export declare const getDownloadTypeForFileHandle: (fileHandle: FileHandle, isInDownloadList?: boolean | undefined) => FileHandleDownloadTypeEnum.ExternalCloudFile | FileHandleDownloadTypeEnum.ExternalFileLink | FileHandleDownloadTypeEnum.TooLarge | FileHandleDownloadTypeEnum.Accessible;
/**
* HasAccess shows if the user has access to the file or not.
*
* The component's behavior changes whether it's passed in a FileHandle or not.
* If passed a file handle then it will give more detailed information about the download.
*
* @export
* @class HasAccess
* @extends {React.Component<HasAccessProps, HasAccessState>}
*/
export default class HasAccess extends React.Component<HasAccessProps, HasAccessState> {
static tooltipText: {
AccessBlockedToAnonymous: string;
AccessBlockedByRestriction: string;
AccessBlockedByACL: string;
TooLarge: string;
ExternalFileLink: string;
ExternalCloudFile: string;
};
static contextType: React.Context<import("../utils/SynapseContext").SynapseContextType | undefined>;
constructor(props: HasAccessProps);
componentDidUpdate(prevProps: HasAccessProps): void;
componentDidMount(): void;
refresh: (forceRefresh?: boolean | undefined) => void;
updateStateFileHandleAccessBlocked: () => void;
getFileEntityFileHandle: (forceRefresh?: boolean | undefined) => Promise<void> | undefined;
getRestrictionInformation: (forceRefresh?: boolean | undefined) => Promise<void> | undefined;
renderIconHelper: (iconProp: IconProp, classColor: string) => JSX.Element;
renderIcon: (downloadType: FileHandleDownloadTypeEnum | string, restrictionInformation?: RestrictionInformationResponse | undefined) => JSX.Element;
handleGetAccess: () => void;
renderARsLink: () => JSX.Element;
render(): JSX.Element;
}
export {};