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

feat(inputs): show input services status count #1430

Merged
merged 22 commits into from
Nov 20, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
22 commits
Select commit Hold shift + click to select a range
8c94459
feat(inputs): added status count of services in inputs page
rohanm-crest Nov 5, 2024
f8c33b3
Merge branch 'develop' into feat/show-status-count
rohanm-crest Nov 6, 2024
e7fbdf7
refactor: added the typography instead of span
rohanm-crest Nov 6, 2024
1928fb8
update screenshots
srv-rr-github-token Nov 6, 2024
bc4f273
feat(inputs): added status count of services in inputs page
rohanm-crest Nov 5, 2024
400530d
refactor: added the typography instead of span
rohanm-crest Nov 6, 2024
ef0f2df
update screenshots
srv-rr-github-token Nov 6, 2024
e22c7bd
test(ui): added unit test case for enable count
rohanm-crest Nov 15, 2024
4b17a28
Merge branch 'feat/show-status-count' of https://github.com/splunk/ad…
rohanm-crest Nov 15, 2024
ecfde0a
Merge branch 'develop' into feat/show-status-count
rohanm-crest Nov 15, 2024
783ceb7
Update ui/src/components/table/TableHeader.jsx
rohanm-crest Nov 15, 2024
942ab51
update screenshots
srv-rr-github-token Nov 15, 2024
88f3468
chore: change variables
rohanm-crest Nov 15, 2024
366ce31
Merge branch 'feat/show-status-count' of https://github.com/splunk/ad…
rohanm-crest Nov 15, 2024
57f20ad
refactor: add condition istab
rohanm-crest Nov 15, 2024
948d78a
update screenshots
srv-rr-github-token Nov 15, 2024
9b56338
refactor: add input page condition
rohanm-crest Nov 15, 2024
0312093
Merge branch 'feat/show-status-count' of https://github.com/splunk/ad…
rohanm-crest Nov 15, 2024
b245687
chore: added classname for smartx
rohanm-crest Nov 18, 2024
2078bf2
Merge branch 'develop' into feat/show-status-count
rohanm-crest Nov 18, 2024
f47cbf1
Merge branch 'develop' of https://github.com/splunk/addonfactory-ucc-…
rohanm-crest Nov 20, 2024
2e3559d
chore: remove unwanted code
rohanm-crest Nov 20, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Binary file modified docs/images/inputs/Tabs_Output.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
21 changes: 17 additions & 4 deletions ui/src/components/table/TableHeader.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@ import React from 'react';
import PropTypes from 'prop-types';
import Select from '@splunk/react-ui/Select';
import Paginator from '@splunk/react-ui/Paginator';
import { Typography } from '@splunk/react-ui/Typography';

import styled from 'styled-components';
import { _ } from '@splunk/ui-utils/i18n';

Expand Down Expand Up @@ -71,13 +73,24 @@ function TableHeader({
);
};

const getInputCountStatus = () => {
const enabledRowCount = allFilteredData.filter((item) => !item.disabled).length;
const showCountStatus = `(${enabledRowCount} of ${totalElement} enabled)`;

return (
<Typography as="span" className="inputNumber">
{totalElement}
{totalElement > 1 ? _(` ${itemLabel}s`) : _(` ${itemLabel}`)}
&nbsp;
{page === PAGE_INPUT && totalElement >= pageSize ? showCountStatus : null}
</Typography>
);
};

