Skip to content

Commit

Permalink
25218 Redirect FF and code cleanup (#713)
Browse files Browse the repository at this point in the history
- app version = 7.4.15
- moved breadcumb functions to a mixin
- saved "noRedirect" to store per initial URL parameter
- deleted unneeded router condition for Digital Credentials (already checked elsewhere)
- ignored errors if getting credentials fails (there is no other error handling for this)
- renamed credential event + function to match button label
- changed Breadcrumb Resources to a mixin so store getters all work
- updated navigateToBusinessDashboard() to use store variable instead of FF
- cleaned up Digital Credentials routes
- don't show error in console if credentials are unauthorized
- fixed getters in configuration store
- deleted "use-business-dashboard" FF
- updated misc code to call navigateToBusinessDashboard()
- updated unit tests

Co-authored-by: Severin Beauvais <severin.beauvais@gov.bc.ca>
  • Loading branch information
severinbeauvais and Severin Beauvais authored Jan 28, 2025
1 parent 5cf66ef commit 0a43154
Show file tree
Hide file tree
Showing 25 changed files with 278 additions and 212 deletions.
4 changes: 2 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "business-filings-ui",
"version": "7.4.14",
"version": "7.4.15",
"private": true,
"appName": "Filings UI",
"sbcName": "SBC Common Components",
Expand Down
33 changes: 15 additions & 18 deletions src/App.vue
Original file line number Diff line number Diff line change
Expand Up @@ -147,14 +147,9 @@ import {
NameRequestInvalidDialog,
NotInGoodStandingDialog
} from '@/components/dialogs'
import {
ConfigJson,
getDashboardBreadcrumb,
getMyBusinessRegistryBreadcrumb,
getRegistryDashboardBreadcrumb,
getStaffDashboardBreadcrumb
} from '@/resources'
import { CommonMixin, DateMixin, DirectorMixin, FilingMixin, NameRequestMixin } from '@/mixins'
import { ConfigJson } from '@/resources'
import { BreadcrumbMixin, CommonMixin, DateMixin, DirectorMixin, FilingMixin, NameRequestMixin }
from '@/mixins'
import { AuthServices, EnumUtilities, LegalServices } from '@/services/'
import {
ApiFilingIF,
Expand Down Expand Up @@ -189,6 +184,7 @@ import { useBusinessStore, useConfigurationStore, useFilingHistoryListStore, use
}
})
export default class App extends Mixins(
BreadcrumbMixin,
CommonMixin,
DateMixin,
DirectorMixin,
Expand Down Expand Up @@ -223,22 +219,22 @@ export default class App extends Mixins(
CorpTypeCd.ULC_CONTINUE_IN
]
// business store references
@Getter(useBusinessStore) getEntityName!: string
// @Getter(useBusinessStore) getLegalType!: CorpTypeCd
// @Getter(useBusinessStore) getIdentifier!: string
@Getter(useBusinessStore) isEntitySoleProp!: boolean
// configuration store references
@Getter(useConfigurationStore) getAuthApiUrl!: string
@Getter(useConfigurationStore) getBusinessesUrl!: string
// @Getter(useConfigurationStore) getBusinessDashUrl!: string
// @Getter(useConfigurationStore) getBusinessesUrl!: string
@Getter(useConfigurationStore) getCreateUrl!: string
@Getter(useConfigurationStore) getRegHomeUrl!: string
// root store references
@Getter(useRootStore) getKeycloakRoles!: Array<string>
@Getter(useRootStore) isBootstrapFiling!: boolean
@Getter(useRootStore) isBootstrapPending!: boolean
@Getter(useRootStore) isBootstrapTodo!: boolean
// @Getter(useRootStore) isNoRedirect!: boolean
@Getter(useRootStore) isRoleStaff!: boolean
@Getter(useRootStore) showFetchingDataSpinner!: boolean
@Getter(useRootStore) showStartingAmalgamationSpinner!: boolean
Expand Down Expand Up @@ -312,20 +308,20 @@ export default class App extends Mixins(
get breadcrumbs (): Array<BreadcrumbIF> {
const breadcrumbs = this.$route?.meta?.breadcrumb
const crumbs: Array<BreadcrumbIF> = [
getDashboardBreadcrumb(this.getEntityName, this.getBusinessDashUrl, this.getIdentifier),
this.getDashboardBreadcrumb(),
...(breadcrumbs || [])
]
// Set base crumbs based on user role
// Staff don't want the home landing page and they can't access the Manage Business Dashboard
if (this.isRoleStaff) {
// If staff, set StaffDashboard as home crumb
crumbs.unshift(getStaffDashboardBreadcrumb(this.getBusinessesUrl))
crumbs.unshift(this.getStaffDashboardBreadcrumb())
} else {
// For non-staff, set Home and Dashboard crumbs
crumbs.unshift(
getRegistryDashboardBreadcrumb(this.getRegHomeUrl),
getMyBusinessRegistryBreadcrumb(this.getBusinessesUrl))
this.getBcRegistriesDashboardBreadcrumb(),
this.getMyBusinessRegistryBreadcrumb())
}
return crumbs
}
Expand Down Expand Up @@ -392,6 +388,7 @@ export default class App extends Mixins(
@Action(useRootStore) setFetchingDataSpinner!: (x: boolean) => void
@Action(useRootStore) setKeycloakRoles!: (x: Array<string>) => void
@Action(useRootStore) setNameRequest!: (x: any) => void
@Action(useRootStore) setNoRedirect!: (x: boolean) => void
@Action(useRootStore) setParties!: (x: Array<PartyIF>) => void
@Action(useRootStore) setPendingsList!: (x: Array<any>) => void
@Action(useRootStore) setRecordsAddress!: (x: OfficeAddressIF) => void
Expand Down Expand Up @@ -450,9 +447,9 @@ export default class App extends Mixins(
console.log('Error fetching user info or updating Launch Darkly =', error)
}
// now that LaunchDarkly has been updated (ie, in case of user targeting),
// check whether to use this Entity Dashboard or the new Business Dashboard
if (GetFeatureFlag('use-business-dashboard') && (this.$route.name === Routes.DASHBOARD)) {
// check whether to redirect to the new Business Dashboard
if (this.$route.query.noRedirect !== undefined) this.setNoRedirect(true)
if (!this.isNoRedirect && (this.$route.name === Routes.DASHBOARD)) {
const identifier = (this.businessId || this.tempRegNumber)
const dashboardUrl = `${this.getBusinessDashUrl}${identifier}${this.$route.fullPath}`
navigate(dashboardUrl)
Expand Down
4 changes: 2 additions & 2 deletions src/components/DigitalCredentials/CredentialsDashboard.vue
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@ export default class CredentialsDashboard extends Vue {
issuedCredentials: Array<DigitalCredentialIF> = []
async mounted (): Promise<void> {
await this.getCredentials()
await this.getCredentials().catch(() => {}) // ignore errors
this.showLoadingContainer = false
}
Expand Down Expand Up @@ -160,7 +160,7 @@ export default class CredentialsDashboard extends Vue {
this.revokeCredentialErrorDialog = true
} else {
this.credentialRevokedDialog = true
await this.getCredentials()
await this.getCredentials().catch(() => {}) // ignore errors
}
this.showLoadingContainer = false
}
Expand Down
6 changes: 3 additions & 3 deletions src/components/DigitalCredentials/CredentialsSimpleSteps.vue
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@
id="return-to-company-dashboard-button"
color="primary"
class="mt-6"
@click="handleGoToCredentialsDashboard()"
@click="handleGoToCompanyDashboard()"
>
Return to Company Dashboard
<v-icon>mdi-chevron-right</v-icon>
Expand All @@ -79,8 +79,8 @@ import { Component, Emit, Vue } from 'vue-property-decorator'
@Component({})
export default class CredentialSimpleSteps extends Vue {
@Emit('onGoToCredentialsDashboard')
handleGoToCredentialsDashboard (): void {
@Emit('onGoToCompanyDashboard')
handleGoToCompanyDashboard (): void {
return undefined
}
Expand Down
15 changes: 9 additions & 6 deletions src/components/DigitalCredentials/CredentialsStepper.vue
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@
<CredentialsSimpleSteps
v-else
@onShowDetailSteps="showDetailSteps = true"
@onGoToCredentialsDashboard="goToCredentialsDashboard()"
@onGoToCompanyDashboard="goToCompanyDashboard()"
/>
</v-col>
<v-col
Expand Down Expand Up @@ -146,9 +146,8 @@
<script lang="ts">
import { DigitalCredentialTypes, Routes } from '@/enums'
import { LegalServices } from '@/services'
import { useBusinessStore } from '@/stores'
import { Getter } from 'pinia-class'
import { Component, Vue } from 'vue-property-decorator'
import { CommonMixin } from '@/mixins'
import { Component, Mixins } from 'vue-property-decorator'
import QrcodeVue from 'qrcode.vue'
import { DigitalCredentialIF, WalletConnectionIF } from '@/interfaces'
import CredentialsWebSocket from '@/components/DigitalCredentials/CredentialsWebSocket.vue'
Expand All @@ -171,8 +170,8 @@ Component.registerHooks(['beforeRouteEnter'])
CredentialsDetailSteps
}
})
export default class CredentialsStepper extends Vue {
@Getter(useBusinessStore) getIdentifier!: string
export default class CredentialsStepper extends Mixins(CommonMixin) {
// @Getter(useBusinessStore) getIdentifier!: string
loadingMessage = 'Loading'
showLoadingContainer = true
Expand Down Expand Up @@ -281,6 +280,10 @@ export default class CredentialsStepper extends Vue {
goToCredentialsDashboard (): void {
this.$router.push({ name: Routes.DIGITAL_CREDENTIALS })
}
goToCompanyDashboard (): void {
this.navigateToBusinessDashboard()
}
}
</script>

Expand Down
1 change: 1 addition & 0 deletions src/interfaces/root-state-interface.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ export interface RootStateIF {
currentDate: string // 'today' as YYYY-MM-DD in Pacific timezone
currentJsDate: Date // 'now' as of dashboard loading in UTC
keycloakRoles: Array<string>
noRedirect: boolean
stateFiling: StateFilingIF
userKeycloakGuid: string

Expand Down
67 changes: 67 additions & 0 deletions src/mixins/breadcrumb-mixin.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
import { Component, Vue } from 'vue-property-decorator'
import { Getter } from 'pinia-class'
import { BreadcrumbIF } from '@bcrs-shared-components/interfaces'
import { CurrentAccountIF } from '@/interfaces'
import { Routes } from '@/enums'
import { useAuthenticationStore, useBusinessStore, useConfigurationStore, useRootStore } from '@/stores'

/**
* Mixin that provides some useful Name Request utilities.
*/
@Component({})
export default class BreadcrumbMixin extends Vue {
@Getter(useAuthenticationStore) getCurrentAccount!: CurrentAccountIF

@Getter(useBusinessStore) getEntityName!: string
@Getter(useBusinessStore) getIdentifier!: string

@Getter(useConfigurationStore) getBusinessesUrl!: string
@Getter(useConfigurationStore) getDashboardUrl!: string
@Getter(useConfigurationStore) getRegHomeUrl!: string

@Getter(useRootStore) isNoRedirect!: boolean

/** Returns the breadcrumb to the BC Registries Dashboard. */
getBcRegistriesDashboardBreadcrumb (): BreadcrumbIF {
const accountId = this.getCurrentAccount?.id || 0
const params = accountId ? `?accountid=${accountId}` : ''
return {
text: 'BC Registries Dashboard',
href: `${this.getRegHomeUrl}dashboard/${params}`
}
}

/** Returns the breadcrumb to the My Business Registry page. */
getMyBusinessRegistryBreadcrumb (): BreadcrumbIF {
const accountId = this.getCurrentAccount?.id || 0
return {
text: 'My Business Registry',
href: `${this.getBusinessesUrl}account/${accountId}/business`
}
}

/** Returns the breadcrumb to the Staff Dashboard. */
getStaffDashboardBreadcrumb (): BreadcrumbIF {
return {
text: 'Staff Dashboard',
href: `${this.getBusinessesUrl}staff/dashboard/active`
}
}

/** Returns the breadcrumb to the Business Dashboard. */
getDashboardBreadcrumb (): BreadcrumbIF {
if (!this.isNoRedirect) {
// redirect to new Business Dashboard
return {
text: this.getEntityName || 'Unknown Name',
href: `${this.getDashboardUrl}${this.getIdentifier}`
}
} else {
// route to old Entity Dashboard
return {
text: this.getEntityName || 'Unknown Name',
to: { name: Routes.DASHBOARD }
}
}
}
}
25 changes: 15 additions & 10 deletions src/mixins/common-mixin.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
import { Component, Vue } from 'vue-property-decorator'
import { isEqual, omit } from 'lodash'
import { Getter } from 'pinia-class'
import { useConfigurationStore } from '@/stores'
import { GetFeatureFlag, navigate } from '@/utils'
import { RawLocation } from 'vue-router'
import { useBusinessStore, useConfigurationStore, useRootStore } from '@/stores'
import { navigate } from '@/utils'
import { Routes } from '@/enums'

/**
Expand All @@ -11,6 +12,8 @@ import { Routes } from '@/enums'
@Component({})
export default class CommonMixin extends Vue {
@Getter(useConfigurationStore) getBusinessDashUrl!: string
@Getter(useBusinessStore) getIdentifier!: string
@Getter(useRootStore) isNoRedirect!: boolean

/** True if Vitest is running the code. */
get isVitestRunning (): boolean {
Expand Down Expand Up @@ -76,22 +79,24 @@ export default class CommonMixin extends Vue {

/**
* Navigates to the dashboard page, optionally with a filing ID.
* @param identifier The identifier to include in the dashboard URL
* @param filingId The filing ID to include in the dashboard URL (optional, defaults to null)
* @param identifier the identifier to include in the dashboard URL (optional)
* @param filingId the filing ID to include in the dashboard URL (optional)
*/
protected navigateToBusinessDashboard (identifier: string, filingId: number = null): void {
if (GetFeatureFlag('use-business-dashboard')) {
protected navigateToBusinessDashboard (identifier = this.getIdentifier, filingId = NaN): void {
if (!this.isNoRedirect) {
// redirect to the new Business Dashboard
let dashboardUrl = `${this.getBusinessDashUrl}/${identifier}`
if (filingId !== null) {
if (!isNaN(filingId)) {
dashboardUrl += `?filing_id=${filingId.toString()}`
}
navigate(dashboardUrl)
} else {
const route: any = { name: Routes.DASHBOARD }
if (filingId !== null) {
// stay in this UI
const route: RawLocation = { name: Routes.DASHBOARD }
if (!isNaN(filingId)) {
route.query = { filing_id: filingId.toString() }
}
this.$router.push(route).catch(() => {}) // Ignore potential navigation abort errors
this.$router.push(route).catch(() => {}) // ignore potential navigation abort errors
}
}
}
2 changes: 2 additions & 0 deletions src/mixins/index.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import AllowableActionsMixin from './allowable-actions-mixin'
import BreadcrumbMixin from './breadcrumb-mixin'
import CommonMixin from './common-mixin'
import DirectorMixin from './director-mixin'
import FilingMixin from './filing-mixin'
Expand All @@ -7,6 +8,7 @@ import ResourceLookupMixin from './resource-lookup-mixin'

export {
AllowableActionsMixin,
BreadcrumbMixin,
CommonMixin,
DirectorMixin,
FilingMixin,
Expand Down
Loading

0 comments on commit 0a43154

Please sign in to comment.