Skip to content

Commit

Permalink
WIP Refactor the commits
Browse files Browse the repository at this point in the history
Signed-off-by: Alejandro Visiedo <[email protected]>
  • Loading branch information
avisiedo committed Sep 29, 2023
1 parent 70aa13a commit d805427
Show file tree
Hide file tree
Showing 15 changed files with 885 additions and 286 deletions.
2 changes: 1 addition & 1 deletion api
60 changes: 57 additions & 3 deletions docs/98-tips.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,22 +28,29 @@ For instance:
import './sample-component.scss';
import React from 'react';

interface SampleComponentProp {
/* SampleComponent component */

interface SampleComponentProps {
name: string;
description: string;
}

const defaultSampleComponentProps: SampleComponentProps = {
name: '',
description: '',
};

/**
* This is a dumb component that only recieves properties from a smart component.
* Dumb components are usually functions and not classes.
*
* @param props the props given by the smart component.
*/
const SampleComponent: React.FC<SampleComponentProp> = (props) => {
const SampleComponent: React.FC<SampleComponentProps> = (props) => {
return <span className="sample-component"> {props.children} </span>;
};

SampleComponent.displayName = 'SampleComponent';
SampleComponent.defaultProps = defaultSampleComponentProps;

export default SampleComponent;
```
Expand Down Expand Up @@ -133,6 +140,43 @@ class MyComponent extends React.Component<MyProps, MyState> {
}
```

## Forward properties when no levels or not many levels

The initial approach would be to define for a new component the interface
with the values to be passed as properties; this include values used and `events`
that will receive the parent component. This is the first immediate mechanism
to communicate with the parent component.

```typescript
interface MyComponentProps {
value: string;
onChange: (value: string) => void;
}

const defaultMyComponentProps: MyComponentProps = {
value: '',
onChange: (value: string) => { return; },
};

const MyComponent: React.FC<MyComponentProps> = (props) => {
const [state, setState] = useState<string>(props.value);
const onChange: (value: string) => {
setState(value);
props.onChange(state);
};
return (
<input onChange={onChange} value={state} />
);
};

MyComponent.defaultProps = defaultMyComponentProps;
```

In the above case, MyComponent receive the value to be displayed into
the `input` component, and when it is changed, the new value is send
to the parent component by calling the onChange callback provided by
the parent component.

## Use context when necessary

The most immediate way to pass information between the components
Expand All @@ -156,6 +200,16 @@ Said this, we can quickly identify some specific cases for our repository:
- The register domain in process, to show and update the info
as we advance in the wizard.

## Document your components

TODO

Document, document, document. Today we are confident about what we are
coding, tomorrow maybe we have forgotten everything about that new,
fancy and awesome component. It is for you, for your team and the
community. A component that is well documented, can be enhanced by
other team mates or the community.

## References

Helpful articles:
Expand Down
212 changes: 106 additions & 106 deletions src/Api/api.ts
Original file line number Diff line number Diff line change
Expand Up @@ -970,56 +970,6 @@ export const ActionsApiAxiosParamCreator = function (configuration?: Configurati
localVarRequestOptions.headers = { ...localVarHeaderParameter, ...headersFromBaseOptions, ...options.headers };
localVarRequestOptions.data = serializeDataIfNeeded(updateDomainAgentRequest, localVarRequestOptions, configuration);

return {
url: toPathString(localVarUrlObj),
options: localVarRequestOptions,
};
},
/**
* Update the rhel-idm domain information.
* @summary Update domain information by user.
* @param {string} uuid The uuid that identify the domain.
* @param {UpdateDomainUserRequest} updateDomainUserRequest Information for an IPA domain so it is updated from the ipa-hcc agent.
* @param {string} [xRhInsightsRequestId] Request id for distributed tracing.
* @param {*} [options] Override http request option.
* @throws {RequiredError}
*/
updateDomainUser: async (
uuid: string,
updateDomainUserRequest: UpdateDomainUserRequest,
xRhInsightsRequestId?: string,
options: AxiosRequestConfig = {}
): Promise<RequestArgs> => {
// verify required parameter 'uuid' is not null or undefined
assertParamExists('updateDomainUser', 'uuid', uuid);
// verify required parameter 'updateDomainUserRequest' is not null or undefined
assertParamExists('updateDomainUser', 'updateDomainUserRequest', updateDomainUserRequest);
const localVarPath = `/domains/{uuid}`.replace(`{${'uuid'}}`, encodeURIComponent(String(uuid)));
// use dummy base URL string because the URL constructor only accepts absolute URLs.
const localVarUrlObj = new URL(localVarPath, DUMMY_BASE_URL);
let baseOptions;
if (configuration) {
baseOptions = configuration.baseOptions;
}

const localVarRequestOptions = { method: 'PATCH', ...baseOptions, ...options };
const localVarHeaderParameter = {} as any;
const localVarQueryParameter = {} as any;

// authentication x-rh-identity required
await setApiKeyToObject(localVarHeaderParameter, 'X-Rh-Identity', configuration);

if (xRhInsightsRequestId != null) {
localVarHeaderParameter['X-Rh-Insights-Request-Id'] = String(xRhInsightsRequestId);
}

localVarHeaderParameter['Content-Type'] = 'application/json';

setSearchParams(localVarUrlObj, localVarQueryParameter);
let headersFromBaseOptions = baseOptions && baseOptions.headers ? baseOptions.headers : {};
localVarRequestOptions.headers = { ...localVarHeaderParameter, ...headersFromBaseOptions, ...options.headers };
localVarRequestOptions.data = serializeDataIfNeeded(updateDomainUserRequest, localVarRequestOptions, configuration);

return {
url: toPathString(localVarUrlObj),
options: localVarRequestOptions,
Expand Down Expand Up @@ -1081,24 +1031,6 @@ export const ActionsApiFp = function (configuration?: Configuration) {
);
return createRequestFunction(localVarAxiosArgs, globalAxios, BASE_PATH, configuration);
},
/**
* Update the rhel-idm domain information.
* @summary Update domain information by user.
* @param {string} uuid The uuid that identify the domain.
* @param {UpdateDomainUserRequest} updateDomainUserRequest Information for an IPA domain so it is updated from the ipa-hcc agent.
* @param {string} [xRhInsightsRequestId] Request id for distributed tracing.
* @param {*} [options] Override http request option.
* @throws {RequiredError}
*/
async updateDomainUser(
uuid: string,
updateDomainUserRequest: UpdateDomainUserRequest,
xRhInsightsRequestId?: string,
options?: AxiosRequestConfig
): Promise<(axios?: AxiosInstance, basePath?: string) => AxiosPromise<DomainResponse>> {
const localVarAxiosArgs = await localVarAxiosParamCreator.updateDomainUser(uuid, updateDomainUserRequest, xRhInsightsRequestId, options);
return createRequestFunction(localVarAxiosArgs, globalAxios, BASE_PATH, configuration);
},
};
};

Expand Down Expand Up @@ -1149,23 +1081,6 @@ export const ActionsApiFactory = function (configuration?: Configuration, basePa
.updateDomainAgent(uuid, xRhIdmVersion, updateDomainAgentRequest, xRhInsightsRequestId, options)
.then((request) => request(axios, basePath));
},
/**
* Update the rhel-idm domain information.
* @summary Update domain information by user.
* @param {string} uuid The uuid that identify the domain.
* @param {UpdateDomainUserRequest} updateDomainUserRequest Information for an IPA domain so it is updated from the ipa-hcc agent.
* @param {string} [xRhInsightsRequestId] Request id for distributed tracing.
* @param {*} [options] Override http request option.
* @throws {RequiredError}
*/
updateDomainUser(
uuid: string,
updateDomainUserRequest: UpdateDomainUserRequest,
xRhInsightsRequestId?: string,
options?: any
): AxiosPromise<DomainResponse> {
return localVarFp.updateDomainUser(uuid, updateDomainUserRequest, xRhInsightsRequestId, options).then((request) => request(axios, basePath));
},
};
};

