Compare commits

11 Commits

29 changed files with 2074 additions and 238 deletions

View File

@ -3,6 +3,8 @@
"Formik",
"clsx",
"fontsource",
"notistack",
"unmount",
"vditor"
]
}

View File

@ -7,6 +7,6 @@ generates:
- "typescript"
- "typescript-operations"
- "typescript-react-apollo"
./graphql.schema.json:
src/generated/graphql.schema.json:
plugins:
- "introspection"

343
package-lock.json generated
View File

@ -1,17 +1,20 @@
{
"name": "fennec-bs",
"version": "0.1.0",
"version": "0.1.1",
"lockfileVersion": 2,
"requires": true,
"packages": {
"": {
"name": "fennec-bs",
"version": "0.1.0",
"version": "0.1.1",
"dependencies": {
"@apollo/client": "^3.3.15",
"@curi/react-dom": "^2.0.4",
"@curi/router": "^2.1.2",
"@date-io/date-fns": "^1.3.13",
"@fortawesome/fontawesome-svg-core": "^1.2.35",
"@fortawesome/free-solid-svg-icons": "^5.15.3",
"@fortawesome/react-fontawesome": "^0.1.14",
"@hickory/browser": "^2.1.0",
"@material-ui/core": "^4.11.3",
"@material-ui/icons": "^4.11.2",
@ -24,12 +27,14 @@
"@types/node": "^12.20.10",
"@types/react": "^17.0.3",
"@types/react-dom": "^17.0.3",
"apollo-link-scalars": "^2.1.3",
"date-fns": "^2.21.1",
"fontsource-roboto": "^4.0.0",
"formik": "^2.2.6",
"formik-material-ui": "^3.0.1",
"formik-material-ui-pickers": "^0.0.12",
"graphql": "^15.5.0",
"graphql-scalars": "^1.9.3",
"material-ui-confirm": "^2.1.2",
"notistack": "^1.0.6",
"ramda": "^0.27.1",
@ -47,7 +52,8 @@
"@graphql-codegen/typescript": "1.21.1",
"@graphql-codegen/typescript-operations": "1.17.15",
"@graphql-codegen/typescript-react-apollo": "2.2.3",
"@types/ramda": "^0.27.40",
"@types/date-fns": "^2.6.0",
"@types/ramda": "^0.27.41",
"@types/yup": "^0.29.11",
"autoprefixer": "^9.8.6",
"postcss": "^7.0.35"
@ -2159,6 +2165,51 @@
"node": ">=8"
}
},
"node_modules/@fortawesome/fontawesome-common-types": {
"version": "0.2.35",
"resolved": "https://registry.npmjs.org/@fortawesome/fontawesome-common-types/-/fontawesome-common-types-0.2.35.tgz",
"integrity": "sha512-IHUfxSEDS9dDGqYwIW7wTN6tn/O8E0n5PcAHz9cAaBoZw6UpG20IG/YM3NNLaGPwPqgjBAFjIURzqoQs3rrtuw==",
"hasInstallScript": true,
"engines": {
"node": ">=6"
}
},
"node_modules/@fortawesome/fontawesome-svg-core": {
"version": "1.2.35",
"resolved": "https://registry.npmjs.org/@fortawesome/fontawesome-svg-core/-/fontawesome-svg-core-1.2.35.tgz",
"integrity": "sha512-uLEXifXIL7hnh2sNZQrIJWNol7cTVIzwI+4qcBIq9QWaZqUblm0IDrtSqbNg+3SQf8SMGHkiSigD++rHmCHjBg==",
"hasInstallScript": true,
"dependencies": {
"@fortawesome/fontawesome-common-types": "^0.2.35"
},
"engines": {
"node": ">=6"
}
},
"node_modules/@fortawesome/free-solid-svg-icons": {
"version": "5.15.3",
"resolved": "https://registry.npmjs.org/@fortawesome/free-solid-svg-icons/-/free-solid-svg-icons-5.15.3.tgz",
"integrity": "sha512-XPeeu1IlGYqz4VWGRAT5ukNMd4VHUEEJ7ysZ7pSSgaEtNvSo+FLurybGJVmiqkQdK50OkSja2bfZXOeyMGRD8Q==",
"hasInstallScript": true,
"dependencies": {
"@fortawesome/fontawesome-common-types": "^0.2.35"
},
"engines": {
"node": ">=6"
}
},
"node_modules/@fortawesome/react-fontawesome": {
"version": "0.1.14",
"resolved": "https://registry.npmjs.org/@fortawesome/react-fontawesome/-/react-fontawesome-0.1.14.tgz",
"integrity": "sha512-4wqNb0gRLVaBm/h+lGe8UfPPivcbuJ6ecI4hIgW0LjI7kzpYB9FkN0L9apbVzg+lsBdcTf0AlBtODjcSX5mmKA==",
"dependencies": {
"prop-types": "^15.7.2"
},
"peerDependencies": {
"@fortawesome/fontawesome-svg-core": "^1.2.32",
"react": ">=16.x"
}
},
"node_modules/@graphql-codegen/cli": {
"version": "1.21.3",
"resolved": "https://registry.npmjs.org/@graphql-codegen/cli/-/cli-1.21.3.tgz",
@ -4079,6 +4130,16 @@
"@babel/types": "^7.3.0"
}
},
"node_modules/@types/date-fns": {
"version": "2.6.0",
"resolved": "https://registry.npmjs.org/@types/date-fns/-/date-fns-2.6.0.tgz",
"integrity": "sha1-sGLKRlYgApCb4MY6ZGftFzE2rME=",
"deprecated": "This is a stub types definition for date-fns (https://github.com/date-fns/date-fns). date-fns provides its own type definitions, so you don't need @types/date-fns installed!",
"dev": true,
"dependencies": {
"date-fns": "*"
}
},
"node_modules/@types/eslint": {
"version": "7.2.10",
"resolved": "https://registry.npmjs.org/@types/eslint/-/eslint-7.2.10.tgz",
@ -4226,9 +4287,9 @@
"integrity": "sha512-1HcDas8SEj4z1Wc696tH56G8OlRaH/sqZOynNNB+HF0WOeXPaxTtbYzJY2oEfiUxjSKjhCKr+MvR7dCHcEelug=="
},
"node_modules/@types/ramda": {
"version": "0.27.40",
"resolved": "https://registry.npmjs.org/@types/ramda/-/ramda-0.27.40.tgz",
"integrity": "sha512-V99ZfTH2tqVYdLDAlgh2uT+N074HPgqnAsMjALKSBqogYd0HbuuGMqNukJ6fk9Ml/Htaus76fsc4Yh3p7q1VdQ==",
"version": "0.27.41",
"resolved": "https://registry.npmjs.org/@types/ramda/-/ramda-0.27.41.tgz",
"integrity": "sha512-SxKnQzrPmA5ly2BvHrTE5BvZEkQgs3kSYBcscWUOWP9FGVDGVdzlWXpiSBJhzBxe0pFQ/amM4cjFRi9R5PFoQg==",
"dev": true,
"dependencies": {
"ts-toolbelt": "^6.15.1"
@ -5011,6 +5072,35 @@
"node": ">= 8"
}
},
"node_modules/apollo-link-scalars": {
"version": "2.1.3",
"resolved": "https://registry.npmjs.org/apollo-link-scalars/-/apollo-link-scalars-2.1.3.tgz",
"integrity": "sha512-yniDMwmRcNcJW2uH8Z10Pj7AaPgysgIlL5stqkabPMnUShHqFIB/4VqQueNQoHBlh5T7sd/5hbqZ1mtWUDel1Q==",
"dependencies": {
"@apollo/client": "^3.0.2",
"lodash.clonedeep": "^4.5.0",
"lodash.every": "^4.6.0",
"lodash.flatmap": "^4.5.0",
"lodash.frompairs": "^4.0.1",
"lodash.has": "^4.5.2",
"lodash.isnull": "^3.0.0",
"lodash.isnumber": "^3.0.3",
"lodash.isstring": "^4.0.1",
"lodash.isundefined": "^3.0.1",
"lodash.mapvalues": "^4.6.0",
"lodash.omit": "^4.5.0",
"lodash.pickby": "^4.6.0",
"lodash.reduce": "^4.6.0",
"lodash.uniqby": "^4.7.0",
"zen-observable-ts": "^1.0.0"
},
"engines": {
"node": ">=10.0"
},
"peerDependencies": {
"graphql": "14.x || 15.x"
}
},
"node_modules/aproba": {
"version": "1.2.0",
"resolved": "https://registry.npmjs.org/aproba/-/aproba-1.2.0.tgz",
@ -11235,6 +11325,25 @@
"node": ">= 6"
}
},
"node_modules/graphql-scalars": {
"version": "1.9.3",
"resolved": "https://registry.npmjs.org/graphql-scalars/-/graphql-scalars-1.9.3.tgz",
"integrity": "sha512-vP71Og4ALfe3PCk6T+B7LcJHH55gL0tYidmAE/kWT3ScE2FUCFS7iiMXFQXjCaYLi8nZcRLn9HuejGcjZ8kRug==",
"dependencies": {
"tslib": "~2.2.0"
},
"engines": {
"node": ">=10"
},
"peerDependencies": {
"graphql": "^0.8.0 || ^0.9.0 || ^0.10.0 || ^0.11.0 || ^0.12.0 || ^0.13.0 || ^14.0.0 || ^15.0.0"
}
},
"node_modules/graphql-scalars/node_modules/tslib": {
"version": "2.2.0",
"resolved": "https://registry.npmjs.org/tslib/-/tslib-2.2.0.tgz",
"integrity": "sha512-gS9GVHRU+RGn5KQM2rllAlR3dU6m7AcpJKdtH8gFvQiC4Otgk98XnmMU+nZenHt/+VhnBPWwgrJsyrdcw6i23w=="
},
"node_modules/graphql-tag": {
"version": "2.12.4",
"resolved": "https://registry.npmjs.org/graphql-tag/-/graphql-tag-2.12.4.tgz",
@ -14743,17 +14852,37 @@
"resolved": "https://registry.npmjs.org/lodash.debounce/-/lodash.debounce-4.0.8.tgz",
"integrity": "sha1-gteb/zCmfEAF/9XiUVMArZyk168="
},
"node_modules/lodash.every": {
"version": "4.6.0",
"resolved": "https://registry.npmjs.org/lodash.every/-/lodash.every-4.6.0.tgz",
"integrity": "sha1-64mYS+vENkJ5uzrvu9HKGb+mxqc="
},
"node_modules/lodash.flatmap": {
"version": "4.5.0",
"resolved": "https://registry.npmjs.org/lodash.flatmap/-/lodash.flatmap-4.5.0.tgz",
"integrity": "sha1-74y/QI9uSCaGYzRTBcaswLd4cC4="
},
"node_modules/lodash.flatten": {
"version": "4.4.0",
"resolved": "https://registry.npmjs.org/lodash.flatten/-/lodash.flatten-4.4.0.tgz",
"integrity": "sha1-8xwiIlqWMtK7+OSt2+8kCqdlph8="
},
"node_modules/lodash.frompairs": {
"version": "4.0.1",
"resolved": "https://registry.npmjs.org/lodash.frompairs/-/lodash.frompairs-4.0.1.tgz",
"integrity": "sha1-vE5SB/onV8E25XNhTpZkUGsrG9I="
},
"node_modules/lodash.get": {
"version": "4.4.2",
"resolved": "https://registry.npmjs.org/lodash.get/-/lodash.get-4.4.2.tgz",
"integrity": "sha1-LRd/ZS+jHpObRDjVNBSZ36OCXpk=",
"dev": true
},
"node_modules/lodash.has": {
"version": "4.5.2",
"resolved": "https://registry.npmjs.org/lodash.has/-/lodash.has-4.5.2.tgz",
"integrity": "sha1-0Z9NwQlQWMzL4rDN9O4P5Ko3yGI="
},
"node_modules/lodash.includes": {
"version": "4.3.0",
"resolved": "https://registry.npmjs.org/lodash.includes/-/lodash.includes-4.3.0.tgz",
@ -14772,11 +14901,15 @@
"integrity": "sha1-YZwK89A/iwTDH1iChAt3sRzWg0M=",
"dev": true
},
"node_modules/lodash.isnull": {
"version": "3.0.0",
"resolved": "https://registry.npmjs.org/lodash.isnull/-/lodash.isnull-3.0.0.tgz",
"integrity": "sha1-+vvlnqHcon7teGU0A53YTC4HxW4="
},
"node_modules/lodash.isnumber": {
"version": "3.0.3",
"resolved": "https://registry.npmjs.org/lodash.isnumber/-/lodash.isnumber-3.0.3.tgz",
"integrity": "sha1-POdoEMWSjQM1IwGsKHMX8RwLH/w=",
"dev": true
"integrity": "sha1-POdoEMWSjQM1IwGsKHMX8RwLH/w="
},
"node_modules/lodash.isplainobject": {
"version": "4.0.6",
@ -14787,20 +14920,44 @@
"node_modules/lodash.isstring": {
"version": "4.0.1",
"resolved": "https://registry.npmjs.org/lodash.isstring/-/lodash.isstring-4.0.1.tgz",
"integrity": "sha1-1SfftUVuynzJu5XV2ur4i6VKVFE=",
"dev": true
"integrity": "sha1-1SfftUVuynzJu5XV2ur4i6VKVFE="
},
"node_modules/lodash.isundefined": {
"version": "3.0.1",
"resolved": "https://registry.npmjs.org/lodash.isundefined/-/lodash.isundefined-3.0.1.tgz",
"integrity": "sha1-I+89lTVWUgOmbO/VuDD4SJEa+0g="
},
"node_modules/lodash.mapvalues": {
"version": "4.6.0",
"resolved": "https://registry.npmjs.org/lodash.mapvalues/-/lodash.mapvalues-4.6.0.tgz",
"integrity": "sha1-G6+lAF3p3W9PJmaMMMo3IwzJaJw="
},
"node_modules/lodash.memoize": {
"version": "4.1.2",
"resolved": "https://registry.npmjs.org/lodash.memoize/-/lodash.memoize-4.1.2.tgz",
"integrity": "sha1-vMbEmkKihA7Zl/Mj6tpezRguC/4="
},
"node_modules/lodash.omit": {
"version": "4.5.0",
"resolved": "https://registry.npmjs.org/lodash.omit/-/lodash.omit-4.5.0.tgz",
"integrity": "sha1-brGa5aHuHdnfC5aeZs4Lf6MLXmA="
},
"node_modules/lodash.once": {
"version": "4.1.1",
"resolved": "https://registry.npmjs.org/lodash.once/-/lodash.once-4.1.1.tgz",
"integrity": "sha1-DdOXEhPHxW34gJd9UEyI+0cal6w=",
"dev": true
},
"node_modules/lodash.pickby": {
"version": "4.6.0",
"resolved": "https://registry.npmjs.org/lodash.pickby/-/lodash.pickby-4.6.0.tgz",
"integrity": "sha1-feoh2MGNdwOifHBMFdO4SmfjOv8="
},
"node_modules/lodash.reduce": {
"version": "4.6.0",
"resolved": "https://registry.npmjs.org/lodash.reduce/-/lodash.reduce-4.6.0.tgz",
"integrity": "sha1-8atrg5KZrUj3hKu/R2WW8DuRTTs="
},
"node_modules/lodash.template": {
"version": "4.5.0",
"resolved": "https://registry.npmjs.org/lodash.template/-/lodash.template-4.5.0.tgz",
@ -14828,6 +14985,11 @@
"resolved": "https://registry.npmjs.org/lodash.uniq/-/lodash.uniq-4.5.0.tgz",
"integrity": "sha1-0CJTc662Uq3BvILklFM5qEJ1R3M="
},
"node_modules/lodash.uniqby": {
"version": "4.7.0",
"resolved": "https://registry.npmjs.org/lodash.uniqby/-/lodash.uniqby-4.7.0.tgz",
"integrity": "sha1-2ZwHpmnp5tJOE2Lf4mbGdhavEwI="
},
"node_modules/log-symbols": {
"version": "4.1.0",
"resolved": "https://registry.npmjs.org/log-symbols/-/log-symbols-4.1.0.tgz",
@ -25052,6 +25214,15 @@
"version": "0.8.15",
"resolved": "https://registry.npmjs.org/zen-observable/-/zen-observable-0.8.15.tgz",
"integrity": "sha512-PQ2PC7R9rslx84ndNBZB/Dkv8V8fZEpk83RLgXtYd0fwUgEjseMn1Dgajh2x6S8QbZAFa9p2qVCEuYZNgve0dQ=="
},
"node_modules/zen-observable-ts": {
"version": "1.0.0",
"resolved": "https://registry.npmjs.org/zen-observable-ts/-/zen-observable-ts-1.0.0.tgz",
"integrity": "sha512-KmWcbz+9kKUeAQ8btY8m1SsEFgBcp7h/Uf3V5quhan7ZWdjGsf0JcGLULQiwOZibbFWnHkYq8Nn2AZbJabovQg==",
"dependencies": {
"@types/zen-observable": "^0.8.2",
"zen-observable": "^0.8.15"
}
}
},
"dependencies": {
@ -26804,6 +26975,35 @@
}
}
},
"@fortawesome/fontawesome-common-types": {
"version": "0.2.35",
"resolved": "https://registry.npmjs.org/@fortawesome/fontawesome-common-types/-/fontawesome-common-types-0.2.35.tgz",
"integrity": "sha512-IHUfxSEDS9dDGqYwIW7wTN6tn/O8E0n5PcAHz9cAaBoZw6UpG20IG/YM3NNLaGPwPqgjBAFjIURzqoQs3rrtuw=="
},
"@fortawesome/fontawesome-svg-core": {
"version": "1.2.35",
"resolved": "https://registry.npmjs.org/@fortawesome/fontawesome-svg-core/-/fontawesome-svg-core-1.2.35.tgz",
"integrity": "sha512-uLEXifXIL7hnh2sNZQrIJWNol7cTVIzwI+4qcBIq9QWaZqUblm0IDrtSqbNg+3SQf8SMGHkiSigD++rHmCHjBg==",
"requires": {
"@fortawesome/fontawesome-common-types": "^0.2.35"
}
},
"@fortawesome/free-solid-svg-icons": {
"version": "5.15.3",
"resolved": "https://registry.npmjs.org/@fortawesome/free-solid-svg-icons/-/free-solid-svg-icons-5.15.3.tgz",
"integrity": "sha512-XPeeu1IlGYqz4VWGRAT5ukNMd4VHUEEJ7ysZ7pSSgaEtNvSo+FLurybGJVmiqkQdK50OkSja2bfZXOeyMGRD8Q==",
"requires": {
"@fortawesome/fontawesome-common-types": "^0.2.35"
}
},
"@fortawesome/react-fontawesome": {
"version": "0.1.14",
"resolved": "https://registry.npmjs.org/@fortawesome/react-fontawesome/-/react-fontawesome-0.1.14.tgz",
"integrity": "sha512-4wqNb0gRLVaBm/h+lGe8UfPPivcbuJ6ecI4hIgW0LjI7kzpYB9FkN0L9apbVzg+lsBdcTf0AlBtODjcSX5mmKA==",
"requires": {
"prop-types": "^15.7.2"
}
},
"@graphql-codegen/cli": {
"version": "1.21.3",
"resolved": "https://registry.npmjs.org/@graphql-codegen/cli/-/cli-1.21.3.tgz",
@ -28337,6 +28537,15 @@
"@babel/types": "^7.3.0"
}
},
"@types/date-fns": {
"version": "2.6.0",
"resolved": "https://registry.npmjs.org/@types/date-fns/-/date-fns-2.6.0.tgz",
"integrity": "sha1-sGLKRlYgApCb4MY6ZGftFzE2rME=",
"dev": true,
"requires": {
"date-fns": "*"
}
},
"@types/eslint": {
"version": "7.2.10",
"resolved": "https://registry.npmjs.org/@types/eslint/-/eslint-7.2.10.tgz",
@ -28484,9 +28693,9 @@
"integrity": "sha512-1HcDas8SEj4z1Wc696tH56G8OlRaH/sqZOynNNB+HF0WOeXPaxTtbYzJY2oEfiUxjSKjhCKr+MvR7dCHcEelug=="
},
"@types/ramda": {
"version": "0.27.40",
"resolved": "https://registry.npmjs.org/@types/ramda/-/ramda-0.27.40.tgz",
"integrity": "sha512-V99ZfTH2tqVYdLDAlgh2uT+N074HPgqnAsMjALKSBqogYd0HbuuGMqNukJ6fk9Ml/Htaus76fsc4Yh3p7q1VdQ==",
"version": "0.27.41",
"resolved": "https://registry.npmjs.org/@types/ramda/-/ramda-0.27.41.tgz",
"integrity": "sha512-SxKnQzrPmA5ly2BvHrTE5BvZEkQgs3kSYBcscWUOWP9FGVDGVdzlWXpiSBJhzBxe0pFQ/amM4cjFRi9R5PFoQg==",
"dev": true,
"requires": {
"ts-toolbelt": "^6.15.1"
@ -29116,6 +29325,29 @@
"picomatch": "^2.0.4"
}
},
"apollo-link-scalars": {
"version": "2.1.3",
"resolved": "https://registry.npmjs.org/apollo-link-scalars/-/apollo-link-scalars-2.1.3.tgz",
"integrity": "sha512-yniDMwmRcNcJW2uH8Z10Pj7AaPgysgIlL5stqkabPMnUShHqFIB/4VqQueNQoHBlh5T7sd/5hbqZ1mtWUDel1Q==",
"requires": {
"@apollo/client": "^3.0.2",
"lodash.clonedeep": "^4.5.0",
"lodash.every": "^4.6.0",
"lodash.flatmap": "^4.5.0",
"lodash.frompairs": "^4.0.1",
"lodash.has": "^4.5.2",
"lodash.isnull": "^3.0.0",
"lodash.isnumber": "^3.0.3",
"lodash.isstring": "^4.0.1",
"lodash.isundefined": "^3.0.1",
"lodash.mapvalues": "^4.6.0",
"lodash.omit": "^4.5.0",
"lodash.pickby": "^4.6.0",
"lodash.reduce": "^4.6.0",
"lodash.uniqby": "^4.7.0",
"zen-observable-ts": "^1.0.0"
}
},
"aproba": {
"version": "1.2.0",
"resolved": "https://registry.npmjs.org/aproba/-/aproba-1.2.0.tgz",
@ -34122,6 +34354,21 @@
}
}
},
"graphql-scalars": {
"version": "1.9.3",
"resolved": "https://registry.npmjs.org/graphql-scalars/-/graphql-scalars-1.9.3.tgz",
"integrity": "sha512-vP71Og4ALfe3PCk6T+B7LcJHH55gL0tYidmAE/kWT3ScE2FUCFS7iiMXFQXjCaYLi8nZcRLn9HuejGcjZ8kRug==",
"requires": {
"tslib": "~2.2.0"
},
"dependencies": {
"tslib": {
"version": "2.2.0",
"resolved": "https://registry.npmjs.org/tslib/-/tslib-2.2.0.tgz",
"integrity": "sha512-gS9GVHRU+RGn5KQM2rllAlR3dU6m7AcpJKdtH8gFvQiC4Otgk98XnmMU+nZenHt/+VhnBPWwgrJsyrdcw6i23w=="
}
}
},
"graphql-tag": {
"version": "2.12.4",
"resolved": "https://registry.npmjs.org/graphql-tag/-/graphql-tag-2.12.4.tgz",
@ -36896,17 +37143,37 @@
"resolved": "https://registry.npmjs.org/lodash.debounce/-/lodash.debounce-4.0.8.tgz",
"integrity": "sha1-gteb/zCmfEAF/9XiUVMArZyk168="
},
"lodash.every": {
"version": "4.6.0",
"resolved": "https://registry.npmjs.org/lodash.every/-/lodash.every-4.6.0.tgz",
"integrity": "sha1-64mYS+vENkJ5uzrvu9HKGb+mxqc="
},
"lodash.flatmap": {
"version": "4.5.0",
"resolved": "https://registry.npmjs.org/lodash.flatmap/-/lodash.flatmap-4.5.0.tgz",
"integrity": "sha1-74y/QI9uSCaGYzRTBcaswLd4cC4="
},
"lodash.flatten": {
"version": "4.4.0",
"resolved": "https://registry.npmjs.org/lodash.flatten/-/lodash.flatten-4.4.0.tgz",
"integrity": "sha1-8xwiIlqWMtK7+OSt2+8kCqdlph8="
},
"lodash.frompairs": {
"version": "4.0.1",
"resolved": "https://registry.npmjs.org/lodash.frompairs/-/lodash.frompairs-4.0.1.tgz",
"integrity": "sha1-vE5SB/onV8E25XNhTpZkUGsrG9I="
},
"lodash.get": {
"version": "4.4.2",
"resolved": "https://registry.npmjs.org/lodash.get/-/lodash.get-4.4.2.tgz",
"integrity": "sha1-LRd/ZS+jHpObRDjVNBSZ36OCXpk=",
"dev": true
},
"lodash.has": {
"version": "4.5.2",
"resolved": "https://registry.npmjs.org/lodash.has/-/lodash.has-4.5.2.tgz",
"integrity": "sha1-0Z9NwQlQWMzL4rDN9O4P5Ko3yGI="
},
"lodash.includes": {
"version": "4.3.0",
"resolved": "https://registry.npmjs.org/lodash.includes/-/lodash.includes-4.3.0.tgz",
@ -36925,11 +37192,15 @@
"integrity": "sha1-YZwK89A/iwTDH1iChAt3sRzWg0M=",
"dev": true
},
"lodash.isnull": {
"version": "3.0.0",
"resolved": "https://registry.npmjs.org/lodash.isnull/-/lodash.isnull-3.0.0.tgz",
"integrity": "sha1-+vvlnqHcon7teGU0A53YTC4HxW4="
},
"lodash.isnumber": {
"version": "3.0.3",
"resolved": "https://registry.npmjs.org/lodash.isnumber/-/lodash.isnumber-3.0.3.tgz",
"integrity": "sha1-POdoEMWSjQM1IwGsKHMX8RwLH/w=",
"dev": true
"integrity": "sha1-POdoEMWSjQM1IwGsKHMX8RwLH/w="
},
"lodash.isplainobject": {
"version": "4.0.6",
@ -36940,20 +37211,44 @@
"lodash.isstring": {
"version": "4.0.1",
"resolved": "https://registry.npmjs.org/lodash.isstring/-/lodash.isstring-4.0.1.tgz",
"integrity": "sha1-1SfftUVuynzJu5XV2ur4i6VKVFE=",
"dev": true
"integrity": "sha1-1SfftUVuynzJu5XV2ur4i6VKVFE="
},
"lodash.isundefined": {
"version": "3.0.1",
"resolved": "https://registry.npmjs.org/lodash.isundefined/-/lodash.isundefined-3.0.1.tgz",
"integrity": "sha1-I+89lTVWUgOmbO/VuDD4SJEa+0g="
},
"lodash.mapvalues": {
"version": "4.6.0",
"resolved": "https://registry.npmjs.org/lodash.mapvalues/-/lodash.mapvalues-4.6.0.tgz",
"integrity": "sha1-G6+lAF3p3W9PJmaMMMo3IwzJaJw="
},
"lodash.memoize": {
"version": "4.1.2",
"resolved": "https://registry.npmjs.org/lodash.memoize/-/lodash.memoize-4.1.2.tgz",
"integrity": "sha1-vMbEmkKihA7Zl/Mj6tpezRguC/4="
},
"lodash.omit": {
"version": "4.5.0",
"resolved": "https://registry.npmjs.org/lodash.omit/-/lodash.omit-4.5.0.tgz",
"integrity": "sha1-brGa5aHuHdnfC5aeZs4Lf6MLXmA="
},
"lodash.once": {
"version": "4.1.1",
"resolved": "https://registry.npmjs.org/lodash.once/-/lodash.once-4.1.1.tgz",
"integrity": "sha1-DdOXEhPHxW34gJd9UEyI+0cal6w=",
"dev": true
},
"lodash.pickby": {
"version": "4.6.0",
"resolved": "https://registry.npmjs.org/lodash.pickby/-/lodash.pickby-4.6.0.tgz",
"integrity": "sha1-feoh2MGNdwOifHBMFdO4SmfjOv8="
},
"lodash.reduce": {
"version": "4.6.0",
"resolved": "https://registry.npmjs.org/lodash.reduce/-/lodash.reduce-4.6.0.tgz",
"integrity": "sha1-8atrg5KZrUj3hKu/R2WW8DuRTTs="
},
"lodash.template": {
"version": "4.5.0",
"resolved": "https://registry.npmjs.org/lodash.template/-/lodash.template-4.5.0.tgz",
@ -36981,6 +37276,11 @@
"resolved": "https://registry.npmjs.org/lodash.uniq/-/lodash.uniq-4.5.0.tgz",
"integrity": "sha1-0CJTc662Uq3BvILklFM5qEJ1R3M="
},
"lodash.uniqby": {
"version": "4.7.0",
"resolved": "https://registry.npmjs.org/lodash.uniqby/-/lodash.uniqby-4.7.0.tgz",
"integrity": "sha1-2ZwHpmnp5tJOE2Lf4mbGdhavEwI="
},
"log-symbols": {
"version": "4.1.0",
"resolved": "https://registry.npmjs.org/log-symbols/-/log-symbols-4.1.0.tgz",
@ -45156,6 +45456,15 @@
"version": "0.8.15",
"resolved": "https://registry.npmjs.org/zen-observable/-/zen-observable-0.8.15.tgz",
"integrity": "sha512-PQ2PC7R9rslx84ndNBZB/Dkv8V8fZEpk83RLgXtYd0fwUgEjseMn1Dgajh2x6S8QbZAFa9p2qVCEuYZNgve0dQ=="
},
"zen-observable-ts": {
"version": "1.0.0",
"resolved": "https://registry.npmjs.org/zen-observable-ts/-/zen-observable-ts-1.0.0.tgz",
"integrity": "sha512-KmWcbz+9kKUeAQ8btY8m1SsEFgBcp7h/Uf3V5quhan7ZWdjGsf0JcGLULQiwOZibbFWnHkYq8Nn2AZbJabovQg==",
"requires": {
"@types/zen-observable": "^0.8.2",
"zen-observable": "^0.8.15"
}
}
}
}

