Skip to content

Commit

Permalink
Bug Bash 2
Browse files Browse the repository at this point in the history
  • Loading branch information
gbdubs committed Jan 16, 2024
1 parent a37da01 commit 447c8a3
Show file tree
Hide file tree
Showing 16 changed files with 150 additions and 47 deletions.
3 changes: 2 additions & 1 deletion cmd/server/pactasrv/user.go
Original file line number Diff line number Diff line change
Expand Up @@ -168,8 +168,9 @@ func (s *Server) userDoAuthzAndAuditLog(ctx context.Context, targetUserID pacta.
if actorInfo.UserID == targetUserID {
as.isAuthorized = true
as.authorizedAsActorType = ptr(pacta.AuditLogActorType_Owner)
} else {
as.isAuthorized, as.authorizedAsActorType = allowIfAdmin(actorInfo)
}
as.isAuthorized, as.authorizedAsActorType = allowIfAdmin(actorInfo)
default:
return fmt.Errorf("unknown action %q for user authz", action)
}
Expand Down
4 changes: 4 additions & 0 deletions frontend/assets/css/overrides.css
Original file line number Diff line number Diff line change
Expand Up @@ -26,4 +26,8 @@ div.p-toast {
display: inline-block;
font-size: 0.75rem;
white-space: pre-wrap;
}

