Skip to content
This repository has been archived by the owner on Dec 7, 2023. It is now read-only.

Commit

Permalink
fix(ui): hide "remove jobs by pattern" button for bullmq queues
Browse files Browse the repository at this point in the history
  • Loading branch information
s-r-x committed Jan 10, 2022
1 parent 5f4dc57 commit d434f64
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 9 deletions.
4 changes: 3 additions & 1 deletion packages/ui/src/demo-mocks/network/queries/get-queues.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
import type { GetQueuesQuery } from '@/typings/gql';
import { QueueProvider } from '@/typings/gql';
import { networkMockData } from '../data';
import type { GetQueuesQuery } from '@/typings/gql';

export const getQueuesMock = (): Promise<GetQueuesQuery> => {
return Promise.resolve({
queues: networkMockData.queues.map((queue) => ({
id: queue.id,
provider: QueueProvider.Bull,
name: queue.name,
isPaused: queue.isPaused,
keyPrefix: queue.keyPrefix,
Expand Down
3 changes: 2 additions & 1 deletion packages/ui/src/network/queries/get-queues.ts
Original file line number Diff line number Diff line change
@@ -1,13 +1,14 @@
import { gqlClient } from '@/network/gql-client';
import type { GetQueuesQuery } from '@/typings/gql';
import { gql } from 'graphql-request';
import type { GetQueuesQuery } from '@/typings/gql';

export const getQueues = (): Promise<GetQueuesQuery> =>
gqlClient.request(
gql`
query GetQueues {
queues {
id
provider
readonly
name
keyPrefix
Expand Down
16 changes: 10 additions & 6 deletions packages/ui/src/screens/jobs/QueueActions/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import { useNetwork } from '@/hooks/use-network';
import AddIcon from '@mui/icons-material/Add';
import { useAbstractMutation } from '@/hooks/use-abstract-mutation';
import { useRemoveJobsModalStore } from '@/stores/remove-jobs-modal';
import { JobStatusClean } from '@/typings/gql';
import { JobStatusClean, QueueProvider } from '@/typings/gql';
import Menu from '@mui/material/Menu';
import MenuItem from '@mui/material/MenuItem';
import IconButton from '@mui/material/IconButton';
Expand Down Expand Up @@ -167,7 +167,8 @@ export default function QueueActions() {
dataSearch,
});
}}
size="large">
size="large"
>
<SaveIcon />
</IconButton>
</Tooltip>
Expand All @@ -176,7 +177,8 @@ export default function QueueActions() {
disabled={isReadonly}
aria-controls="more-queue-actions-menu"
aria-haspopup="true"
size="large">
size="large"
>
<MoreIcon />
</IconButton>
<Menu
Expand All @@ -190,9 +192,11 @@ export default function QueueActions() {
{isRefetchLocked ? 'Enable jobs polling' : 'Disable jobs polling'}
</MenuItem>
)}
<MenuItem onClick={openRemoveJobsModal}>
Remove jobs by pattern
</MenuItem>
{queueData?.provider === QueueProvider.Bull && (
<MenuItem onClick={openRemoveJobsModal}>
Remove jobs by pattern
</MenuItem>
)}
{isQueuePaused ? (
<MenuItem onClick={() => resumeMutation.mutate(sharedMutationArg)}>
Resume
Expand Down
8 changes: 7 additions & 1 deletion packages/ui/src/typings/gql.ts
Original file line number Diff line number Diff line change
Expand Up @@ -262,6 +262,7 @@ export type QueryJobArgs = {

export type Queue = {
id: Scalars['String'];
provider: QueueProvider;
name: Scalars['String'];
readonly?: Maybe<Scalars['Boolean']>;
keyPrefix?: Maybe<Scalars['String']>;
Expand Down Expand Up @@ -303,6 +304,11 @@ export type QueueMetrics = {
processingTimeMax?: Maybe<Scalars['Float']>;
};

export enum QueueProvider {
Bull = 'bull',
Bullmq = 'bullmq'
}

export type RedisInfo = {
redis_version: Scalars['String'];
used_memory: Scalars['String'];
Expand Down Expand Up @@ -548,7 +554,7 @@ export type GetQueuesQueryVariables = Exact<{ [key: string]: never; }>;


export type GetQueuesQuery = { queues?: Maybe<Array<(
Pick<Queue, 'id' | 'readonly' | 'name' | 'keyPrefix' | 'isPaused'>
Pick<Queue, 'id' | 'provider' | 'readonly' | 'name' | 'keyPrefix' | 'isPaused'>
& { jobsCounts: Pick<QueueJobsCounts, 'waiting' | 'active' | 'completed' | 'failed' | 'delayed' | 'paused'> }
)>> };

Expand Down

0 comments on commit d434f64

Please sign in to comment.