View File

@ -1,12 +1,15 @@
{
"name": "fennec-bs",
"version": "0.1.0",
"version": "0.1.1",
"private": true,
"dependencies": {
"@apollo/client": "^3.3.15",
"@curi/react-dom": "^2.0.4",
"@curi/router": "^2.1.2",
"@date-io/date-fns": "^1.3.13",
"@fortawesome/fontawesome-svg-core": "^1.2.35",
"@fortawesome/free-solid-svg-icons": "^5.15.3",
"@fortawesome/react-fontawesome": "^0.1.14",
"@hickory/browser": "^2.1.0",
"@material-ui/core": "^4.11.3",
"@material-ui/icons": "^4.11.2",
@ -19,12 +22,14 @@
"@types/node": "^12.20.10",
"@types/react": "^17.0.3",
"@types/react-dom": "^17.0.3",
"apollo-link-scalars": "^2.1.3",
"date-fns": "^2.21.1",
"fontsource-roboto": "^4.0.0",
"formik": "^2.2.6",
"formik-material-ui": "^3.0.1",
"formik-material-ui-pickers": "^0.0.12",
"graphql": "^15.5.0",
"graphql-scalars": "^1.9.3",
"material-ui-confirm": "^2.1.2",
"notistack": "^1.0.6",
"ramda": "^0.27.1",
@ -68,7 +73,8 @@
"@graphql-codegen/typescript": "1.21.1",
"@graphql-codegen/typescript-operations": "1.17.15",
"@graphql-codegen/typescript-react-apollo": "2.2.3",
"@types/ramda": "^0.27.40",
"@types/date-fns": "^2.6.0",
"@types/ramda": "^0.27.41",
"@types/yup": "^0.29.11",
"autoprefixer": "^9.8.6",
"postcss": "^7.0.35"

274
src/commits/commit-list.tsx Normal file
View File

@ -0,0 +1,274 @@
import { useMutation, useQuery, useSubscription } from "@apollo/client";
import { Link, useResponse, useRouter } from "@curi/react-dom";
import { faPlayCircle, faVial } from "@fortawesome/free-solid-svg-icons";
import { FontAwesomeIcon } from "@fortawesome/react-fontawesome";
import {
Backdrop,
CircularProgress,
Collapse,
IconButton,
LinearProgress,
List,
ListItem,
ListItemIcon,
ListItemSecondaryAction,
ListItemText,
makeStyles,
useTheme,
withStyles,
} from "@material-ui/core";
import {
Cancel,
CheckCircle,
CloudDownload,
ShoppingCart,
Stop,
Timer,
} from "@material-ui/icons";
import { format } from "date-fns";
import { useSnackbar } from "notistack";
import { complement, equals, find, propEq, takeWhile } from "ramda";
import {
FC,
Fragment,
MouseEventHandler,
ReactNode,
useCallback,
useMemo,
useState,
} from "react";
import {
Commit,
CreatePipelineTaskInput,
Pipeline,
PipelineTask,
TaskStatuses,
PipelineUnits,
} from "../generated/graphql";
import { CREATE_PIPELINE_TASK, STOP_PIPELINE_TASK } from "./mutations";
import { COMMITS } from "./queries";
import { SYNC_COMMITS } from "./subscriptions";
interface Props {
pipeline: Pipeline;
}
const useStyles = makeStyles((theme) => ({
root: {
flex: "1 1 100%",
},
nested: {
paddingLeft: theme.spacing(4),
},
}));
export const CommitList: FC<Props> = ({ pipeline }) => {
const { enqueueSnackbar } = useSnackbar();
const { data, loading, refetch } = useQuery<{ commits?: Commit[] }>(COMMITS, {
variables: {
pipelineId: pipeline.id,
},
});
const { loading: syncing } = useSubscription<{ syncCommits: boolean }>(
SYNC_COMMITS,
{
variables: {
pipelineId: pipeline.id,
},
onSubscriptionData({ subscriptionData: { data, error } }) {
if (error) {
enqueueSnackbar(error.message, {
variant: "warning",
});
}
if (data?.syncCommits) {
refetch({
appInstance: data.syncCommits,
});
}
},
}
);
const classes = useStyles();
return (
<section className={classes.root}>
{(() => {
if (loading) {
return <LinearProgress color="secondary" />;
}
return (
<section>
{syncing && <LinearProgress color="secondary" />}
<List>
{data?.commits?.map((commit) => (
<Item key={commit.hash} commit={commit} pipeline={pipeline} />
))}
</List>
</section>
);
})()}
</section>
);
};
const unitActionPairs: Array<[PipelineUnits, ReactNode, string]> = [
[PipelineUnits.Checkout, <ShoppingCart />, "checkout"],
[
PipelineUnits.InstallDependencies,
<CloudDownload />,
"install dependencies",
],
[PipelineUnits.Test, <FontAwesomeIcon icon={faVial} />, "test"],
[PipelineUnits.Deploy, <FontAwesomeIcon icon={faPlayCircle} />, "deploy"],
];
const Item: FC<{ commit: Commit; pipeline: Pipeline }> = ({
commit,
pipeline,
}) => {
const [isOpen, setOpen] = useState(() => false);
const [createTask, { loading }] =
useMutation<
{ createPipelineTask: PipelineTask },
{ task: CreatePipelineTaskInput }
>(CREATE_PIPELINE_TASK);
const units = useMemo(
() => pipeline.workUnitMetadata.units.map((unit) => unit.type),
[pipeline]
);
const { navigate, url } = useRouter();
const { response } = useResponse();
const handleCreateTask = useCallback(
(unit: PipelineUnits) => {
const _units = [...takeWhile(complement(equals(unit)), units), unit];
createTask({
variables: {
task: {
units: _units,
pipelineId: pipeline.id,
commit: commit.hash,
},
},
}).then(({ data }) => {
navigate({
url: url({
name: "pipeline-task-detail",
params: { ...response.params, taskId: data?.createPipelineTask.id },
}),
});
});
},
[commit, createTask, navigate, pipeline, response, units, url]
);
const actions = useMemo(
() =>
units.map((unit) => {
const pair = find(propEq(0, unit), unitActionPairs);
return (
pair && (
<IconButton
key={unit}
aria-label={pair[2]}
disabled={loading}
onClick={() => handleCreateTask(unit)}
>
{pair[1]}
</IconButton>
)
);
}),
[units, handleCreateTask, loading]
);
return (
<Fragment>
<ListItem button onClick={() => setOpen(!isOpen)}>
<ListItemText
primary={commit.message}
secondary={commit.date && format(commit.date, "yyyy-MM-dd HH:mm:ss")}
/>
<ListItemSecondaryAction>{actions}</ListItemSecondaryAction>
</ListItem>
{loading && <LinearProgress color="secondary" />}
<Collapse in={isOpen} timeout="auto" unmountOnExit>
<List component="div" disablePadding>
{commit.tasks.map((task) => (
<Link
key={task.id}
name="pipeline-task-detail"
params={{ ...response.params, taskId: task.id }}
>
<TaskItem task={task} />
</Link>
))}
</List>
</Collapse>
</Fragment>
);
};
const TaskItem: FC<{ task: PipelineTask }> = ({ task }) => {
const classes = useStyles();
const theme = useTheme();
const statusIcon: ReactNode = (() => {
switch (task.status) {
case TaskStatuses.Pending:
return <Timer style={{ color: theme.palette.info.main }} />;
case TaskStatuses.Success:
return <CheckCircle style={{ color: theme.palette.success.main }} />;
case TaskStatuses.Failed:
return <Cancel style={{ color: theme.palette.error.main }} />;
case TaskStatuses.Working:
return (
<CircularProgress style={{ color: theme.palette.secondary.main }} />
);
}
})();
const [stopTask, { loading: stopTaskWaiting }] = useMutation(
STOP_PIPELINE_TASK,
{
variables: { taskId: task.id },
}
);
const stop: MouseEventHandler = useCallback(
(event) => {
event.stopPropagation();
event.preventDefault();
stopTask();
},
[stopTask]
);
return (
<ListItem button className={classes.nested}>
<ListItemIcon>{statusIcon}</ListItemIcon>
<ListItemText
primary={
task.startedAt && format(task.startedAt, "yyyy-MM-dd HH:mm:ss")
}
/>
<ListItemSecondaryAction>
{task.status === TaskStatuses.Working && (
<IconButton edge="end" aria-label="stop" onClick={stop}>
<Stop />
</IconButton>
)}
</ListItemSecondaryAction>
<LimitedBackdrop open={stopTaskWaiting} />
</ListItem>
);
};
const LimitedBackdrop = withStyles({
root: {
position: "absolute",
zIndex: 1,
},
})(Backdrop);

17
src/commits/mutations.ts Normal file
View File

@ -0,0 +1,17 @@
import { gql } from '@apollo/client';
export const CREATE_PIPELINE_TASK = gql`
mutation CreatePipelineTask($task: CreatePipelineTaskInput!) {
createPipelineTask(task: $task) {
id
status
startedAt
endedAt
}
}
`;
export const STOP_PIPELINE_TASK = gql`
mutation StopPipelineTask($taskId: String!) {
stopPipelineTask(id: $taskId)
}
`;

20
src/commits/queries.ts Normal file
View File

@ -0,0 +1,20 @@
import { gql } from '@apollo/client';
export const COMMITS = gql`
query Commits($pipelineId: String!) {
commits(pipelineId: $pipelineId) {
message
hash
date
body
author_name
tasks {
id
units
status
startedAt
endedAt
}
}
}
`;

View File

@ -0,0 +1,6 @@
import { gql } from "@apollo/client";
export const SYNC_COMMITS = gql`
subscription SyncCommits($pipelineId: String!) {
syncCommits(pipelineId: $pipelineId)
}
`;

View File

@ -0,0 +1,11 @@
import { Typography } from '@material-ui/core';
import React, { FC } from 'react';
export const ErrorPage: FC = ({children}) => {
return (
<section>
<Typography component="h2">Something is wrong :(</Typography>
<Typography variant="body1" component="div">{children}</Typography>
</section>
);
}

View File

@ -1,6 +0,0 @@
import { ApolloClient, InMemoryCache } from "@apollo/client";
export const client = new ApolloClient({
uri: "/api/graphql",
cache: new InMemoryCache(),
});

View File

@ -0,0 +1,113 @@
import {
ApolloClient,
ApolloLink,
HttpLink,
InMemoryCache,
split,
ApolloProvider,
} from "@apollo/client";
import { withScalars } from "apollo-link-scalars";
import { buildClientSchema, IntrospectionQuery } from "graphql";
import { DateTimeResolver } from "graphql-scalars";
import { FC } from "react";
import introspectionResult from "../../generated/graphql.schema.json";
import { onError } from "@apollo/client/link/error";
import { WebSocketLink } from "@apollo/client/link/ws";
import { getMainDefinition } from "@apollo/client/utilities";
import { useSnackbar } from "notistack";
import { deepOmit } from "../../utils/deep-omit";
const schema = buildClientSchema(
introspectionResult as unknown as IntrospectionQuery
);
const typesMap = {
DateTime: DateTimeResolver,
};
const cleanTypeName = new ApolloLink((operation, forward) => {
if (operation.variables) {
operation.variables = deepOmit(["__typename"], operation.variables);
}
const rt = forward(operation);
return (
rt.map?.((data) => {
return data;
}) ?? rt
);
});
export const FennecApolloClientProvider: FC = ({ children }) => {
const { enqueueSnackbar } = useSnackbar();
const errorLink = onError(({ graphQLErrors, networkError }) => {
if (graphQLErrors) {
graphQLErrors.forEach((error) => {
enqueueSnackbar(error.message, {
variant: "error",
});
});
graphQLErrors.forEach(({ message, locations, path }) => {
console.error(
`[GraphQL error]: Message: ${message}, Location: ${locations}, Path: ${path}`
);
});
}
if (networkError) {
console.log(`[Network error]: ${networkError}`);
enqueueSnackbar(networkError.message, {
variant: "error",
});
}
});
const wsLink = new WebSocketLink({
uri: `${window.location.protocol.replace("http", "ws")}//${
window.location.hostname
}:${window.location.port}/api/graphql`,
options: {
reconnect: true,
},
});
const httpLink = new HttpLink({
uri: "/api/graphql",
});
const splitLink = split(
({ query }) => {
const definition = getMainDefinition(query);
return (
definition.kind === "OperationDefinition" &&
definition.operation === "subscription"
);
},
wsLink,
httpLink
);
const link = ApolloLink.from([
errorLink,
withScalars({ schema, typesMap }) as unknown as ApolloLink,
cleanTypeName,
splitLink,
]);
const client = new ApolloClient({
connectToDevTools: true,
ssrMode: typeof window === "undefined",
link,
cache: new InMemoryCache({
typePolicies: {
// PipelineTaskLogs: {
// keyFields: ["unit"],
// },
// PipelineTask: {
// fields: {
// logs: {
// merge(existing = [], incoming: any[]) {
// return [...existing, ...incoming];
// },
// },
// },
// },
},
}),
});
return <ApolloProvider client={client}>{children}</ApolloProvider>;
};

View File

@ -0,0 +1,26 @@
import { gql } from '@apollo/client';
export const COMMIT_LIST_QUERY = gql`
query CommitListQuery($projectId: String!, $pipelineId: String!) {
project(id: $projectId) {
id
name
comment
webUrl
sshUrl
webHookSecret
}
pipeline(id: $pipelineId) {
id
name
branch
workUnitMetadata {
version
units {
type
scripts
}
}
}
}
`;

View File

@ -0,0 +1,20 @@
import { ActiveHookProps, Link, LinkProps, useActive } from '@curi/react-dom';
import React, { FC, ReactNode } from 'react';
export type ActiveLinkProps = ActiveHookProps &
LinkProps & {
className?: string;
children: ReactNode;
};
export const ActiveLink:FC<ActiveLinkProps> = ({ name, params, partial, className = "", ...rest }) => {
const active = useActive({ name, params, partial });
return (
<Link
name={name}
params={params}
{...rest}
className={active ? `${className} active` : className}
/>
);
};

View File

@ -0,0 +1,31 @@
import { useApolloClient } from "@apollo/client";
import { createRouterComponent } from "@curi/react-dom";
import { createRouter, announce } from "@curi/router";
import { browser } from "@hickory/browser";
import { FC, ReactNode, useEffect, useMemo, useState } from "react";
import routes from "../../routes";
import { LinearProgress } from "@material-ui/core";
const Component: FC = ({ children }) => {
const client = useApolloClient();
const [body, setBody] = useState<any>(null);
useEffect(() => {
const router = createRouter(browser, routes, {
sideEffects: [
announce(({ response }) => {
return `Navigated to ${response.location.pathname}`;
}),
],
external: { client },
});
const Router = createRouterComponent(router);
router.once(() => {
setBody(<Router>{children}</Router>);
});
}, [setBody, client, children]);
return body ?? <LinearProgress />;
};
export default Component;

View File

@ -10,6 +10,163 @@
"name": "Subscription"
},
"types": [
{
"kind": "OBJECT",
"name": "Commit",
"description": null,
"fields": [
{
"name": "hash",
"description": null,
"args": [],
"type": {
"kind": "NON_NULL",
"name": null,
"ofType": {
"kind": "SCALAR",
"name": "String",
"ofType": null
}
},
"isDeprecated": false,
"deprecationReason": null
},
{
"name": "date",
"description": null,
"args": [],
"type": {
"kind": "NON_NULL",
"name": null,
"ofType": {
"kind": "SCALAR",
"name": "DateTime",
"ofType": null
}
},
"isDeprecated": false,
"deprecationReason": null
},
{
"name": "message",
"description": null,
"args": [],
"type": {
"kind": "NON_NULL",
"name": null,
"ofType": {
"kind": "SCALAR",
"name": "String",
"ofType": null
}
},
"isDeprecated": false,
"deprecationReason": null
},
{
"name": "refs",
"description": null,
"args": [],
"type": {
"kind": "NON_NULL",
"name": null,
"ofType": {
"kind": "SCALAR",
"name": "String",
"ofType": null
}
},
"isDeprecated": false,
"deprecationReason": null
},
{
"name": "body",
"description": null,
"args": [],
"type": {
"kind": "NON_NULL",
"name": null,
"ofType": {
"kind": "SCALAR",
"name": "String",
"ofType": null
}
},
"isDeprecated": false,
"deprecationReason": null
},
{
"name": "author_name",
"description": null,
"args": [],
"type": {
"kind": "NON_NULL",
"name": null,
"ofType": {
"kind": "SCALAR",
"name": "String",
"ofType": null
}
},
"isDeprecated": false,
"deprecationReason": null
},
{
"name": "author_email",
"description": null,
"args": [],
"type": {
"kind": "NON_NULL",
"name": null,
"ofType": {
"kind": "SCALAR",
"name": "String",
"ofType": null
}
},
"isDeprecated": false,
"deprecationReason": null
},
{
"name": "tasks",
"description": null,
"args": [],
"type": {
"kind": "NON_NULL",
"name": null,
"ofType": {
"kind": "LIST",
"name": null,
"ofType": {
"kind": "NON_NULL",
"name": null,
"ofType": {
"kind": "OBJECT",
"name": "PipelineTask",
"ofType": null
}
}
}
},
"isDeprecated": false,
"deprecationReason": null
}
],
"inputFields": null,
"interfaces": [],
"enumValues": null,
"possibleTypes": null
},
{
"kind": "SCALAR",
"name": "String",
"description": "The `String` scalar type represents textual data, represented as UTF-8 character sequences. The String type is most often used by GraphQL to represent free-form human-readable text.",
"fields": null,
"inputFields": null,
"interfaces": null,
"enumValues": null,
"possibleTypes": null
},
{
"kind": "INPUT_OBJECT",
"name": "CreatePipelineInput",
@ -85,16 +242,6 @@
"enumValues": null,
"possibleTypes": null
},
{
"kind": "SCALAR",
"name": "String",
"description": "The `String` scalar type represents textual data, represented as UTF-8 character sequences. The String type is most often used by GraphQL to represent free-form human-readable text.",
"fields": null,
"inputFields": null,
"interfaces": null,
"enumValues": null,
"possibleTypes": null
},
{
"kind": "INPUT_OBJECT",
"name": "CreatePipelineTaskInput",
@ -429,83 +576,6 @@
"enumValues": null,
"possibleTypes": null
},
{
"kind": "OBJECT",
"name": "LogList",
"description": null,
"fields": [
{
"name": "all",
"description": null,
"args": [],
"type": {
"kind": "NON_NULL",
"name": null,
"ofType": {
"kind": "LIST",
"name": null,
"ofType": {
"kind": "NON_NULL",
"name": null,
"ofType": {
"kind": "OBJECT",
"name": "LogFields",
"ofType": null
}
}
}
},
"isDeprecated": false,
"deprecationReason": null
},
{
"name": "total",
"description": null,
"args": [],
"type": {
"kind": "NON_NULL",
"name": null,
"ofType": {
"kind": "SCALAR",
"name": "Float",
"ofType": null
}
},
"isDeprecated": false,
"deprecationReason": null
},
{
"name": "latest",
"description": null,
"args": [],
"type": {
"kind": "NON_NULL",
"name": null,
"ofType": {
"kind": "OBJECT",
"name": "LogFields",
"ofType": null
}
},
"isDeprecated": false,
"deprecationReason": null
}
],
"inputFields": null,
"interfaces": [],
"enumValues": null,
"possibleTypes": null
},
{
"kind": "SCALAR",
"name": "Float",
"description": "The `Float` scalar type represents signed double-precision fractional values as specified by [IEEE 754](https://en.wikipedia.org/wiki/IEEE_floating_point).",
"fields": null,
"inputFields": null,
"interfaces": null,
"enumValues": null,
"possibleTypes": null
},
{
"kind": "OBJECT",
"name": "Mutation",
@ -648,7 +718,7 @@
"description": null,
"args": [
{
"name": "Pipeline",
"name": "pipeline",
"description": null,
"type": {
"kind": "NON_NULL",
@ -741,6 +811,39 @@
},
"isDeprecated": false,
"deprecationReason": null
},
{
"name": "stopPipelineTask",
"description": null,
"args": [
{
"name": "id",
"description": null,
"type": {
"kind": "NON_NULL",
"name": null,
"ofType": {
"kind": "SCALAR",
"name": "String",
"ofType": null
}
},
"defaultValue": null,
"isDeprecated": false,
"deprecationReason": null
}
],
"type": {
"kind": "NON_NULL",
"name": null,
"ofType": {
"kind": "SCALAR",
"name": "Boolean",
"ofType": null
}
},
"isDeprecated": false,
"deprecationReason": null
}
],
"inputFields": null,
@ -748,6 +851,26 @@
"enumValues": null,
"possibleTypes": null
},
{
"kind": "SCALAR",
"name": "Float",
"description": "The `Float` scalar type represents signed double-precision fractional values as specified by [IEEE 754](https://en.wikipedia.org/wiki/IEEE_floating_point).",
"fields": null,
"inputFields": null,
"interfaces": null,
"enumValues": null,
"possibleTypes": null
},
{
"kind": "SCALAR",
"name": "Boolean",
"description": "The `Boolean` scalar type represents `true` or `false`.",
"fields": null,
"inputFields": null,
"interfaces": null,
"enumValues": null,
"possibleTypes": null
},
{
"kind": "OBJECT",
"name": "Pipeline",
@ -1021,6 +1144,22 @@
},
"isDeprecated": false,
"deprecationReason": null
},
{
"name": "runOn",
"description": null,
"args": [],
"type": {
"kind": "NON_NULL",
"name": null,
"ofType": {
"kind": "SCALAR",
"name": "String",
"ofType": null
}
},
"isDeprecated": false,
"deprecationReason": null
}
],
"inputFields": null,
@ -1030,9 +1169,57 @@
},
{
"kind": "OBJECT",
"name": "PipelineTaskLogMessage",
"name": "PipelineTaskEvent",
"description": null,
"fields": [
{
"name": "taskId",
"description": null,
"args": [],
"type": {
"kind": "NON_NULL",
"name": null,
"ofType": {
"kind": "SCALAR",
"name": "String",
"ofType": null
}
},
"isDeprecated": false,
"deprecationReason": null
},
{
"name": "pipelineId",
"description": null,
"args": [],
"type": {
"kind": "NON_NULL",
"name": null,
"ofType": {
"kind": "SCALAR",
"name": "String",
"ofType": null
}
},
"isDeprecated": false,
"deprecationReason": null
},
{
"name": "projectId",
"description": null,
"args": [],
"type": {
"kind": "NON_NULL",
"name": null,
"ofType": {
"kind": "SCALAR",
"name": "String",
"ofType": null
}
},
"isDeprecated": false,
"deprecationReason": null
},
{
"name": "unit",
"description": null,
@ -1046,7 +1233,7 @@
"deprecationReason": null
},
{
"name": "time",
"name": "emittedAt",
"description": null,
"args": [],
"type": {
@ -1078,7 +1265,7 @@
"deprecationReason": null
},
{
"name": "isError",
"name": "messageType",
"description": null,
"args": [],
"type": {
@ -1086,7 +1273,23 @@
"name": null,
"ofType": {
"kind": "SCALAR",
"name": "Boolean",
"name": "String",
"ofType": null
}
},
"isDeprecated": false,
"deprecationReason": null
},
{
"name": "status",
"description": null,
"args": [],
"type": {
"kind": "NON_NULL",
"name": null,
"ofType": {
"kind": "ENUM",
"name": "TaskStatuses",
"ofType": null
}
},
@ -1099,16 +1302,6 @@
"enumValues": null,
"possibleTypes": null
},
{
"kind": "SCALAR",
"name": "Boolean",
"description": "The `Boolean` scalar type represents `true` or `false`.",
"fields": null,
"inputFields": null,
"interfaces": null,
"enumValues": null,
"possibleTypes": null
},
{
"kind": "OBJECT",
"name": "PipelineTaskLogs",
@ -1480,6 +1673,43 @@
"isDeprecated": false,
"deprecationReason": null
},
{
"name": "commits",
"description": null,
"args": [
{
"name": "pipelineId",
"description": null,
"type": {
"kind": "NON_NULL",
"name": null,
"ofType": {
"kind": "SCALAR",
"name": "String",
"ofType": null
}
},
"defaultValue": null,
"isDeprecated": false,
"deprecationReason": null
}
],
"type": {
"kind": "LIST",
"name": null,
"ofType": {
"kind": "NON_NULL",
"name": null,
"ofType": {
"kind": "OBJECT",
"name": "Commit",
"ofType": null
}
}
},
"isDeprecated": false,
"deprecationReason": null
},
{
"name": "listPipelineTaskByPipelineId",
"description": null,
@ -1522,7 +1752,7 @@
"deprecationReason": null
},
{
"name": "findPipelineTask",
"name": "pipelineTask",
"description": null,
"args": [
{
@ -1566,11 +1796,23 @@
"description": null,
"fields": [
{
"name": "listLogsForPipeline",
"name": "syncCommits",
"description": null,
"args": [
{
"name": "id",
"name": "appInstance",
"description": null,
"type": {
"kind": "SCALAR",
"name": "String",
"ofType": null
},
"defaultValue": null,
"isDeprecated": false,
"deprecationReason": null
},
{
"name": "pipelineId",
"description": null,
"type": {
"kind": "NON_NULL",
@ -1587,19 +1829,15 @@
}
],
"type": {
"kind": "NON_NULL",
"name": null,
"ofType": {
"kind": "OBJECT",
"name": "LogList",
"kind": "SCALAR",
"name": "String",
"ofType": null
}
},
"isDeprecated": false,
"deprecationReason": null
},
{
"name": "pipelineTaskLog",
"name": "pipelineTaskEvent",
"description": null,
"args": [
{
@ -1624,7 +1862,7 @@
"name": null,
"ofType": {
"kind": "OBJECT",
"name": "PipelineTaskLogMessage",
"name": "PipelineTaskEvent",
"ofType": null
}
},
@ -2011,7 +2249,7 @@
"name": null,
"ofType": {
"kind": "SCALAR",
"name": "Float",
"name": "Int",
"ofType": null
}
},
@ -2048,6 +2286,16 @@
"enumValues": null,
"possibleTypes": null
},
{
"kind": "SCALAR",
"name": "Int",
"description": "The `Int` scalar type represents non-fractional signed whole numeric values. Int can represent values between -(2^31) and 2^31 - 1.",
"fields": null,
"inputFields": null,
"interfaces": null,
"enumValues": null,
"possibleTypes": null
},
{
"kind": "INPUT_OBJECT",
"name": "WorkUnitMetadataInput",
@ -2059,7 +2307,7 @@
"description": null,
"type": {
"kind": "SCALAR",
"name": "Float",
"name": "Int",
"ofType": null
},
"defaultValue": "1",

View File

@ -14,6 +14,18 @@ export type Scalars = {
DateTime: any;
};
export type Commit = {
__typename?: 'Commit';
hash: Scalars['String'];
date: Scalars['DateTime'];
message: Scalars['String'];
refs: Scalars['String'];
body: Scalars['String'];
author_name: Scalars['String'];
author_email: Scalars['String'];
tasks: Array<PipelineTask>;
};
export type CreatePipelineInput = {
projectId: Scalars['String'];
branch: Scalars['String'];
@ -53,13 +65,6 @@ export type LogFields = {
tasks: Array<PipelineTask>;
};
export type LogList = {
__typename?: 'LogList';
all: Array<LogFields>;
total: Scalars['Float'];
latest: LogFields;
};
export type Mutation = {
__typename?: 'Mutation';
createProject: Project;
@ -69,6 +74,7 @@ export type Mutation = {
updatePipeline: Pipeline;
deletePipeline: Scalars['Float'];
createPipelineTask: PipelineTask;
stopPipelineTask: Scalars['Boolean'];
};
@ -93,7 +99,7 @@ export type MutationCreatePipelineArgs = {
export type MutationUpdatePipelineArgs = {
Pipeline: UpdatePipelineInput;
pipeline: UpdatePipelineInput;
};
@ -106,6 +112,11 @@ export type MutationCreatePipelineTaskArgs = {
task: CreatePipelineTaskInput;
};
export type MutationStopPipelineTaskArgs = {
id: Scalars['String'];
};
export type Pipeline = {
__typename?: 'Pipeline';
id: Scalars['ID'];
@ -127,14 +138,19 @@ export type PipelineTask = {
status: TaskStatuses;
startedAt?: Maybe<Scalars['DateTime']>;
endedAt?: Maybe<Scalars['DateTime']>;
runOn: Scalars['String'];
};
export type PipelineTaskLogMessage = {
__typename?: 'PipelineTaskLogMessage';
export type PipelineTaskEvent = {
__typename?: 'PipelineTaskEvent';
taskId: Scalars['String'];
pipelineId: Scalars['String'];
projectId: Scalars['String'];
unit?: Maybe<PipelineUnits>;
time: Scalars['DateTime'];
emittedAt: Scalars['DateTime'];
message: Scalars['String'];
isError: Scalars['Boolean'];
messageType: Scalars['String'];
status: TaskStatuses;
};
export type PipelineTaskLogs = {
@ -172,8 +188,9 @@ export type Query = {
project: Project;
pipelines: Array<Pipeline>;
pipeline: Pipeline;
commits?: Maybe<Array<Commit>>;
listPipelineTaskByPipelineId: Array<PipelineTask>;
findPipelineTask: PipelineTask;
pipelineTask: PipelineTask;
};
@ -192,29 +209,35 @@ export type QueryPipelineArgs = {
};
export type QueryCommitsArgs = {
pipelineId: Scalars['String'];
};
export type QueryListPipelineTaskByPipelineIdArgs = {
pipelineId: Scalars['String'];
};
export type QueryFindPipelineTaskArgs = {
export type QueryPipelineTaskArgs = {
id: Scalars['String'];
};
export type Subscription = {
__typename?: 'Subscription';
listLogsForPipeline: LogList;
pipelineTaskLog: PipelineTaskLogMessage;
syncCommits?: Maybe<Scalars['String']>;
pipelineTaskEvent: PipelineTaskEvent;
pipelineTaskChanged: PipelineTask;
};
export type SubscriptionListLogsForPipelineArgs = {
id: Scalars['String'];
export type SubscriptionSyncCommitsArgs = {
appInstance?: Maybe<Scalars['String']>;
pipelineId: Scalars['String'];
};
export type SubscriptionPipelineTaskLogArgs = {
export type SubscriptionPipelineTaskEventArgs = {
taskId: Scalars['String'];
};
@ -261,11 +284,11 @@ export type WorkUnitInput = {
export type WorkUnitMetadata = {
__typename?: 'WorkUnitMetadata';
version: Scalars['Float'];
version: Scalars['Int'];
units: Array<WorkUnit>;
};
export type WorkUnitMetadataInput = {
version?: Maybe<Scalars['Float']>;
version?: Maybe<Scalars['Int']>;
units: Array<WorkUnitInput>;
};

View File

@ -4,46 +4,30 @@ import "./index.css";
import "fontsource-roboto";
import App from "./App";
import reportWebVitals from "./reportWebVitals";
import { client } from "./commons/graphql/client";
import { ApolloProvider } from "@apollo/client";
import { FennecApolloClientProvider } from "./commons/graphql/client";
import { MuiPickersUtilsProvider } from "@material-ui/pickers";
import DateFnsUtils from "@date-io/date-fns";
import zhLocale from "date-fns/locale/zh-CN";
import { createRouterComponent } from "@curi/react-dom";
import { createRouter, announce } from "@curi/router";
import { browser } from "@hickory/browser";
import routes from "./routes";
import { ConfirmProvider } from 'material-ui-confirm';
import { SnackbarProvider } from 'notistack';
import { ConfirmProvider } from "material-ui-confirm";
import { SnackbarProvider } from "notistack";
import Router from './commons/route/router';
const router = createRouter(browser, routes, {
sideEffects: [
announce(({ response }) => {
return `Navigated to ${response.location.pathname}`;
}),
],
external: { client }
});
const Router = createRouterComponent(router);
router.once(() => {
ReactDOM.render(
<React.StrictMode>
<ConfirmProvider>
<SnackbarProvider maxSnack={5}>
<ApolloProvider client={client}>
<FennecApolloClientProvider>
<MuiPickersUtilsProvider utils={DateFnsUtils} locale={zhLocale}>
<Router>
<App />
</Router>
</MuiPickersUtilsProvider>
</ApolloProvider>
</FennecApolloClientProvider>
</SnackbarProvider>
</ConfirmProvider>
</React.StrictMode>,
document.getElementById("root")
);
});
// If you want to start measuring performance in your app, pass a function
// to log results (for example: reportWebVitals(console.log))

View File

@ -0,0 +1,189 @@
import { gql, useQuery, useSubscription } from "@apollo/client";
import { LinearProgress, makeStyles, Typography } from "@material-ui/core";
import { format } from "date-fns";
import { FC, useState } from "react";
import { ErrorPage } from "../commons/fallbacks/error-page";
import {
PipelineTask,
PipelineTaskEvent,
PipelineTaskLogs,
TaskStatuses,
} from "../generated/graphql";
import { PIPELINE_TASK_EVENT } from "./subscriptions";
import { clone, find, propEq } from "ramda";
interface Props {
taskId: string;
}
const PIPELINE_TASK = gql`
query FindPipelineTask($taskId: String!) {
pipelineTask(id: $taskId) {
id
units
commit
status
startedAt
endedAt
logs {
unit
logs
status
startedAt
endedAt
}
}
}
`;
const useStyles = makeStyles((theme) => ({
root: {},
groupTitle: {
backgroundColor: "white",
fontWeight: 500,
borderTop: "1px solid #eee",
fontSize: "16px",
padding: "12px",
marginLeft: "1px",
},
logText: {
fontFamily: 'Menlo, Monaco, "Courier New", monospace',
whiteSpace: "pre-wrap",
border: "none",
margin: "6px 12px",
display: "block",
},
}));
export const PipelineTaskDetail: FC<Props> = ({ taskId }) => {
const [taskEvents, setTaskEvents] = useState(
() => new Array<PipelineTaskEvent>()
);
const { data, loading, error, client } = useQuery<{
pipelineTask: PipelineTask;
}>(PIPELINE_TASK, {
variables: { taskId },
});
const task = data?.pipelineTask;
useSubscription<{ pipelineTaskEvent: PipelineTaskEvent }>(
PIPELINE_TASK_EVENT,
{
variables: { taskId },
onSubscriptionData({ subscriptionData: { data } }) {
const event = data?.pipelineTaskEvent;
console.log(event);
if (event && task) {
setTaskEvents((prev) => [...prev, event]);
if (event.unit) {
// event of running scripts
client.cache.modify({
id: client.cache.identify(task!),
fields: {
logs(before: PipelineTaskLogs[]) {
before = clone(before);
let l = find(propEq("unit", event.unit), before);
if (l) {
l.logs += event.message;
} else {
l = {
unit: event.unit!,
logs: event.message,
status: event.status,
startedAt: event.emittedAt,
endedAt: null,
__typename: "PipelineTaskLogs",
};
before.push(l);
}
if (event.status === TaskStatuses.Working) {
l.startedAt || (l.startedAt = event.emittedAt);
}
if (
[TaskStatuses.Failed, TaskStatuses.Success].includes(
event.status
)
) {
l.startedAt && (l.startedAt = event.emittedAt);
l.endedAt = event.emittedAt;
}
l.status = event.status;
return before;
},
},
});
} else {
// event of task status change
client.cache.modify({
id: client.cache.identify(task!),
fields: {
status() {
return event.status;
},
startedAt(before) {
if (event.status === TaskStatuses.Working) {
return event.emittedAt;
} else {
return before;
}
},
endedAt(before) {
if (
[TaskStatuses.Success, TaskStatuses.Failed].includes(
event.status
)
) {
return event.emittedAt;
} else {
return before;
}
},
},
});
}
}
},
}
);
const classes = useStyles();
if (error) {
return <ErrorPage>{error.message}</ErrorPage>;
}
if (loading) {
return <LinearProgress color="secondary" />;
}
return (
<div className={classes.root}>
<Typography variant="h4" component="h2">
{taskId} detail
</Typography>
<Typography variant="h5" component="h3">
{task?.status}
</Typography>
<Typography variant="h5" component="h3">
{task?.startedAt && format(task?.startedAt, "yyyy-MM-dd HH:mm:ss.SSS")}-
{task?.endedAt && format(task?.endedAt, "yyyy-MM-dd HH:mm:ss.SSS")}
</Typography>
{task?.logs.map((logs) => (
<LogGroup key={logs.unit} logs={logs} />
))}
</div>
);
};
const LogGroup: FC<{ logs: PipelineTaskLogs }> = ({ logs }) => {
const classes = useStyles();
return (
<div>
<div className={classes.groupTitle}>
{logs.unit}{" "}
{logs.startedAt && format(logs.startedAt, "yyyy-MM-dd HH:mm:ss")}{" "}
{logs.endedAt && format(logs.endedAt, "yyyy-MM-dd HH:mm:ss")} {logs.status}
</div>
<code className={classes.logText}>{logs.logs}</code>
</div>
);
};

View File

@ -0,0 +1,16 @@
import { gql } from "@apollo/client";
export const PIPELINE_TASK_EVENT = gql`
subscription PipelineTaskEvent($taskId: String!) {
pipelineTaskEvent(taskId: $taskId) {
taskId
pipelineId
projectId
unit
emittedAt
message
messageType
status
}
}
`;

3
src/pipelines/index.ts Normal file
View File

@ -0,0 +1,3 @@
export * from './pipeline-detail';
export * from './pipeline-list';
export * from './queries';

View File

@ -0,0 +1,43 @@
import { gql } from "@apollo/client";
export const CREATE_PIPELINE = gql`
mutation CreatePipeline($pipeline: CreatePipelineInput!) {
createPipeline(pipeline: $pipeline) {
id
projectId
branch
name
workUnitMetadata {
version
units {
type
scripts
}
}
}
}
`;
export const UPDATE_PIPELINE = gql`
mutation UpdatePipeline($pipeline: UpdatePipelineInput!) {
updatePipeline(pipeline: $pipeline) {
id
projectId
branch
name
workUnitMetadata {
version
units {
type
scripts
}
}
}
}
`;
export const DELETE_PIPELINE = gql`
mutation DeletePipeline($id: String!) {
deletePipeline(id: $id)
}
`;

View File

@ -0,0 +1,11 @@
import { FC } from 'react';
import { Pipeline } from '../generated/graphql';
interface Props {
pipeline: Pipeline;
}
export const PipelineDetail: FC<Props> = ({pipeline}) => {
return <div>PipelineDetail</div>
}

View File

@ -0,0 +1,285 @@
import { gql, Reference, useMutation, useQuery } from "@apollo/client";
import { useRouter } from "@curi/react-dom";
import {
Button,
Grid,
IconButton,
LinearProgress,
makeStyles,
Paper,
Portal,
Typography,
} from "@material-ui/core";
import { Delete } from "@material-ui/icons";
import { FormikHelpers, Formik, Form, Field } from "formik";
import { TextField, TextFieldProps } from "formik-material-ui";
import { TextField as MuiTextField } from "@material-ui/core";
import { useConfirm } from "material-ui-confirm";
import { useSnackbar } from "notistack";
import { not, omit } from "ramda";
import { ChangeEvent, FC } from "react";
import {
Pipeline,
WorkUnitMetadata,
PipelineUnits,
} from "../generated/graphql";
import { useHeaderContainer } from "../layouts";
import { CREATE_PIPELINE, DELETE_PIPELINE, UPDATE_PIPELINE } from "./mutations";
import { PIPELINE } from "./queries";
import * as Yup from "yup";
import { useField } from "formik";
type Values = Partial<Pipeline>;
interface Props {
pipeline: Values;
}
const useStyles = makeStyles((theme) => ({
root: {
flex: "1 1 100%",
},
nested: {
paddingLeft: theme.spacing(4),
},
form: {
margin: 16,
},
metadataList: {
padding: 0,
},
metadataItem: {
listStyle: "none",
},
metadataContainer: {
padding: "10px 30px",
margin: "10px 0",
},
}));
export const PipelineEditor: FC<Props> = ({ pipeline }) => {
const { enqueueSnackbar } = useSnackbar();
const isCreate = not("id" in pipeline);
const [createPipeline] = useMutation<{ createPipeline: Pipeline }>(
CREATE_PIPELINE,
{
update(cache, { data }) {
cache.modify({
fields: {
pipelines(exiting = []) {
const pipelineRef = cache.writeFragment({
data: data!.createPipeline,
fragment: gql`
fragment newPipeline on Pipeline {
id
projectId
branch
name
workUnitMetadata {
version
units {
type
scripts
}
}
}
`,
});
return [pipelineRef, ...exiting];
},
},
});
},
}
);
const [updatePipeline] = useMutation(UPDATE_PIPELINE);
const router = useRouter();
const submitForm = async (
values: Values,
formikHelpers: FormikHelpers<Values>
) => {
try {
let pipelineId = pipeline.id;
let projectId = pipeline.projectId;
if (isCreate) {
await createPipeline({
variables: {
input: values,
},
}).then(({ data }) => {
pipelineId = data!.createPipeline.id;
projectId = data!.createPipeline.projectId;
});
} else {
await updatePipeline({
variables: {
pipeline: omit(["projectId"], values),
},
});
}
enqueueSnackbar("Saved successfully", {
variant: "success",
});
router.navigate({
url: router.url({
name: "pipeline-commits",
params: {
pipelineId,
projectId,
},
}),
method: "replace",
});
} finally {
formikHelpers.setSubmitting(false);
}
};
const [deletePipeline, { loading: deleting }] = useMutation(DELETE_PIPELINE, {
variables: { id: pipeline.id },
update(cache) {
cache.modify({
fields: {
projects(exiting: Reference[] = [], { readField }) {
return exiting.filter(
(ref) => pipeline.id !== readField("id", ref)
);
},
},
});
},
});
const confirm = useConfirm();
const handleDelete = async () => {
try {
await confirm({ description: `This will delete ${pipeline.name}.` });
await deletePipeline();
enqueueSnackbar("Deleted successfully", {
variant: "success",
});
router.navigate({
url: router.url({
name: "dashboard",
}),
});
} catch {}
};
const headerContainer = useHeaderContainer();
const units = [
PipelineUnits.Checkout,
PipelineUnits.InstallDependencies,
PipelineUnits.Test,
PipelineUnits.Deploy,
PipelineUnits.CleanUp,
];
const classes = useStyles();
return (
<Paper className={classes.root}>
<Portal container={headerContainer}>
<Grid container justify="space-between" alignItems="center">
<Typography variant="h6" component="h1">
{isCreate ? "Create" : "Edit"} Pipeline
</Typography>
{isCreate ? null : (
<IconButton
color="inherit"
onClick={handleDelete}
disabled={deleting}
>
<Delete />
</IconButton>
)}
</Grid>
</Portal>
<Formik
initialValues={pipeline}
validationSchema={Yup.object({
name: Yup.string()
.max(32, "Must be 32 characters or less")
.required("Required"),
branch: Yup.string()
.max(32, "Must be 32 characters or less")
.required("Required"),
})}
onSubmit={submitForm}
>
{({ submitForm, isSubmitting, values }) => {
return (
<Form className={classes.form}>
<Field component={TextField} name="name" label="Name" fullWidth />
<Field
component={TextField}
name="branch"
label="Branch"
fullWidth
margin="normal"
/>
<Paper className={classes.metadataContainer}>
<Field
component={TextField}
name="workUnitMetadata.version"
label="Version"
fullWidth
readonly
margin="normal"
/>
<ol className={classes.metadataList}>
{units.map((unit, index) => {
return (
<li key={unit} className={classes.metadataItem}>
<Field
name={`workUnitMetadata.units[${index}].scripts]`}
component={ScriptsField}
label={`${unit} Scripts`}
fullWidth
multiline
margin="normal"
/>
</li>
);
})}
</ol>
</Paper>
{isSubmitting && <LinearProgress />}
<Button
variant="contained"
color="primary"
disabled={isSubmitting}
onClick={submitForm}
fullWidth
>
Submit
</Button>
</Form>
);
}}
</Formik>
</Paper>
);
};
const ScriptsField: FC<TextFieldProps> = ({ field, form, meta, ...props }) => {
return (
<TextField
{...props}
form={form}
meta={meta}
field={{
...field,
value: field.value?.join("\n") ?? "",
onChange: (ev: ChangeEvent<HTMLInputElement>) =>
form.setFieldValue(
field.name,
ev.target.value?.split("\n").map((it) => it.trim()) ?? []
),
}}
/>
);
};

View File

@ -1,10 +1,18 @@
import { gql, useQuery } from '@apollo/client';
import { Link } from '@curi/react-dom';
import { List, ListItem, Typography, ListItemText } from '@material-ui/core';
import { FC } from 'react';
import { Pipeline } from '../generated/graphql';
import { Fragment } from 'react';
import { CallMerge } from '@material-ui/icons';
import { gql, useQuery } from "@apollo/client";
import { Link, useRouter } from "@curi/react-dom";
import {
List,
ListItem,
Typography,
ListItemText,
ListItemSecondaryAction,
IconButton,
} from "@material-ui/core";
import { FC, MouseEventHandler, useMemo } from "react";
import { Pipeline, Project } from "../generated/graphql";
import { CallMerge, Edit } from "@material-ui/icons";
import { clone } from "ramda";
import { useEffect } from "react";
interface Props {
projectId: string;
@ -17,19 +25,31 @@ const PIPELINES = gql`
name
branch
}
project(id: $projectId) {
id
}
`
}
`;
export const PipelineList: FC<Props> = ({ projectId }) => {
const {data, loading} = useQuery<{pipelines: Pipeline[]}, {projectId: string}>(PIPELINES, {
variables: {projectId}
})
const { data, loading } = useQuery<
{ pipelines: Pipeline[]; project: Project },
{ projectId: string }
>(PIPELINES, {
variables: { projectId },
});
const pipelines = useMemo(() => {
return data?.pipelines?.map((pipeline) => ({
...pipeline,
project: data?.project,
}));
}, [data]);
return (
<List>
{data?.pipelines.map((pipeline) => (
{pipelines?.map((pipeline) => (
<Link
name="pipeline-details"
params={{ pipelineId: pipeline.id }}
name="pipeline-commits"
params={{ pipelineId: pipeline.id, projectId: projectId }}
key={pipeline.id}
>
<Item pipeline={pipeline} />
@ -37,10 +57,19 @@ export const PipelineList: FC<Props> = ({ projectId }) => {
))}
</List>
);
}
const Item = ({pipeline}: {pipeline: Pipeline}) => {
};
const Item = ({ pipeline }: { pipeline: Pipeline }) => {
const { navigate, url } = useRouter();
const modify: MouseEventHandler = (ev) => {
ev.preventDefault();
navigate({
url: url({
name: "edit-pipeline",
params: { pipelineId: pipeline.id, projectId: pipeline.project.id },
}),
});
};
return (
<ListItem button>
<ListItemText
@ -52,6 +81,11 @@ const Item = ({pipeline}: {pipeline: Pipeline}) => {
</Typography>
}
/>
<ListItemSecondaryAction>
<IconButton edge="end" aria-label="edit" onClick={modify}>
<Edit />
</IconButton>
</ListItemSecondaryAction>
</ListItem>
);
}
};

19
src/pipelines/queries.ts Normal file
View File

@ -0,0 +1,19 @@
import { gql } from '@apollo/client';
export const PIPELINE = gql`
query Pipeline($id: String!) {
pipeline(id: $id) {
id
name
projectId
branch
workUnitMetadata {
version
units {
type
scripts
}
}
}
}
`;

View File

@ -23,7 +23,7 @@ const useStyles = makeStyles(() => ({
},
}));
export const ProjectDetail: FC<Props> = ({ project }) => {
export const ProjectDetail: FC<Props> = ({ project, children }) => {
const headerContainer = useHeaderContainer();
const classes = useStyles();
@ -55,16 +55,24 @@ export const ProjectDetail: FC<Props> = ({ project }) => {
</Portal>
<Grid
container
spacing={1}
spacing={0}
direction="row"
alignItems="stretch"
className={classes.root}
>
<Grid item xs={3} style={{ height: "100%", display: "flex" }}>
<Grid item xs={3} lg={2} style={{ height: "100%", display: "flex" }}>
<Paper className={classes.pipelineListContainer}>
<PipelineList projectId={project.id} />
</Paper>
</Grid>
<Grid
item
xs={9}
lg={10}
style={{ height: "100%", display: "flex", overflowY: "auto" }}
>
{children}
</Grid>
</Grid>
</Fragment>
);

View File

@ -1,12 +1,12 @@
import { gql, useQuery } from '@apollo/client';
import { Link, useRouter } from '@curi/react-dom';
import { Box, List, ListItem } from '@material-ui/core';
import { find, propEq } from 'ramda';
import React, { useState, FC, useEffect } from 'react';
import { Project } from '../generated/graphql';
import { ListItemText } from '@material-ui/core';
import { Button } from '@material-ui/core';
import { AddBox } from '@material-ui/icons';
import { gql, useQuery } from "@apollo/client";
import { Link } from "@curi/react-dom";
import { Box, List, ListItem, makeStyles, Theme } from "@material-ui/core";
import { FC } from "react";
import { Project } from "../generated/graphql";
import { ListItemText } from "@material-ui/core";
import { Button } from "@material-ui/core";
import { AddBox } from "@material-ui/icons";
import { ActiveLink } from "../commons/route/active-link";
const PROJECTS = gql`
query Projects {
@ -21,13 +21,31 @@ const PROJECTS = gql`
}
`;
const useStyles = makeStyles((theme: Theme) => ({
item: {
position: "relative",
".active &": {
backgroundColor: theme.palette.background.default,
},
".active &::before": {
position: "absolute",
top: 0,
bottom: 0,
left: 0,
content: '""',
display: "block",
borderLeftColor: theme.palette.secondary.main,
borderLeftWidth: 4,
borderLeftStyle: "solid",
},
},
}));
export function ProjectPanel() {
return (
<section>
<Box m={2}>
<Link
name="create-project"
>
<Link name="create-project">
<Button
variant="contained"
color="primary"
@ -44,32 +62,23 @@ export function ProjectPanel() {
}
const ProjectList: FC<{}> = () => {
const { data, refetch } = useQuery<{
const { data } = useQuery<{
projects: Project[];
}>(PROJECTS);
const projects = data?.projects;
const [currentProject, setCurrentProject] = useState<Project | undefined>(
undefined
);
const { current } = useRouter();
useEffect(() => {
const currId = current()?.response?.params.projectId;
console.log(currId);
setCurrentProject(find(propEq("id", currId), projects ?? []));
}, [current, projects]);
const classes = useStyles();
const items = projects?.map((item) => (
<Link
<ActiveLink
name="project-detail"
params={{ projectId: item.id }}
key={item.id}
onNav={() => setCurrentProject(item)}
>
<ListItem button>
<ListItem button className={classes.item}>
<ListItemText primary={item.name} secondary={item.comment} />
</ListItem>
</Link>
</ActiveLink>
));
return <List>{items}</List>;
};

View File

@ -1,9 +1,19 @@
import { ApolloClient, InMemoryCache } from "@apollo/client";
import { prepareRoutes } from "@curi/router";
import { omit } from 'ramda';
import React from 'react';
import { CreateProjectInput, Project } from './generated/graphql';
import React from "react";
import { ProjectDetail, ProjectEditor, PROJECT } from "./projects";
import { COMMIT_LIST_QUERY } from './commons/graphql/queries';
import { CommitList } from './commits/commit-list';
import { PipelineTaskDetail } from './pipeline-tasks/pipeline-task-detail';
import { PipelineEditor } from "./pipelines/pipeline-editor";
import {
CreatePipelineInput,
CreateProjectInput,
Pipeline,
Project,
} from "./generated/graphql";
import { PIPELINE } from "./pipelines";
export default prepareRoutes([
{
@ -12,7 +22,7 @@ export default prepareRoutes([
respond() {
return { body: () => <div>DashBoard</div> };
},
},
}, // dashboard
{
name: "create-project",
path: "projects/create",
@ -26,7 +36,7 @@ export default prepareRoutes([
};
return { body: () => <ProjectEditor project={input} /> };
},
},
}, // create-project
{
name: "edit-project",
path: "projects/:projectId/edit",
@ -47,7 +57,50 @@ export default prepareRoutes([
respond({ resolved }) {
return resolved;
},
}, // edit-project
{
name: "create-pipeline",
path: "projects/:projectId/pipelines/create",
async resolve(
matched,
{ client }: { client: ApolloClient<InMemoryCache> }
) {
const input: CreatePipelineInput = {
name: "",
branch: "",
projectId: matched!.params.projectId,
workUnitMetadata: {
version: 1,
units: [],
},
};
return {
body: () => <PipelineEditor pipeline={input as any} />,
};
},
respond({ resolved }) {
return resolved;
},
}, // create-pipeline
{
name: "edit-pipeline",
path: "projects/:projectId/pipelines/:pipelineId/edit",
async resolve(
matched,
{ client }: { client: ApolloClient<InMemoryCache> }
) {
const { data } = await client.query<{ pipeline: Pipeline }>({
query: PIPELINE,
variables: { id: matched?.params.pipelineId },
});
return {
body: () => <PipelineEditor pipeline={data.pipeline} />,
};
},
respond({ resolved }) {
return resolved;
},
}, // edit-pipeline
{
name: "project-detail",
path: "projects/:projectId",
@ -68,5 +121,65 @@ export default prepareRoutes([
respond({ resolved }) {
return resolved;
},
children: [
{
name: "pipeline-commits",
path: "pipelines/:pipelineId/commits",
async resolve(
matched,
{ client }: { client: ApolloClient<InMemoryCache> }
) {
const { data } = await client.query<{
pipeline: Pipeline;
project: Project;
}>({
query: COMMIT_LIST_QUERY,
variables: {
projectId: matched?.params.projectId,
pipelineId: matched?.params.pipelineId,
},
});
return {
body: () => (
<ProjectDetail project={omit(["__typename"], data.project)}>
<CommitList pipeline={omit(["__typename"], data.pipeline)} />
</ProjectDetail>
),
};
},
respond({ resolved, error }) {
return resolved || <div>Failed</div>;
},
}, // pipeline-commits
{
name: "pipeline-task-detail",
path: "pipelines/:pipelineId/tasks/:taskId",
async resolve(
matched,
{ client }: { client: ApolloClient<InMemoryCache> }
) {
const { data } = await client.query<{
pipeline: Pipeline;
project: Project;
}>({
query: COMMIT_LIST_QUERY,
variables: {
projectId: matched?.params.projectId,
pipelineId: matched?.params.pipelineId,
},
});
return {
body: () => (
<ProjectDetail project={omit(["__typename"], data.project)}>
<PipelineTaskDetail taskId={matched?.params.taskId} />
</ProjectDetail>
),
};
},
respond({ resolved, error }) {
return resolved || <div>Failed</div>;
},
}, // pipeline-task-detail
],
}, // project-detail
]);

22
src/utils/deep-omit.ts Normal file
View File

@ -0,0 +1,22 @@
import { fromPairs, map, omit, pipe, toPairs, type } from "ramda";
export const deepOmit = <T = any, K = any>(
names: readonly string[],
value: K
): T => {
switch (type(value)) {
case "Array":
return (value as unknown as Array<any>).map((item: any) =>
deepOmit(names, item)
) as unknown as T;
case "Object":
return pipe(
omit(names),
toPairs,
map(([key, val]) => [key, deepOmit(names, val)] as any),
fromPairs
)(value) as unknown as T;
default:
return value as unknown as T;
}
};