From 294888454df4005cfcf7da4383b4a4128694eefa Mon Sep 17 00:00:00 2001 From: Alejandro Celaya Date: Sun, 23 Aug 2020 10:52:37 +0200 Subject: [PATCH] Renamed NewServerData to ServerData, as it's used in other contexts too --- src/servers/CreateServer.tsx | 4 ++-- src/servers/data/index.ts | 2 +- src/servers/helpers/ImportServersBtn.tsx | 4 ++-- src/servers/reducers/servers.ts | 6 +++--- src/servers/services/ServersImporter.ts | 6 +++--- 5 files changed, 11 insertions(+), 11 deletions(-) diff --git a/src/servers/CreateServer.tsx b/src/servers/CreateServer.tsx index dd140b3f..de171ac3 100644 --- a/src/servers/CreateServer.tsx +++ b/src/servers/CreateServer.tsx @@ -6,7 +6,7 @@ import NoMenuLayout from '../common/NoMenuLayout'; import { StateFlagTimeout } from '../utils/helpers/hooks'; import { ServerForm } from './helpers/ServerForm'; import { ImportServersBtnProps } from './helpers/ImportServersBtn'; -import { NewServerData, ServerWithId } from './data'; +import { ServerData, ServerWithId } from './data'; import './CreateServer.scss'; const SHOW_IMPORT_MSG_TIME = 4000; @@ -36,7 +36,7 @@ const CreateServer = (ImportServersBtn: FC, useStateFlagT ) => { const [ serversImported, setServersImported ] = useStateFlagTimeout(false, SHOW_IMPORT_MSG_TIME); const [ errorImporting, setErrorImporting ] = useStateFlagTimeout(false, SHOW_IMPORT_MSG_TIME); - const handleSubmit = (serverData: NewServerData) => { + const handleSubmit = (serverData: ServerData) => { const id = uuid(); createServer({ ...serverData, id }); diff --git a/src/servers/data/index.ts b/src/servers/data/index.ts index 97ade453..222b418e 100644 --- a/src/servers/data/index.ts +++ b/src/servers/data/index.ts @@ -1,4 +1,4 @@ -export interface NewServerData { +export interface ServerData { name: string; url: string; apiKey: string; diff --git a/src/servers/helpers/ImportServersBtn.tsx b/src/servers/helpers/ImportServersBtn.tsx index 95464210..41a7d465 100644 --- a/src/servers/helpers/ImportServersBtn.tsx +++ b/src/servers/helpers/ImportServersBtn.tsx @@ -1,7 +1,7 @@ import React, { useRef, RefObject, ChangeEvent, MutableRefObject } from 'react'; import { UncontrolledTooltip } from 'reactstrap'; import ServersImporter from '../services/ServersImporter'; -import { NewServerData } from '../data'; +import { ServerData } from '../data'; type Ref = RefObject | MutableRefObject; @@ -11,7 +11,7 @@ export interface ImportServersBtnProps { } interface ImportServersBtnConnectProps extends ImportServersBtnProps { - createServers: (servers: NewServerData[]) => void; + createServers: (servers: ServerData[]) => void; fileRef: Ref; } diff --git a/src/servers/reducers/servers.ts b/src/servers/reducers/servers.ts index 9d97dd8c..17fc71b2 100644 --- a/src/servers/reducers/servers.ts +++ b/src/servers/reducers/servers.ts @@ -1,7 +1,7 @@ import { handleActions } from 'redux-actions'; import { pipe, assoc, map, reduce, dissoc } from 'ramda'; import { v4 as uuid } from 'uuid'; -import { NewServerData, ServerWithId } from '../data'; +import { ServerData, ServerWithId } from '../data'; /* eslint-disable padding-line-between-statements */ export const EDIT_SERVER = 'shlink/servers/EDIT_SERVER'; @@ -13,7 +13,7 @@ export type ServersMap = Record; const initialState: ServersMap = {}; -const serverWithId = (server: ServerWithId | NewServerData): ServerWithId => { +const serverWithId = (server: ServerWithId | ServerData): ServerWithId => { if ((server as ServerWithId).id) { return server as ServerWithId; } @@ -39,7 +39,7 @@ export const createServers = pipe( export const createServer = (server: ServerWithId) => createServers([ server ]); -export const editServer = (serverId: string, serverData: Partial) => ({ +export const editServer = (serverId: string, serverData: Partial) => ({ type: EDIT_SERVER, serverId, serverData, diff --git a/src/servers/services/ServersImporter.ts b/src/servers/services/ServersImporter.ts index 2ffe8bda..8876d3fd 100644 --- a/src/servers/services/ServersImporter.ts +++ b/src/servers/services/ServersImporter.ts @@ -1,12 +1,12 @@ import { CsvJson } from 'csvjson'; -import { NewServerData } from '../data'; +import { ServerData } from '../data'; const CSV_MIME_TYPE = 'text/csv'; export default class ServersImporter { public constructor(private readonly csvjson: CsvJson, private readonly fileReaderFactory: () => FileReader) {} - public importServersFromFile = async (file?: File | null): Promise => { + public importServersFromFile = async (file?: File | null): Promise => { if (!file || file.type !== CSV_MIME_TYPE) { throw new Error('No file provided or file is not a CSV'); } @@ -16,7 +16,7 @@ export default class ServersImporter { return new Promise((resolve) => { reader.addEventListener('loadend', (e: ProgressEvent) => { const content = e.target?.result?.toString() ?? ''; - const servers = this.csvjson.toObject(content); + const servers = this.csvjson.toObject(content); resolve(servers); });