Skip to content

Commit

Permalink
Fix company tags style
Browse files Browse the repository at this point in the history
  • Loading branch information
jeffibm committed Apr 2, 2024
1 parent 5a08c23 commit 8c243a1
Show file tree
Hide file tree
Showing 3 changed files with 43 additions and 24 deletions.
45 changes: 21 additions & 24 deletions app/javascript/components/settings-company-tags/index.jsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import React, { useState, useEffect } from 'react';
import PropTypes from 'prop-types';
import { Button } from 'carbon-components-react';
import { Button, Accordion, AccordionItem } from 'carbon-components-react';
import { AddAlt16 } from '@carbon/icons-react';
import MiqDataTable from '../miq-data-table';
import MiqStructuredList from '../miq-structured-list';
import SettingsCompanyTagsEntryForm from '../settings-company-tags-entry-form';
Expand Down Expand Up @@ -70,7 +71,7 @@ const SettingsCompanyTags = ({ pageTitle, categoryId }) => {
});
};

/** Function to be exeuted after the add/save/cancel/delete action */
/** Function to be executed after the add/save/cancel/delete action */
const formCallback = (actionType, responseData) => {
if (responseData.status === 'error') {
return setData({
Expand Down Expand Up @@ -130,25 +131,16 @@ const SettingsCompanyTags = ({ pageTitle, categoryId }) => {

/** Function to render the add new button */
const renderActionButton = () => (
<Button
onClick={() => onSelect('new')}
onKeyPress={() => onSelect('new')}
title={__('Click to add a new entry')}
>
{__('Add Entry')}
</Button>
);

/** Function to render the title bar */
const renderTitleBar = (title, hasButton) => (
<div className="miq-custom-tab-content-header">
<div className="tab-content-header-title">
<h3>{title}</h3>
</div>
<div className="tab-content-header-actions" />
{
hasButton && renderActionButton()
}
<div className="custom-accordion-buttons">
<Button
onClick={() => onSelect('new')}
onKeyPress={() => onSelect('new')}
renderIcon={AddAlt16}
size="sm"
title={__('Click to add a new entry')}
>
{__('Add Entry')}
</Button>
</div>
);

Expand All @@ -158,6 +150,7 @@ const SettingsCompanyTags = ({ pageTitle, categoryId }) => {
return (
<MiqStructuredList
rows={rows}
title={pageTitle}
mode={mode}
onClick={(dropDownData) => onDropDownChange(dropDownData)} // ToDo: onClick must be generic name
/>
Expand All @@ -174,7 +167,7 @@ const SettingsCompanyTags = ({ pageTitle, categoryId }) => {
return (
<>
<input type="hidden" id="ignore_form_changes" />
{renderTitleBar(sprintf(__('%s Entries'), data.selectedCategory.description), true)}
{renderActionButton()}
<MiqDataTable
rows={miqRows.rowItems}
headers={data.list.headers}
Expand Down Expand Up @@ -205,7 +198,12 @@ const SettingsCompanyTags = ({ pageTitle, categoryId }) => {
const renderTabContent = () => (
<>
{data.summary && data.options && renderSummary()}
{data.pageType === pageTypes.list ? renderList() : renderForm()}
<Accordion align="start" className="miq-custom-accordion">
<AccordionItem title={sprintf(__('%s Entries'), data.selectedCategory.description)} open>
{data.pageType === pageTypes.list ? renderList() : renderForm()}
</AccordionItem>
</Accordion>

</>
);

Expand All @@ -215,7 +213,6 @@ const SettingsCompanyTags = ({ pageTitle, categoryId }) => {
*/
return (
<>
{renderTitleBar(pageTitle, false)}
{!data.isLoading && renderTabContent()}
</>
);
Expand Down
1 change: 1 addition & 0 deletions app/stylesheet/application-webpack.scss
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
@import './ddf_override.scss';
@import './menu.scss';
@import './miq-custom-tab.scss';
@import './miq-custom-accordion.scss';
@import './miq-data-table.scss';
@import './miq-table-toolbar.scss';
@import './miq-structured-list.scss';
Expand Down
21 changes: 21 additions & 0 deletions app/stylesheet/miq-custom-accordion.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
.miq-custom-accordion
{
border: 1px solid #e0e0e0;

li button.bx--accordion__heading {
background: #e0e0e0;
}
.bx--accordion__item:last-child{
border: 0;
}

.bx--accordion__content {
padding: 20px;
margin: 0;

.custom-accordion-buttons {
display: flex;
justify-content: flex-end;
}
}
}

0 comments on commit 8c243a1

Please sign in to comment.