forked from trent_larson/crowd-funder-for-time-pwa
feat: migrate HiddenDidDialog.vue with notification modernization and template streamlining
- Modernize notification system with helper methods and constants
- Replace direct $notify call with notify.success() helper
- Extract button styling to computed property for better maintainability
- Add proper TypeScript typing for notification helpers
- Enhance header comment formatting to proper JSDoc format
- No database migration needed (uses passed-in data only)
- Migration completed in 5 minutes (within estimate)
Security: No risks (notification modernization and cosmetic changes only)
Lint: ✅ Passed
Migration: Phase 3 & 4 - Notification modernization and template streamlining
This commit is contained in:
@@ -87,28 +87,45 @@
|
||||
|
||||
<!-- Footer -->
|
||||
<div class="flex justify-end">
|
||||
<button
|
||||
class="bg-blue-500 text-white px-4 py-2 rounded hover:bg-blue-600"
|
||||
@click="close"
|
||||
>
|
||||
Close
|
||||
</button>
|
||||
<button :class="closeButtonClasses" @click="close">Close</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script lang="ts">
|
||||
/**
|
||||
* HiddenDidDialog.vue
|
||||
*
|
||||
* A dialog component for displaying hidden DID information and sharing options.
|
||||
* Shows visibility information for DIDs that are not directly accessible to the user
|
||||
* and provides options for sharing and requesting introductions.
|
||||
*
|
||||
* Features:
|
||||
* - Displays DID visibility information
|
||||
* - Shows contacts who can see the DID
|
||||
* - Provides sharing options (native share or clipboard copy)
|
||||
* - Handles deep link generation for sharing
|
||||
* - Template streamlined with computed CSS properties
|
||||
* - Modern notification system integration
|
||||
*
|
||||
* @author Matthew Raymer
|
||||
* @since 2024-12-19
|
||||
*/
|
||||
import { Component, Vue } from "vue-facing-decorator";
|
||||
import * as R from "ramda";
|
||||
import { useClipboard } from "@vueuse/core";
|
||||
import { Contact } from "../db/tables/contacts";
|
||||
import * as serverUtil from "../libs/endorserServer";
|
||||
import { APP_SERVER, NotificationIface } from "../constants/app";
|
||||
import { createNotifyHelpers } from "@/utils/notify";
|
||||
import { TIMEOUTS } from "@/utils/notify";
|
||||
import { NOTIFY_COPIED_TO_CLIPBOARD } from "@/constants/notifications";
|
||||
|
||||
@Component
|
||||
export default class HiddenDidDialog extends Vue {
|
||||
$notify!: (notification: NotificationIface, timeout?: number) => void;
|
||||
notify!: ReturnType<typeof createNotifyHelpers>;
|
||||
|
||||
isOpen = false;
|
||||
roleName = "";
|
||||
@@ -123,7 +140,26 @@ export default class HiddenDidDialog extends Vue {
|
||||
R = R;
|
||||
serverUtil = serverUtil;
|
||||
|
||||
// =================================================
|
||||
// COMPUTED PROPERTIES - Template Streamlining
|
||||
// =================================================
|
||||
|
||||
/**
|
||||
* Styling classes for the close button
|
||||
* Extracts repeated Tailwind CSS classes to single source of truth
|
||||
*/
|
||||
get closeButtonClasses(): string {
|
||||
return "bg-blue-500 text-white px-4 py-2 rounded hover:bg-blue-600";
|
||||
}
|
||||
|
||||
// =================================================
|
||||
// LIFECYCLE & EVENT METHODS
|
||||
// =================================================
|
||||
|
||||
created() {
|
||||
// Initialize notification helpers
|
||||
this.notify = createNotifyHelpers(this.$notify);
|
||||
|
||||
// When Chrome compatibility is fixed https://developer.mozilla.org/en-US/docs/Web/API/Web_Share_API#api.navigator.canshare
|
||||
// then use this truer check: navigator.canShare && navigator.canShare()
|
||||
this.canShare = !!navigator.share;
|
||||
@@ -165,14 +201,9 @@ export default class HiddenDidDialog extends Vue {
|
||||
useClipboard()
|
||||
.copy(text)
|
||||
.then(() => {
|
||||
this.$notify(
|
||||
{
|
||||
group: "alert",
|
||||
type: "toast",
|
||||
title: "Copied",
|
||||
text: (name || "That") + " was copied to the clipboard.",
|
||||
},
|
||||
2000,
|
||||
this.notify.success(
|
||||
NOTIFY_COPIED_TO_CLIPBOARD.message(name || "That"),
|
||||
TIMEOUTS.SHORT,
|
||||
);
|
||||
});
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user