Files
speckle-server/packages/frontend-2/lib/common/helpers/resources.ts
T
Kristaps Fabians Geikins 6af6c656a4 feat(fe2): app authorization workflow redesign [WBX-217] (#2044)
* WIP

* new permissions table

* permissions grouped

* updated scope descriptions

* more scope copy adjustments

* allow auth error handling

* manually closable toast notification

* fixed mentions rendering

* error view

* not you? feature

* cleanup

* minor styling changes

* WIP table

* finished authorized apps table

* minor cleanup

* cleaning up comment

* testing changes
2024-02-23 16:50:07 +02:00

35 lines
1.1 KiB
TypeScript

const streamRewriteRgx = /stream(?=$|s|\W)/gi
const branchRewriteRgx = /branch(es)?(?=$|\W)/gi
const commitRewriteRgx = /commit(?=$|s|\W)/gi
export function isObjectId(id: string) {
return id.length === 32
}
export const buildModelTreeItemId = (projectId: string, fullName: string) =>
`${projectId}-${fullName}`
/**
* Converts old terminology (streams, branches, commits, etc.) to new one (projects, models, versions)
*/
export const toNewProductTerminology = (str: string): string => {
const isFirstCharUppercase = (val: string): boolean =>
val?.length ? val[0] === val[0].toUpperCase() : false
return str
.replaceAll(streamRewriteRgx, (match) =>
isFirstCharUppercase(match) ? 'Project' : 'project'
)
.replaceAll(branchRewriteRgx, (match) => {
const shouldBeUppercase = isFirstCharUppercase(match)
if (match === 'branches') {
return shouldBeUppercase ? 'Models' : 'models'
} else {
return shouldBeUppercase ? 'Model' : 'model'
}
})
.replaceAll(commitRewriteRgx, (match) =>
isFirstCharUppercase(match) ? 'Version' : 'version'
)
}