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

[UI] Add edit option to resources that have create template in annotation #2846

Merged
merged 21 commits into from
Oct 12, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
21 commits
Select commit Hold shift + click to select a range
6556d57
Add edit option to resources that have create template in anno - WIP
AlinaGoaga Oct 10, 2022
5f2fc33
Move edit option to resource details page
AlinaGoaga Oct 11, 2022
47285b3
Refactor edit in details
AlinaGoaga Oct 11, 2022
1ac02d4
Extract custom actions component
AlinaGoaga Oct 11, 2022
491a431
Remove edit from core details table
AlinaGoaga Oct 11, 2022
97a4e0d
Merge branch 'main' into edit-resource
AlinaGoaga Oct 11, 2022
4ca296b
Remove edit from core details table - updated
AlinaGoaga Oct 11, 2022
e209316
Merge branch 'edit-resource' of github.com:weaveworks/weave-gitops in…
AlinaGoaga Oct 11, 2022
9c01559
Fix some errors
AlinaGoaga Oct 11, 2022
50f2029
Merge branch 'main' into edit-resource
AlinaGoaga Oct 11, 2022
d0efad6
Add custom actions to the details page
AlinaGoaga Oct 11, 2022
045a53d
Merge branch 'edit-resource' of github.com:weaveworks/weave-gitops in…
AlinaGoaga Oct 11, 2022
18dd2f7
Add custom actions to the details page - updated
AlinaGoaga Oct 11, 2022
a61ac7f
Merge branch 'main' of github.com:weaveworks/weave-gitops into edit-r…
AlinaGoaga Oct 11, 2022
43911a9
Merge branch 'main' into edit-resource
AlinaGoaga Oct 11, 2022
9179cd3
Add actions type and move edit button
AlinaGoaga Oct 12, 2022
3a14416
Merge branch 'edit-resource' of github.com:weaveworks/weave-gitops in…
AlinaGoaga Oct 12, 2022
48aabb0
Add actions type and move edit button - updated
AlinaGoaga Oct 12, 2022
eca59b0
Lint
AlinaGoaga Oct 12, 2022
c34a161
Merge branch 'main' into edit-resource
AlinaGoaga Oct 12, 2022
ec2eedc
Merge branch 'main' into edit-resource
AlinaGoaga Oct 12, 2022
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
11 changes: 10 additions & 1 deletion ui/components/AutomationDetail.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import { useToggleSuspend } from "../hooks/flux";
import { Kind } from "../lib/api/core/types.pb";
import { Automation } from "../lib/objects";
import Button from "./Button";
import CustomActions from "./CustomActions";
import DependenciesView from "./DependenciesView";
import EventsTable from "./EventsTable";
import Flex from "./Flex";
Expand All @@ -28,9 +29,16 @@ type Props = {
className?: string;
info: InfoField[];
customTabs?: Array<routeTab>;
customActions?: JSX.Element[];
};