Expand Down Expand Up @@ -1215,27 +1130,6 @@ export class ActionsApi extends BaseAPI {
.updateDomainAgent(uuid, xRhIdmVersion, updateDomainAgentRequest, xRhInsightsRequestId, options)
.then((request) => request(this.axios, this.basePath));
}

/**
* Update the rhel-idm domain information.
* @summary Update domain information by user.
* @param {string} uuid The uuid that identify the domain.
* @param {UpdateDomainUserRequest} updateDomainUserRequest Information for an IPA domain so it is updated from the ipa-hcc agent.
* @param {string} [xRhInsightsRequestId] Request id for distributed tracing.
* @param {*} [options] Override http request option.
* @throws {RequiredError}
* @memberof ActionsApi
*/
public updateDomainUser(
uuid: string,
updateDomainUserRequest: UpdateDomainUserRequest,
xRhInsightsRequestId?: string,
options?: AxiosRequestConfig
) {
return ActionsApiFp(this.configuration)
.updateDomainUser(uuid, updateDomainUserRequest, xRhInsightsRequestId, options)
.then((request) => request(this.axios, this.basePath));
}
}

/**
Expand Down Expand Up @@ -1510,6 +1404,56 @@ export const ResourcesApiAxiosParamCreator = function (configuration?: Configura
localVarRequestOptions.headers = { ...localVarHeaderParameter, ...headersFromBaseOptions, ...options.headers };
localVarRequestOptions.data = serializeDataIfNeeded(registerDomainRequest, localVarRequestOptions, configuration);

return {
url: toPathString(localVarUrlObj),
options: localVarRequestOptions,
};
},
/**
* Update the rhel-idm domain information.
* @summary Update domain information by user.
* @param {string} uuid The uuid that identify the domain.
* @param {UpdateDomainUserRequest} updateDomainUserRequest Information for an IPA domain so it is updated from the ipa-hcc agent.
* @param {string} [xRhInsightsRequestId] Request id for distributed tracing.
* @param {*} [options] Override http request option.
* @throws {RequiredError}
*/
updateDomainUser: async (
uuid: string,
updateDomainUserRequest: UpdateDomainUserRequest,
xRhInsightsRequestId?: string,
options: AxiosRequestConfig = {}
): Promise<RequestArgs> => {
// verify required parameter 'uuid' is not null or undefined
assertParamExists('updateDomainUser', 'uuid', uuid);
// verify required parameter 'updateDomainUserRequest' is not null or undefined
assertParamExists('updateDomainUser', 'updateDomainUserRequest', updateDomainUserRequest);
const localVarPath = `/domains/{uuid}`.replace(`{${'uuid'}}`, encodeURIComponent(String(uuid)));
// use dummy base URL string because the URL constructor only accepts absolute URLs.
const localVarUrlObj = new URL(localVarPath, DUMMY_BASE_URL);
let baseOptions;
if (configuration) {
baseOptions = configuration.baseOptions;
}

const localVarRequestOptions = { method: 'PATCH', ...baseOptions, ...options };
const localVarHeaderParameter = {} as any;
const localVarQueryParameter = {} as any;

// authentication x-rh-identity required
await setApiKeyToObject(localVarHeaderParameter, 'X-Rh-Identity', configuration);

if (xRhInsightsRequestId != null) {
localVarHeaderParameter['X-Rh-Insights-Request-Id'] = String(xRhInsightsRequestId);
}

localVarHeaderParameter['Content-Type'] = 'application/json';

setSearchParams(localVarUrlObj, localVarQueryParameter);
let headersFromBaseOptions = baseOptions && baseOptions.headers ? baseOptions.headers : {};
localVarRequestOptions.headers = { ...localVarHeaderParameter, ...headersFromBaseOptions, ...options.headers };
localVarRequestOptions.data = serializeDataIfNeeded(updateDomainUserRequest, localVarRequestOptions, configuration);

return {
url: toPathString(localVarUrlObj),
options: localVarRequestOptions,
Expand Down Expand Up @@ -1631,6 +1575,24 @@ export const ResourcesApiFp = function (configuration?: Configuration) {
);
return createRequestFunction(localVarAxiosArgs, globalAxios, BASE_PATH, configuration);
},
/**
* Update the rhel-idm domain information.
* @summary Update domain information by user.
* @param {string} uuid The uuid that identify the domain.
* @param {UpdateDomainUserRequest} updateDomainUserRequest Information for an IPA domain so it is updated from the ipa-hcc agent.
* @param {string} [xRhInsightsRequestId] Request id for distributed tracing.
* @param {*} [options] Override http request option.
* @throws {RequiredError}
*/
async updateDomainUser(
uuid: string,
updateDomainUserRequest: UpdateDomainUserRequest,
xRhInsightsRequestId?: string,
options?: AxiosRequestConfig
): Promise<(axios?: AxiosInstance, basePath?: string) => AxiosPromise<DomainResponse>> {
const localVarAxiosArgs = await localVarAxiosParamCreator.updateDomainUser(uuid, updateDomainUserRequest, xRhInsightsRequestId, options);
return createRequestFunction(localVarAxiosArgs, globalAxios, BASE_PATH, configuration);
},
};
};

