Skip to content

Commit

Permalink
[OpenMFP] Fix value access of ref (#2230)
Browse files Browse the repository at this point in the history
* fix value access of ref

(cherry picked from commit 9e10550)

* decompose openMFP
  • Loading branch information
petersutter authored Dec 16, 2024
1 parent 8754a10 commit aaa6f68
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 7 deletions.
6 changes: 4 additions & 2 deletions frontend/src/composables/useProjectContext.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,8 @@ export function createProjectContextComposable (options = {}) {
configStore = useConfigStore(),
} = options

const { accountId } = openMFP

function normalizeManifest (value) {
const object = Object.assign({
apiVersion: 'core.gardener.cloud/v1beta1',
Expand Down Expand Up @@ -62,9 +64,9 @@ export function createProjectContextComposable (options = {}) {

function createProjectManifest () {
manifest.value = {}
if (openMFP.accountId) {
if (accountId.value) {
set(manifest.value, ['metadata', 'label', 'openmfp.org/managed-by'], 'true')
set(manifest.value, ['metadata', 'annotations', 'openmfp.org/account-id'], openMFP.accountId)
set(manifest.value, ['metadata', 'annotations', 'openmfp.org/account-id'], accountId.value)
}
initialManifest.value = cloneDeep(normalizedManifest.value)
}
Expand Down
6 changes: 4 additions & 2 deletions frontend/src/views/GAdministration.vue
Original file line number Diff line number Diff line change
Expand Up @@ -547,6 +547,8 @@ useProvideProjectContext({
configStore,
})

const { accountId } = openMFP

const color = ref('primary')
const errorMessage = ref(undefined)
const detailedErrorMessage = ref(undefined)
Expand Down Expand Up @@ -651,9 +653,9 @@ async function updateProperty (key, value, options = {}) {
metadata: { name },
spec: { namespace },
}
if (openMFP.accountId && !get(projectStore.project, ['metadata', 'annotations', 'openmfp.org/account-id'])) {
if (accountId.value && !get(projectStore.project, ['metadata', 'annotations', 'openmfp.org/account-id'])) {
set(mergePatchDocument, ['metadata', 'labels', 'openmfp.org/managed-by'], 'true')
set(mergePatchDocument, ['metadata', 'annotations', 'openmfp.org/account-id'], openMFP.accountId)
set(mergePatchDocument, ['metadata', 'annotations', 'openmfp.org/account-id'], accountId.value)
}
set(mergePatchDocument, ['spec', key], value)
await projectStore.patchProject(mergePatchDocument)
Expand Down
6 changes: 3 additions & 3 deletions frontend/src/views/GProjectList.vue
Original file line number Diff line number Diff line change
Expand Up @@ -146,15 +146,15 @@ import filter from 'lodash/filter'

const projectStore = useProjectStore()
const authzStore = useAuthzStore()
const openMFP = useOpenMFP()
const { accountId } = useOpenMFP()

const canCreateProject = toRef(authzStore, 'canCreateProject')

const projectDialog = ref(false)

const projectList = computed(() => {
const belongsToAccount = project => openMFP.accountId === get(project, ['metadata', 'annotations', 'openmfp.org/account-id'])
return !openMFP.accountId
const belongsToAccount = project => accountId.value === get(project, ['metadata', 'annotations', 'openmfp.org/account-id'])
return !accountId.value
? projectStore.projectList
: filter(projectStore.projectList, belongsToAccount)
})
Expand Down

0 comments on commit aaa6f68

Please sign in to comment.