Skip to content

Commit

Permalink
refactor
Browse files Browse the repository at this point in the history
  • Loading branch information
vashjs committed Feb 15, 2024
1 parent bcbdc62 commit ee28151
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 8 deletions.
8 changes: 2 additions & 6 deletions src/components/BulkEditActionMenu/BulkEditActionMenu.js
Original file line number Diff line number Diff line change
Expand Up @@ -43,10 +43,7 @@ const BulkEditActionMenu = ({
const {
step,
currentRecordType,
capabilities,
queryRecordType,
} = useSearchParams();
const availableRecordType = capabilities || queryRecordType;

const [columnSearch, setColumnSearch] = useState('');

Expand Down Expand Up @@ -99,7 +96,7 @@ const BulkEditActionMenu = ({

const columnsOptions = columns.map(item => ({
...item,
label: item.ignoreTranslation ? item.label : intl.formatMessage({ id: `ui-bulk-edit.columns.${availableRecordType}.${item.label}` }),
label: item.ignoreTranslation ? item.label : intl.formatMessage({ id: `ui-bulk-edit.columns.${currentRecordType}.${item.label}` }),
disabled: isLastUnselectedColumn(item.value) || !countOfRecords,
}));

Expand All @@ -112,7 +109,7 @@ const BulkEditActionMenu = ({
});

setVisibleColumns(changedColumns);
localStorage.setItem(`${BULK_VISIBLE_COLUMNS}_${availableRecordType}`, JSON.stringify(changedColumns));
localStorage.setItem(`${BULK_VISIBLE_COLUMNS}_${currentRecordType}`, JSON.stringify(changedColumns));
};

const handleOnStartEdit = (approach) => {
Expand Down Expand Up @@ -208,7 +205,6 @@ const BulkEditActionMenu = ({
<ActionMenuGroup title={<FormattedMessage id="ui-bulk-edit.menuGroup.showColumns" />}>
{Boolean(columnsOptions.length) && renderColumnsFilter()}
</ActionMenuGroup>

</>
);
};
Expand Down
11 changes: 10 additions & 1 deletion src/components/BulkEditList/BulkEditList.js
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ import { useResetAppState } from '../../hooks/useResetAppState';
import BulkEditInAppLayer from './BulkEditListResult/BulkEditInAppLayer/BulkEditInAppLayer';
import { BulkEditListSidebar } from './BulkEditListSidebar/BulkEditListSidebar';
import { useSearchParams } from '../../hooks/useSearchParams';
import { useBulkOperationDetails } from '../../hooks/api';

export const BulkEditList = () => {
const history = useHistory();
Expand Down Expand Up @@ -62,6 +63,9 @@ export const BulkEditList = () => {
criteria,
initialFileName
} = useSearchParams();

const { bulkDetails } = useBulkOperationDetails({ id: bulkOperationId, additionalQueryKeys: [step] });

const identifierFilters = Object.values(IDENTIFIER_FILTERS).map((el) => search.getAll(el));
const queryFilters = Object.values(QUERY_FILTERS).map((el) => search.getAll(el));
const logsFilters = Object.values(LOGS_FILTERS).map((el) => search.getAll(el));
Expand Down Expand Up @@ -118,7 +122,12 @@ export const BulkEditList = () => {
};

const isLogsTab = criteria === CRITERIA.LOGS;
const isActionMenuVisible = visibleColumns?.length && isActionMenuShown && !isLogsTab;
const isQueryTab = criteria === CRITERIA.QUERY;
const isIdentifierTab = criteria === CRITERIA.IDENTIFIER;
const isQueryTabWithPreview = isQueryTab && visibleColumns?.length && bulkDetails?.fqlQuery;
const isIdentifierTabWithPreview = isIdentifierTab && visibleColumns?.length && !bulkDetails?.fqlQuery;

const isActionMenuVisible = (isQueryTabWithPreview || isIdentifierTabWithPreview) && isActionMenuShown && !isLogsTab;

const actionMenu = () => (
isActionMenuVisible && (
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,7 @@ export const IdentifierTab = () => {
search: buildSearch({
identifier: e.target.value,
step: null,
fileName: null,
}, location.search),
});

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,6 @@ export const QueryTab = () => {

const handleCapabilityChange = (e) => {
history.replace({
pathname: '/bulk-edit',
search: buildSearch({
queryRecordType: e.target.value,
}, history.location.search),
Expand Down

0 comments on commit ee28151

Please sign in to comment.