mirror of
https://github.com/ansible/awx.git
synced 2026-05-18 06:47:41 -02:30
Prettier
This commit is contained in:
committed by
John Westcott IV
parent
5be90fd36b
commit
c20e8eb712
@@ -1,5 +1,5 @@
|
|||||||
import React, { useCallback, useEffect, useState } from 'react';
|
import React, { useCallback, useEffect, useState } from 'react';
|
||||||
import {t} from "@lingui/macro";
|
import { t } from '@lingui/macro';
|
||||||
import ScreenHeader from 'components/ScreenHeader/ScreenHeader';
|
import ScreenHeader from 'components/ScreenHeader/ScreenHeader';
|
||||||
import { HostMetricsAPI } from 'api';
|
import { HostMetricsAPI } from 'api';
|
||||||
import useRequest from 'hooks/useRequest';
|
import useRequest from 'hooks/useRequest';
|
||||||
@@ -9,11 +9,11 @@ import PaginatedTable, {
|
|||||||
} from 'components/PaginatedTable';
|
} from 'components/PaginatedTable';
|
||||||
import DataListToolbar from 'components/DataListToolbar';
|
import DataListToolbar from 'components/DataListToolbar';
|
||||||
import { getQSConfig, parseQueryString } from 'util/qs';
|
import { getQSConfig, parseQueryString } from 'util/qs';
|
||||||
import {Card, PageSection} from "@patternfly/react-core";
|
import { Card, PageSection } from '@patternfly/react-core';
|
||||||
import { useLocation } from 'react-router-dom';
|
import { useLocation } from 'react-router-dom';
|
||||||
import useSelected from 'hooks/useSelected';
|
import useSelected from 'hooks/useSelected';
|
||||||
import HostMetricsListItem from "./HostMetricsListItem";
|
import HostMetricsListItem from './HostMetricsListItem';
|
||||||
import HostMetricsDeleteButton from "./HostMetricsDeleteButton";
|
import HostMetricsDeleteButton from './HostMetricsDeleteButton';
|
||||||
|
|
||||||
const QS_CONFIG = getQSConfig('host_metrics', {
|
const QS_CONFIG = getQSConfig('host_metrics', {
|
||||||
page: 1,
|
page: 1,
|
||||||
@@ -39,7 +39,7 @@ function HostMetrics() {
|
|||||||
const list = await HostMetricsAPI.read(params);
|
const list = await HostMetricsAPI.read(params);
|
||||||
return {
|
return {
|
||||||
count: list.data.count,
|
count: list.data.count,
|
||||||
results: list.data.results
|
results: list.data.results,
|
||||||
};
|
};
|
||||||
}, [location]),
|
}, [location]),
|
||||||
{ results: [], count: 0 }
|
{ results: [], count: 0 }
|
||||||
@@ -54,10 +54,7 @@ function HostMetrics() {
|
|||||||
|
|
||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
<ScreenHeader
|
<ScreenHeader streamType="none" breadcrumbConfig={breadcrumbConfig} />
|
||||||
streamType="none"
|
|
||||||
breadcrumbConfig={breadcrumbConfig}
|
|
||||||
/>
|
|
||||||
<PageSection>
|
<PageSection>
|
||||||
<Card>
|
<Card>
|
||||||
<PaginatedTable
|
<PaginatedTable
|
||||||
@@ -69,16 +66,24 @@ function HostMetrics() {
|
|||||||
renderRow={(item, index) => (
|
renderRow={(item, index) => (
|
||||||
<HostMetricsListItem
|
<HostMetricsListItem
|
||||||
item={item}
|
item={item}
|
||||||
isSelected={selected.some((row) => row.hostname === item.hostname)}
|
isSelected={selected.some(
|
||||||
|
(row) => row.hostname === item.hostname
|
||||||
|
)}
|
||||||
onSelect={() => handleSelect(item)}
|
onSelect={() => handleSelect(item)}
|
||||||
rowIndex={index}
|
rowIndex={index}
|
||||||
/>
|
/>
|
||||||
)}
|
)}
|
||||||
qsConfig={QS_CONFIG}
|
qsConfig={QS_CONFIG}
|
||||||
toolbarSearchColumns={[{name: t`Hostname`, key: 'hostname__icontains', isDefault: true}]}
|
toolbarSearchColumns={[
|
||||||
|
{
|
||||||
|
name: t`Hostname`,
|
||||||
|
key: 'hostname__icontains',
|
||||||
|
isDefault: true,
|
||||||
|
},
|
||||||
|
]}
|
||||||
toolbarSearchableKeys={[]}
|
toolbarSearchableKeys={[]}
|
||||||
toolbarRelatedSearchableKeys={[]}
|
toolbarRelatedSearchableKeys={[]}
|
||||||
renderToolbar={(props) =>
|
renderToolbar={(props) => (
|
||||||
<DataListToolbar
|
<DataListToolbar
|
||||||
{...props}
|
{...props}
|
||||||
advancedSearchDisabled
|
advancedSearchDisabled
|
||||||
@@ -89,43 +94,52 @@ function HostMetrics() {
|
|||||||
<HostMetricsDeleteButton
|
<HostMetricsDeleteButton
|
||||||
key="delete"
|
key="delete"
|
||||||
onDelete={() =>
|
onDelete={() =>
|
||||||
Promise.all(selected.map((hostMetric) =>
|
Promise.all(
|
||||||
HostMetricsAPI.destroy(hostMetric.id)))
|
selected.map((hostMetric) =>
|
||||||
.then(() => { readHostMetrics(); clearSelected(); })
|
HostMetricsAPI.destroy(hostMetric.id)
|
||||||
|
)
|
||||||
|
).then(() => {
|
||||||
|
readHostMetrics();
|
||||||
|
clearSelected();
|
||||||
|
})
|
||||||
}
|
}
|
||||||
itemsToDelete={selected}
|
itemsToDelete={selected}
|
||||||
pluralizedItemName={t`Host Metrics`}
|
pluralizedItemName={t`Host Metrics`}
|
||||||
/>]}
|
/>,
|
||||||
/>}
|
]}
|
||||||
|
/>
|
||||||
|
)}
|
||||||
headerRow={
|
headerRow={
|
||||||
<HeaderRow qsConfig={QS_CONFIG}>
|
<HeaderRow qsConfig={QS_CONFIG}>
|
||||||
<HeaderCell
|
<HeaderCell sortKey="hostname">{t`Hostname`}</HeaderCell>
|
||||||
sortKey="hostname">
|
|
||||||
{t`Hostname`}
|
|
||||||
</HeaderCell>
|
|
||||||
<HeaderCell
|
<HeaderCell
|
||||||
sortKey="first_automation"
|
sortKey="first_automation"
|
||||||
tooltip={t`When was the host first automated`}>
|
tooltip={t`When was the host first automated`}
|
||||||
|
>
|
||||||
{t`First automated`}
|
{t`First automated`}
|
||||||
</HeaderCell>
|
</HeaderCell>
|
||||||
<HeaderCell
|
<HeaderCell
|
||||||
sortKey="last_automation"
|
sortKey="last_automation"
|
||||||
tooltip={t`When was the host last automated`}>
|
tooltip={t`When was the host last automated`}
|
||||||
|
>
|
||||||
{t`Last automated`}
|
{t`Last automated`}
|
||||||
</HeaderCell>
|
</HeaderCell>
|
||||||
<HeaderCell
|
<HeaderCell
|
||||||
sortKey="automated_counter"
|
sortKey="automated_counter"
|
||||||
tooltip={t`How many times was the host automated`}>
|
tooltip={t`How many times was the host automated`}
|
||||||
|
>
|
||||||
{t`Automation`}
|
{t`Automation`}
|
||||||
</HeaderCell>
|
</HeaderCell>
|
||||||
<HeaderCell
|
<HeaderCell
|
||||||
sortKey="used_in_inventories"
|
sortKey="used_in_inventories"
|
||||||
tooltip={t`How many inventories is the host in, recomputed on a weekly schedule`}>
|
tooltip={t`How many inventories is the host in, recomputed on a weekly schedule`}
|
||||||
|
>
|
||||||
{t`Inventories`}
|
{t`Inventories`}
|
||||||
</HeaderCell>
|
</HeaderCell>
|
||||||
<HeaderCell
|
<HeaderCell
|
||||||
sortKey="deleted_counter"
|
sortKey="deleted_counter"
|
||||||
tooltip={t`How many times was the host deleted`}>
|
tooltip={t`How many times was the host deleted`}
|
||||||
|
>
|
||||||
{t`Deleted`}
|
{t`Deleted`}
|
||||||
</HeaderCell>
|
</HeaderCell>
|
||||||
</HeaderRow>
|
</HeaderRow>
|
||||||
|
|||||||
@@ -19,7 +19,7 @@ const mockHostMetrics = [
|
|||||||
used_in_inventories: 1,
|
used_in_inventories: 1,
|
||||||
deleted_counter: 1,
|
deleted_counter: 1,
|
||||||
id: 1,
|
id: 1,
|
||||||
}
|
},
|
||||||
];
|
];
|
||||||
|
|
||||||
function waitForLoaded(wrapper) {
|
function waitForLoaded(wrapper) {
|
||||||
|
|||||||
@@ -1,18 +1,7 @@
|
|||||||
import React, { useState } from 'react';
|
import React, { useState } from 'react';
|
||||||
import {
|
import { func, node, string, arrayOf, shape } from 'prop-types';
|
||||||
func,
|
|
||||||
node,
|
|
||||||
string,
|
|
||||||
arrayOf,
|
|
||||||
shape,
|
|
||||||
} from 'prop-types';
|
|
||||||
import styled from 'styled-components';
|
import styled from 'styled-components';
|
||||||
import {
|
import { Alert, Badge, Button, Tooltip } from '@patternfly/react-core';
|
||||||
Alert,
|
|
||||||
Badge,
|
|
||||||
Button,
|
|
||||||
Tooltip,
|
|
||||||
} from '@patternfly/react-core';
|
|
||||||
import { t } from '@lingui/macro';
|
import { t } from '@lingui/macro';
|
||||||
import { getRelatedResourceDeleteCounts } from 'util/getRelatedResourceDeleteDetails';
|
import { getRelatedResourceDeleteCounts } from 'util/getRelatedResourceDeleteDetails';
|
||||||
import AlertModal from '../../components/AlertModal';
|
import AlertModal from '../../components/AlertModal';
|
||||||
@@ -82,8 +71,7 @@ function HostMetricsDeleteButton({
|
|||||||
|
|
||||||
const modalTitle = t`Soft delete ${pluralizedItemName}?`;
|
const modalTitle = t`Soft delete ${pluralizedItemName}?`;
|
||||||
|
|
||||||
const isDisabled =
|
const isDisabled = itemsToDelete.length === 0;
|
||||||
itemsToDelete.length === 0;
|
|
||||||
|
|
||||||
const buildDeleteWarning = () => {
|
const buildDeleteWarning = () => {
|
||||||
const deleteMessages = [];
|
const deleteMessages = [];
|
||||||
@@ -181,7 +169,10 @@ function HostMetricsDeleteButton({
|
|||||||
>
|
>
|
||||||
<div>{t`This action will soft delete the following:`}</div>
|
<div>{t`This action will soft delete the following:`}</div>
|
||||||
{itemsToDelete.map((item) => (
|
{itemsToDelete.map((item) => (
|
||||||
<span key={item.hostname} id={`item-to-be-deleted-${item.hostname}`}>
|
<span
|
||||||
|
key={item.hostname}
|
||||||
|
id={`item-to-be-deleted-${item.hostname}`}
|
||||||
|
>
|
||||||
<strong>{item.hostname}</strong>
|
<strong>{item.hostname}</strong>
|
||||||
<br />
|
<br />
|
||||||
</span>
|
</span>
|
||||||
|
|||||||
@@ -3,21 +3,27 @@ import React from 'react';
|
|||||||
import { Tr, Td } from '@patternfly/react-table';
|
import { Tr, Td } from '@patternfly/react-table';
|
||||||
import { formatDateString } from 'util/dates';
|
import { formatDateString } from 'util/dates';
|
||||||
import { HostMetrics } from 'types';
|
import { HostMetrics } from 'types';
|
||||||
import {t} from "@lingui/macro";
|
import { t } from '@lingui/macro';
|
||||||
import {bool, func} from "prop-types";
|
import { bool, func } from 'prop-types';
|
||||||
|
|
||||||
function HostMetricsListItem({ item, isSelected, onSelect, rowIndex }) {
|
function HostMetricsListItem({ item, isSelected, onSelect, rowIndex }) {
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<Tr id={`host_metrics-row-${item.hostname}`} ouiaId={`host-metrics-row-${item.hostname}`}>
|
<Tr
|
||||||
|
id={`host_metrics-row-${item.hostname}`}
|
||||||
|
ouiaId={`host-metrics-row-${item.hostname}`}
|
||||||
|
>
|
||||||
<Td select={{ rowIndex, isSelected, onSelect }} dataLabel={t`Selected`} />
|
<Td select={{ rowIndex, isSelected, onSelect }} dataLabel={t`Selected`} />
|
||||||
<Td dataLabel={t`Hostname`}>{item.hostname}</Td>
|
<Td dataLabel={t`Hostname`}>{item.hostname}</Td>
|
||||||
<Td dataLabel={t`First automation`}>{formatDateString(item.first_automation)}</Td>
|
<Td dataLabel={t`First automation`}>
|
||||||
<Td dataLabel={t`Last automation`}>{formatDateString(item.last_automation)}</Td>
|
{formatDateString(item.first_automation)}
|
||||||
|
</Td>
|
||||||
|
<Td dataLabel={t`Last automation`}>
|
||||||
|
{formatDateString(item.last_automation)}
|
||||||
|
</Td>
|
||||||
<Td dataLabel={t`Automation`}>{item.automated_counter}</Td>
|
<Td dataLabel={t`Automation`}>{item.automated_counter}</Td>
|
||||||
<Td dataLabel={t`Inventories`}>{item.used_in_inventories || 0}</Td>
|
<Td dataLabel={t`Inventories`}>{item.used_in_inventories || 0}</Td>
|
||||||
<Td dataLabel={t`Deleted`}>{item.deleted_counter}</Td><
|
<Td dataLabel={t`Deleted`}>{item.deleted_counter}</Td>
|
||||||
/Tr>
|
</Tr>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user