Skip to content

Commit

Permalink
[Chore]: Technical: Translate cloud-providers (#1778)
Browse files Browse the repository at this point in the history
* Renamed js files

Signed-off-by: Maksim Suslov <maksim.suslov@actionengine.com>

* Moved types from index.d.ts file to provider.ts

Signed-off-by: Maksim Suslov <maksim.suslov@actionengine.com>

* Fixed ts erros

Signed-off-by: Maksim Suslov <maksim.suslov@actionengine.com>

* Deleted index.d.ts file

Signed-off-by: Maksim Suslov <maksim.suslov@actionengine.com>

* Cleanup

Signed-off-by: Maksim Suslov <maksim.suslov@actionengine.com>
  • Loading branch information
HeimEndyd committed Apr 14, 2022
1 parent 24e3549 commit ec3351b
Show file tree
Hide file tree
Showing 3 changed files with 63 additions and 71 deletions.
53 changes: 0 additions & 53 deletions src/cloud-providers/index.d.ts

This file was deleted.

Expand Up @@ -19,3 +19,4 @@
// THE SOFTWARE.

export {default as Provider, FILE_CONFLICT_MSG} from './provider';
export type {MapListItem, Millisecond, Thumbnail, ProviderProps} from './provider';
80 changes: 62 additions & 18 deletions src/cloud-providers/provider.js → src/cloud-providers/provider.ts
Expand Up @@ -19,6 +19,37 @@
// THE SOFTWARE.

import {Upload} from 'components/common/icons';
import {MapData, ExportFileOptions} from 'actions/provider-actions';
import {ComponentType} from 'react';

export type Millisecond = number;

export type MapListItem = {
id: string;
title: string;
description: string;
loadParams: any;
imageUrl?: string;
lastModification?: Millisecond;
privateMap?: boolean;
};

export type Thumbnail = {
width: number;
height: number;
};

export type ProviderProps = {
name?: string;
displayName?: string;
icon?: ComponentType<IconProps>;
thumbnail?: Thumbnail;
};

interface IconProps {
height?: string;
width?: string;
}

const NAME = 'cloud-provider';
const DISPLAY_NAME = 'Cloud Provider';
Expand All @@ -45,7 +76,13 @@ export const FILE_CONFLICT_MSG = 'file_conflict';
* })
*/
export default class Provider {
constructor(props) {
name: string;
displayName: string;
icon: ComponentType<IconProps>;
thumbnail: Thumbnail;
getManagementUrl?: () => string;

constructor(props: ProviderProps) {
this.name = props.name || NAME;
this.displayName = props.displayName || DISPLAY_NAME;
this.icon = props.icon || ICON;
Expand All @@ -54,57 +91,57 @@ export default class Provider {

/**
* Whether this provider support upload map to a private storage. If truthy, user will be displayed with the storage save icon on the top right of the side bar.
* @returns {boolean}
* @returns
* @public
*/
hasPrivateStorage() {
hasPrivateStorage(): boolean {
return true;
}

/**
* Whether this provider support share map via a public url, if truthy, user will be displayed with a share map via url under the export map option on the top right of the side bar
* @returns {boolean}
* @returns
* @public
*/
hasSharingUrl() {
hasSharingUrl(): boolean {
return true;
}

/**
* This method is called after user share a map, to display the share url.
* @param {boolean} fullUrl - Whether to return the full url with domain, or just the location
* @returns {string} shareUrl
* @param fullUrl - Whether to return the full url with domain, or just the location
* @returns shareUrl
* @public
*/
getShareUrl(fullUrl = false) {
getShareUrl(fullUrl: boolean = false): string {
return '';
}

/**
* This method is called by kepler.gl demo app to pushes a new location to history, becoming the current location.
* @param {boolean} fullURL - Whether to return the full url with domain, or just the location
* @returns {string} mapUrl
* @param fullURL - Whether to return the full url with domain, or just the location
* @returns mapUrl
* @public
*/
getMapUrl(fullURL = true) {
getMapUrl(fullURL: boolean = true): string {
return '';
}

/**
* This method is called to determine whether user already logged in to this provider
* @public
* @returns {boolean} true if a user already logged in
* @returns true if a user already logged in
*/
getAccessToken() {
getAccessToken(): boolean {
return true;
}

/**
* This method is called to get the user name of the current user. It will be displayed in the cloud provider tile.
* @public
* @returns {string} true if a user already logged in
* @returns true if a user already logged in
*/
getUserName() {
getUserName(): string {
return '';
}

Expand Down Expand Up @@ -150,7 +187,13 @@ export default class Provider {
* @param {boolean} [param.options.isPublic] - whether user wish to share the map with others. if isPublic is truthy, kepler will call this.getShareUrl() to display an URL they can share with others
* @public
*/
async uploadMap({mapData, options = {}}) {
async uploadMap({
mapData,
options = {}
}: {
mapData: MapData;
options: ExportFileOptions;
}): Promise<any> {
return;
}

Expand All @@ -173,7 +216,7 @@ export default class Provider {
* ];
* }
*/
async listMaps() {
async listMaps(): Promise<MapListItem[]> {
return [];
}

Expand Down Expand Up @@ -202,7 +245,8 @@ export default class Provider {
* return downloadMap;
* }
*/
async downloadMap(loadParams) {
async downloadMap(loadParams): Promise<{map: MapData; format: string}> {
// @ts-expect-error
return;
}

Expand Down

0 comments on commit ec3351b

Please sign in to comment.