Skip to content

Commit

Permalink
fix(console): refine the code
Browse files Browse the repository at this point in the history
refine the code
  • Loading branch information
simeng-li committed May 15, 2024
1 parent efb41a4 commit cb54d71
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 5 deletions.
13 changes: 9 additions & 4 deletions packages/console/src/consts/webhooks.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,13 +15,19 @@ export const dataHookEventsLabel = Object.freeze({
[DataHookSchema.OrganizationScope]: 'webhooks.schemas.organization_scope',
} satisfies Record<DataHookSchema, AdminConsoleKey>);

export const interactionHookEvents = Object.values(InteractionHookEvent);

const dataHookEvents: DataHookEvent[] = hookEvents.filter(
(event): event is DataHookEvent => !(event in InteractionHookEvent)
// eslint-disable-next-line no-restricted-syntax
(event): event is DataHookEvent => !interactionHookEvents.includes(event as InteractionHookEvent)
);

const isDataHookSchema = (schema: string): schema is DataHookSchema => schema in DataHookSchema;
const isDataHookSchema = (schema: string): schema is DataHookSchema =>
// eslint-disable-next-line no-restricted-syntax
Object.values(DataHookSchema).includes(schema as DataHookSchema);

// Group DataHook events by schema
// TODO: Replace this using groupBy once Node v22 goes LTS

Check warning on line 30 in packages/console/src/consts/webhooks.ts

View workflow job for this annotation

GitHub Actions / ESLint Report Analysis

packages/console/src/consts/webhooks.ts#L30

[no-warning-comments] Unexpected 'todo' comment: 'TODO: Replace this using groupBy once...'.
const schemaGroupedDataHookEventsMap = dataHookEvents.reduce<Map<DataHookSchema, DataHookEvent[]>>(
(eventGroup, event) => {
const [schema] = event.split('.');
Expand All @@ -35,8 +41,7 @@ const schemaGroupedDataHookEventsMap = dataHookEvents.reduce<Map<DataHookSchema,
new Map()
);

export const interactionHookEvents = Object.values(InteractionHookEvent);

// Sort the grouped DataHook events per console product design
const hookEventSchemaOrder: {
[key in DataHookSchema]: number;
} = {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
}

.groupList {
// max two column
// Max two columns
gap: _.unit(5);
display: grid;
grid-template-columns: repeat(2, 1fr);
Expand Down

0 comments on commit cb54d71

Please sign in to comment.