diff options
Diffstat (limited to 'server/sonar-web/src/main/js/helpers')
11 files changed, 91 insertions, 119 deletions
diff --git a/server/sonar-web/src/main/js/helpers/__tests__/branches-test.ts b/server/sonar-web/src/main/js/helpers/__tests__/branches-test.ts index 934ef060ecc..7fb383a1c27 100644 --- a/server/sonar-web/src/main/js/helpers/__tests__/branches-test.ts +++ b/server/sonar-web/src/main/js/helpers/__tests__/branches-test.ts @@ -18,13 +18,6 @@ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ import { sortBranchesAsTree, isSameBranchLike } from '../branches'; -import { - MainBranch, - BranchType, - ShortLivingBranch, - LongLivingBranch, - PullRequest -} from '../../app/types'; describe('#sortBranchesAsTree', () => { it('sorts main branch and short-living branches', () => { @@ -102,28 +95,28 @@ describe('#isSameBranchLike', () => { }); }); -function mainBranch(): MainBranch { +function mainBranch(): T.MainBranch { return { isMain: true, name: 'master' }; } -function shortLivingBranch(overrides?: Partial<ShortLivingBranch>): ShortLivingBranch { +function shortLivingBranch(overrides?: Partial<T.ShortLivingBranch>): T.ShortLivingBranch { const status = { bugs: 0, codeSmells: 0, qualityGateStatus: 'OK', vulnerabilities: 0 }; return { isMain: false, mergeBranch: 'master', name: 'foo', status, - type: BranchType.SHORT, + type: 'SHORT', ...overrides }; } -function longLivingBranch(overrides?: Partial<LongLivingBranch>): LongLivingBranch { +function longLivingBranch(overrides?: Partial<T.LongLivingBranch>): T.LongLivingBranch { const status = { qualityGateStatus: 'OK' }; - return { isMain: false, name: 'foo', status, type: BranchType.LONG, ...overrides }; + return { isMain: false, name: 'foo', status, type: 'LONG', ...overrides }; } -function pullRequest(overrides?: Partial<PullRequest>): PullRequest { +function pullRequest(overrides?: Partial<T.PullRequest>): T.PullRequest { const status = { bugs: 0, codeSmells: 0, qualityGateStatus: 'OK', vulnerabilities: 0 }; return { base: 'master', diff --git a/server/sonar-web/src/main/js/helpers/__tests__/organizations-test.ts b/server/sonar-web/src/main/js/helpers/__tests__/organizations-test.ts index 959a9777b69..f36fdec8725 100644 --- a/server/sonar-web/src/main/js/helpers/__tests__/organizations-test.ts +++ b/server/sonar-web/src/main/js/helpers/__tests__/organizations-test.ts @@ -18,9 +18,8 @@ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ import { hasPrivateAccess, isCurrentUserMemberOf } from '../organizations'; -import { OrganizationSubscription } from '../../app/types'; -const org = { key: 'foo', name: 'Foo', subscription: OrganizationSubscription.Paid }; +const org: T.Organization = { key: 'foo', name: 'Foo', subscription: 'PAID' }; const adminOrg = { actions: { admin: true }, key: 'bar', name: 'Bar' }; const randomOrg = { key: 'bar', name: 'Bar' }; diff --git a/server/sonar-web/src/main/js/helpers/almIntegrations.ts b/server/sonar-web/src/main/js/helpers/almIntegrations.ts index 29af8561f5a..04f3ecccacb 100644 --- a/server/sonar-web/src/main/js/helpers/almIntegrations.ts +++ b/server/sonar-web/src/main/js/helpers/almIntegrations.ts @@ -18,9 +18,8 @@ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ import { isLoggedIn } from './users'; -import { CurrentUser, AlmOrganization } from '../app/types'; -export function hasAdvancedALMIntegration(user: CurrentUser) { +export function hasAdvancedALMIntegration(user: T.CurrentUser) { return ( isLoggedIn(user) && (isBitbucket(user.externalProvider) || isGithub(user.externalProvider)) ); @@ -38,7 +37,7 @@ export function isVSTS(almKey?: string) { return almKey === 'microsoft'; } -export function isPersonal(organization?: AlmOrganization) { +export function isPersonal(organization?: T.AlmOrganization) { return Boolean(organization && organization.personal); } diff --git a/server/sonar-web/src/main/js/helpers/branches.ts b/server/sonar-web/src/main/js/helpers/branches.ts index 86dc7e10671..f0ec53fc427 100644 --- a/server/sonar-web/src/main/js/helpers/branches.ts +++ b/server/sonar-web/src/main/js/helpers/branches.ts @@ -18,54 +18,42 @@ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ import { sortBy } from 'lodash'; -import { - BranchLike, - Branch, - BranchType, - ShortLivingBranch, - LongLivingBranch, - PullRequest, - MainBranch, - BranchParameters -} from '../app/types'; - -export function isBranch(branchLike?: BranchLike): branchLike is Branch { - return branchLike !== undefined && (branchLike as Branch).isMain !== undefined; + +export function isBranch(branchLike?: T.BranchLike): branchLike is T.Branch { + return branchLike !== undefined && (branchLike as T.Branch).isMain !== undefined; } -export function isShortLivingBranch(branchLike?: BranchLike): branchLike is ShortLivingBranch { +export function isShortLivingBranch(branchLike?: T.BranchLike): branchLike is T.ShortLivingBranch { return ( isBranch(branchLike) && !branchLike.isMain && - (branchLike as ShortLivingBranch).type === BranchType.SHORT + (branchLike as T.ShortLivingBranch).type === 'SHORT' ); } -export function isLongLivingBranch(branchLike?: BranchLike): branchLike is LongLivingBranch { +export function isLongLivingBranch(branchLike?: T.BranchLike): branchLike is T.LongLivingBranch { return ( - isBranch(branchLike) && - !branchLike.isMain && - (branchLike as LongLivingBranch).type === BranchType.LONG + isBranch(branchLike) && !branchLike.isMain && (branchLike as T.LongLivingBranch).type === 'LONG' ); } -export function isMainBranch(branchLike?: BranchLike): branchLike is MainBranch { +export function isMainBranch(branchLike?: T.BranchLike): branchLike is T.MainBranch { return isBranch(branchLike) && branchLike.isMain; } -export function isPullRequest(branchLike?: BranchLike): branchLike is PullRequest { - return branchLike !== undefined && (branchLike as PullRequest).key !== undefined; +export function isPullRequest(branchLike?: T.BranchLike): branchLike is T.PullRequest { + return branchLike !== undefined && (branchLike as T.PullRequest).key !== undefined; } -export function getPullRequestDisplayName(pullRequest: PullRequest) { +export function getPullRequestDisplayName(pullRequest: T.PullRequest) { return `${pullRequest.key} – ${pullRequest.title}`; } -export function getBranchLikeDisplayName(branchLike: BranchLike) { +export function getBranchLikeDisplayName(branchLike: T.BranchLike) { return isPullRequest(branchLike) ? getPullRequestDisplayName(branchLike) : branchLike.name; } -export function getBranchLikeKey(branchLike: BranchLike) { +export function getBranchLikeKey(branchLike: T.BranchLike) { return isPullRequest(branchLike) ? `pull-request-${branchLike.key}` : `branch-${branchLike.name}`; } @@ -81,7 +69,7 @@ export function getBranchQualityGateColor(status: string) { return indicatorColor; } -export function isSameBranchLike(a: BranchLike | undefined, b: BranchLike | undefined) { +export function isSameBranchLike(a: T.BranchLike | undefined, b: T.BranchLike | undefined) { // main branches are always equal if (isMainBranch(a) && isMainBranch(b)) { return true; @@ -104,8 +92,8 @@ export function isSameBranchLike(a: BranchLike | undefined, b: BranchLike | unde return a === b; } -export function sortBranchesAsTree(branchLikes: BranchLike[]) { - const result: BranchLike[] = []; +export function sortBranchesAsTree(branchLikes: T.BranchLike[]) { + const result: T.BranchLike[] = []; const mainBranch = branchLikes.find(isMainBranch); const longLivingBranches = branchLikes.filter(isLongLivingBranch); @@ -140,7 +128,7 @@ export function sortBranchesAsTree(branchLikes: BranchLike[]) { /** Get all short-living branches (possibly nested) which should be merged to a given branch */ function getNestedShortLivingBranches(mergeBranch: string) { - const found: ShortLivingBranch[] = shortLivingBranches.filter( + const found: T.ShortLivingBranch[] = shortLivingBranches.filter( branch => branch.mergeBranch === mergeBranch ); @@ -159,7 +147,7 @@ export function sortBranchesAsTree(branchLikes: BranchLike[]) { } } -export function getBranchLikeQuery(branchLike?: BranchLike): BranchParameters { +export function getBranchLikeQuery(branchLike?: T.BranchLike): T.BranchParameters { if (isShortLivingBranch(branchLike) || isLongLivingBranch(branchLike)) { return { branch: branchLike.name }; } else if (isPullRequest(branchLike)) { @@ -173,16 +161,16 @@ export function getBranchLikeQuery(branchLike?: BranchLike): BranchParameters { export function fillBranchLike( branch?: string, pullRequest?: string -): ShortLivingBranch | PullRequest | undefined { +): T.ShortLivingBranch | T.PullRequest | undefined { if (branch) { return { isMain: false, mergeBranch: '', name: branch, - type: BranchType.SHORT - } as ShortLivingBranch; + type: 'SHORT' + } as T.ShortLivingBranch; } else if (pullRequest) { - return { base: '', branch: '', key: pullRequest, title: '' } as PullRequest; + return { base: '', branch: '', key: pullRequest, title: '' } as T.PullRequest; } return undefined; } diff --git a/server/sonar-web/src/main/js/helpers/constants.ts b/server/sonar-web/src/main/js/helpers/constants.ts index 44cf06ffd8f..a4a4b8dec71 100644 --- a/server/sonar-web/src/main/js/helpers/constants.ts +++ b/server/sonar-web/src/main/js/helpers/constants.ts @@ -18,21 +18,21 @@ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ import * as theme from '../app/theme'; -import { RuleType, IssueType } from '../app/types'; export const SEVERITIES = ['BLOCKER', 'CRITICAL', 'MAJOR', 'MINOR', 'INFO']; export const STATUSES = ['OPEN', 'REOPENED', 'CONFIRMED', 'RESOLVED', 'CLOSED']; -export const ISSUE_TYPES = [ - IssueType.Bug, - IssueType.Vulnerability, - IssueType.CodeSmell, - IssueType.Hotspot +export const ISSUE_TYPES: T.IssueType[] = [ + 'BUG', + 'VULNERABILITY', + 'CODE_SMELL', + 'SECURITY_HOTSPOT' ]; -export const RULE_TYPES = [ - RuleType.Bug, - RuleType.Vulnerability, - RuleType.CodeSmell, - RuleType.Hotspot +export const RULE_TYPES: T.RuleType[] = [ + 'BUG', + 'VULNERABILITY', + 'CODE_SMELL', + 'SECURITY_HOTSPOT', + 'UNKNOWN' ]; export const RULE_STATUSES = ['READY', 'BETA', 'DEPRECATED']; diff --git a/server/sonar-web/src/main/js/helpers/issues.ts b/server/sonar-web/src/main/js/helpers/issues.ts index 1842d50738a..d92db831e8a 100644 --- a/server/sonar-web/src/main/js/helpers/issues.ts +++ b/server/sonar-web/src/main/js/helpers/issues.ts @@ -19,7 +19,6 @@ */ import { flatten, sortBy } from 'lodash'; import { SEVERITIES } from './constants'; -import { Issue, FlowLocation, TextRange, Omit } from '../app/types'; interface Comment { login: string; @@ -49,7 +48,7 @@ export interface RawIssue extends IssueBase { component: string; flows?: Array<{ // `componentName` is not available in RawIssue - locations?: Array<Omit<FlowLocation, 'componentName'>>; + locations?: Array<T.Omit<T.FlowLocation, 'componentName'>>; }>; key: string; line?: number; @@ -57,10 +56,10 @@ export interface RawIssue extends IssueBase { rule: string; status: string; subProject?: string; - textRange?: TextRange; + textRange?: T.TextRange; } -export function sortBySeverity(issues: Issue[]): Issue[] { +export function sortBySeverity(issues: T.Issue[]): T.Issue[] { return sortBy(issues, issue => SEVERITIES.indexOf(issue.severity)); } @@ -100,15 +99,15 @@ function injectCommentsRelational(issue: RawIssue, users?: User[]) { function prepareClosed( issue: RawIssue, - secondaryLocations: FlowLocation[], - flows: FlowLocation[][] + secondaryLocations: T.FlowLocation[], + flows: T.FlowLocation[][] ) { return issue.status === 'CLOSED' ? { flows: [], line: undefined, textRange: undefined, secondaryLocations: [] } : { flows, secondaryLocations }; } -function ensureTextRange(issue: RawIssue): { textRange?: TextRange } { +function ensureTextRange(issue: RawIssue): { textRange?: T.TextRange } { return issue.line && !issue.textRange ? { textRange: { @@ -121,7 +120,7 @@ function ensureTextRange(issue: RawIssue): { textRange?: TextRange } { : {}; } -function reverseLocations(locations: FlowLocation[]): FlowLocation[] { +function reverseLocations(locations: T.FlowLocation[]): T.FlowLocation[] { const x = [...locations]; x.reverse(); return x; @@ -130,8 +129,8 @@ function reverseLocations(locations: FlowLocation[]): FlowLocation[] { function splitFlows( issue: RawIssue, components: Component[] = [] -): { secondaryLocations: FlowLocation[]; flows: FlowLocation[][] } { - const parsedFlows: FlowLocation[][] = (issue.flows || []) +): { secondaryLocations: T.FlowLocation[]; flows: T.FlowLocation[][] } { + const parsedFlows: T.FlowLocation[][] = (issue.flows || []) .filter(flow => flow.locations !== undefined) .map(flow => flow.locations!.filter(location => location.textRange != null)) .map(flow => @@ -148,7 +147,7 @@ function splitFlows( : { secondaryLocations: [], flows: parsedFlows.map(reverseLocations) }; } -function orderLocations(locations: FlowLocation[]) { +function orderLocations(locations: T.FlowLocation[]) { return sortBy( locations, location => location.textRange && location.textRange.startLine, @@ -161,7 +160,7 @@ export function parseIssueFromResponse( components?: Component[], users?: User[], rules?: Rule[] -): Issue { +): T.Issue { const { secondaryLocations, flows } = splitFlows(issue, components); return { ...issue, @@ -173,5 +172,5 @@ export function parseIssueFromResponse( ...injectCommentsRelational(issue, users), ...prepareClosed(issue, secondaryLocations, flows), ...ensureTextRange(issue) - } as Issue; + } as T.Issue; } diff --git a/server/sonar-web/src/main/js/helpers/measures.ts b/server/sonar-web/src/main/js/helpers/measures.ts index 78256f28078..44f2bee718c 100644 --- a/server/sonar-web/src/main/js/helpers/measures.ts +++ b/server/sonar-web/src/main/js/helpers/measures.ts @@ -18,7 +18,6 @@ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ import { translate, translateWithParameters, getCurrentLocale } from './l10n'; -import { Metric, Measure, MeasureEnhanced } from '../app/types'; const HOURS_IN_DAY = 8; @@ -52,18 +51,18 @@ export function getShortType(type: string): string { } export function enhanceMeasuresWithMetrics( - measures: Measure[], - metrics: Metric[] -): MeasureEnhanced[] { + measures: T.Measure[], + metrics: T.Metric[] +): T.MeasureEnhanced[] { return measures.map(measure => { - const metric = metrics.find(metric => metric.key === measure.metric) as Metric; + const metric = metrics.find(metric => metric.key === measure.metric) as T.Metric; return { ...measure, metric }; }); } /** Get period value of a measure */ export function getPeriodValue( - measure: Measure | MeasureEnhanced, + measure: T.Measure | T.MeasureEnhanced, periodIndex: number ): string | undefined { const { periods } = measure; @@ -72,7 +71,7 @@ export function getPeriodValue( } export function isPeriodBestValue( - measure: Measure | MeasureEnhanced, + measure: T.Measure | T.MeasureEnhanced, periodIndex: number ): boolean { const { periods } = measure; @@ -356,6 +355,6 @@ export function getRatingTooltip(metricKey: string, value: number | string): str : translate('metric', finalMetricKey, 'tooltip', ratingLetter); } -export function getDisplayMetrics(metrics: Metric[]) { +export function getDisplayMetrics(metrics: T.Metric[]) { return metrics.filter(metric => !metric.hidden && !['DATA', 'DISTRIB'].includes(metric.type)); } diff --git a/server/sonar-web/src/main/js/helpers/organizations.ts b/server/sonar-web/src/main/js/helpers/organizations.ts index 81852dd8776..6f124a53fbc 100644 --- a/server/sonar-web/src/main/js/helpers/organizations.ts +++ b/server/sonar-web/src/main/js/helpers/organizations.ts @@ -18,16 +18,15 @@ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ import { isLoggedIn } from './users'; -import { Organization, OrganizationSubscription, CurrentUser } from '../app/types'; -export function isPaidOrganization(organization: Organization | undefined): boolean { - return Boolean(organization && organization.subscription === OrganizationSubscription.Paid); +export function isPaidOrganization(organization: T.Organization | undefined): boolean { + return Boolean(organization && organization.subscription === 'PAID'); } export function hasPrivateAccess( - currentUser: CurrentUser, - organization: Organization | undefined, - userOrganizations: Organization[] + currentUser: T.CurrentUser, + organization: T.Organization | undefined, + userOrganizations: T.Organization[] ): boolean { return ( !isPaidOrganization(organization) || @@ -36,9 +35,9 @@ export function hasPrivateAccess( } export function isCurrentUserMemberOf( - currentUser: CurrentUser, - organization: Organization | undefined, - userOrganizations: Organization[] + currentUser: T.CurrentUser, + organization: T.Organization | undefined, + userOrganizations: T.Organization[] ): boolean { return Boolean( organization && diff --git a/server/sonar-web/src/main/js/helpers/periods.ts b/server/sonar-web/src/main/js/helpers/periods.ts index baa0651439d..bce39948602 100644 --- a/server/sonar-web/src/main/js/helpers/periods.ts +++ b/server/sonar-web/src/main/js/helpers/periods.ts @@ -19,21 +19,20 @@ */ import { translate, translateWithParameters } from './l10n'; import { parseDate } from './dates'; -import { Period, PeriodMode, PeriodMeasure } from '../app/types'; -function getPeriod<T extends Period | PeriodMeasure>(periods: T[] | undefined, index: number) { +function getPeriod<T extends T.Period | T.PeriodMeasure>(periods: T[] | undefined, index: number) { if (!Array.isArray(periods)) { return undefined; } return periods.find(period => period.index === index); } -export function getLeakPeriod<T extends Period | PeriodMeasure>(periods: T[] | undefined) { +export function getLeakPeriod<T extends T.Period | T.PeriodMeasure>(periods: T[] | undefined) { return getPeriod(periods, 1); } export function getPeriodLabel( - period: Period | undefined, + period: T.Period | undefined, dateFormatter: (date: string) => string ) { if (!period) { @@ -41,11 +40,11 @@ export function getPeriodLabel( } let parameter = period.modeParam || period.parameter; - if (period.mode === PeriodMode.PreviousVersion && !parameter) { + if (period.mode === 'previous_version' && !parameter) { return translate('overview.period.previous_version_only_date'); } - if (period.mode === PeriodMode.Date && parameter) { + if (period.mode === 'date' && parameter) { parameter = dateFormatter(parameter); } diff --git a/server/sonar-web/src/main/js/helpers/urls.ts b/server/sonar-web/src/main/js/helpers/urls.ts index 8a1349419c3..c8c7db886a5 100644 --- a/server/sonar-web/src/main/js/helpers/urls.ts +++ b/server/sonar-web/src/main/js/helpers/urls.ts @@ -26,7 +26,6 @@ import { getBranchLikeQuery } from './branches'; import { getProfilePath } from '../apps/quality-profiles/utils'; -import { BranchLike, HomePage, HomePageType } from '../app/types'; interface Query { [x: string]: string | undefined; @@ -65,7 +64,7 @@ export function getComponentBackgroundTaskUrl(componentKey: string, status?: str return { pathname: '/project/background_tasks', query: { id: componentKey, status } }; } -export function getBranchLikeUrl(project: string, branchLike?: BranchLike): Location { +export function getBranchLikeUrl(project: string, branchLike?: T.BranchLike): Location { if (isPullRequest(branchLike)) { return getPullRequestUrl(project, branchLike.key); } else if (isShortLivingBranch(branchLike)) { @@ -110,7 +109,7 @@ export function getComponentIssuesUrl(componentKey: string, query?: Query): Loca export function getComponentDrilldownUrl(options: { componentKey: string; metric: string; - branchLike?: BranchLike; + branchLike?: T.BranchLike; selectionKey?: string; treemapView?: boolean; }): Location { @@ -129,7 +128,7 @@ export function getComponentDrilldownUrlWithSelection( componentKey: string, selectionKey: string, metric: string, - branchLike?: BranchLike + branchLike?: T.BranchLike ): Location { return getComponentDrilldownUrl({ componentKey, selectionKey, metric, branchLike }); } @@ -138,7 +137,7 @@ export function getMeasureTreemapUrl(componentKey: string, metric: string) { return getComponentDrilldownUrl({ componentKey, metric, treemapView: true }); } -export function getActivityUrl(component: string, branchLike?: BranchLike) { +export function getActivityUrl(component: string, branchLike?: T.BranchLike) { return { pathname: '/project/activity', query: { id: component, ...getBranchLikeQuery(branchLike) } @@ -148,7 +147,7 @@ export function getActivityUrl(component: string, branchLike?: BranchLike) { /** * Generate URL for a component's measure history */ -export function getMeasureHistoryUrl(component: string, metric: string, branchLike?: BranchLike) { +export function getMeasureHistoryUrl(component: string, metric: string, branchLike?: T.BranchLike) { return { pathname: '/project/activity', query: { @@ -218,7 +217,7 @@ export function getMarkdownHelpUrl(): string { return getBaseUrl() + '/markdown/help'; } -export function getCodeUrl(project: string, branchLike?: BranchLike, selected?: string) { +export function getCodeUrl(project: string, branchLike?: T.BranchLike, selected?: string) { return { pathname: '/code', query: { id: project, ...getBranchLikeQuery(branchLike), selected } }; } @@ -226,26 +225,26 @@ export function getOrganizationUrl(organization: string) { return `/organizations/${organization}`; } -export function getHomePageUrl(homepage: HomePage) { +export function getHomePageUrl(homepage: T.HomePage) { switch (homepage.type) { - case HomePageType.Application: + case 'APPLICATION': return homepage.branch ? getProjectUrl(homepage.component, homepage.branch) : getProjectUrl(homepage.component); - case HomePageType.Project: + case 'PROJECT': return homepage.branch ? getLongLivingBranchUrl(homepage.component, homepage.branch) : getProjectUrl(homepage.component); - case HomePageType.Organization: + case 'ORGANIZATION': return getOrganizationUrl(homepage.organization); - case HomePageType.Portfolio: + case 'PORTFOLIO': return getPortfolioUrl(homepage.component); - case HomePageType.Portfolios: + case 'PORTFOLIOS': return '/portfolios'; - case HomePageType.MyProjects: + case 'MY_PROJECTS': return '/projects'; - case HomePageType.Issues: - case HomePageType.MyIssues: + case 'ISSUES': + case 'MY_ISSUES': return { pathname: '/issues', query: { resolved: 'false' } }; } diff --git a/server/sonar-web/src/main/js/helpers/users.ts b/server/sonar-web/src/main/js/helpers/users.ts index 77968f08e3f..3fb6a77a198 100644 --- a/server/sonar-web/src/main/js/helpers/users.ts +++ b/server/sonar-web/src/main/js/helpers/users.ts @@ -17,15 +17,13 @@ * along with this program; if not, write to the Free Software Foundation, * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ -import { CurrentUser, LoggedInUser } from '../app/types'; - -export function hasGlobalPermission(user: CurrentUser, permission: string): boolean { +export function hasGlobalPermission(user: T.CurrentUser, permission: string): boolean { if (!user.permissions) { return false; } return user.permissions.global.includes(permission); } -export function isLoggedIn(user: CurrentUser): user is LoggedInUser { +export function isLoggedIn(user: T.CurrentUser): user is T.LoggedInUser { return user.isLoggedIn; } |