npm package: @gooddata/data-source-management
Description: GoodData Datasource management helps you to connect your cloud data to our platform.
Latest version: 2.0.151

# GoodData Datasource management

GoodData Datasource management helps you to connect your cloud data to our platform.

## Getting Started

### Prerequisites

```
nodejs
yarn (also will work with npm, but we strongly recommend yarn)
```

### Usage

With yarn installed, go to your project directory and run

```
$> yarn install --frozen-lockfile
```

### Local development

If you are developing on a Mac or Linux machine, add gd-developer-portal.local to the end of the line starting withc 127.0.0.1 in your /etc/hosts file (you may need administrator/root privileges for that). Here is an example of how the /etc/hosts file may look on a Mac:

```
##
# Host Database
#
# localhost is used to configure the loopback interface
# when the system is booting. Do not change this entry.
##
127.0.0.1 localhost
255.255.255.255 broadcasthost
::1 localhost

127.0.0.1   gdc-datasource-management.local
```

Create .env file according to the example and set up the `REACT_APP_CUSTOM_DOMAIN` variable to domain you are using for development. Make sure CORS are enabled on your dev domain for `gdc-datasource-management.local`.

For development, you can use hot reloading by separately command

```
$> yarn dev-tiger
```

### Access

Access the app at `https://gdc-datasource-management.local:3003/`

### Backend usage

The components in the package are supposed to be used as a plugin in another application. Therefore, they do not have
their own SDK backend instance. The backend is expected to be provided from the app that uses the components. See the
example in chapter below about how to do that.

When you make changes to the components, do not create new instances of the backend. Either use `useBackend` hook to
get the `backend` or `tigerSpecificFunctions` instance or define service function or utility with parameter that can
be used to provide backend to the function.

**Every backend call must be done via either `backend` or `tigerSpecificFunctions` instance from
`@gooddata/sdk-backend-tiger`**. The direct usage of `@gooddata/api-client-tiger` (such as calling `sdk.axios` and
making AJAX calls directly in the app) is **not allowed!** Such calls do not handle various errors states that
application, or in this case pluggable components, must react.

## How to use

Import the styles somewhere in your app.

```
@import '~@gooddata/data-source-management/build/styles/main';
```

Then, use a component called "CreateEditDataSource" to create a new data source or to edit an existing one.

The component must be wrapped in a context provider that provides component with SDK backend instances and
tiger specific functions object that is created when IAnalyticalBackend is initialized.

```
import { CreateEditDataSource, BackendProvider, ITigerSpecificFunctions } from "@gooddata/data-source-management";

const backend: IAnalyticalBackend = { ... };
const tigerSpecificFunctions: ITigerSpecificFunctions = { ... }

<BackendProvider backend={backend} tigerSpecificFunctions={tigerSpecificFunctions}>
    <CreateEditDataSource
        dataSourceType={<dataSourceType>}
        dataSourceId={<dataSourceId>}
        canDelete={true}
        onDataSourceClosed={onDataSourceClosed}
        onDataSourceSaved={onDataSourceSaved}
        onDataSourceDeleted={onDataSourceDeleted}
    />
</BackendProvider>
```

## License

(c) 2022 GoodData Corporation

This repository is under a BSD 3 license available in the [LICENSE](https://github.com/gooddata/gdc-datasource-management/blob/nas-master/LICENSE) file.