Skip to content

Commit b0a27a7

Browse files
committed
upcoming: [DPS-34879] - Delivery bugfixes after devcloud release
1 parent d3a83c8 commit b0a27a7

17 files changed

Lines changed: 103 additions & 63 deletions
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"@linode/api-v4": Upcoming Features
3+
---
4+
5+
Logs Delivery Stream details type update ([#12898](https://github.com/linode/manager/pull/12898))

packages/api-v4/src/delivery/types.ts

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ export interface AuditData {
2121

2222
export interface Stream extends AuditData {
2323
destinations: Destination[];
24-
details: StreamDetails;
24+
details: StreamDetailsType;
2525
id: number;
2626
label: string;
2727
primary_destination_id: number;
@@ -36,6 +36,8 @@ export interface StreamDetails {
3636
is_auto_add_all_clusters_enabled?: boolean;
3737
}
3838

39+
export type StreamDetailsType = null | StreamDetails;
40+
3941
export const destinationType = {
4042
CustomHttps: 'custom_https',
4143
LinodeObjectStorage: 'linode_object_storage',
@@ -103,18 +105,17 @@ interface CustomHeader {
103105

104106
export interface CreateStreamPayload {
105107
destinations: number[];
106-
details: StreamDetails;
108+
details?: StreamDetailsType;
107109
label: string;
108110
status?: StreamStatus;
109111
type: StreamType;
110112
}
111113

112114
export interface UpdateStreamPayload {
113115
destinations: number[];
114-
details: StreamDetails;
116+
details?: StreamDetailsType;
115117
label: string;
116118
status: StreamStatus;
117-
type: StreamType;
118119
}
119120

120121
export interface UpdateStreamPayloadWithId extends UpdateStreamPayload {
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"@linode/manager": Upcoming Features
3+
---
4+
5+
Logs Delivery fixes after devcloud release ([#12898](https://github.com/linode/manager/pull/12898))

packages/manager/src/factories/delivery.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ export const streamFactory = Factory.Sync.makeFactory<Stream>({
2727
destinations: Factory.each(() => [
2828
{ ...destinationFactory.build(), id: 123 },
2929
]),
30-
details: {},
30+
details: null,
3131
updated: '2025-07-30',
3232
updated_by: 'username',
3333
id: Factory.each((id) => id),

packages/manager/src/features/Delivery/Streams/StreamForm/Delivery/StreamFormDelivery.test.tsx

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,9 @@ describe('StreamFormDelivery', () => {
8686
label: '',
8787
type: destinationType.LinodeObjectStorage,
8888
},
89+
stream: {
90+
destinations: [],
91+
},
8992
},
9093
},
9194
});

packages/manager/src/features/Delivery/Streams/StreamForm/Delivery/StreamFormDelivery.tsx

Lines changed: 18 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,11 @@ export const StreamFormDelivery = () => {
4444
const theme = useTheme();
4545
const { control, setValue, clearErrors } =
4646
useFormContext<StreamAndDestinationFormType>();
47-
const { data: destinations, isLoading, error } = useAllDestinationsQuery();
47+
const {
48+
data: destinations,
49+
isLoading,
50+
error,
51+
} = useAllDestinationsQuery({ page_size: 100 });
4852

4953
const [creatingNewDestination, setCreatingNewDestination] =
5054
useState<boolean>(false);
@@ -67,11 +71,19 @@ export const StreamFormDelivery = () => {
6771
name: 'stream.destinations',
6872
});
6973

70-
const destinationNameFilterOptions = createFilterOptions<DestinationName>();
74+
const destinationNameFilterOptions = createFilterOptions<DestinationName>({
75+
stringify: (destination) => destination.label,
76+
});
7177

7278
const findDestination = (id: number) =>
7379
destinations?.data?.find((destination) => destination.id === id);
7480

81+
const restDestinationForm = () => {
82+
Object.values(controlPaths).forEach((controlPath) =>
83+
setValue(controlPath, '')
84+
);
85+
};
86+
7587
const getDestinationForm = () => (
7688
<>
7789
<Controller
@@ -121,6 +133,10 @@ export const StreamFormDelivery = () => {
121133
onChange={(_, newValue) => {
122134
const id = newValue?.id;
123135

136+
if (id === undefined && selectedDestinations.length > 0) {
137+
restDestinationForm();
138+
}
139+
124140
setValue('stream.destinations', id ? [id] : []);
125141
const selectedDestination = id ? findDestination(id) : undefined;
126142
if (selectedDestination) {

packages/manager/src/features/Delivery/Streams/StreamForm/StreamCreate.tsx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,8 @@ export const StreamCreate = () => {
3333
defaultValues: {
3434
stream: {
3535
type: streamType.AuditLogs,
36-
details: {},
36+
details: null,
37+
destinations: [],
3738
},
3839
destination: {
3940
type: destinationType.LinodeObjectStorage,

packages/manager/src/features/Delivery/Streams/StreamForm/StreamEdit.tsx

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ export const StreamEdit = () => {
2525
data: destinations,
2626
isLoading: isLoadingDestinations,
2727
error: errorDestinations,
28-
} = useAllDestinationsQuery();
28+
} = useAllDestinationsQuery({ page_size: 100 });
2929
const {
3030
data: stream,
3131
isLoading: isLoadingStream,
@@ -51,7 +51,8 @@ export const StreamEdit = () => {
5151
defaultValues: {
5252
stream: {
5353
type: streamType.AuditLogs,
54-
details: {},
54+
details: null,
55+
destinations: [],
5556
},
5657
destination: {
5758
type: destinationType.LinodeObjectStorage,
@@ -65,15 +66,14 @@ export const StreamEdit = () => {
6566
});
6667

6768
useEffect(() => {
68-
if (stream) {
69-
const details =
70-
Object.keys(stream.details).length > 0
71-
? {
72-
is_auto_add_all_clusters_enabled: false,
73-
cluster_ids: [],
74-
...stream.details,
75-
}
76-
: {};
69+
if (stream && destinations) {
70+
const details = stream.details
71+
? {
72+
is_auto_add_all_clusters_enabled: false,
73+
cluster_ids: [],
74+
...stream.details,
75+
}
76+
: null;
7777

7878
const streamsDestinationIds = stream.destinations.map(({ id }) => id);
7979
form.reset({

packages/manager/src/features/Delivery/Streams/StreamForm/StreamForm.tsx

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -119,7 +119,6 @@ export const StreamForm = (props: StreamFormProps) => {
119119
await updateStream({
120120
id: streamId,
121121
label,
122-
type,
123122
status: status as StreamStatus,
124123
destinations: [destinationId],
125124
details: payloadDetails,
@@ -172,7 +171,7 @@ export const StreamForm = (props: StreamFormProps) => {
172171
<FormSubmitBar
173172
blockSubmit={!selectedDestinations?.length}
174173
connectionTested={destinationVerified}
175-
destinationType={destination.type}
174+
destinationType={destination?.type}
176175
formType={'stream'}
177176
isSubmitting={isSubmitting}
178177
isTesting={isVerifyingDestination}

packages/manager/src/features/Delivery/Streams/StreamForm/StreamFormGeneralInfo.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ export const StreamFormGeneralInfo = (props: StreamFormGeneralInfoProps) => {
2626
if (value === streamType.LKEAuditLogs) {
2727
setValue('stream.details.is_auto_add_all_clusters_enabled', false);
2828
} else {
29-
setValue('stream.details', {});
29+
setValue('stream.details', null);
3030
}
3131
};
3232

0 commit comments

Comments
 (0)