Skip to content

Commit

Permalink
chore: apply linter and prettier code
Browse files Browse the repository at this point in the history
  • Loading branch information
pedroferreira1 committed Aug 20, 2024
1 parent 1ffaaea commit 802ae8f
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 18 deletions.
13 changes: 8 additions & 5 deletions src/api/nanoApi.js
Original file line number Diff line number Diff line change
Expand Up @@ -77,11 +77,14 @@ const nanoApi = {
*/
getBlueprintSourceCode(blueprintId) {
const data = { blueprint_id: blueprintId };
return requestExplorerServiceV1.get(`node_api/nc_blueprint_source_code`, {params: data}).then((res) => {
return res.data
}, (res) => {
throw new Error(res.data.message);
});
return requestExplorerServiceV1.get(`node_api/nc_blueprint_source_code`, { params: data }).then(
res => {
return res.data;
},
res => {
throw new Error(res.data.message);
}
);
},
};

Expand Down
30 changes: 17 additions & 13 deletions src/screens/nano/BlueprintDetail.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,10 @@
*/

import React, { useEffect, useRef, useState } from 'react';
import Loading from '../../components/Loading';
import nanoApi from '../../api/nanoApi';
import hljs from 'highlight.js/lib/core';
import python from 'highlight.js/lib/languages/python';
import Loading from '../../components/Loading';
import nanoApi from '../../api/nanoApi';

hljs.registerLanguage('python', python);

Expand Down Expand Up @@ -41,14 +41,14 @@ function BlueprintDetail(props) {
setLoading(true);
setBlueprintInformation(null);
try {
const blueprintInformation = await nanoApi.getBlueprintInformation(blueprintId);
const blueprintSourceCode = await nanoApi.getBlueprintSourceCode(blueprintId);
const blueprintInformationData = await nanoApi.getBlueprintInformation(blueprintId);
const blueprintSourceCodeData = await nanoApi.getBlueprintSourceCode(blueprintId);
if (ignore) {
// This is to prevent setting a state after the component has been already cleaned
return;
}
setBlueprintInformation(blueprintInformation);
setBlueprintSourceCode(blueprintSourceCode.source_code);
setBlueprintInformation(blueprintInformationData);
setBlueprintSourceCode(blueprintSourceCodeData.source_code);
} catch (e) {
if (ignore) {
// This is to prevent setting a state after the component has been already cleaned
Expand Down Expand Up @@ -142,10 +142,10 @@ function BlueprintDetail(props) {
*
* @param {Event} e Click event
*/
const onToggleShowCode = (e) => {
const onToggleShowCode = e => {
e.preventDefault();
setShowCode(!showCode);
}
};

return (
<div className="content-wrapper">
Expand All @@ -160,16 +160,20 @@ function BlueprintDetail(props) {
{blueprintInformation.name}
</p>
<h4 className="mt-5 mb-4">Attributes</h4>
{ renderBlueprintAttributes() }
{ renderBlueprintMethods('public_methods', 'Public Methods') }
{ renderBlueprintMethods('private_methods', 'Private Methods') }
{renderBlueprintAttributes()}
{renderBlueprintMethods('public_methods', 'Public Methods')}
{renderBlueprintMethods('private_methods', 'Private Methods')}
<div className="d-flex flex-row align-items-center mb-4 mt-4">
<h4 className="mb-0 mr-3">Source Code</h4>
<a href="true" onClick={(e) => onToggleShowCode(e)}>{showCode ? 'Hide' : 'Show'}</a>
<a href="true" onClick={e => onToggleShowCode(e)}>
{showCode ? 'Hide' : 'Show'}
</a>
</div>
<div className={`source-code ${showCode ? 'show' : ''}`}>
<pre>
<code ref={codeRef} className='language-python'>{blueprintSourceCode}</code>
<code ref={codeRef} className="language-python">
{blueprintSourceCode}
</code>
</pre>
</div>
</div>
Expand Down

0 comments on commit 802ae8f

Please sign in to comment.