Skip to content

Commit

Permalink
wip
Browse files Browse the repository at this point in the history
  • Loading branch information
bimalgrg519 committed Jan 23, 2025
1 parent 70c1e3f commit 1cc0d4b
Show file tree
Hide file tree
Showing 5 changed files with 41 additions and 33 deletions.
2 changes: 1 addition & 1 deletion ui/web-v2/src/assets/lang/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -634,4 +634,4 @@
"urlCode": "URL code",
"warning": "Warning",
"yes": "Yes"
}
}
4 changes: 2 additions & 2 deletions ui/web-v2/src/components/CheckBoxList/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -133,8 +133,8 @@ export const CheckBoxList: FC<CheckBoxListProps> = memo(
return (
<div
className={classNames(
'border shadow-sm bg-white text-gray-500 p-1',
'text-xs rounded whitespace-normal break-words w-64'
'border shadow-sm bg-gray-900 text-white p-1',
'text-xs rounded whitespace-normal break-words w-80'
)}
>
{f(messages.notification.tagsTooltipMessage)}
Expand Down
9 changes: 7 additions & 2 deletions ui/web-v2/src/components/NotificationUpdateForm/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,12 @@ export const NotificationUpdateForm: FC<NotificationUpdateFormProps> = memo(
register,
control,
getValues,
formState: { errors, isValid, isDirty, isSubmitted }
formState: { errors, isValid, isDirty, isSubmitted },
watch
} = methods;

console.log('watch', watch('sourceTypes'));

const [defaultValues] = useState(() =>
SOURCE_TYPE_ITEMS.filter((item) =>
getValues()?.sourceTypes?.includes(Number(item.value))
Expand Down Expand Up @@ -89,7 +92,9 @@ export const NotificationUpdateForm: FC<NotificationUpdateFormProps> = memo(
const convList = values.map((value) =>
Number(value)
);
field.onChange(convList.sort());
field.onChange(
convList.sort().map((v) => String(v))
);
}}
disabled={!editable || isSubmitted}
defaultValues={defaultValues}
Expand Down
49 changes: 29 additions & 20 deletions ui/web-v2/src/modules/notifications.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ import {
import { Subscription } from '../proto/notification/subscription_pb';

import { AppState } from '.';
import { add } from 'date-fns';

Check failure on line 35 in ui/web-v2/src/modules/notifications.ts

View workflow job for this annotation

GitHub Actions / build

'add' is defined but never used

const MODULE_NAME = 'notifications';

Expand Down Expand Up @@ -152,37 +153,45 @@ export const updateNotification = createAsyncThunk<
request.setRenameSubscriptionCommand(cmd);
}

const addList = params.sourceTypes.filter(
(type) => !params.currentSourceTypes.includes(type)
);
// DOMAIN_EVENT_FEATURE must be included in sourceTypes if featureFlagTagsList is set
// if (
// params.featureFlagTagsList &&
// !params.sourceTypes.includes(Subscription.SourceType.DOMAIN_EVENT_FEATURE)
// ) {
// addList.push(Subscription.SourceType.DOMAIN_EVENT_FEATURE);
// }
if (addList.length > 0) {
// let addList = [];
if (params.sourceTypes.length > 0) {
const addList = params.sourceTypes.filter(
(type) => !params.currentSourceTypes.includes(type)
);

const cmd = new AddSourceTypesCommand();
cmd.setSourceTypesList(addList);
request.setAddSourceTypesCommand(cmd);

const deleteList = params.currentSourceTypes.filter(
(type) => !params.sourceTypes.includes(type)
);
if (deleteList.length > 0) {
const cmd = new DeleteSourceTypesCommand();
cmd.setSourceTypesList(deleteList);
request.setDeleteSourceTypesCommand(cmd);
}
}
const deleteList = params.currentSourceTypes.filter(
(type) => !params.sourceTypes.includes(type)
);
if (deleteList.length > 0) {
const cmd = new DeleteSourceTypesCommand();
cmd.setSourceTypesList(deleteList);
request.setDeleteSourceTypesCommand(cmd);
}
console.log({ params, addList, deleteList });

if (params.featureFlagTagsList) {
// DOMAIN_EVENT_FEATURE must be included in sourceTypes if featureFlagTagsList is set
// if (
// !params.sourceTypes.includes(Subscription.SourceType.DOMAIN_EVENT_FEATURE)
// ) {
// addList.push(Subscription.SourceType.DOMAIN_EVENT_FEATURE);
// }

const cmd = new UpdateSubscriptionFeatureFlagTagsCommand();
cmd.setFeatureFlagTagsList(params.featureFlagTagsList);
request.setUpdateSubscriptionFeatureTagsCommand(cmd);
}

// if (addList.length > 0) {
// const cmd = new AddSourceTypesCommand();
// cmd.setSourceTypesList(addList);
// request.setAddSourceTypesCommand(cmd);
// }

await subscriptionGrpc.updateSubscription(request);
});

Expand Down
10 changes: 2 additions & 8 deletions ui/web-v2/src/pages/notification/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -223,10 +223,11 @@ export const NotificationIndexPage: FC = memo(() => {
const handleOnClickUpdate = useCallback(
(s: Subscription.AsObject) => {
setOpen(true);
const sourceTypes = [...s.sourceTypesList].sort().map((v) => String(v));
resetUpdate({
name: s.name,
webhookUrl: s.recipient.slackChannelRecipient.webhookUrl,
sourceTypes: [...s.sourceTypesList].sort(),
sourceTypes,
featureFlagTagsList: s.featureFlagTagsList
});
history.push({
Expand Down Expand Up @@ -254,13 +255,6 @@ export const NotificationIndexPage: FC = memo(() => {
featureFlagTagsList = data.featureFlagTagsList;
}

console.log({
data,
dirtyFields,
sourceTypes,
featureFlagTagsList
});

dispatch(
updateNotification({
environmentId: currentEnvironment.id,
Expand Down

0 comments on commit 1cc0d4b

Please sign in to comment.