.p-message-wrapper .p-message-icon, .p-message-wrapper .p-message-close {
flex-shrink: 0;
}
2 changes: 1 addition & 1 deletion frontend/components/form/FieldHeader.vue
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ const helpTextTextClass = computed(() => helpTextExpanded.value ? 'mb-2' : 'h-0'
<div class="flex flex-column mb-1">
<div class="flex align-items-center mb-1 gap-2">
<label
class="inline-block text-lg ml-1"
class="inline-block text-lg"
:for="id"
>
{{ props.label }}
Expand Down
6 changes: 3 additions & 3 deletions frontend/components/inputs/EngagementStrategy.vue
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,9 @@ const model = computed({
<template>
<ExplicitTriStateCheckbox
v-model:value="model"
:true-label="tt('These file represents Engagement Strategy data')"
:false-label="tt('These files do not represent engagement strategy data')"
:unset-label="tt('Not specified')"
:true-label="tt('True')"
:false-label="tt('False')"
:unset-label="tt('Unset')"
:disabled="props.disabled"
/>
</template>
6 changes: 3 additions & 3 deletions frontend/components/inputs/Esg.vue
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,9 @@ const model = computed({
<template>
<ExplicitTriStateCheckbox
v-model:value="model"
:true-label="tt('These file represents ESG data')"
:false-label="tt('These files do not represent ESG data')"
:unset-label="tt('Not specified')"
:true-label="tt('True')"
:false-label="tt('False')"
:unset-label="tt('Unset')"
:disabled="props.disabled"
/>
</template>
6 changes: 3 additions & 3 deletions frontend/components/inputs/External.vue
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,9 @@ const model = computed({
<template>
<ExplicitTriStateCheckbox
v-model:value="model"
:true-label="tt('These file represents external data')"
:false-label="tt('These files represent internal data')"
:unset-label="tt('Not specified')"
:true-label="tt('True')"
:false-label="tt('False')"
:unset-label="tt('Unset')"
:disabled="props.disabled"
/>
</template>
31 changes: 24 additions & 7 deletions frontend/components/language/Selector.vue
Original file line number Diff line number Diff line change
Expand Up @@ -2,17 +2,20 @@
import { type LanguageOption, LanguageOptions, languageToOption } from '@/lib/language'
import { type Language } from '@/openapi/generated/pacta'
const { t } = useI18n()
const tt = (key: string) => t(`components/language/Selector.${key}`)
interface Props {
value: Language
value: Language | undefined
}
interface Emits {
(e: 'update:value', value: Language): void
(e: 'update:value', value: Language | undefined): void
}
const props = defineProps<Props>()
const emits = defineEmits<Emits>()
const model = computed<LanguageOption>({
get: () => languageToOption(props.value),
set: (v: LanguageOption) => {
const model = computed<LanguageOption | undefined>({
get: () => props.value ? languageToOption(props.value) : undefined,
set: (v: LanguageOption | undefined) => {
emits('update:value', v.language)
},
})
Expand All @@ -25,10 +28,24 @@ const model = computed<LanguageOption>({
:options="LanguageOptions"
>
<template #value="slotProps">
<LanguageRepresentation :code="slotProps.value.code" />
<LanguageRepresentation
v-if="slotProps.value"
:code="slotProps.value.code"
/>
<span
v-else
class="font-italic font-light"
>{{ tt('Unset') }}</span>
</template>
<template #option="slotProps">
<LanguageRepresentation :code="slotProps.option.code" />
<LanguageRepresentation
v-if="slotProps.option"
:code="slotProps.option.code"
/>
<span
v-else
class="font-italic font-light"
>{{ tt('Unset') }}</span>
</template>
</PVDropdown>
</template>
14 changes: 11 additions & 3 deletions frontend/components/portfolio/ListView.vue
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,7 @@ const deletePortfolio = (id: string) => withLoading(
() => pactaClient.deletePortfolio(id),
`${prefix}.deletePortfolio`,
)
const deleteThisPortfolio = (id: string) => deletePortfolio(id).then(refresh)
const deleteSelected = () => Promise.all([selectedRows.value.map((row) => deletePortfolio(row.id))]).then(refresh)
</script>

Expand Down Expand Up @@ -122,6 +123,11 @@ const deleteSelected = () => Promise.all([selectedRows.value.map((row) => delete
sort-field="editorValues.value.createdAt.originalValue"
:sort-order="-1"
>
<template #empty>
<PVMessage severity="info">
{{ tt('No Uploaded Portfolios Message') }}
</PVMessage>
</template>
<PVColumn selection-mode="multiple" />
<PVColumn
field="editorValues.value.createdAt.originalValue"
Expand Down Expand Up @@ -223,7 +229,7 @@ const deleteSelected = () => Promise.all([selectedRows.value.map((row) => delete
icon="pi pi-trash"
class="p-button-danger p-button-outlined"
:label="tt('Delete')"
@click="() => deletePortfolio(slotProps.data.id)"
@click="() => deleteThisPortfolio(slotProps.data.id)"
/>
<div v-tooltip.bottom="slotProps.data.saveTooltip">
<PVButton
Expand All @@ -244,13 +250,15 @@ const deleteSelected = () => Promise.all([selectedRows.value.map((row) => delete
</PVDataTable>
<div class="flex flex-wrap gap-3 w-full justify-content-between">
<LinkButton
class="p-button-outlined"
icon="pi pi-arrow-left"
:class="props.portfolios.length > 0 ? 'p-button-outlined' : ''"
icon="pi pi-arrow-right"
icon-pos="right"
to="/upload"
:label="tt('Upload New Portfolios')"
/>
<!-- TODO(grady) Hook this up to something. -->
<PVButton
v-if="props.portfolios.length > 0"
class="p-button-outlined"
:label="tt('How To Run a Report')"
icon="pi pi-question-circle"
Expand Down
8 changes: 7 additions & 1 deletion frontend/components/portfolio/group/ListView.vue
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,11 @@ const editorObjectToIds = (editorObject: EditorObject): string[] => {
sort-field="editorValues.value.createdAt.originalValue"
:sort-order="-1"
>
<template #empty>
<PVMessage severity="info">
{{ tt('No Portfolio Groups Message') }}
</PVMessage>
</template>
<PVColumn selection-mode="multiple" />
<PVColumn
field="editorValues.value.name.originalValue"
Expand Down Expand Up @@ -184,13 +189,14 @@ const editorObjectToIds = (editorObject: EditorObject): string[] => {
</PVDataTable>
<div class="flex flex-wrap gap-3 w-full justify-content-between">
<PVButton
class="p-button-outlined"
:class="portfolioGroups.length > 0 ? 'p-button-outlined' : ''"
icon="pi pi-plus"
:label="tt('New Portfolio Group')"
@click="() => newPortfolioGroupVisible = true"
/>
<!-- TODO(grady) Hook this up to something. -->
<PVButton
v-if="portfolioGroups.length > 0"
class="p-button-outlined"
:label="tt('How To Run a Report')"
icon="pi pi-question-circle"
Expand Down
7 changes: 6 additions & 1 deletion frontend/components/portfolio/group/NewModal.vue
Original file line number Diff line number Diff line change
Expand Up @@ -25,11 +25,16 @@ const {
currentValue: portfolioGroup,
saveTooltip,
canSave,
resetEditor,
} = portfolioGroupEditor(defaultPortfolioGroup, i18n)
const discard = () => { newPortfolioGroupVisible.value = false }
const save = () => withLoading(
() => pactaClient.createPortfolioGroup(portfolioGroup.value)
.then(() => { emit('created'); newPortfolioGroupVisible.value = false }),
.then(() => {
emit('created')
newPortfolioGroupVisible.value = false
resetEditor()
}),
`${prefix}.save`,
)
const tt = (key: string) => t(`components/portfolio/group/NewModal.${key}`)
Expand Down
2 changes: 1 addition & 1 deletion frontend/composables/useLocalStorage.ts
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ export const useLocalStorage = () => {
return presentOrSuggestReload(deviceId.value)
}

const helpTextExpanded = (helpTextId: string) => computedBooleanLocalStorageValue(`helpTextExpanded-${helpTextId}`, true)
const helpTextExpanded = (helpTextId: string) => computedBooleanLocalStorageValue(`helpTextExpanded-${helpTextId}`, false)
const showStandardDebug = computedBooleanLocalStorageValue('showStandardDebug', false)

const languageWasSelectedOrDismissed = computedBooleanLocalStorageValue('languageWasSelectedOrDismissed', false)
Expand Down
56 changes: 52 additions & 4 deletions frontend/lang/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
"Metadata": "Metadata",
"Number of Rows": "Number of Rows",
"Save Changes": "Save Changes",
"Refresh": "Refresh"
"Refresh": "Refresh",
},
"components/initiative/Toolbar": {
"Edit": "Edit",
Expand All @@ -37,6 +37,9 @@
"Availabile In": "This site is available in:",
"Bottom Right": "You can change the language at any time in the bottom right corner of the page. ↘️"
},
"components/language/Selector": {
"Unset": "Unset"
},
"components/modal/Error": {
"Common Steps": "Some common troubleshooting steps that might be helpful:",
"Connection": "Check your internet connection",
Expand Down Expand Up @@ -100,6 +103,21 @@
"Copy to Clipboard": "Copy to Clipboard",
"Download File": "Download File"
},
"components/inputs/Esg": {
"Unset": "Unspecified",
"True": "These portfolios represent ESG data",
"False": "These portfolios do not represent ESG data"
},
"components/inputs/External": {
"Unset": "Unspecified",
"True": "These portfolios represent external data",
"False": "These portfolios represent internal data"
},
"components/inputs/EngagementStrategy": {
"Unset": "Unspecified",
"True": "These portfolios represent engagement strategy data",
"False": "These portfolios represent non-engageement strategy data"
},
"components/modal/PermissionDenied": {
"Email Us": "If you think this is a bug (something that you should have access to), or if you want to let us know how you got here, please email us at",
"Heading": "Permission Denied",
Expand Down Expand Up @@ -128,6 +146,7 @@
"Editable Properties": "Editable Properties",
"Holdings Date": "Holdings Date",
"Metadata": "Metadata",
"No Uploaded Portfolios Message": "It looks like you haven't uploaded any portfolios yet - the first step to using the PACTA tool is uploading your portfolio to the platform, where it can be processed, parsed, and validated. Click the button below to upload a new portfolio.",
"Number of Rows": "Number of Rows",
"Save Changes": "Save Changes",
"Refresh": "Refresh"
Expand All @@ -140,7 +159,8 @@
"Delete": "Delete",
"New Portfolio Group": "New Portfolio Group",
"How To Run a Report": "How To Run a Report",
"Refresh": "Refresh"
"Refresh": "Refresh",
"No Portfolio Groups Message": "Portfolio groups are mechanisms for organizing your portfolios, like a folder or a tag. You can create a portfolio group by clicking the button below."
},
"components/portfolio/group/NewModal": {
"Discard": "Discard",
Expand Down Expand Up @@ -234,7 +254,13 @@
"Description": "Description",
"DescriptionHelpText": "The description is optional, but can be used to provide additional context for the portfolio.",
"Admin Debugging Enabled": "Admin Debugging Enabled",
"AdminDebuggingEnabledHelpText": "If enabled, this content of this portfolio will be accessible to administrators. When disabled, only you, the owner of this content, can access it."
"AdminDebuggingEnabledHelpText": "If enabled, this content of this portfolio will be accessible to administrators. When disabled, only you, the owner of this content, can access it.",
"ESG": "Environmental, Social, and Governance (ESG)",
"ESGHelpText": "If enabled, this portfolio represents ESG data. If disabled, this portfolio represents non-ESG data.",
"External": "External",
"ExternalHelpText": "If enabled, this portfolio represents external data. If disabled, this portfolio represents internal data.",
"Engagement Strategy": "Engagement Strategy",
"EngagementStrategyHelpText": "If enabled, this portfolio represents engagement strategy data. If disabled, this portfolio represents non-engagement strategy data."
},
"lib/editor/portfolio_group": {
"Created At": "Created At",
Expand All @@ -243,6 +269,19 @@
"Members": "Members",
"Name": "Name"
},
"lib/editor/user": {
"Admin": "Admin",
"AdminHelpText": "If enabled, this user is an administrator. Enable this only with extreme caution.",
"Canonical Email": "Canonical Email",
"Entered Email": "Entered Email",
"ID": "ID",
"Name": "Name",
"NameHelpText": "This username will be visible to other users on the platform. It can be changed at any time.",
"Preferred Language": "Preferred Language",
"PreferredLanguageHelpText": "This is your preffered language for report generation and platform text.",
"Super Admin": "Super Admin",
"SuperAdminHelpText": "If enabled, this user becomes a super-administrator, and can do anything that a user can do through the site."
},
"lib/editor/utils": {
"AllChangesSaved": "All Changes Saved",
"CannotSaveWithInvalidFields": "Cannot save with invalid fields"
Expand Down Expand Up @@ -300,13 +339,22 @@
"Discard Changes": "Discard Changes"
},
"pages/upload": {
"Add File(s)": "Add File(s)",
"Add More File(s)": "Add More File(s)",
"Cleaning Up": "Cleaning Up",
"Done": "Done",
"Selected": "Selected",
"Uploaded": "Uploaded",
"Uploading": "Uploading",
"Validating": "Validating",
"Waiting": "Waiting"
"Waiting": "Waiting",
"Begin Upload": "Begin Upload",
"ErrMustBeCSV": "File must be a CSV file",
"ErrNameTooLong" : "Filename is too long (1000 characters max).",
"ErrDuplicate": "This file may be a duplicate, consider removing it.",
"ErrTooLarge": "File is too large (100MB max)",
"Optional Portfolio Properties": "Optional Portfolio Properties",
"No Edit Properties": "The portfolios have already been created with the settings you selected. You can change their settings by editing each portfolio you created individually."
},
"pages/audit-logs": {
"Action": "Action",
Expand Down
2 changes: 1 addition & 1 deletion frontend/lib/editor/incomplete_upload.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ const createEditorIncompleteUploadFields = (translation: Translation): EditorInc
},
propertyESG: {
name: 'propertyESG',
label: tt('Environmental, Social, and Governance (ESG)'),
label: tt('ESG'),
helpText: tt('ESGHelpText'),
},
propertyExternal: {
Expand Down
2 changes: 1 addition & 1 deletion frontend/lib/editor/portfolio.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ const createEditorPortfolioFields = (translation: Translation): EditorPortfolioF
},
propertyESG: {
name: 'propertyESG',
label: tt('Environmental, Social, and Governance (ESG)'),
label: tt('ESG'),
helpText: tt('ESGHelpText'),
},
propertyExternal: {
Expand Down
4 changes: 4 additions & 0 deletions frontend/lib/editor/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,9 @@ export const getEditorComputedValues = <R> (key: string, r: R, toEFF: ToEFF<R>,
if (isInvalid.value) { return `${cannotSave}: ${invalidFields.value.join(', ')}` }
return undefined
})
const resetEditor = () => {
editorValues.value = createEditorValues(r)
}

return {
setEditorValue,
Expand All @@ -64,5 +67,6 @@ export const getEditorComputedValues = <R> (key: string, r: R, toEFF: ToEFF<R>,
isInvalid,
canSave,
saveTooltip,
resetEditor,
}
}
Loading

0 comments on commit 447c8a3

Please sign in to comment.