forked from weaveworks/weave-gitops
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Init image automation (weaveworks#3258)
* init image automation * chore: Add sample manifests for image automation objects * create image automation kind * set last updates * add image automation updates details page * add imagePolicy * make ui-prettify-format * init onboarding Image update widget * useCheckCRDInstalled * run prettier * run make proto * update snap * make proto * update snap -_- * revert docs changes * address PR comments * Update ui/components/ImageAutomation/updates/ImageAutomationUpdatesDetails.tsx Co-authored-by: Jordan Pellizzari <[email protected]> Co-authored-by: Yiannis <[email protected]> Co-authored-by: Jordan Pellizzari <[email protected]>
- Loading branch information
1 parent
46ce7c8
commit c9da1a0
Showing
22 changed files
with
791 additions
and
81 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
import React from "react"; | ||
import { useRouteMatch } from "react-router-dom"; | ||
import ImageRepositoriesTable from "../../components/ImageAutomation/repositories/ImageRepositoriesTable"; | ||
import ImageAutomationUpdatesTable from "../../components/ImageAutomation/updates/ImageAutomationUpdatesTable"; | ||
import { routeTab } from "../../components/KustomizationDetail"; | ||
import SubRouterTabs, { RouterTab } from "../../components/SubRouterTabs"; | ||
import Flex from "../Flex"; | ||
|
||
const ImageAutomation = () => { | ||
const { path } = useRouteMatch(); | ||
|
||
const tabs: Array<routeTab> = [ | ||
{ | ||
name: "Image Update Automations", | ||
path: `${path}/updates`, | ||
component: () => { | ||
return <ImageAutomationUpdatesTable />; | ||
}, | ||
visible: true, | ||
}, | ||
{ | ||
name: "Image Repositories", | ||
path: `${path}/repositories`, | ||
component: () => { | ||
return <ImageRepositoriesTable />; | ||
}, | ||
visible: true, | ||
}, | ||
]; | ||
return ( | ||
<Flex wide tall column> | ||
<SubRouterTabs rootPath={tabs[0].path} clearQuery> | ||
{tabs.map( | ||
(subRoute, index) => | ||
subRoute.visible && ( | ||
<RouterTab name={subRoute.name} path={subRoute.path} key={index}> | ||
{subRoute.component()} | ||
</RouterTab> | ||
) | ||
)} | ||
</SubRouterTabs> | ||
</Flex> | ||
); | ||
}; | ||
|
||
export default ImageAutomation; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,79 @@ | ||
import React from "react"; | ||
import { Kind } from "../../lib/api/core/types.pb"; | ||
import EventsTable from "../EventsTable"; | ||
import Flex from "../Flex"; | ||
import InfoList, { InfoField } from "../InfoList"; | ||
import PageStatus from "../PageStatus"; | ||
import Spacer from "../Spacer"; | ||
import SubRouterTabs, { RouterTab } from "../SubRouterTabs"; | ||
import Text from "../Text"; | ||
import YamlView from "../YamlView"; | ||
|
||
interface Props { | ||
data: any; | ||
kind: Kind; | ||
rootPath: string; | ||
infoFields: InfoField[]; | ||
children?: any; | ||
} | ||
|
||
const ImageAutomationDetails = ({ | ||
data, | ||
kind, | ||
rootPath, | ||
infoFields, | ||
children, | ||
}: Props) => { | ||
const { name, namespace, clusterName, suspended, conditions } = data; | ||
return ( | ||
<Flex wide tall column> | ||
<Text size="large" semiBold titleHeight> | ||
{name} | ||
</Text> | ||
<Spacer margin="xs" /> | ||
<PageStatus conditions={conditions} suspended={suspended} /> | ||
<Spacer margin="xs" /> | ||
{/* ImageUpdateAutomation sync is not supported yet and it'll be added in future PR */} | ||
{/* <SyncActions | ||
name={name} | ||
namespace={namespace} | ||
clusterName={clusterName} | ||
kind={kind} | ||
/> | ||
<Spacer margin="xs" /> */} | ||
|
||
<SubRouterTabs rootPath={`${rootPath}/details`}> | ||
<RouterTab name="Details" path={`${rootPath}/details`}> | ||
<> | ||
<InfoList items={infoFields} /> | ||
<Spacer margin="xs" /> | ||
{children} | ||
</> | ||
</RouterTab> | ||
<RouterTab name="Events" path={`${rootPath}/events`}> | ||
<EventsTable | ||
namespace={namespace} | ||
involvedObject={{ | ||
kind: kind, | ||
name: name, | ||
namespace: namespace, | ||
clusterName: clusterName, | ||
}} | ||
/> | ||
</RouterTab> | ||
<RouterTab name="yaml" path={`${rootPath}/yaml`}> | ||
<YamlView | ||
yaml={data.yaml} | ||
object={{ | ||
kind: kind, | ||
name: name, | ||
namespace: namespace, | ||
}} | ||
/> | ||
</RouterTab> | ||
</SubRouterTabs> | ||
</Flex> | ||
); | ||
}; | ||
|
||
export default ImageAutomationDetails; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,63 @@ | ||
import React from "react"; | ||
import { useSyncFluxObject } from "../../hooks/automations"; | ||
import { useToggleSuspend } from "../../hooks/flux"; | ||
import { Kind } from "../../lib/api/core/types.pb"; | ||
import Button from "../Button"; | ||
import Flex from "../Flex"; | ||
import Spacer from "../Spacer"; | ||
import SyncButton from "../SyncButton"; | ||
|
||
interface Props { | ||
name?: string; | ||
namespace?: string; | ||
clusterName?: string; | ||
kind?: Kind; | ||
suspended?: boolean; | ||
} | ||
const SyncActions = ({ | ||
name, | ||
namespace, | ||
clusterName, | ||
kind, | ||
suspended, | ||
}: Props) => { | ||
const suspend = useToggleSuspend( | ||
{ | ||
objects: [ | ||
{ | ||
name, | ||
namespace, | ||
clusterName, | ||
kind, | ||
}, | ||
], | ||
suspend: !suspended, | ||
}, | ||
"sources" | ||
); | ||
|
||
const sync = useSyncFluxObject([ | ||
{ | ||
name, | ||
namespace, | ||
clusterName, | ||
kind, | ||
}, | ||
]); | ||
return ( | ||
<Flex wide start> | ||
<SyncButton | ||
onClick={() => sync.mutateAsync({ withSource: false })} | ||
loading={sync.isLoading} | ||
disabled={suspended} | ||
hideDropdown={true} | ||
/> | ||
<Spacer padding="xs" /> | ||
<Button onClick={() => suspend.mutateAsync()} loading={suspend.isLoading}> | ||
{suspended ? "Resume" : "Suspend"} | ||
</Button> | ||
</Flex> | ||
); | ||
}; | ||
|
||
export default SyncActions; |
Oops, something went wrong.