Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 14 additions & 0 deletions graphql.schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -9339,6 +9339,20 @@
},
"defaultValue": null
},
{
"name": "external_id",
"description": null,
"type": {
"kind": "NON_NULL",
"name": null,
"ofType": {
"kind": "SCALAR",
"name": "String",
"ofType": null
}
},
"defaultValue": null
},
{
"name": "name",
"description": null,
Expand Down
1 change: 1 addition & 0 deletions hasura/metadata/actions.graphql
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ type Mutation {
create_election(
election_event_id: String!
name: String!
external_id: String!
presentation: jsonb
description: String
): CreateElectionOutput
Expand Down
16 changes: 16 additions & 0 deletions packages/admin-portal/graphql.schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -10215,6 +10215,22 @@
"isDeprecated": false,
"deprecationReason": null
},
{
"name": "external_id",
"description": null,
"type": {
"kind": "NON_NULL",
"name": null,
"ofType": {
"kind": "SCALAR",
"name": "String",
"ofType": null
}
},
"defaultValue": null,
"isDeprecated": false,
"deprecationReason": null
},
{
"name": "name",
"description": null,
Expand Down
4 changes: 3 additions & 1 deletion packages/admin-portal/src/components/ContestItem.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
//
// SPDX-License-Identifier: AGPL-3.0-only

import {useAliasRenderer} from "@/hooks/useAliasRenderer"
import {GET_AREA_WITH_AREA_CONTESTS} from "@/queries/GetAreaWithAreaContest"
import {useQuery} from "@apollo/client"
import styled from "@emotion/styled"
Expand All @@ -26,8 +27,9 @@ interface ContestItemProps {

export const ContestItem: React.FC<ContestItemProps> = (props) => {
const {record} = props
const aliasRendere = useAliasRenderer()

const {data} = useGetOne("sequent_backend_contest", {id: record})

return <>{data ? <Chip label={data?.name} /> : null}</>
return <>{data ? <Chip label={aliasRendere(data)} /> : null}</>
}
11 changes: 3 additions & 8 deletions packages/admin-portal/src/components/MiruExportWizard.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -55,12 +55,12 @@ import {useAtomValue} from "jotai"
import {tallyQueryData} from "@/atoms/tally-candidates"
import {CREATE_TRANSMISSION_PACKAGE} from "@/queries/CreateTransmissionPackage"
import {GET_UPLOAD_URL} from "@/queries/GetUploadUrl"
import {translateElection} from "@sequentech/ui-core"
import {ETasksExecution} from "@/types/tasksExecution"
import {useWidgetStore} from "@/providers/WidgetsContextProvider"
import {WidgetProps} from "@/components/Widget"
import {CancelButton} from "@/resources/Tally/styles"
import ArrowBackIosIcon from "@mui/icons-material/ArrowBackIos"
import {useAliasRenderer} from "@/hooks/useAliasRenderer"

interface IMiruExportWizardProps {}

Expand All @@ -86,6 +86,7 @@ export const MiruExportWizard: React.FC<IMiruExportWizardProps> = ({}) => {
const [passwordState, setPasswordState] = useState<string>("")
const [signatureId, setSignatureId] = useState<string>("")
const authContext = useContext(AuthContext)
const aliasRenderer = useAliasRenderer()
const [addWidget, setWidgetTaskId, updateWidgetFail] = useWidgetStore()

const {data: areaData} = useGetOne<Sequent_Backend_Area>(
Expand Down Expand Up @@ -556,13 +557,7 @@ export const MiruExportWizard: React.FC<IMiruExportWizardProps> = ({}) => {
[tallySessionData, tally]
)

const eventName =
(election &&
(translateElection(election, "alias", i18n.language) ||
translateElection(election, "name", i18n.language))) ||
election?.alias ||
election?.name ||
"-"
const eventName = aliasRenderer(election)

const canDownloadMiru = authContext.hasRole(IPermissions.MIRU_DOWNLOAD)
const canSendMiru = authContext.hasRole(IPermissions.MIRU_SEND)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ import {WizardStyles} from "@/components/styles/WizardStyles"
import {GET_PRIVATE_KEY} from "@/queries/GetPrivateKey"
import {Dialog} from "@sequentech/ui-essentials"
import {useNotify} from "react-admin"
import {useAliasRenderer} from "@/hooks/useAliasRenderer"

export interface DownloadStepProps {
electionEvent: Sequent_Backend_Election_Event
Expand All @@ -40,6 +41,7 @@ export const DownloadStep: React.FC<DownloadStepProps> = ({
const [openConfirmationModal, setOpenConfirmationModal] = useState(false)
const [errors, setErrors] = useState<String | null>(null)
const notify = useNotify()
const aliasRenderer = useAliasRenderer()
const [checkboxState, setCheckboxState] = React.useState({
firstCheckbox: false,
secondCheckbox: false,
Expand Down Expand Up @@ -81,7 +83,7 @@ export const DownloadStep: React.FC<DownloadStepProps> = ({
const blob = new Blob([privateKey], {type: "text/plain"})
const blobUrl = window.URL.createObjectURL(blob)
const username = authContext.username
const electionName = electionEvent.alias || electionEvent.name
const electionName = aliasRenderer(electionEvent.presentation)
const fileName = `encrypted_private_key_trustee_${username}_${electionName}.txt`
var tempLink = document.createElement("a")
tempLink.href = blobUrl
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ import {
IContest,
IElection,
ICandidate,
translateFromPresentation,
} from "@sequentech/ui-core"
import SearchIcon from "@mui/icons-material/Search"
import {
Expand Down Expand Up @@ -53,6 +54,7 @@ import {
} from "@/queries/GetElectionEventsTree"
import {useElectionEventTallyStore} from "@/providers/ElectionEventTallyProvider"
import {sortCandidatesInContest, sortContestList, sortElectionList} from "@sequentech/ui-core"
import {useAliasRenderer} from "@/hooks/useAliasRenderer"

const MenuItem = styled(Menu.Item)`
color: ${adminTheme.palette.brandColor};
Expand Down Expand Up @@ -215,6 +217,7 @@ export default function ElectionEvents() {
const [instantSearchInput, setInstantSearchInput] = useState<string>("")
const [searchInput, setSearchInput] = useState<string>("")
const navigate = useNavigate()
const aliasRenderer = useAliasRenderer()

const [isArchivedElectionEvents, setArchivedElectionEvents] = useAtom(
archivedElectionEventSelection
Expand Down Expand Up @@ -468,13 +471,23 @@ export default function ElectionEvents() {
openImportDrawer?.()
}

const transformElectionEvent = (electionEvent: ElectionEventType): ElectionEventType => {
return {
...electionEvent,
name: translateFromPresentation(electionEvent, "name", i18n.language) ?? "-",
alias: aliasRenderer(electionEvent),
}
}

const transformElectionsForSort = (elections: ElectionType[]): IElection[] => {
return elections.map((election) => {
return {
...election,
tenant_id: tenantId || "",
image_document_id: election.image_document_id ?? "",
contests: [],
name: translateFromPresentation(election, "name", i18n.language) ?? "-",
alias: aliasRenderer(election),
}
})
}
Expand All @@ -489,6 +502,8 @@ export default function ElectionEvents() {
min_votes: 0,
winning_candidates_num: 0,
is_encrypted: false,
name: translateFromPresentation(contest, "name", i18n.language) ?? "-",
alias: aliasRenderer(contest),
}
})
}
Expand All @@ -500,6 +515,8 @@ export default function ElectionEvents() {
id: candidate.id,
election_id: electionId || "",
tenant_id: tenantId || "",
name: translateFromPresentation(candidate, "name", i18n.language) ?? "-",
alias: aliasRenderer(candidate),
}
})
}
Expand All @@ -516,7 +533,7 @@ export default function ElectionEvents() {
(electionEvent: ElectionEventType) => {
const electionOrderType = electionEvent?.presentation?.elections_order
return {
...electionEvent,
...transformElectionEvent(electionEvent),
...(electionEvent.id === electionEventId
? {
active: true,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ import {useActionPermissions} from "../use-tree-menu-hook"
import {useTenantStore} from "@/providers/TenantContextProvider"
import {NewResourceContext} from "@/providers/NewResourceProvider"
import {adminTheme} from "@sequentech/ui-essentials"
import {translateElection} from "@sequentech/ui-core"
import {translateFromPresentation} from "@sequentech/ui-core"
import {SettingsContext} from "@/providers/SettingsContextProvider"
import {Box, Menu, MenuItem} from "@mui/material"
import {MenuStyles, TreeMenuItemContainer} from "@/components/styles/Menu"
Expand All @@ -35,6 +35,7 @@ import {useElectionEventTallyStore} from "@/providers/ElectionEventTallyProvider
import {useCreateElectionEventStore} from "@/providers/CreateElectionEventContextProvider"
import {useNavigate} from "react-router-dom"
import RefreshIcon from "@mui/icons-material/Refresh"
import {useAliasRenderer} from "@/hooks/useAliasRenderer"

export const mapAddResource: Record<ResourceName, string> = {
sequent_backend_election_event: "createResource.electionEvent",
Expand Down Expand Up @@ -120,6 +121,7 @@ function TreeLeaves({
const {t, i18n} = useTranslation()
const {openCreateDrawer, openImportDrawer} = useCreateElectionEventStore()
const [anchorEl, setAnchorEl] = useState<HTMLElement | null>(null)
const aliasRenderer = useAliasRenderer()

useEffect(() => {
const dir = i18n.dir(i18n.language)
Expand Down Expand Up @@ -209,13 +211,7 @@ function TreeLeaves({
parentData={resource}
superParentData={parentData}
id={resource.id}
name={
translateElection(resource, "alias", i18n.language) ||
translateElection(resource, "name", i18n.language) ||
resource.alias ||
resource.name ||
"-"
}
name={aliasRenderer(resource)}
treeResourceNames={treeResourceNames}
isArchivedElectionEvents={isArchivedElectionEvents}
fullPath={fillPath(resource)}
Expand Down
4 changes: 2 additions & 2 deletions packages/admin-portal/src/gql/gql.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ import { TypedDocumentNode as DocumentNode } from '@graphql-typed-document-node/
const documents = {
"\n mutation ChangeApplicationStatus(\n $election_event_id: String!\n $user_id: String!\n $id: String!\n $tenant_id: String\n $area_id: String\n $rejection_reason: String\n $rejection_message: String\n ) {\n ApplicationChangeStatus(\n body: {\n election_event_id: $election_event_id\n id: $id\n user_id: $user_id\n tenant_id: $tenant_id\n area_id: $area_id\n rejection_reason: $rejection_reason\n rejection_message: $rejection_message\n }\n ) {\n message\n error\n }\n }\n": types.ChangeApplicationStatusDocument,
"\n mutation CheckPrivateKey(\n $electionEventId: String!\n $keysCeremonyId: String!\n $privateKeyBase64: String!\n ) {\n check_private_key(\n object: {\n election_event_id: $electionEventId\n keys_ceremony_id: $keysCeremonyId\n private_key_base64: $privateKeyBase64\n }\n ) {\n is_valid\n }\n }\n": types.CheckPrivateKeyDocument,
"\n mutation CreateElection(\n $electionEventId: String!\n $name: String!\n $presentation: jsonb\n $description: String\n ) {\n create_election(\n election_event_id: $electionEventId\n name: $name\n presentation: $presentation\n description: $description\n ) {\n id\n }\n }\n": types.CreateElectionDocument,
"\n mutation CreateElection(\n $electionEventId: String!\n $name: String!\n $externalId: String!\n $presentation: jsonb\n $description: String\n ) {\n create_election(\n election_event_id: $electionEventId\n name: $name\n external_id: $externalId\n presentation: $presentation\n description: $description\n ) {\n id\n }\n }\n": types.CreateElectionDocument,
"\n mutation CreateKeysCeremony(\n $electionEventId: String!\n $threshold: Int!\n $trusteeNames: [String!]\n $electionId: String\n $name: String\n ) {\n create_keys_ceremony(\n object: {\n election_event_id: $electionEventId\n threshold: $threshold\n trustee_names: $trusteeNames\n election_id: $electionId\n name: $name\n }\n ) {\n keys_ceremony_id\n error_message\n }\n }\n": types.CreateKeysCeremonyDocument,
"\n mutation InsertReport($object: sequent_backend_report_insert_input!) {\n insert_sequent_backend_report(objects: [$object]) {\n returning {\n id\n election_event_id\n tenant_id\n election_id\n report_type\n template_alias\n cron_config\n encryption_policy\n }\n affected_rows\n }\n }\n": types.InsertReportDocument,
"\n mutation CreateRole($tenantId: String!, $role: KeycloakRole2!) {\n create_role(tenant_id: $tenantId, role: $role) {\n id\n name\n permissions\n access\n attributes\n client_roles\n }\n }\n": types.CreateRoleDocument,
Expand Down Expand Up @@ -145,7 +145,7 @@ export function graphql(source: "\n mutation CheckPrivateKey(\n $elect
/**
* The graphql function is used to parse GraphQL queries into a document that can be used by GraphQL clients.
*/
export function graphql(source: "\n mutation CreateElection(\n $electionEventId: String!\n $name: String!\n $presentation: jsonb\n $description: String\n ) {\n create_election(\n election_event_id: $electionEventId\n name: $name\n presentation: $presentation\n description: $description\n ) {\n id\n }\n }\n"): (typeof documents)["\n mutation CreateElection(\n $electionEventId: String!\n $name: String!\n $presentation: jsonb\n $description: String\n ) {\n create_election(\n election_event_id: $electionEventId\n name: $name\n presentation: $presentation\n description: $description\n ) {\n id\n }\n }\n"];
export function graphql(source: "\n mutation CreateElection(\n $electionEventId: String!\n $name: String!\n $externalId: String!\n $presentation: jsonb\n $description: String\n ) {\n create_election(\n election_event_id: $electionEventId\n name: $name\n external_id: $externalId\n presentation: $presentation\n description: $description\n ) {\n id\n }\n }\n"): (typeof documents)["\n mutation CreateElection(\n $electionEventId: String!\n $name: String!\n $externalId: String!\n $presentation: jsonb\n $description: String\n ) {\n create_election(\n election_event_id: $electionEventId\n name: $name\n external_id: $externalId\n presentation: $presentation\n description: $description\n ) {\n id\n }\n }\n"];
/**
* The graphql function is used to parse GraphQL queries into a document that can be used by GraphQL clients.
*/
Expand Down
Loading
Loading