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

fix(app-aco): construct where condition when applied to ROOT folder #4287

Merged
merged 3 commits into from
Oct 2, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
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 @@ -111,6 +111,7 @@ export interface BulkActionParams {
model: CmsModel;
action: string;
where?: Record<string, any>;
search?: string;
data?: Record<string, any>;
}

Expand Down Expand Up @@ -410,7 +411,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 @@ -420,6 +421,7 @@ export const CmsProvider = (props: CmsProviderProps) => {
variables: {
action,
where,
search,
data
}
});
Expand Down
Loading