function AutomationDetail({ automation, className, info, customTabs }: Props) {
function AutomationDetail({
automation,
className,
info,
customTabs,
customActions,
}: Props) {
const { path } = useRouteMatch();
const { setNodeYaml, appState } = React.useContext(AppContext);
const nodeYaml = appState.nodeYaml;
Expand Down Expand Up @@ -152,6 +160,7 @@ function AutomationDetail({ automation, className, info, customTabs }: Props) {
>
{automation.suspended ? "Resume" : "Suspend"}
</Button>
<CustomActions actions={customActions} />
</Flex>

<SubRouterTabs rootPath={`${path}/details`}>
Expand Down
4 changes: 3 additions & 1 deletion ui/components/BucketDetail.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,10 @@ import { InfoField } from "./InfoList";
type Props = {
className?: string;
bucket: Bucket;
customActions?: JSX.Element[];
};

function BucketDetail({ className, bucket }: Props) {
function BucketDetail({ className, bucket, customActions }: Props) {
const { data } = useFeatureFlags();
const flags = data?.flags || {};

Expand All @@ -32,6 +33,7 @@ function BucketDetail({ className, bucket }: Props) {
className={className}
type={Kind.Bucket}
source={bucket}
customActions={customActions}
info={[
["Type", Kind.Bucket],
["Endpoint", bucket.endpoint],
Expand Down
17 changes: 17 additions & 0 deletions ui/components/CustomActions.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
import * as React from "react";
import Spacer from "./Spacer";

function CustomActions({ actions }: { actions: JSX.Element[] }) {
return actions?.length > 0 ? (
<>
{actions?.map((action, index) => (
<React.Fragment key={index}>
<Spacer padding="xs" />
{action}
</React.Fragment>
))}
</>
) : null;
}

export default CustomActions;
8 changes: 7 additions & 1 deletion ui/components/GitRepositoryDetail.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,14 @@ import { InfoField } from "./InfoList";
type Props = {
className?: string;
gitRepository: GitRepository;
customActions?: JSX.Element[];
};

function GitRepositoryDetail({ className, gitRepository }: Props) {
function GitRepositoryDetail({
className,
gitRepository,
customActions,
}: Props) {
const { data } = useFeatureFlags();
const flags = data?.flags || {};

Expand All @@ -32,6 +37,7 @@ function GitRepositoryDetail({ className, gitRepository }: Props) {
className={className}
type={Kind.GitRepository}
source={gitRepository}
customActions={customActions}
info={[
["Type", Kind.GitRepository],
[
Expand Down
4 changes: 3 additions & 1 deletion ui/components/HelmChartDetail.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,10 @@ import { InfoField } from "./InfoList";
type Props = {
className?: string;
helmChart: HelmChart;
customActions?: JSX.Element[];
};

function HelmChartDetail({ className, helmChart }: Props) {
function HelmChartDetail({ className, helmChart, customActions }: Props) {
const { data } = useFeatureFlags();
const flags = data?.flags || {};

Expand All @@ -31,6 +32,7 @@ function HelmChartDetail({ className, helmChart }: Props) {
type={Kind.HelmChart}
className={className}
source={helmChart}
customActions={customActions}
info={[
["Type", Kind.HelmChart],
["Chart", helmChart.chart],
Expand Down
9 changes: 8 additions & 1 deletion ui/components/HelmReleaseDetail.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ type Props = {
helmRelease?: HelmRelease;
className?: string;
customTabs?: Array<routeTab>;
customActions?: JSX.Element[];
};

function helmChartLink(helmRelease: HelmRelease) {
Expand Down Expand Up @@ -49,7 +50,12 @@ function helmChartLink(helmRelease: HelmRelease) {
);
}

function HelmReleaseDetail({ helmRelease, className, customTabs }: Props) {
function HelmReleaseDetail({
helmRelease,
className,
customTabs,
customActions,
}: Props) {
const { data } = useFeatureFlags();
const flags = data?.flags || {};

Expand All @@ -67,6 +73,7 @@ function HelmReleaseDetail({ helmRelease, className, customTabs }: Props) {
className={className}
automation={helmRelease}
customTabs={customTabs}
customActions={customActions}
info={[
["Source", helmChartLink(helmRelease)],
["Chart", helmRelease?.helmChart.chart],
Expand Down
8 changes: 7 additions & 1 deletion ui/components/HelmRepositoryDetail.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,14 @@ import Timestamp from "./Timestamp";
type Props = {
className?: string;
helmRepository: HelmRepository;
customActions?: JSX.Element[];
};

function HelmRepositoryDetail({ className, helmRepository }: Props) {
function HelmRepositoryDetail({
className,
helmRepository,
customActions,
}: Props) {
const { data } = useFeatureFlags();
const flags = data?.flags || {};

Expand All @@ -32,6 +37,7 @@ function HelmRepositoryDetail({ className, helmRepository }: Props) {
className={className}
type={Kind.HelmRepository}
source={helmRepository}
customActions={customActions}
info={[
["Type", Kind.HelmRepository],
["Repository Type", helmRepository.repositoryType.toLowerCase()],
Expand Down
9 changes: 8 additions & 1 deletion ui/components/KustomizationDetail.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,15 @@ type Props = {
kustomization?: Kustomization;
className?: string;
customTabs?: Array<routeTab>;
customActions?: JSX.Element[];
};

function KustomizationDetail({ kustomization, className, customTabs }: Props) {
function KustomizationDetail({
kustomization,
className,
customTabs,
customActions,
}: Props) {
const { data } = useFeatureFlags();
const flags = data?.flags || {};

Expand All @@ -42,6 +48,7 @@ function KustomizationDetail({ kustomization, className, customTabs }: Props) {
className={className}
customTabs={customTabs}
automation={kustomization}
customActions={customActions}
info={[
[
"Source",
Expand Down
9 changes: 8 additions & 1 deletion ui/components/OCIRepositoryDetail.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,18 @@ import Interval from "./Interval";
import Link from "./Link";
import SourceDetail from "./SourceDetail";
import Timestamp from "./Timestamp";

type Props = {
className?: string;
ociRepository: OCIRepository;
customActions?: JSX.Element[];
};

function OCIRepositoryDetail({ className, ociRepository }: Props) {
function OCIRepositoryDetail({
className,
ociRepository,
customActions,
}: Props) {
const { data } = useFeatureFlags();
const flags = data?.flags || {};

Expand All @@ -31,6 +37,7 @@ function OCIRepositoryDetail({ className, ociRepository }: Props) {
className={className}
type={Kind.OCIRepository}
source={ociRepository}
customActions={customActions}
info={[
["Type", Kind.OCIRepository],
["URL", <Link href={ociRepository.url}>{ociRepository.url}</Link>],
Expand Down
5 changes: 4 additions & 1 deletion ui/components/SourceDetail.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import { HelmRelease, Source } from "../lib/objects";
import { getSourceRefForAutomation } from "../lib/utils";
import AutomationsTable from "./AutomationsTable";
import Button from "./Button";
import CustomActions from "./CustomActions";
import EventsTable from "./EventsTable";
import Flex from "./Flex";
import InfoList, { InfoField } from "./InfoList";
Expand All @@ -27,9 +28,10 @@ type Props = {
children?: JSX.Element;
source: Source;
info: InfoField[];
customActions?: JSX.Element[];
};

function SourceDetail({ className, source, info, type }: Props) {
function SourceDetail({ className, source, info, type, customActions }: Props) {
const { data: automations, isLoading: automationsLoading } =
useListAutomations();
const { path } = useRouteMatch();
Expand Down Expand Up @@ -107,6 +109,7 @@ function SourceDetail({ className, source, info, type }: Props) {
>
{source?.suspended ? "Resume" : "Suspend"}
</Button>
<CustomActions actions={customActions} />
</Flex>

<SubRouterTabs rootPath={`${path}/details`}>
Expand Down