Skip to content

Commit

Permalink
remove assumptions of main as default branch
Browse files Browse the repository at this point in the history
  • Loading branch information
AjBreidenbach committed Jul 15, 2024
1 parent d2faa14 commit d449a8d
Show file tree
Hide file tree
Showing 24 changed files with 322 additions and 286 deletions.
2 changes: 2 additions & 0 deletions packages/oc-pages/.eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@ module.exports = {
},
rules: {
semi: 'off', // XXX [1]
"vue/multi-word-component-names": "off",
"vue/no-v-text-v-html-on-component": "off",
"no-console": process.env.NODE_ENV === "production" ? "warn" : "off",
"no-debugger": process.env.NODE_ENV === "production" ? "warn" : "off",
/*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
import {GlDropdown, GlButtonGroup} from '@gitlab/ui'
import {mapGetters, mapActions} from 'vuex'
import {lookupKey} from 'oc_vue_shared/storage-keys'
import {homeProjectDefaultBranch} from 'oc_vue_shared/mixins/default-branch'
import ControlButtons from './deployment-controls/control-buttons.vue'
import * as routes from '../../router/constants'
Expand Down Expand Up @@ -158,7 +159,7 @@ export default {
return this.deployPath? `/${this.getHomeProjectPath}/-/jobs?var_deploy_path=${encodeURIComponent(this.deployPath.name)}`: null
},
viewInRepositoryLink() {
let result = `/${this.getHomeProjectPath}/-/tree/main/${this.deployPath.name}`
let result = `/${this.getHomeProjectPath}/-/tree/${this.homeProjectDefaultBranch}/${this.deployPath.name}`
if(window.gon.unfurl_gui && window.gon.gitlab_url) {
result = window.gon.gitlab_url + result
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,20 +34,20 @@ export default {
]),
async doSetup() {
await this.environmentFetchTypesWithParams({
environmentName: this.environmentName,
environmentName: this.exportEnvironmentName,
options: {
fallbackTypeRepository: {
url: 'https://unfurl.cloud/onecommons/std.git'
}
}
})
const types = this.environmentResourceTypeDict(this.environmentName)
const types = this.environmentResourceTypeDict(this.exportEnvironmentName)
this.blueprints = Object.values(types).filter(t => t.directives?.includes('substitute'))
if(this.blueprints.length == 0) {
this.createError({
message: 'No valid blueprints found',
context: {
environmentName: this.environmentName,
environmentName: this.exportEnvironmentName,
visibleTypes: Object.values(types).map(type => type.name)
}
})
Expand Down Expand Up @@ -143,7 +143,7 @@ export default {
ready() {
return this.enabled && this.environmentsAreReady
},
environmentName() {
exportEnvironmentName() {
return this.$route.name == 'dashboardEnvironments' ?
this.$route.params.name :
'defaults'
Expand Down
2 changes: 1 addition & 1 deletion packages/oc-pages/dashboard/components/quantity-card.vue
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ export default {
p: String,
color: String,
to: {
type: Object,
type: [Object, String],
default: () => '#'
},
secondaryLink: [String, Object],
Expand Down
1 change: 1 addition & 0 deletions packages/oc-pages/dashboard/pages/deployment.vue
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ const ONE_HOUR = 60 * 60
const ONE_MINUTE = 60
export default {
name: 'Deployment',
components: {
DeploymentResources,
DashboardBreadcrumbs,
Expand Down
4 changes: 3 additions & 1 deletion packages/oc-pages/project_overview/components/main.vue
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
<script>
import { FLASH_TYPES } from 'oc_vue_shared/client_utils/oc-flash';
import { __ } from '~/locale';
import * as routes from '../router/constants'
import {getOrFetchDefaultBranch} from 'oc_vue_shared/client_utils/projects'
export default {
name: 'MainComponent',
Expand Down Expand Up @@ -39,7 +41,7 @@ export default {
].includes(this.$route.name)
const projectPath = this.$store.getters.getHomeProjectPath
const branch = this.$route.query.branch || 'main'
const branch = this.$route.query.branch || await getOrFetchDefaultBranch(encodeURIComponent(projectPath))
const fetchEnvironments = this.$store.dispatch('ocFetchEnvironments', {projectPath, branch, includeDeployments, only: !includeDeployments && this.$route.params.environment})
.catch(err => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import { Button as ElButton, Select as ElSelect, Option as ElOption } from 'elem
import _ from 'lodash'
import * as mime from 'mime-types'
import { FLASH_TYPES } from 'oc_vue_shared/client_utils/oc-flash'
import {blueprintDefaultBranch, homeProjectDefaultBranch} from 'oc_vue_shared/mixins/default-branch'
// ?.input selections are to play nice with a formily workaround
function readExpressionValue(property, index=0) {
Expand All @@ -29,6 +30,7 @@ function getMime(fileName) {
export default {
name: 'FileSelector',
mixins: [blueprintDefaultBranch, homeProjectDefaultBranch],
components: {
ElButton, Tree,
ElSelect, ElOption,
Expand Down Expand Up @@ -265,10 +267,10 @@ export default {
return `${this.schemaDefaultPrefix}${this.expressionFile}` || '/'
},
linkForDisplayValue() {
return `/${this.fileRepository}/-/blob/main/${this.displayValue}`
return `/${this.fileRepository}/-/blob/${this.defaultEditBranch}/${this.displayValue}`
},
linkForViewInRepository() {
return `/${this.fileRepository}/-/tree/main/${this.schemaDefaultPrefix}`
return `/${this.fileRepository}/-/tree/${this.defaultEditBranch}/${this.schemaDefaultPrefix}`
},
fileRepository() {
if(['.', 'project'].includes(this.location)) {
Expand Down Expand Up @@ -299,6 +301,14 @@ export default {
projectFiles() {
return this.treeFromProjectFiles(this.filteredFiles)
},
defaultEditBranch() {
if(['.', 'project'].includes(this.location)) {
return this.homeProjectDefaultBranch
} else if(this.location == 'spec') {
return this.blueprintDefaultBranch
}
}
},
watch: {
Expand Down
10 changes: 10 additions & 0 deletions packages/oc-pages/project_overview/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,16 @@ export default (elemId='js-oc-project-overview') => {
projectPath = normpath(projectPath)
window.gon.home_project = normpath(window.gon.home_project)
window.gon.working_dir_project = normpath(window.gon.working_dir_project)

// force /-/overview for route consistence with standalone
if(window.gon.unfurl_gui && !window.location.pathname.includes('/-/overview')) {
window.history.replaceState(
{},
'',
window.location.pathname.replace(projectPath, `${projectPath}/-/overview`) + window.location.search + window.location.hash
)
}

const base = window.location.pathname.includes('/-/overview') ?
`${projectPath}/-/overview` : projectPath

Expand Down
Loading

0 comments on commit d449a8d

Please sign in to comment.