From 8051e703cd4554970b8f9c54c306bf6713825285 Mon Sep 17 00:00:00 2001 From: Luciano Gorza Date: Tue, 2 Jan 2024 13:04:15 -0300 Subject: [PATCH] Format file --- .../components/settings/api/api-table.js | 198 +++++++++++------- 1 file changed, 127 insertions(+), 71 deletions(-) diff --git a/plugins/main/public/components/settings/api/api-table.js b/plugins/main/public/components/settings/api/api-table.js index 2833942ebc..89bed290c1 100644 --- a/plugins/main/public/components/settings/api/api-table.js +++ b/plugins/main/public/components/settings/api/api-table.js @@ -41,7 +41,7 @@ import { formatUIDate } from '../../../react-services/time-service'; export const ApiTable = compose( withErrorBoundary, - withReduxProvider + withReduxProvider, )( class ApiTable extends Component { constructor(props) { @@ -62,7 +62,9 @@ export const ApiTable = compose( async getApisAvailableUpdates(forceUpdate = false) { try { this.setState({ refreshingAvailableUpdates: true }); - const availableUpdates = await this.state.getAvailableUpdates(forceUpdate); + const availableUpdates = await this.state.getAvailableUpdates( + forceUpdate, + ); this.setState({ availableUpdates }); } catch (error) { const options = { @@ -73,7 +75,9 @@ export const ApiTable = compose( error: { error: error, message: error.message || error, - title: `Error checking available updates: ${error.message || error}`, + title: `Error checking available updates: ${ + error.message || error + }`, }, }; @@ -141,7 +145,12 @@ export const ApiTable = compose( refreshingEntries: false, }); } catch (error) { - if (error && error.data && error.data.message && error.data.code === 2001) { + if ( + error && + error.data && + error.data.message && + error.data.code === 2001 + ) { this.props.showAddApiWithInitialError(error); } } @@ -154,7 +163,7 @@ export const ApiTable = compose( async checkApi(api) { try { const entries = this.state.apiEntries; - const idx = entries.map((e) => e.id).indexOf(api.id); + const idx = entries.map(e => e.id).indexOf(api.id); try { await this.props.checkManager(api); entries[idx].status = 'online'; @@ -183,7 +192,9 @@ export const ApiTable = compose( error: { error: error, message: error.message || error, - title: `Error checking manager connection: ${error.message || error}`, + title: `Error checking manager connection: ${ + error.message || error + }`, }, }; @@ -213,13 +224,14 @@ export const ApiTable = compose( }, }; - const isLoading = this.state.refreshingEntries || this.state.refreshingAvailableUpdates; + const isLoading = + this.state.refreshingEntries || this.state.refreshingAvailableUpdates; const items = [ - ...this.state.apiEntries?.map((apiEntry) => { + ...this.state.apiEntries?.map(apiEntry => { const versionData = this.state.availableUpdates?.apis_available_updates?.find( - (apiAvailableUpdates) => apiAvailableUpdates.api_id === apiEntry.id + apiAvailableUpdates => apiAvailableUpdates.api_id === apiEntry.id, ) || {}; return { @@ -272,44 +284,56 @@ export const ApiTable = compose( name: 'Status', align: 'left', sortable: true, - render: (item) => { + render: item => { if (item) { return item === 'online' ? ( - + Online ) : item.status === 'down' ? ( - + - + Warning - + this.props.copyToClipBoard(item.downReason)} + color='primary' + iconType='questionInCircle' + aria-label='Info about the error' + onClick={() => + this.props.copyToClipBoard(item.downReason) + } /> ) : ( - + - + Offline - + this.props.copyToClipBoard(item.downReason)} + color='primary' + iconType='questionInCircle' + aria-label='Info about the error' + onClick={() => + this.props.copyToClipBoard(item.downReason) + } /> @@ -318,7 +342,7 @@ export const ApiTable = compose( } else { return ( - +   Checking ); @@ -338,11 +362,16 @@ export const ApiTable = compose( render: (item, api) => { const color = API_UPDATES_STATUS_COLUMN[item]?.color ?? 'subdued'; - const content = API_UPDATES_STATUS_COLUMN[item]?.text ?? 'Never checked'; + const content = + API_UPDATES_STATUS_COLUMN[item]?.text ?? 'Never checked'; if (!this.state.refreshingAvailableUpdates) { return ( - + {content} @@ -351,36 +380,50 @@ export const ApiTable = compose( {!item ? ( Click Check updates button to get information

} > - +
) : null} {item === 'availableUpdates' ? ( - View available updates

}> + View available updates

} + > this.setState({ apiAvailableUpdateDetails: api })} + aria-label='Availabe updates' + iconType='eye' + onClick={() => + this.setState({ apiAvailableUpdateDetails: api }) + } />
) : null} {item === 'error' && api.error?.detail ? ( - + this.props.copyToClipBoard(api.error.detail)} + color='primary' + iconType='questionInCircle' + aria-label='Info about the error' + onClick={() => + this.props.copyToClipBoard(api.error.detail) + } /> @@ -390,7 +433,7 @@ export const ApiTable = compose( } else { return ( - +   Checking ); @@ -403,20 +446,20 @@ export const ApiTable = compose( align: 'center', sortable: true, width: '80px', - render: (value) => { + render: value => { return value === API_USER_STATUS_RUN_AS.ENABLED ? ( - + ) : value === API_USER_STATUS_RUN_AS.USER_NOT_ALLOWED ? ( - + ) : ( '' @@ -425,15 +468,19 @@ export const ApiTable = compose( }, { name: 'Actions', - render: (item) => ( + render: item => ( Set as default

}} - iconType={item.id === this.props.currentDefault ? 'starFilled' : 'starEmpty'} - aria-label="Set as default" + iconType={ + item.id === this.props.currentDefault + ? 'starFilled' + : 'starEmpty' + } + aria-label='Set as default' onClick={async () => { const currentDefault = await this.props.setDefault(item); this.setState({ @@ -443,12 +490,12 @@ export const ApiTable = compose( />
- Check connection

}> + Check connection

}> await this.checkApi(item)} - color="success" + color='success' />
@@ -466,8 +513,8 @@ export const ApiTable = compose( return ( - - + + @@ -479,8 +526,8 @@ export const ApiTable = compose( this.props.showAddApi()} > @@ -488,26 +535,33 @@ export const ApiTable = compose( - await this.refresh()}> + await this.refresh()} + > Refresh await this.getApisAvailableUpdates(true)} > Check updates{' '} - + @@ -518,32 +572,34 @@ export const ApiTable = compose( - - From here you can manage and configure the API entries. You can also check their - connection and status. + + From here you can manage and configure the API entries. You + can also check their connection and status. this.setState({ apiAvailableUpdateDetails: undefined })} + onClose={() => + this.setState({ apiAvailableUpdateDetails: undefined }) + } /> ); } - } + }, ); ApiTable.propTypes = {