mirror of
https://github.com/moghtech/komodo.git
synced 2026-09-07 08:00:54 +00:00
non admins able to get procedure updates
This commit is contained in:
@@ -48,6 +48,8 @@ impl Resolve<ListUpdates, User> for State {
|
||||
Build::get_resource_ids_for_non_admin(&user.id).await?;
|
||||
let repo_ids =
|
||||
Repo::get_resource_ids_for_non_admin(&user.id).await?;
|
||||
let procedure_ids =
|
||||
Procedure::get_resource_ids_for_non_admin(&user.id).await?;
|
||||
let builder_ids =
|
||||
Builder::get_resource_ids_for_non_admin(&user.id).await?;
|
||||
let alerter_ids =
|
||||
@@ -59,6 +61,7 @@ impl Resolve<ListUpdates, User> for State {
|
||||
{ "target.type": "Deployment", "target.id": { "$in": &deployment_ids } },
|
||||
{ "target.type": "Build", "target.id": { "$in": &build_ids } },
|
||||
{ "target.type": "Repo", "target.id": { "$in": &repo_ids } },
|
||||
{ "target.type": "Procedure", "target.id": { "$in": &procedure_ids } },
|
||||
{ "target.type": "Builder", "target.id": { "$in": &builder_ids } },
|
||||
{ "target.type": "Alerter", "target.id": { "$in": &alerter_ids } },
|
||||
]
|
||||
|
||||
@@ -85,13 +85,7 @@ async fn main() -> anyhow::Result<()> {
|
||||
|
||||
fn cors() -> anyhow::Result<CorsLayer> {
|
||||
let cors = CorsLayer::new()
|
||||
.allow_origin(
|
||||
// core_config()
|
||||
// .host
|
||||
// .parse::<HeaderValue>()
|
||||
// .context("failed to parse host into origin")?,
|
||||
Any,
|
||||
)
|
||||
.allow_origin(Any)
|
||||
.allow_methods(Any)
|
||||
.allow_headers(Any);
|
||||
Ok(cors)
|
||||
|
||||
@@ -56,26 +56,30 @@ export const BuildConfig = ({ id }: { id: string }) => {
|
||||
<div className="text-xl">
|
||||
v{major}.{minor}.{patch}
|
||||
</div>
|
||||
<Button
|
||||
variant="secondary"
|
||||
onClick={() =>
|
||||
set({
|
||||
version: { major: major + 1, minor, patch: 0 },
|
||||
})
|
||||
}
|
||||
>
|
||||
+ Major
|
||||
</Button>
|
||||
<Button
|
||||
variant="secondary"
|
||||
onClick={() =>
|
||||
set({
|
||||
version: { major, minor: minor + 1, patch: 0 },
|
||||
})
|
||||
}
|
||||
>
|
||||
+ Minor
|
||||
</Button>
|
||||
{!disabled && (
|
||||
<Button
|
||||
variant="secondary"
|
||||
onClick={() =>
|
||||
set({
|
||||
version: { major: major + 1, minor, patch: 0 },
|
||||
})
|
||||
}
|
||||
>
|
||||
+ Major
|
||||
</Button>
|
||||
)}
|
||||
{!disabled && (
|
||||
<Button
|
||||
variant="secondary"
|
||||
onClick={() =>
|
||||
set({
|
||||
version: { major, minor: minor + 1, patch: 0 },
|
||||
})
|
||||
}
|
||||
>
|
||||
+ Minor
|
||||
</Button>
|
||||
)}
|
||||
</div>
|
||||
</ConfigItem>
|
||||
);
|
||||
@@ -86,6 +90,7 @@ export const BuildConfig = ({ id }: { id: string }) => {
|
||||
type="Builder"
|
||||
selected={id}
|
||||
onSelect={(builder_id) => set({ builder_id })}
|
||||
disabled={disabled}
|
||||
/>
|
||||
</ConfigItem>
|
||||
),
|
||||
@@ -129,7 +134,9 @@ export const BuildConfig = ({ id }: { id: string }) => {
|
||||
/>
|
||||
),
|
||||
use_buildx: true,
|
||||
labels: (l, set) => <LabelsConfig labels={l ?? []} set={set} disabled={disabled} />,
|
||||
labels: (l, set) => (
|
||||
<LabelsConfig labels={l ?? []} set={set} disabled={disabled} />
|
||||
),
|
||||
extra_args: (value, set) => (
|
||||
<ExtraArgs args={value ?? []} set={set} disabled={disabled} />
|
||||
),
|
||||
|
||||
@@ -35,6 +35,7 @@ export const EnvVars = ({
|
||||
placeholder="VARIABLE=value"
|
||||
value={env}
|
||||
onChange={(e) => setEnv(e.target.value)}
|
||||
disabled={disabled}
|
||||
/>
|
||||
</ConfigItem>
|
||||
);
|
||||
|
||||
@@ -58,12 +58,14 @@ const BuildVersionSelector = ({
|
||||
const ImageTypeSelector = ({
|
||||
selected,
|
||||
onSelect,
|
||||
disabled,
|
||||
}: {
|
||||
selected: Types.DeploymentImage["type"] | undefined;
|
||||
onSelect: (type: Types.DeploymentImage["type"]) => void;
|
||||
disabled: boolean;
|
||||
}) => (
|
||||
<Select value={selected || undefined} onValueChange={onSelect}>
|
||||
<SelectTrigger className="max-w-[150px]">
|
||||
<Select value={selected || undefined} onValueChange={onSelect} disabled={disabled}>
|
||||
<SelectTrigger className="max-w-[150px]" disabled={disabled}>
|
||||
<SelectValue placeholder="Select Type" />
|
||||
</SelectTrigger>
|
||||
<SelectContent>
|
||||
@@ -86,6 +88,7 @@ export const ImageConfig = ({
|
||||
<div className="flex gap-4 w-full justify-end">
|
||||
<ImageTypeSelector
|
||||
selected={image?.type}
|
||||
disabled={disabled}
|
||||
onSelect={(type) =>
|
||||
set({
|
||||
image: {
|
||||
@@ -146,6 +149,7 @@ export const ImageConfig = ({
|
||||
}
|
||||
className="w-full lg:w-[300px]"
|
||||
placeholder="image name"
|
||||
disabled={disabled}
|
||||
/>
|
||||
)}
|
||||
</div>
|
||||
|
||||
@@ -34,6 +34,7 @@ export const Resource = () => {
|
||||
perms
|
||||
)
|
||||
: false;
|
||||
const canWrite = perms === Types.PermissionLevel.Write;
|
||||
|
||||
return (
|
||||
<Page
|
||||
@@ -89,13 +90,15 @@ export const Resource = () => {
|
||||
|
||||
{/* Config and Danger Zone */}
|
||||
<Components.Config id={id} />
|
||||
<Section
|
||||
title="Danger Zone"
|
||||
icon={<AlertTriangle className="w-4 h-4" />}
|
||||
actions={type !== "Server" && <CopyResource type={type} id={id} />}
|
||||
>
|
||||
<Components.DangerZone id={id} />
|
||||
</Section>
|
||||
{canWrite && (
|
||||
<Section
|
||||
title="Danger Zone"
|
||||
icon={<AlertTriangle className="w-4 h-4" />}
|
||||
actions={type !== "Server" && <CopyResource type={type} id={id} />}
|
||||
>
|
||||
<Components.DangerZone id={id} />
|
||||
</Section>
|
||||
)}
|
||||
</Page>
|
||||
);
|
||||
};
|
||||
|
||||
@@ -188,6 +188,9 @@ function addPerms<I>(
|
||||
const PermissionsTable = () => {
|
||||
const { toast } = useToast();
|
||||
const [showNone, setShowNone] = useState(false);
|
||||
const [resourceType, setResourceType] = useState<UsableResource | "All">(
|
||||
"All"
|
||||
);
|
||||
const [search, setSearch] = useState("");
|
||||
const searchSplit = search.toLowerCase().split(" ");
|
||||
const inv = useInvalidate();
|
||||
@@ -210,6 +213,23 @@ const PermissionsTable = () => {
|
||||
onChange={(e) => setSearch(e.target.value)}
|
||||
className="w-[300px]"
|
||||
/>
|
||||
<Select
|
||||
value={resourceType}
|
||||
onValueChange={(value) =>
|
||||
setResourceType(value as UsableResource | "All")
|
||||
}
|
||||
>
|
||||
<SelectTrigger className="w-44">
|
||||
<SelectValue />
|
||||
</SelectTrigger>
|
||||
<SelectContent>
|
||||
{["All", ...Object.keys(ResourceComponents)].map((type) => (
|
||||
<SelectItem key={type} value={type}>
|
||||
{type === "All" ? "All" : type + "s"}
|
||||
</SelectItem>
|
||||
))}
|
||||
</SelectContent>
|
||||
</Select>
|
||||
<div
|
||||
className="flex gap-3 items-center"
|
||||
onClick={() => setShowNone(!showNone)}
|
||||
@@ -225,6 +245,9 @@ const PermissionsTable = () => {
|
||||
data={
|
||||
permissions?.filter(
|
||||
(permission) =>
|
||||
(resourceType === "All"
|
||||
? true
|
||||
: permission.resource_target.type === resourceType) &&
|
||||
(showNone
|
||||
? true
|
||||
: permission.level !== Types.PermissionLevel.None) &&
|
||||
|
||||
Reference in New Issue
Block a user