@appscode/ui-builder
Version:
## Motivation
122 lines (110 loc) • 2.84 kB
JavaScript
import Vue from "vue";
import VueRouter from "vue-router";
import Auth from "../views/Auth.vue";
import UiBuilder from "../views/UiBuilder.vue";
import Editor from "../views/Editor.vue";
import store from "../store";
import defaultPresetJson from "@/plugins/presets";
Vue.use(VueRouter);
const routes = [
{
path: "/",
name: "Home",
component: UiBuilder,
props: {
showOptionsStep: true,
onOptionsValid() {
console.log("Options form is valid");
// change the jsons to main
const selectedPreset = store.state.selectedPreset || {};
const { ui, schema, model, functionsString, language } = selectedPreset;
defaultPresetJson.jsonSetter(
store,
ui || {},
schema || {},
model || {},
functionsString || "",
language || {}
);
},
onOptionsInvalid() {
console.log("Options form is invalid");
},
onOptionsCancel() {
console.log("Options form is canceled");
},
onValid() {
console.log("Form is Valid");
return [
{
name: "file1.yaml",
format: "yaml",
content: `time:${new Date()} 1`,
},
{
name: "file2.yaml",
format: "yaml",
content: `time:${new Date()} 2`,
},
{
name: "file3.yaml",
format: "yaml",
content: `time:${new Date()} 3`,
},
];
},
onInvalid() {
console.log("Form is Invalid");
},
onCancel() {
console.log("Form is canceled");
// change the jsons to options
const selectedPreset = store.state.selectedPreset || {};
const {
optionsUi: ui,
optionsSchema: schema,
optionsModel: model,
optionsFunctionsString: functionsString,
optionsLanguage: language,
} = selectedPreset;
defaultPresetJson.jsonSetter(
store,
ui || {},
schema || {},
model || {},
functionsString || {},
language || {}
);
},
onDeploy() {
console.log("Deploying....");
},
chartUrl:
"https://raw.githubusercontent.com/bytebuilders/ui-wizards/master/stable",
},
beforeEnter: (to, from, next) => {
// set configure options
store.commit("wizard/configureOptions$set", ["basic_info"]);
next();
},
},
{
path: "/authenticate",
name: "AuthPage",
component: Auth,
},
{
path: "/edit",
name: "Editor",
component: Editor,
},
];
const router = new VueRouter({
mode: "history",
base: process.env.BASE_URL,
routes,
});
router.beforeEach((to, from, next) => {
next();
});
export default router;