Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Refactor/customdata docs update #11

Merged
merged 13 commits into from
Jan 10, 2023
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@

- Replace `phone_number` with `phone` and `preferred_username` with `username` (INDIGO Sprint 221209, [!10](https://github.com/TeskaLabs/seacat-admin-webui/pull/10))

- Refactorization of CustomDataContainer to prevent passing invalid format of `uri` prop. Added documentation. (INDIGO Sprint 221209, [!11](https://github.com/TeskaLabs/seacat-admin-webui/pull/11))

## v22.48

### Compatibility
Expand Down
51 changes: 51 additions & 0 deletions doc/components/CustomDataContainer.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
# CustomDataContainer


`CustomDataContainer` renders a plug'n'play custom data card.


## Props:


- `app`

- `resources`: array, of credential's resources - used for ButtonWithAuthz granting option to edit Custom data

- `customData`: object, containing data provided by api

- `setCustomData`: function managing customData's state in parent component

- `loading`: boolean, comming from the parent component deciding whether the data has already been fetched or not. if false, displays content loader

- `resource`: string, resource granting option to edit CustomData

- `uri`: string, SeaCatAuths API endpoint do save edited data. should be in format 'credentials/mongodb:JJ68' for unification, avoid passing '/credentials/mongodb:JJ68' with slash as the first character


## Example:

```
import React from 'react';
import { CustomDataContainer } from '../components/CustomDataContainer';

const YourComponent = (props) => {

...

return (
<>

...

<CustomDataaContainer
resources={resources}
customData={customCredentialData}
setCustomData={setCustomCredentialData}
app={props.app}
loading={loadingCustomData}
uri={`path/to/${success}`}
/>
</>
)
}
```
2 changes: 1 addition & 1 deletion src/modules/auth/components/CustomDataContainer.js
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ export function CustomDataContainer({app, resources, customData, setCustomData,
// first, transform data to appropirate format for api request and skip pairs with empty key field
let objToSubmit = await prepForRequest(data);
try {
let response = await SeaCatAuthAPI.put(`/${uri}`, {"data": objToSubmit});
let response = await SeaCatAuthAPI.put(`/${uri.replace(/^\//g, "")}`, {"data": objToSubmit});
if (response.data.result !== "OK") {
throw new Error(t("CustomDataContainer|Something went wrong, failed to update data"));
};
Expand Down
224 changes: 0 additions & 224 deletions src/modules/auth/tenant/TenantCustomDataContainer.js

This file was deleted.