Pārlūkot izejas kodu

add support for registry-only and repo-only source selector on launch

Justin Rhee 3 gadi atpakaļ
vecāks
revīzija
bc8eadd591

+ 1 - 0
dashboard/src/main/home/launch/launch-flow/LaunchFlow.tsx

@@ -367,6 +367,7 @@ const LaunchFlow: React.FC<PropsType> = (props) => {
       return (
         <SourcePage
           sourceType={sourceType}
+          hasSource={form.hasSource}
           setSourceType={setSourceType}
           templateName={templateName}
           setPage={setCurrentPage}

+ 15 - 10
dashboard/src/main/home/launch/launch-flow/SourcePage.tsx

@@ -27,6 +27,8 @@ type PropsType = RouteComponentProps & {
   imageTag: string;
   setImageTag: (x: string) => void;
 
+  hasSource?: string;
+
   actionConfig: ActionConfigType;
   setActionConfig: (
     x: ActionConfigType | ((prevState: ActionConfigType) => ActionConfigType)
@@ -55,17 +57,18 @@ const defaultActionConfig: ActionConfigType = {
   image_repo_uri: "",
   git_branch: "",
   git_repo_id: 0,
+  kind: "github",
 };
 
 class SourcePage extends Component<PropsType, StateType> {
   renderSourceSelector = () => {
     let { capabilities, setCurrentModal } = this.context;
-    let { sourceType, setSourceType } = this.props;
+    let { sourceType, setSourceType, hasSource } = this.props;
 
     if (sourceType === "") {
       return (
         <BlockList>
-          {capabilities.github || capabilities.gitlab ? (
+          {(capabilities.github || capabilities.gitlab) && hasSource !== "registry-only" && (
             <Block onClick={() => setSourceType("repo")}>
               <BlockIcon src="https://git-scm.com/images/logos/downloads/Git-Icon-1788C.png" />
               <BlockTitle>Git repository</BlockTitle>
@@ -73,14 +76,16 @@ class SourcePage extends Component<PropsType, StateType> {
                 Deploy using source from a Git repo.
               </BlockDescription>
             </Block>
-          ) : null}
-          <Block onClick={() => setSourceType("registry")}>
-            <BlockIcon src="https://cdn4.iconfinder.com/data/icons/logos-and-brands/512/97_Docker_logo_logos-512.png" />
-            <BlockTitle>Docker registry</BlockTitle>
-            <BlockDescription>
-              Deploy a container from an image registry.
-            </BlockDescription>
-          </Block>
+          )}
+          {hasSource !== "repo-only" && (
+            <Block onClick={() => setSourceType("registry")}>
+              <BlockIcon src="https://cdn4.iconfinder.com/data/icons/logos-and-brands/512/97_Docker_logo_logos-512.png" />
+              <BlockTitle>Docker registry</BlockTitle>
+              <BlockDescription>
+                Deploy a container from an image registry.
+              </BlockDescription>
+            </Block>
+          )}
         </BlockList>
       );
     }