Skip to content

Commit

Permalink
fix(app-aco): construct where condition when applied to ROOT folder (#…
Browse files Browse the repository at this point in the history
  • Loading branch information
leopuleo authored Oct 2, 2024
1 parent c4892c6 commit f5ade1a
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 8 deletions.
8 changes: 3 additions & 5 deletions packages/app-aco/src/contexts/acoList.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -288,12 +288,10 @@ export const AcoListProvider = ({ children, ...props }: AcoListProviderProps) =>

let where = dotPropImmutable.set({}, folderIdPath, state.folderId);

// In case of a search or filters applied, let's get the where condition based on the current folder ID,
// ownership status, and other existing filters in the state.
if (isSearch) {
if (state.folderId === ROOT_FOLDER) {
where = undefined;
} else {
where = getWhere();
}
where = getWhere();
}

const params: ListSearchRecordsQueryVariables = {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ export const BaseBulkAction = makeDecoratable(

const useWorker = () => {
const { model } = useModel();
const { selected, setSelected, getWhere, isSelectedAll } = useContentEntriesList();
const { selected, setSelected, getWhere, isSelectedAll, search } = useContentEntriesList();
const { bulkAction } = useCms();
const { current: worker } = useRef(new Worker<CmsContentEntry>());

Expand All @@ -100,7 +100,7 @@ const useWorker = () => {
) => worker.processInSeries(callback, chunkSize),
processInBulk: async ({ action, where: initialWhere, data }: ProcessInBulkParams) => {
const where = merge(getWhere(), initialWhere);
await bulkAction({ model, action, where, data });
await bulkAction({ model, action, where, search, data });
},
resetItems: resetItems,
results: worker.results,
Expand Down
4 changes: 3 additions & 1 deletion packages/app-headless-cms/src/admin/contexts/Cms/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -143,6 +143,7 @@ export interface BulkActionParams {
model: CmsModel;
action: string;
where?: Record<string, any>;
search?: string;
data?: Record<string, any>;
}

Expand Down Expand Up @@ -544,7 +545,7 @@ export const CmsProvider = (props: CmsProviderProps) => {

return true;
},
bulkAction: async ({ model, action, where, data }) => {
bulkAction: async ({ model, action, where, search, data }) => {
const mutation = createBulkActionMutation(model);
const response = await value.apolloClient.mutate<
CmsEntryBulkActionMutationResponse,
Expand All @@ -554,6 +555,7 @@ export const CmsProvider = (props: CmsProviderProps) => {
variables: {
action,
where,
search,
data
}
});
Expand Down

0 comments on commit f5ade1a

Please sign in to comment.