diff --git a/src/components/EntityGrid.vue b/src/components/EntityGrid.vue index 2fcf7acba..ec5fe2364 100644 --- a/src/components/EntityGrid.vue +++ b/src/components/EntityGrid.vue @@ -22,7 +22,7 @@ projects, and special entities with selection. * * @author Matthew Raymer */

- {{ member.name || "Unnamed Member" }} + {{ member.name || unnamedMember }}

= []; + /** + * Get the unnamed member constant + */ + get unnamedMember(): string { + return UNNAMED_MEMBER; + } + async created() { this.notify = createNotifyHelpers(this.$notify); diff --git a/src/components/ProjectCard.vue b/src/components/ProjectCard.vue index 7f09eda8a..f0ba9e6c5 100644 --- a/src/components/ProjectCard.vue +++ b/src/components/ProjectCard.vue @@ -15,7 +15,7 @@ issuer information. * * @author Matthew Raymer */

- {{ project.name || "Unnamed Project" }} + {{ project.name || unnamedProject }}

@@ -31,6 +31,7 @@ import ProjectIcon from "./ProjectIcon.vue"; import { PlanData } from "../interfaces/records"; import { Contact } from "../db/tables/contacts"; import { didInfo } from "../libs/endorserServer"; +import { UNNAMED_PROJECT } from "@/constants/entities"; /** * ProjectCard - Displays a project entity with selection capability @@ -63,6 +64,13 @@ export default class ProjectCard extends Vue { @Prop({ required: true }) allContacts!: Contact[]; + /** + * Get the unnamed project constant + */ + get unnamedProject(): string { + return UNNAMED_PROJECT; + } + /** * Computed display name for the project issuer */ diff --git a/src/components/PushNotificationPermission.vue b/src/components/PushNotificationPermission.vue index 7372c63d3..37b266a09 100644 --- a/src/components/PushNotificationPermission.vue +++ b/src/components/PushNotificationPermission.vue @@ -115,6 +115,7 @@ import { urlBase64ToUint8Array } from "../libs/crypto/vc/util"; import * as libsUtil from "../libs/util"; import { logger } from "../utils/logger"; import { PlatformServiceMixin } from "../utils/PlatformServiceMixin"; +import { UNNAMED_ENTITY_NAME } from "@/constants/entities"; // Example interface for error interface ErrorResponse { @@ -602,7 +603,7 @@ export default class PushNotificationPermission extends Vue { * Returns the default message for direct push */ get notificationMessagePlaceholder(): string { - return "Click to share some gratitude with the world -- even if they're unnamed."; + return `Click to share some gratitude with the world -- even if they're ${UNNAMED_ENTITY_NAME.toLowerCase()}.`; } /** diff --git a/src/constants/entities.ts b/src/constants/entities.ts new file mode 100644 index 000000000..2a539e7e0 --- /dev/null +++ b/src/constants/entities.ts @@ -0,0 +1,17 @@ +/** + * Constants for entity-related strings, particularly for unnamed/unknown person entities + */ + +// Core unnamed entity names +export const UNNAMED_ENTITY_NAME = "Unnamed"; + +// Descriptive phrases for unnamed entities +export const SOMEONE_UNNAMED = "Someone Unnamed"; +export const UNNAMED_MEMBER = "Unnamed Member"; +export const UNNAMED_PERSON = "That unnamed person"; +export const UNNAMED_USER = "unnamed user"; + +// Project-related unnamed entities +export const UNNAMED_PROJECT = "Unnamed Project"; + + diff --git a/src/constants/notifications.ts b/src/constants/notifications.ts index 474e0d5e8..d08c7f83d 100644 --- a/src/constants/notifications.ts +++ b/src/constants/notifications.ts @@ -1,4 +1,5 @@ import axios from "axios"; +import { UNNAMED_PERSON } from "./entities"; // Notification message constants for user-facing notifications // Add new notification messages here as needed @@ -867,7 +868,7 @@ export const NOTIFY_CONTACT_LINK_COPIED = { // Template for registration success message // Used in: ContactsView.vue (register method - registration success with contact name) export const getRegisterPersonSuccessMessage = (name?: string): string => - `${name || "That unnamed person"} ${NOTIFY_REGISTER_PERSON_SUCCESS.message}`; + `${name || UNNAMED_PERSON} ${NOTIFY_REGISTER_PERSON_SUCCESS.message}`; // Template for visibility success message // Used in: ContactsView.vue (setVisibility method - visibility success with contact name) @@ -1372,7 +1373,7 @@ export function createQRContactAddedMessage(hasVisibility: boolean): string { export function createQRRegistrationSuccessMessage( contactName: string, ): string { - return `${contactName || "That unnamed person"}${NOTIFY_QR_REGISTRATION_SUCCESS.message}`; + return `${contactName || UNNAMED_PERSON}${NOTIFY_QR_REGISTRATION_SUCCESS.message}`; } // ContactQRScanShowView.vue timeout constants diff --git a/src/libs/endorserServer.ts b/src/libs/endorserServer.ts index 735252f73..6b0d27920 100644 --- a/src/libs/endorserServer.ts +++ b/src/libs/endorserServer.ts @@ -60,6 +60,7 @@ import { PlanSummaryRecord } from "../interfaces/records"; import { logger } from "../utils/logger"; import { PlatformServiceFactory } from "@/services/PlatformServiceFactory"; import { APP_SERVER } from "@/constants/app"; +import { SOMEONE_UNNAMED } from "@/constants/entities"; /** * Standard context for schema.org data @@ -309,7 +310,7 @@ export function didInfoForContact( showDidForVisible: boolean = false, // eslint-disable-next-line @typescript-eslint/no-explicit-any ): { known: boolean; displayName: string; profileImageUrl?: string } { - if (!did) return { displayName: "Someone Unnamed/Unknown", known: false }; + if (!did) return { displayName: SOMEONE_UNNAMED, known: false }; if (did === activeDid) { return { displayName: "You", known: true }; } else if (contact) { diff --git a/src/libs/util.ts b/src/libs/util.ts index c65f2f8a3..9db225172 100644 --- a/src/libs/util.ts +++ b/src/libs/util.ts @@ -33,6 +33,7 @@ import { logger } from "../utils/logger"; import { PlatformServiceFactory } from "../services/PlatformServiceFactory"; import { IIdentifier } from "@veramo/core"; import { DEFAULT_ROOT_DERIVATION_PATH } from "./crypto"; +import { UNNAMED_USER } from "@/constants/entities"; // Consolidate this with src/utils/PlatformServiceMixin.mapQueryResultToValues function mapQueryResultToValues( @@ -192,7 +193,7 @@ export const nameForContact = ( ): string => { return ( (contact?.name as string) || - (capitalize ? "This" : "this") + " unnamed user" + (capitalize ? "This" : "this") + " " + UNNAMED_USER ); }; diff --git a/src/views/ContactGiftingView.vue b/src/views/ContactGiftingView.vue index 31bec1068..0f52b0365 100644 --- a/src/views/ContactGiftingView.vue +++ b/src/views/ContactGiftingView.vue @@ -42,13 +42,13 @@ icon="circle-question" class="text-slate-400 text-4xl shrink-0" /> - (Unnamed/Unknown) + {{ unnamedEntityName }} @@ -108,6 +108,7 @@ import { GiverReceiverInputInfo } from "../libs/util"; import { logger } from "../utils/logger"; import { PlatformServiceMixin } from "@/utils/PlatformServiceMixin"; import { createNotifyHelpers, TIMEOUTS } from "@/utils/notify"; +import { UNNAMED_ENTITY_NAME } from "@/constants/entities"; @Component({ components: { GiftedDialog, QuickNav, EntityIcon }, mixins: [PlatformServiceMixin], @@ -246,7 +247,7 @@ export default class ContactGiftingView extends Vue { return { did: this.activeDid, name: "You" }; } else if (!contact.did || contact.did === "") { // If DID is empty/null, create "Unnamed" entity - return { did: "", name: "Unnamed" }; + return { did: "", name: UNNAMED_ENTITY_NAME }; } else { // Create a copy of the contact to avoid modifying the original return { ...contact }; @@ -267,7 +268,7 @@ export default class ContactGiftingView extends Vue { return { giver, recipient }; } else { // We're selecting a recipient, so the selected entity becomes the recipient - const recipient = selectedEntity || { did: "", name: "Unnamed" }; + const recipient = selectedEntity || { did: "", name: UNNAMED_ENTITY_NAME }; const giver = this.createGiverFromContext(); return { giver, recipient }; } @@ -292,7 +293,7 @@ export default class ContactGiftingView extends Vue { name: this.recipientProjectName, }; } else { - return { did: "", name: "Unnamed" }; + return { did: "", name: UNNAMED_ENTITY_NAME }; } } } @@ -316,11 +317,20 @@ export default class ContactGiftingView extends Vue { name: this.giverProjectName, }; } else { - return { did: "", name: "Unnamed" }; + return { did: "", name: UNNAMED_ENTITY_NAME }; } } } + /** + * Get the unnamed entity name constant + */ + get unnamedEntityName(): string { + return UNNAMED_ENTITY_NAME; + } + + + get shouldShowYouEntity(): boolean { if (this.stepType === "giver") { // When selecting a giver, show "You" if the current recipient is not "You" @@ -346,3 +356,4 @@ export default class ContactGiftingView extends Vue { } } + diff --git a/src/views/DIDView.vue b/src/views/DIDView.vue index 4294ec4f5..927f271f0 100644 --- a/src/views/DIDView.vue +++ b/src/views/DIDView.vue @@ -290,6 +290,7 @@ import { NOTIFY_SERVER_ACCESS_ERROR, NOTIFY_NO_IDENTITY_ERROR, } from "@/constants/notifications"; +import { UNNAMED_PERSON } from "@/constants/entities"; /** * DIDView Component @@ -549,7 +550,7 @@ export default class DIDView extends Vue { contact.registered = true; await this.$updateContact(contact.did, { registered: true }); - const name = contact.name || "That unnamed person"; + const name = contact.name || UNNAMED_PERSON; this.notify.success( `${name} ${NOTIFY_REGISTRATION_SUCCESS.message}`, TIMEOUTS.LONG, diff --git a/src/views/DiscoverView.vue b/src/views/DiscoverView.vue index 452120fbb..abf72e6b8 100644 --- a/src/views/DiscoverView.vue +++ b/src/views/DiscoverView.vue @@ -233,7 +233,7 @@

- {{ project.name || "Unnamed Project" }} + {{ project.name || unnamedProject }}

; + /** + * Get the unnamed project constant + */ + get unnamedProject(): string { + return UNNAMED_PROJECT; + } + activeDid = ""; allContacts: Array = []; allMyDids: Array = []; diff --git a/src/views/HelpView.vue b/src/views/HelpView.vue index 021061699..3d7798131 100644 --- a/src/views/HelpView.vue +++ b/src/views/HelpView.vue @@ -199,7 +199,7 @@

Then you can record your appreciation for... whatever: select any contact on the home page - (or "Unnamed") and send it. The main goal is to record what people + (or "{{ unnamedEntityName }}") and send it. The main goal is to record what people have given you, to grow giving economies. You can also record your own ideas for projects. Each claim is recorded on a custom ledger. @@ -598,6 +598,7 @@ import * as Package from "../../package.json"; import QuickNav from "../components/QuickNav.vue"; import { APP_SERVER } from "../constants/app"; import { PlatformServiceMixin } from "@/utils/PlatformServiceMixin"; +import { UNNAMED_ENTITY_NAME } from "@/constants/entities"; /** * HelpView.vue - Comprehensive Help System Component @@ -645,6 +646,13 @@ export default class HelpView extends Vue { APP_SERVER = APP_SERVER; Capacitor = Capacitor; + /** + * Get the unnamed entity name constant + */ + get unnamedEntityName(): string { + return UNNAMED_ENTITY_NAME; + } + // Ideally, we put no functionality in here, especially in the setup, // because we never want this page to have a chance of throwing an error. diff --git a/src/views/HomeView.vue b/src/views/HomeView.vue index 7c4789f7d..b6dea7e0b 100644 --- a/src/views/HomeView.vue +++ b/src/views/HomeView.vue @@ -305,6 +305,7 @@ import { PlatformServiceMixin } from "@/utils/PlatformServiceMixin"; import { createNotifyHelpers, TIMEOUTS } from "@/utils/notify"; import { NOTIFY_CONTACT_LOADING_ISSUE } from "@/constants/notifications"; import * as Package from "../../package.json"; +import { UNNAMED_ENTITY_NAME } from "@/constants/entities"; // consolidate this with GiveActionClaim in src/interfaces/claims.ts interface Claim { @@ -1506,7 +1507,7 @@ export default class HomeView extends Vue { return { did: this.activeDid, name: "You" }; } else if (!giver.did || giver.did === "") { // If DID is empty/null, create "Unnamed" entity - return { did: "", name: "Unnamed" }; + return { did: "", name: UNNAMED_ENTITY_NAME }; } else { // Return the giver as-is return giver; diff --git a/src/views/ProjectViewView.vue b/src/views/ProjectViewView.vue index f0a5a4c1e..eb36f6e66 100644 --- a/src/views/ProjectViewView.vue +++ b/src/views/ProjectViewView.vue @@ -183,7 +183,7 @@ class="text-blue-500" @click="onClickLoadProject(plan.handleId)" > - {{ plan.name || "Unnamed Project" }} + {{ plan.name || unnamedProject }}

@@ -207,7 +207,7 @@ class="text-blue-500" @click="onClickLoadProject(fulfilledByThis.handleId)" > - {{ fulfilledByThis.name || "Unnamed Project" }} + {{ fulfilledByThis.name || unnamedProject }}
@@ -611,6 +611,7 @@ import { PlatformServiceMixin } from "@/utils/PlatformServiceMixin"; import { createNotifyHelpers, TIMEOUTS } from "@/utils/notify"; import { NOTIFY_CONFIRM_CLAIM } from "@/constants/notifications"; import { APP_SERVER } from "@/constants/app"; +import { UNNAMED_PROJECT } from "@/constants/entities"; /** * Project View Component * @author Matthew Raymer @@ -664,6 +665,13 @@ export default class ProjectViewView extends Vue { /** Notification helpers instance */ notify!: ReturnType; + /** + * Get the unnamed project constant + */ + get unnamedProject(): string { + return UNNAMED_PROJECT; + } + // Account and Settings State /** Currently active DID */ activeDid = ""; diff --git a/src/views/ProjectsView.vue b/src/views/ProjectsView.vue index 7c4f05605..a37ab6e53 100644 --- a/src/views/ProjectsView.vue +++ b/src/views/ProjectsView.vue @@ -247,7 +247,7 @@

- {{ project.name || "Unnamed Project" }} + {{ project.name || unnamedProject }}

{{ project.description }} @@ -289,6 +289,7 @@ import { NOTIFY_OFFERS_FETCH_ERROR, NOTIFY_CAMERA_SHARE_METHOD, } from "@/constants/notifications"; +import { UNNAMED_PROJECT } from "@/constants/entities"; /** * Projects View Component @@ -327,6 +328,13 @@ export default class ProjectsView extends Vue { notify!: ReturnType; + /** + * Get the unnamed project constant + */ + get unnamedProject(): string { + return UNNAMED_PROJECT; + } + // User account state activeDid = ""; allContacts: Array = []; diff --git a/test-playwright/00-noid-tests.spec.ts b/test-playwright/00-noid-tests.spec.ts index 5218c3305..fbddd6dc3 100644 --- a/test-playwright/00-noid-tests.spec.ts +++ b/test-playwright/00-noid-tests.spec.ts @@ -69,6 +69,7 @@ */ import { test, expect } from '@playwright/test'; +import { UNNAMED_ENTITY_NAME } from '../src/constants/entities'; import { deleteContact, generateAndRegisterEthrUser, importUser } from './testUtils'; test('Check activity feed - check that server is running', async ({ page }) => { @@ -177,7 +178,7 @@ test('Check User 0 can register a random person', async ({ page }) => { await page.goto('./'); await page.getByTestId('closeOnboardingAndFinish').click(); await page.getByRole('button', { name: 'Person' }).click(); - await page.getByRole('listitem').filter({ hasText: 'Unnamed' }).locator('svg').click(); + await page.getByRole('listitem').filter({ hasText: UNNAMED_ENTITY_NAME }).locator('svg').click(); await page.getByPlaceholder('What was given').fill('Gave me access!'); await page.getByRole('button', { name: 'Sign & Send' }).click(); await expect(page.getByText('That gift was recorded.')).toBeVisible(); diff --git a/test-playwright/30-record-gift.spec.ts b/test-playwright/30-record-gift.spec.ts index d8ee96983..cd9422365 100644 --- a/test-playwright/30-record-gift.spec.ts +++ b/test-playwright/30-record-gift.spec.ts @@ -79,6 +79,7 @@ * ``` */ import { test, expect } from '@playwright/test'; +import { UNNAMED_ENTITY_NAME } from '../src/constants/entities'; import { importUser } from './testUtils'; test('Record something given', async ({ page }) => { @@ -101,7 +102,7 @@ test('Record something given', async ({ page }) => { await page.goto('./'); await page.getByTestId('closeOnboardingAndFinish').click(); await page.getByRole('button', { name: 'Person' }).click(); - await page.getByRole('listitem').filter({ hasText: 'Unnamed' }).locator('svg').click(); + await page.getByRole('listitem').filter({ hasText: UNNAMED_ENTITY_NAME }).locator('svg').click(); await page.getByPlaceholder('What was given').fill(finalTitle); await page.getByRole('spinbutton').fill(randomNonZeroNumber.toString()); await page.getByRole('button', { name: 'Sign & Send' }).click(); diff --git a/test-playwright/33-record-gift-x10.spec.ts b/test-playwright/33-record-gift-x10.spec.ts index f0dfeef4a..37c5eb024 100644 --- a/test-playwright/33-record-gift-x10.spec.ts +++ b/test-playwright/33-record-gift-x10.spec.ts @@ -85,6 +85,7 @@ */ import { test, expect } from '@playwright/test'; +import { UNNAMED_ENTITY_NAME } from '../src/constants/entities'; import { importUser, createUniqueStringsArray, createRandomNumbersArray } from './testUtils'; test('Record 9 new gifts', async ({ page }) => { @@ -116,7 +117,7 @@ test('Record 9 new gifts', async ({ page }) => { await page.getByTestId('closeOnboardingAndFinish').click(); } await page.getByRole('button', { name: 'Person' }).click(); - await page.getByRole('listitem').filter({ hasText: 'Unnamed' }).locator('svg').click(); + await page.getByRole('listitem').filter({ hasText: UNNAMED_ENTITY_NAME }).locator('svg').click(); await page.getByPlaceholder('What was given').fill(finalTitles[i]); await page.getByRole('spinbutton').fill(finalNumbers[i].toString()); await page.getByRole('button', { name: 'Sign & Send' }).click();