Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@linode/api-v4": Upcoming Features
---

Logs Delivery Stream details type update ([#12898](https://github.com/linode/manager/pull/12898))
9 changes: 5 additions & 4 deletions packages/api-v4/src/delivery/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ export interface AuditData {

export interface Stream extends AuditData {
destinations: Destination[];
details: StreamDetails;
details: StreamDetailsType;
id: number;
label: string;
primary_destination_id: number;
Expand All @@ -36,6 +36,8 @@ export interface StreamDetails {
is_auto_add_all_clusters_enabled?: boolean;
}

export type StreamDetailsType = null | StreamDetails;

export const destinationType = {
CustomHttps: 'custom_https',
LinodeObjectStorage: 'linode_object_storage',
Expand Down Expand Up @@ -103,18 +105,17 @@ interface CustomHeader {

export interface CreateStreamPayload {
destinations: number[];
details: StreamDetails;
details?: StreamDetailsType;
label: string;
status?: StreamStatus;
type: StreamType;
}

export interface UpdateStreamPayload {
destinations: number[];
details: StreamDetails;
details?: StreamDetailsType;
label: string;
status: StreamStatus;
type: StreamType;
}

export interface UpdateStreamPayloadWithId extends UpdateStreamPayload {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@linode/manager": Upcoming Features
---

Logs Delivery fixes after devcloud release ([#12898](https://github.com/linode/manager/pull/12898))
4 changes: 2 additions & 2 deletions packages/manager/src/components/PrimaryNav/PrimaryNav.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,6 @@ export type NavEntity =
| 'Cloud Load Balancers'
| 'Dashboard'
| 'Databases'
| 'Delivery'
| 'Domains'
| 'Firewalls'
| 'Help & Support'
Expand All @@ -49,6 +48,7 @@ export type NavEntity =
| 'Kubernetes'
| 'Linodes'
| 'Login History'
| 'Logs'
| 'Longview'
| 'Maintenance'
| 'Managed'
Expand Down Expand Up @@ -240,7 +240,7 @@ export const PrimaryNav = (props: PrimaryNavProps) => {
to: '/longview',
},
{
display: 'Delivery',
display: 'Logs',
hide: !flags.aclpLogs?.enabled,
to: '/logs/delivery',
isBeta: flags.aclpLogs?.beta,
Expand Down
2 changes: 1 addition & 1 deletion packages/manager/src/factories/delivery.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ export const streamFactory = Factory.Sync.makeFactory<Stream>({
destinations: Factory.each(() => [
{ ...destinationFactory.build(), id: 123 },
]),
details: {},
details: null,
updated: '2025-07-30',
updated_by: 'username',
id: Factory.each((id) => id),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,9 @@ describe('StreamFormDelivery', () => {
label: '',
type: destinationType.LinodeObjectStorage,
},
stream: {
destinations: [],
},
},
},
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -67,11 +67,19 @@ export const StreamFormDelivery = () => {
name: 'stream.destinations',
});

const destinationNameFilterOptions = createFilterOptions<DestinationName>();
const destinationNameFilterOptions = createFilterOptions<DestinationName>({
stringify: (destination) => destination.label,
});

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

const restDestinationForm = () => {
Object.values(controlPaths).forEach((controlPath) =>
setValue(controlPath, '')
);
};

const getDestinationForm = () => (
<>
<Controller
Expand Down Expand Up @@ -121,6 +129,10 @@ export const StreamFormDelivery = () => {
onChange={(_, newValue) => {
const id = newValue?.id;

if (id === undefined && selectedDestinations.length > 0) {
restDestinationForm();
}

setValue('stream.destinations', id ? [id] : []);
const selectedDestination = id ? findDestination(id) : undefined;
if (selectedDestination) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,8 @@ export const StreamCreate = () => {
defaultValues: {
stream: {
type: streamType.AuditLogs,
details: {},
details: null,
destinations: [],
},
destination: {
type: destinationType.LinodeObjectStorage,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,26 @@ describe('StreamEdit', () => {
{ exact: false }
);
await userEvent.click(createNewTestDestination);
const hostInput = screen.getByLabelText('Host');
await waitFor(() => {
expect(hostInput).toBeDefined();
});
await userEvent.type(hostInput, 'Test');
const bucketInput = screen.getByLabelText('Bucket');
await userEvent.type(bucketInput, 'Test');
const regionAutocomplete = screen.getByLabelText('Region');
await userEvent.click(regionAutocomplete);
await userEvent.type(regionAutocomplete, 'US, Chi');
const chicagoRegion = await screen.findByText(
'US, Chicago, IL (us-ord)'
);
await userEvent.click(chicagoRegion);
const accessKeyIDInput = screen.getByLabelText('Access Key ID');
await userEvent.type(accessKeyIDInput, 'Test');
const secretAccessKeyInput = screen.getByLabelText('Secret Access Key');
await userEvent.type(secretAccessKeyInput, 'Test');
const logPathPrefixInput = screen.getByLabelText('Log Path Prefix');
await userEvent.type(logPathPrefixInput, 'Test');
};

describe('when form properly filled out and Test Connection button clicked and connection verified positively', () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,8 @@ export const StreamEdit = () => {
defaultValues: {
stream: {
type: streamType.AuditLogs,
details: {},
details: null,
destinations: [],
},
destination: {
type: destinationType.LinodeObjectStorage,
Expand All @@ -66,15 +67,14 @@ export const StreamEdit = () => {
});

useEffect(() => {
if (stream) {
const details =
Object.keys(stream.details).length > 0
? {
is_auto_add_all_clusters_enabled: false,
cluster_ids: [],
...stream.details,
}
: {};
if (stream && destinations) {
const details = stream.details
? {
is_auto_add_all_clusters_enabled: false,
cluster_ids: [],
...stream.details,
}
: null;

const streamsDestinationIds = stream.destinations.map(({ id }) => id);
const destination = destinations?.data?.find(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,6 @@ export const StreamForm = (props: StreamFormProps) => {
await updateStream({
id: streamId,
label,
type,
status: status as StreamStatus,
destinations: [destinationId],
details: payloadDetails,
Expand Down Expand Up @@ -186,7 +185,7 @@ export const StreamForm = (props: StreamFormProps) => {
<FormSubmitBar
blockSubmit={!selectedDestinations?.length}
connectionTested={destinationVerified}
destinationType={destination.type}
destinationType={destination?.type}
formType={'stream'}
isSubmitting={isSubmitting}
isTesting={isVerifyingDestination}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ export const StreamFormGeneralInfo = (props: StreamFormGeneralInfoProps) => {
if (value === streamType.LKEAuditLogs) {
setValue('stream.details.is_auto_add_all_clusters_enabled', false);
} else {
setValue('stream.details', {});
setValue('stream.details', null);
}
};

Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,11 @@
import type { CreateStreamPayload } from '@linode/api-v4';
import type { CreateStreamPayload, StreamDetailsType } from '@linode/api-v4';
import type { DestinationFormType } from 'src/features/Delivery/Shared/types';

export interface StreamFromType extends Omit<CreateStreamPayload, 'details'> {
details: StreamDetailsType;
}

export interface StreamAndDestinationFormType {
destination: DestinationFormType;
stream: CreateStreamPayload;
stream: StreamFromType;
}
Original file line number Diff line number Diff line change
Expand Up @@ -159,8 +159,7 @@ describe('Streams Landing Table', () => {
status: 'inactive',
label: 'Stream 1',
destinations: [123],
details: {},
type: 'audit_logs',
details: null,
});
});
});
Expand All @@ -182,8 +181,7 @@ describe('Streams Landing Table', () => {
status: 'active',
label: 'Stream 1',
destinations: [123],
details: {},
type: 'audit_logs',
details: null,
});
});
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ export const StreamsLanding = () => {
label: { '+contains': search?.label },
}),
...(search?.status !== undefined && {
status: { '+contains': search?.status },
status: search?.status,
}),
};

Expand Down Expand Up @@ -151,15 +151,13 @@ export const StreamsLanding = () => {
destinations,
details,
label,
type,
status,
}: Stream) => {
updateStream({
id,
destinations: destinations.map(({ id: destinationId }) => destinationId),
details,
label,
type,
status:
status === streamStatus.Active
? streamStatus.Inactive
Expand Down
24 changes: 12 additions & 12 deletions packages/manager/src/features/Delivery/deliveryUtils.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,11 @@
import {
type Destination,
type DestinationDetails,
type DestinationDetailsPayload,
isEmpty,
type Stream,
type StreamDetailsType,
type StreamType,
streamType,
} from '@linode/api-v4';
import { omitProps } from '@linode/ui';
Expand All @@ -11,12 +15,6 @@ import {
streamTypeOptions,
} from 'src/features/Delivery/Shared/types';

import type {
DestinationDetails,
DestinationDetailsPayload,
StreamDetails,
StreamType,
} from '@linode/api-v4';
import type {
FormMode,
LabelValueOption,
Expand All @@ -36,19 +34,21 @@ export const isFormInEditMode = (mode: FormMode) => mode === 'edit';

export const getStreamPayloadDetails = (
type: StreamType,
details: StreamDetails
): StreamDetails => {
let payloadDetails: StreamDetails = {};
details: StreamDetailsType
): StreamDetailsType => {
if (!details) {
return null;
}

if (!isEmpty(details) && type === streamType.LKEAuditLogs) {
if (details.is_auto_add_all_clusters_enabled) {
payloadDetails = omitProps(details, ['cluster_ids']);
return omitProps(details, ['cluster_ids']);
} else {
payloadDetails = omitProps(details, ['is_auto_add_all_clusters_enabled']);
return omitProps(details, ['is_auto_add_all_clusters_enabled']);
}
}

return payloadDetails;
return null;
};

export const getDestinationPayloadDetails = (
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ export const createStreams = (mockState: MockState) => [
destinations: payload['destinations'].map((destinationId: number) =>
destinations?.find(({ id }) => id === destinationId)
),
details: payload['details'],
details: payload['details'] ?? null,
created: DateTime.now().toISO(),
updated: DateTime.now().toISO(),
});
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@linode/validation": Upcoming Features
---

Logs Delivery Stream details validation update ([#12898](https://github.com/linode/manager/pull/12898))
Loading