return (
<TableHeaderWrapper>
<div>
<span className="inputNumber">
rohanm-crest marked this conversation as resolved.
Show resolved Hide resolved
{totalElement}
{totalElement > 1 ? _(` ${itemLabel}s`) : _(` ${itemLabel}`)}
</span>
{getInputCountStatus()}
{page === PAGE_INPUT ? (
<TableSelectBoxWrapper>
<Select
Expand Down
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
100 changes: 100 additions & 0 deletions ui/src/components/table/stories/rowDataMockup.ts
Original file line number Diff line number Diff line change
Expand Up @@ -394,6 +394,98 @@ export const ROW_DATA = [
},
];

export const ROW_DATA_FOR_COUNT = [
...ROW_DATA,
{
name: 'testsomethingelse1',
id: 'https://localhost:8000/servicesNS/nobody/Splunk_TA_UCCExample/splunk_ta_uccexample_account/testsomethingelse',
updated: '1970-01-01T00:00:00+00:00',
links: {
alternate:
'/servicesNS/nobody/Splunk_TA_UCCExample/splunk_ta_uccexample_account/testsomethingelse',
list: '/servicesNS/nobody/Splunk_TA_UCCExample/splunk_ta_uccexample_account/testsomethingelse',
edit: '/servicesNS/nobody/Splunk_TA_UCCExample/splunk_ta_uccexample_account/testsomethingelse',
remove: '/servicesNS/nobody/Splunk_TA_UCCExample/splunk_ta_uccexample_account/testsomethingelse',
},
author: 'admin',
acl: {
app: 'Splunk_TA_UCCExample',
can_change_perms: true,
can_list: true,
can_share_app: true,
can_share_global: true,
can_share_user: true,
can_write: true,
modifiable: true,
owner: 'admin',
perms: {
read: ['*'],
write: ['admin', 'sc_admin'],
},
removable: true,
sharing: 'global',
},
content: {
account_multiple_select: 'two',
account_radio: '1',
auth_type: 'basic',
custom_endpoint: 'login.example.com',
disabled: true,
'eai:acl': null,
'eai:appName': 'Splunk_TA_UCCExample',
'eai:userName': 'nobody',
password: '******',
custom_text: 'testsomethingelse',
token: '******',
username: 'test1',
},
},
{
name: 'zzzzzzzz',
id: 'https://localhost:8000/servicesNS/nobody/Splunk_TA_UCCExample/splunk_ta_uccexample_account/zzzzzzz',
updated: '1970-01-01T00:00:00+00:00',
links: {
alternate:
'/servicesNS/nobody/Splunk_TA_UCCExample/splunk_ta_uccexample_account/zzzzzzz',
list: '/servicesNS/nobody/Splunk_TA_UCCExample/splunk_ta_uccexample_account/zzzzzzz',
edit: '/servicesNS/nobody/Splunk_TA_UCCExample/splunk_ta_uccexample_account/zzzzzzz',
remove: '/servicesNS/nobody/Splunk_TA_UCCExample/splunk_ta_uccexample_account/zzzzzzz',
},
author: 'admin',
acl: {
app: 'Splunk_TA_UCCExample',
can_change_perms: true,
can_list: true,
can_share_app: true,
can_share_global: true,
can_share_user: true,
can_write: true,
modifiable: true,
owner: 'admin',
perms: {
read: ['*'],
write: ['admin', 'sc_admin'],
},
removable: true,
sharing: 'global',
},
content: {
account_multiple_select: 'one',
account_radio: '1',
auth_type: 'basic',
custom_endpoint: 'login.example.com',
disabled: true,
'eai:acl': null,
'eai:appName': 'Splunk_TA_UCCExample',
'eai:userName': 'nobody',
password: '******',
custom_text: '222222',
token: '******',
username: 'zzzzz',
},
},
];

export const MockRowData = {
links: {
create: `/servicesNS/nobody/-/splunk_ta_uccexample_account/_new`,
Expand All @@ -402,6 +494,14 @@ export const MockRowData = {
entry: ROW_DATA,
messages: [],
};
export const MockRowDataForStatusCount = {
links: {
create: `/servicesNS/nobody/-/splunk_ta_uccexample_account/_new`,
},
updated: '2023-08-21T11:54:12+00:00',
entry: ROW_DATA_FOR_COUNT,
messages: [],
};

export const ServerHandlers = [
http.get(`/servicesNS/nobody/-/splunk_ta_uccexample_account`, () =>
Expand Down
34 changes: 32 additions & 2 deletions ui/src/components/table/tests/TableWrapper.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,16 @@ import userEvent from '@testing-library/user-event';
import React from 'react';
import { http, HttpResponse } from 'msw';
import { BrowserRouter } from 'react-router-dom';
import { MockRowData } from '../stories/rowDataMockup';
import { MockRowData, MockRowDataForStatusCount } from '../stories/rowDataMockup';
import TableWrapper, { ITableWrapperProps } from '../TableWrapper';
import { server } from '../../../mocks/server';
import { TableContextProvider } from '../../../context/TableContext';
import { setUnifiedConfig } from '../../../util/util';
import { getSimpleConfigWithMapping, SIMPLE_NAME_TABLE_MOCK_DATA } from '../stories/configMockups';
import {
getSimpleConfigStylePage,
getSimpleConfigWithMapping,
SIMPLE_NAME_TABLE_MOCK_DATA,
} from '../stories/configMockups';

jest.mock('immutability-helper');

Expand Down Expand Up @@ -183,3 +187,29 @@ it('Correctly render status labels with mapped values', async () => {
const inActiveStatusCell = within(inActiveRow).getByTestId('status');
expect(inActiveStatusCell).toHaveTextContent('Disabled Field');
});

it('Check inputs count is visible', async () => {
const props = {
page: 'inputs',
serviceName: 'example_input_one',
handleRequestModalOpen,
handleOpenPageStyleDialog,
displayActionBtnAllRows: false,
} satisfies ITableWrapperProps;
server.use(
http.get('/servicesNS/nobody/-/splunk_ta_uccexample_example_input_one', () =>
HttpResponse.json(MockRowDataForStatusCount)
)
);

setUnifiedConfig(getSimpleConfigStylePage());

render(
<TableContextProvider>
<TableWrapper {...props} />
</TableContextProvider>,
{ wrapper: BrowserRouter }
);
const statusCount = await screen.findByText('11 Inputs (7 of 11 enabled)');
expect(statusCount).toBeInTheDocument();
});
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading