Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: Set release channels for policy and env #183

Merged
merged 7 commits into from
Oct 30, 2024
Merged
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
Prev Previous commit
Next Next commit
more cleanup
adityachoudhari26 committed Oct 30, 2024
commit 47c081337c24fdd8edd7ad31fbf04e6a90a10f9a
Original file line number Diff line number Diff line change
@@ -32,6 +32,74 @@ type Deployment = SCHEMA.Deployment & {
releaseChannels: SCHEMA.ReleaseChannel[];
};

type DeploymentSelectProps = {
deployment: Deployment;
releaseChannels: Record<string, string | null>;
policyReleaseChannels: Record<string, string | null>;
updateReleaseChannel: (
deploymentId: string,
channelId: string | null,
) => void;
};

const DeploymentSelect: React.FC<DeploymentSelectProps> = ({
deployment,
releaseChannels,
policyReleaseChannels,
updateReleaseChannel,
}) => {
const releaseChannelId = releaseChannels[deployment.id];
const releaseChannel = deployment.releaseChannels.find(
(rc) => rc.id === releaseChannelId,
);
const policyReleaseChannelId = policyReleaseChannels[deployment.id];
const policyReleaseChannel = deployment.releaseChannels.find(
(rc) => rc.id === policyReleaseChannelId,
);

const onChange = (channelId: string) =>
updateReleaseChannel(
deployment.id,
channelId === "null" ? null : channelId,
);

const value = releaseChannelId ?? undefined;

const display =
releaseChannel?.name ?? policyReleaseChannel?.name ?? "No release channel";

const isFromPolicy =
releaseChannelId == null && policyReleaseChannelId != null;

return (
<div className="flex items-center gap-2">
<span className="w-40 truncate">{deployment.name}</span>
<Select value={value} onValueChange={onChange}>
<SelectTrigger className="w-72">
<div className="flex w-60 items-center justify-start gap-2">
<span className="truncate text-xs">{display}</span>
{isFromPolicy && (
<span className="flex items-start text-xs text-muted-foreground">
(From policy)
</span>
)}
</div>
</SelectTrigger>
<SelectContent className="overflow-y-auto">
<SelectItem value="null" className="w-72">
No release channel
</SelectItem>
{deployment.releaseChannels.map((rc) => (
<SelectItem key={rc.id} value={rc.id} className="w-72">
<span className="truncate">{rc.name}</span>
</SelectItem>
))}
</SelectContent>
</Select>
</div>
);
};

type ReleaseChannelsProps = {
environment: Environment;
deployments: Deployment[];
@@ -88,55 +156,15 @@ export const ReleaseChannels: React.FC<ReleaseChannelsProps> = ({
<span className="w-40">Deployment</span>
<span className="w-72">Release Channel</span>
</div>
{deploymentsWithReleaseChannels.map((d) => {
const releaseChannelId = releaseChannels[d.id];
const releaseChannel = d.releaseChannels.find(
(rc) => rc.id === releaseChannelId,
);
const policyReleaseChannelId = policyReleaseChannels[d.id];
const policyReleaseChannel = d.releaseChannels.find(
(rc) => rc.id === policyReleaseChannelId,
);

const onChange = (channelId: string) =>
updateReleaseChannel(d.id, channelId === "null" ? null : channelId);

const value = releaseChannelId ?? undefined;

const display =
releaseChannel?.name ??
policyReleaseChannel?.name ??
"No release channel";

const isFromPolicy =
releaseChannelId == null && policyReleaseChannelId != null;

return (
<div key={d.id} className="flex items-center gap-2">
<span className="w-40 truncate">{d.name}</span>
<Select value={value} onValueChange={onChange}>
<SelectTrigger className="flex w-72 items-center gap-2">
<span className="truncate text-xs">{display}</span>
{isFromPolicy && (
<span className="shrink-0 text-xs text-muted-foreground">
(From policy)
</span>
)}
</SelectTrigger>
<SelectContent className="overflow-y-auto">
<SelectItem value="null" className="w-72">
No release channel
</SelectItem>
{d.releaseChannels.map((rc) => (
<SelectItem key={rc.id} value={rc.id} className="w-72">
<span className="truncate">{rc.name}</span>
</SelectItem>
))}
</SelectContent>
</Select>
</div>
);
})}
{deploymentsWithReleaseChannels.map((d) => (
<DeploymentSelect
key={d.id}
deployment={d}
releaseChannels={releaseChannels}
policyReleaseChannels={policyReleaseChannels}
updateReleaseChannel={updateReleaseChannel}
/>
))}
</div>
<Button onClick={onSubmit} disabled={updateReleaseChannels.isPending}>
Save
Original file line number Diff line number Diff line change
@@ -23,6 +23,57 @@ type Deployment = SCHEMA.Deployment & {

type ReleaseChannelProps = { policy: Policy; deployments: Deployment[] };

type DeploymentSelectProps = {
deployment: Deployment;
releaseChannels: Record<string, string | null>;
updateReleaseChannel: (
deploymentId: string,
channelId: string | null,
) => void;
};

const DeploymentSelect: React.FC<DeploymentSelectProps> = ({
deployment,
releaseChannels,
updateReleaseChannel,
}) => {
const releaseChannelId = releaseChannels[deployment.id];
const releaseChannel = deployment.releaseChannels.find(
(rc) => rc.id === releaseChannelId,
);
const value = releaseChannel?.id;

const onChange = (channelId: string) =>
updateReleaseChannel(
deployment.id,
channelId === "null" ? null : channelId,
);

return (
<div className="flex items-center gap-2">
<span className="w-40 truncate">{deployment.name}</span>
<Select value={value} onValueChange={onChange}>
<SelectTrigger className="w-72">
<SelectValue
placeholder="Select release channel"
className="truncate"
/>
</SelectTrigger>
<SelectContent className="overflow-y-auto">
<SelectItem value="null" className="w-72">
No release channel
</SelectItem>
{deployment.releaseChannels.map((rc) => (
<SelectItem key={rc.id} value={rc.id} className="w-72">
<span className="truncate">{rc.name}</span>
</SelectItem>
))}
</SelectContent>
</Select>
</div>
);
};

export const ReleaseChannels: React.FC<ReleaseChannelProps> = ({
policy,
deployments,
@@ -66,40 +117,14 @@ export const ReleaseChannels: React.FC<ReleaseChannelProps> = ({
<span className="w-40">Deployment</span>
<span className="w-72">Release Channel</span>
</div>
{deploymentsWithReleaseChannels.map((d) => {
const releaseChannelId = releaseChannels[d.id];
const releaseChannel = d.releaseChannels.find(
(rc) => rc.id === releaseChannelId,
);
const value = releaseChannel?.id;

const onChange = (channelId: string) =>
updateReleaseChannel(d.id, channelId === "null" ? null : channelId);

return (
<div key={d.id} className="flex items-center gap-2">
<span className="w-40 truncate">{d.name}</span>
<Select value={value} onValueChange={onChange}>
<SelectTrigger className="w-72">
<SelectValue
placeholder="Select release channel"
className="truncate"
/>
</SelectTrigger>
<SelectContent className="overflow-y-auto">
<SelectItem value="null" className="w-72">
No release channel
</SelectItem>
{d.releaseChannels.map((rc) => (
<SelectItem key={rc.id} value={rc.id} className="w-72">
<span className="truncate">{rc.name}</span>
</SelectItem>
))}
</SelectContent>
</Select>
</div>
);
})}
{deploymentsWithReleaseChannels.map((d) => (
<DeploymentSelect
key={d.id}
deployment={d}
releaseChannels={releaseChannels}
updateReleaseChannel={updateReleaseChannel}
/>
))}
</div>
<Button onClick={onSubmit} disabled={updateReleaseChannels.isPending}>
Save

Unchanged files with check annotations Beta

EXPOSE 3000
ENV PORT=3000
ENV AUTH_TRUST_HOST=true

Check warning on line 60 in apps/webservice/Dockerfile

GitHub Actions / build (linux/amd64)

Sensitive data should not be used in the ARG or ENV commands

SecretsUsedInArgOrEnv: Do not use ARG or ENV instructions for sensitive data (ENV "AUTH_TRUST_HOST") More info: https://docs.docker.com/go/dockerfile/rule/secrets-used-in-arg-or-env/
ENV NODE_ENV=production
ENV HOSTNAME=0.0.0.0