Expand Down Expand Up @@ -1717,6 +1679,23 @@ export const ResourcesApiFactory = function (configuration?: Configuration, base
.registerDomain(xRhIdmRegistrationToken, xRhIdmVersion, registerDomainRequest, xRhInsightsRequestId, options)
.then((request) => request(axios, basePath));
},
/**
* Update the rhel-idm domain information.
* @summary Update domain information by user.
* @param {string} uuid The uuid that identify the domain.
* @param {UpdateDomainUserRequest} updateDomainUserRequest Information for an IPA domain so it is updated from the ipa-hcc agent.
* @param {string} [xRhInsightsRequestId] Request id for distributed tracing.
* @param {*} [options] Override http request option.
* @throws {RequiredError}
*/
updateDomainUser(
uuid: string,
updateDomainUserRequest: UpdateDomainUserRequest,
xRhInsightsRequestId?: string,
options?: any
): AxiosPromise<DomainResponse> {
return localVarFp.updateDomainUser(uuid, updateDomainUserRequest, xRhInsightsRequestId, options).then((request) => request(axios, basePath));
},
};
};

Expand Down Expand Up @@ -1824,4 +1803,25 @@ export class ResourcesApi extends BaseAPI {
.registerDomain(xRhIdmRegistrationToken, xRhIdmVersion, registerDomainRequest, xRhInsightsRequestId, options)
.then((request) => request(this.axios, this.basePath));
}

/**
* Update the rhel-idm domain information.
* @summary Update domain information by user.
* @param {string} uuid The uuid that identify the domain.
* @param {UpdateDomainUserRequest} updateDomainUserRequest Information for an IPA domain so it is updated from the ipa-hcc agent.
* @param {string} [xRhInsightsRequestId] Request id for distributed tracing.
* @param {*} [options] Override http request option.
* @throws {RequiredError}
* @memberof ResourcesApi
*/
public updateDomainUser(
uuid: string,
updateDomainUserRequest: UpdateDomainUserRequest,
xRhInsightsRequestId?: string,
options?: AxiosRequestConfig
) {
return ResourcesApiFp(this.configuration)
.updateDomainUser(uuid, updateDomainUserRequest, xRhInsightsRequestId, options)
.then((request) => request(this.axios, this.basePath));
}
}
Loading

0 comments on commit d805427

Please sign in to comment.