Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
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
19 changes: 18 additions & 1 deletion components/dashboard/src/data/prebuilds/prebuild-queries.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,11 @@
*/

import { useMutation, useQuery } from "@tanstack/react-query";
import { prebuildClient, stream } from "../../service/public-api";
import { configurationClient, prebuildClient, stream } from "../../service/public-api";
import { Prebuild, PrebuildPhase_Phase } from "@gitpod/public-api/lib/gitpod/v1/prebuild_pb";
import { ApplicationError, ErrorCodes } from "@gitpod/gitpod-protocol/lib/messaging/error";
import { PlainMessage, toPlainMessage } from "@bufbuild/protobuf";
import { GetConfigurationWebhookActivityStatusResponse } from "@gitpod/public-api/lib/gitpod/v1/configuration_pb";

export function usePrebuildQuery(prebuildId: string) {
return useQuery<Prebuild, Error>(
Expand Down Expand Up @@ -75,3 +77,18 @@ export function useTriggerPrebuildMutation(configurationId?: string, gitRef?: st
},
});
}

export function useWebhookActivityStatusQuery(configurationId: string) {
return useQuery<PlainMessage<GetConfigurationWebhookActivityStatusResponse>, Error>(
["webhookActivityStatus", configurationId],
async () => {
const resp = await configurationClient.getConfigurationWebhookActivityStatus({ configurationId });
return toPlainMessage(resp);
},
{
retry: false,
staleTime: 1000 * 60, // 1 minute
cacheTime: 1000 * 60 * 15, // 15 minutes
},
);
}
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,17 @@ export const ConfigurationDetailPrebuilds: FC<Props> = ({ configuration }) => {
<>
<ConfigurationSettingsField>
<Heading3>Prebuilds</Heading3>
<Subheading className="max-w-lg">Prebuilds reduce wait time for new workspaces.</Subheading>
<Subheading className="max-w-lg">
Prebuilds reduce wait time for new workspaces.{" "}
<a
href="https://www.gitpod.io/docs/configure/repositories/prebuilds"
target="_blank"
rel="noreferrer"
className="gp-link"
>
Learn more
</a>
</Subheading>

<SwitchInputField
className="mt-6"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ export const EnablePrebuildsError: FC<Props> = ({ error, onReconnect }) => {
// We need to authorize with the provider to acquire the correct scopes to install webhooks
if (error instanceof ApplicationError && error.code === ErrorCodes.NOT_AUTHENTICATED) {
return (
<RepositoryUnauthroizedErrorMessage
<RepositoryUnauthorizedErrorMessage
error={error.data as RepositoryUnauthorizedError}
onReconnect={onReconnect}
/>
Expand Down Expand Up @@ -63,11 +63,11 @@ const GenericErrorMessage: FC<GenericErrorMessageProps> = ({ message }) => {
);
};

type RepositoryUnauthroizedErrorMessageProps = {
type RepositoryUnauthorizedErrorMessageProps = {
error: RepositoryUnauthorizedError;
onReconnect: () => void;
};
const RepositoryUnauthroizedErrorMessage: FC<RepositoryUnauthroizedErrorMessageProps> = ({ error, onReconnect }) => {
const RepositoryUnauthorizedErrorMessage: FC<RepositoryUnauthorizedErrorMessageProps> = ({ error, onReconnect }) => {
const { toast } = useToast();

const authorizeWithProvider = useCallback(async () => {
Expand Down Expand Up @@ -106,7 +106,7 @@ const RepositoryUnauthroizedErrorMessage: FC<RepositoryUnauthroizedErrorMessageP
</span>
) : (
<span>
Unable to enable prebuilds. This could be because you don’t have admin/write premissions for
Unable to enable prebuilds. This could be because you don’t have admin/write permissions for
this repo or it could be an invalid token. Please try to reconnect. If the problem persists, you
can contact support.
</span>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import {
import { FC, FormEvent, useCallback, useMemo, useState } from "react";
import { ConfigurationSettingsField } from "../ConfigurationSettingsField";
import { Heading3, Subheading } from "@podkit/typography/Headings";
import { Text } from "@podkit/typography/Text";
import { InputField } from "../../../components/forms/InputField";
import { PartialConfiguration, useConfigurationMutation } from "../../../data/configurations/configuration-queries";
import { useToast } from "../../../components/toasts/Toasts";
Expand All @@ -28,6 +29,8 @@ import { trackEvent } from "../../../Analytics";
import dayjs from "dayjs";
import { SwitchInputField } from "@podkit/switch/Switch";
import { useFeatureFlag } from "../../../data/featureflag-query";
import { TextMuted } from "@podkit/typography/TextMuted";
import { InfoIcon } from "lucide-react";

const DEFAULT_PREBUILD_COMMIT_INTERVAL = 20;

Expand Down Expand Up @@ -224,6 +227,22 @@ export const PrebuildSettingsForm: FC<Props> = ({ configuration }) => {
</InputField>
)}

<div className="mt-4">
<Text className="font-semibold text-md text-pk-content-secondary">Prebuild trigger strategy</Text>
<TextMuted className="text-sm mt-1 flex flex-row gap-1 items-center">
{configuration.prebuildSettings?.triggerStrategy === PrebuildTriggerStrategy.ACTIVITY_BASED
? "Activity-based"
: "Webhook-based"}
<a
href="https://www.gitpod.io/docs/configure/repositories/prebuilds#triggers"
target="_blank"
rel="noreferrer"
>
<InfoIcon size={14} />
</a>
</TextMuted>
</div>

<Heading3 className="mt-8">Machine type</Heading3>
<Subheading>Choose the workspace machine type for your prebuilds.</Subheading>

Expand Down
20 changes: 20 additions & 0 deletions components/public-api/gitpod/v1/configuration.proto
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,9 @@ service ConfigurationService {

// Deletes a configuration.
rpc DeleteConfiguration(DeleteConfigurationRequest) returns (DeleteConfigurationResponse) {}

// GetConfigurationWebhookActivityStatus returns the observed status of installed prebuild webhooks on the configuration
rpc GetConfigurationWebhookActivityStatus(GetConfigurationWebhookActivityStatusRequest) returns (GetConfigurationWebhookActivityStatusResponse) {}
}

message CreateConfigurationRequest {
Expand Down Expand Up @@ -147,3 +150,20 @@ message DeleteConfigurationRequest {
}

message DeleteConfigurationResponse {}

message GetConfigurationWebhookActivityStatusRequest {
string configuration_id = 1;
}

message GetConfigurationWebhookActivityStatusResponse {
message WebhookEvent {
string commit = 1;
google.protobuf.Timestamp creation_time = 2;
}

// is_webhook_active determines whether the webhook is active or not for the configuration.
bool is_webhook_active = 1;

// latest_webhook_event is the latest event that was observed by the webhook. Only set if is_webhook_active is true.
WebhookEvent latest_webhook_event = 2;
}
Loading
Loading