Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

25307 Redirect FF and code cleanup #713

Merged
merged 1 commit into from
Jan 28, 2025
Merged
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
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
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This getter is used in this module but if I uncomment this then I get a warning that it's already imported in a mixin. Still, it's nice to see, here, where this is imported from.

// @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(),
Copy link
Collaborator Author

@severinbeauvais severinbeauvais Jan 27, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since this function is now in a mixin, it has full access to the store and this simplifies things.

Ditto below.

...(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)) {
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This allows devs to use the old Filings UI dashboard. The FF is now obsolete.

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()"
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Renamed as per button text.

>
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 {
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I changed this to a mixin so that it could directly access the store getters.

I know it's sometimes possible to access the store externally, ie:

const authenticationStore = useAuthenticationStore()
const currentAccound = authenticationStore.getCurrentAccount

However, I found that I was not seeing the latest store value that I cared about (isNoRedirect) -- it was set to True but I was getting False. So, I'm using a mixing and the Getter mechanism.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

PS This mixin is used exclusively by App.vue so using a mixin isn't polluting this any more than necessary.

@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)
*/
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The main change, below, is that I swapped the "then" and "else" conditions to avoid a double negative condition (ie, "if !isNoRedirect").

I also provide a default value for identifier and a proper "no value" default for filing id (NaN).

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
Loading