From fb4cebe67d837edb995bf0cb77d0a065eeec2dbc Mon Sep 17 00:00:00 2001 From: Grady Berry Ward Date: Mon, 22 Jan 2024 11:58:19 -0700 Subject: [PATCH] Creates Access Control Section for Analyses (#160) --- cmd/server/pactasrv/conv/pacta_to_oapi.go | 2 +- .../AdminDebugEnabledToggleButton.vue | 5 +- .../components/SharedToPublicToggleButton.vue | 77 +++++++++++++++++++ frontend/components/analysis/ListView.vue | 72 ++++++++++++++++- frontend/components/standard/Nav.vue | 4 +- frontend/lang/en.json | 22 +++++- frontend/lib/auditlogquery/index.ts | 6 +- frontend/pages/index.vue | 19 +++-- 8 files changed, 187 insertions(+), 20 deletions(-) create mode 100644 frontend/components/SharedToPublicToggleButton.vue diff --git a/cmd/server/pactasrv/conv/pacta_to_oapi.go b/cmd/server/pactasrv/conv/pacta_to_oapi.go index 54831b5..5c1f32a 100644 --- a/cmd/server/pactasrv/conv/pacta_to_oapi.go +++ b/cmd/server/pactasrv/conv/pacta_to_oapi.go @@ -395,7 +395,7 @@ func AnalysisArtifactToOAPI(aa *pacta.AnalysisArtifact) (*api.AnalysisArtifact, return &api.AnalysisArtifact{ Id: string(aa.ID), AdminDebugEnabled: aa.AdminDebugEnabled, - SharedToPublic: aa.AdminDebugEnabled, + SharedToPublic: aa.SharedToPublic, Blob: *blob, }, nil } diff --git a/frontend/components/AdminDebugEnabledToggleButton.vue b/frontend/components/AdminDebugEnabledToggleButton.vue index 203b040..e0cfaab 100644 --- a/frontend/components/AdminDebugEnabledToggleButton.vue +++ b/frontend/components/AdminDebugEnabledToggleButton.vue @@ -53,13 +53,14 @@ const visible = newModalVisibilityState('AdminDebugEnabledWarning') :sub-header="tt('ModalSubheading')" >

- TODO - add good copy for this + {{ tt('Paragraph1' ) }}

+ {{ tt('Paragraph1' ) }} You're enabling administrator access to this resource. If you do so, site administrators will be able to access the content of this data.

-
+
+const { newModalVisibilityState } = useModal() +const { computedBooleanLocalStorageValue } = useLocalStorage() +const { t } = useI18n() + +interface Props { + value: boolean +} +const props = defineProps() +interface Emits { + (e: 'update:value', value: boolean): void +} +const emit = defineEmits() + +const prefix = 'components/SharedToPublicToggleButton' +const tt = (s: string) => t(`${prefix}.${s}`) +const everAcked = computedBooleanLocalStorageValue(`${prefix}.everAcked`, false) + +const model = computed({ + get: () => props.value, + set: (value: boolean) => { + if (value && !everAcked.value) { + visible.value = true + return + } else { + emit('update:value', value) + } + }, +}) + +const ack = () => { + everAcked.value = true + model.value = true + visible.value = false +} +const noAck = () => { + model.value = false +} + +const visible = newModalVisibilityState('SharedToPublicWarning') + + + diff --git a/frontend/components/analysis/ListView.vue b/frontend/components/analysis/ListView.vue index 9b18e80..df39910 100644 --- a/frontend/components/analysis/ListView.vue +++ b/frontend/components/analysis/ListView.vue @@ -1,12 +1,14 @@