Skip to content

Commit

Permalink
refactor: 🔧 update ES module or lib to benefit from latest array func…
Browse files Browse the repository at this point in the history
…tions
  • Loading branch information
clairenollet committed Oct 31, 2023
1 parent 7b9ef4b commit 6faacae
Show file tree
Hide file tree
Showing 13 changed files with 27 additions and 25 deletions.
2 changes: 1 addition & 1 deletion apps/client/.eslintrc.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
"vue/setup-compiler-macros": true,
"cypress/globals": true,
"browser": true,
"es2022": true
"es2023": true
},
"rules": {
"vue/no-v-html": 0,
Expand Down
12 changes: 8 additions & 4 deletions apps/client/jsconfig.json
Original file line number Diff line number Diff line change
@@ -1,14 +1,18 @@
{
"compilerOptions": {
"module": "esnext",
"target": "esnext",
"module": "ESNext",
"target": "ESNext",
"baseUrl": ".",
"paths": {
"@/*": ["./src/*"]
"@/*": [
"./src/*"
]
},
"moduleResolution": "node",
"sourceMap": true,
"jsx": "preserve",
},
"exclude": ["node_modules"]
"exclude": [
"node_modules"
]
}
12 changes: 5 additions & 7 deletions apps/client/src/components/PermissionForm.vue
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
<script lang="ts" setup>
import { ref, onMounted, watch, computed } from 'vue'
import { ref, onMounted, watch, computed, type Ref } from 'vue'
import SuggestionInput from './SuggestionInput.vue'
import RangeInput from './RangeInput.vue'
import { levels, projectIsLockedInfo, type PermissionModel } from '@dso-console/shared'
import { levels, projectIsLockedInfo, type PermissionModel, type EnvironmentModel } from '@dso-console/shared'
import { useProjectStore } from '@/stores/project.js'
import { useProjectPermissionStore } from '@/stores/project-permission.js'
import { useUserStore } from '@/stores/user.js'
Expand All @@ -20,7 +20,7 @@ const projectStore = useProjectStore()
const projectPermissionStore = useProjectPermissionStore()
const userStore = useUserStore()
const snackbarStore = useSnackbarStore()
const environment = ref(props.environment)
const environment: Ref<EnvironmentModel | Record<string, any> | undefined> = ref(props.environment)
const permissions = ref([])
const permissionToUpdate = ref({})
const userToLicence = ref('')
Expand All @@ -40,9 +40,7 @@ const usersToLicence = computed(() =>
const suggestions = computed(() => usersToLicence.value?.map(user => user.email))
const setPermissions = () => {
// TODO: (#536) change 'sort' to 'toSorted' with Nodejs v20
// @ts-ignore
permissions.value = environment.value.permissions.sort((a, b) => a.user?.email >= b.user?.email ? 1 : -1)
permissions.value = environment.value?.permissions?.toSorted((a: PermissionModel, b: PermissionModel) => a?.user?.email >= b?.user?.email ? 1 : -1)
}
const addPermission = async (userEmail: string) => {
Expand Down Expand Up @@ -91,7 +89,7 @@ const getDynamicTitle = (locked: boolean, permission: PermissionModel) => {
watch(project, () => {
environment.value = project.value?.environments?.find(env =>
env.id === environment.value.id,
env.id === environment.value?.id,
)
setPermissions()
})
Expand Down
1 change: 1 addition & 0 deletions apps/client/src/views/admin/ListClusters.vue
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,7 @@ const updateCluster = async (cluster) => {
const removeCluster = async (clusterId) => {
isUpdatingCluster.value = true
try {
console.log({ clusterId })
// await adminClusterStore.removeCluster(clusterId)
await adminClusterStore.getAllClusters()
} catch (error) {
Expand Down
2 changes: 1 addition & 1 deletion apps/client/tsconfig.app.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
],
"compilerOptions": {
"allowJs": true,
"module": "ES2022",
"module": "ESNext",
"composite": true,
"baseUrl": ".",
"paths": {
Expand Down
2 changes: 1 addition & 1 deletion apps/client/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
],
"files": [],
"compilerOptions": {
"module": "ES2022"
"module": "ESNext"
},
"references": [
{
Expand Down
2 changes: 1 addition & 1 deletion apps/client/vite.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,6 @@ export default defineConfig({
dedupe: ['vue', 'oh-vue-icons'],
},
build: {
target: 'esnext',
target: 'ESNext',
},
})
4 changes: 3 additions & 1 deletion packages/shared/src/resources/environment/model.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { projectStatus } from '../../utils/index.js'
import { ClusterModel } from '../cluster/model.js'
import { PermissionModel } from '../permission/model.js'
import { ProjectModel } from '../project/index.js'

export type EnvironmentModel = {
Expand All @@ -8,5 +9,6 @@ export type EnvironmentModel = {
projectId: ProjectModel['id']
quotaStageId: string,
clusterId: ClusterModel['id'],
status: typeof projectStatus[number]
status: typeof projectStatus[number],
permissions?: PermissionModel[],
}
1 change: 1 addition & 0 deletions packages/shared/src/resources/permission/model.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,5 @@ export type PermissionModel = {
userId: UserModel['id']
environmentId: EnvironmentModel['id']
level: number
user?: UserModel
}
6 changes: 1 addition & 5 deletions packages/shared/src/utils/functions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,8 @@ export const calcProjectNameMaxLength = (organizationName: string) => {
}

export const getUniqueListBy = (arr, key) => [...new Map(arr.map(item => [item[key], item])).values()]
interface Keyable {
[key: string]: any
}

// TODO: (#536) change 'sort' to 'toSorted' with Nodejs v20
export const sortArrByObjKeyAsc = (arr: Array<Keyable>, key: string) => arr?.slice()?.sort((a: object, b: object) => a[key] >= b[key] ? 1 : -1)
export const sortArrByObjKeyAsc = (arr: Record<string, unknown>[], key: string) => arr?.toSorted((a: object, b: object) => a[key] >= b[key] ? 1 : -1)

export const removeTrailingSlash = (url: string) => url?.endsWith('/')
? url?.slice(0, -1)
Expand Down
2 changes: 1 addition & 1 deletion packages/shared/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
"declaration": true,
"declarationDir": "./types",
"lib": [
"ES2020"
"ESNext"
]
}
}
2 changes: 1 addition & 1 deletion packages/test-utils/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
"declaration": true,
"declarationDir": "./types",
"lib": [
"ES2020"
"ESNext"
]
}
}
4 changes: 2 additions & 2 deletions packages/tsconfig/tsconfig.base.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
// "disableSolutionSearching": true, /* Opt a project out of multi-project reference checking when editing. */
// "disableReferencedProjectLoad": true, /* Reduce the number of projects loaded automatically by TypeScript. */
/* Language and Environment */
"target": "ES2022", /* Set the JavaScript language version for emitted JavaScript and include compatible library declarations. */
"target": "ESNext", /* Set the JavaScript language version for emitted JavaScript and include compatible library declarations. */
// "lib": [], /* Specify a set of bundled library declaration files that describe the target runtime environment. */
// "jsx": "preserve", /* Specify what JSX code is generated. */
// "experimentalDecorators": true, /* Enable experimental support for TC39 stage 2 draft decorators. */
Expand All @@ -21,7 +21,7 @@
// "noLib": true, /* Disable including any library files, including the default lib.d.ts. */
// "useDefineForClassFields": true, /* Emit ECMAScript-standard-compliant class fields. */
/* Modules */
"module": "ES2022", /* Specify what module code is generated. */
"module": "ESNext", /* Specify what module code is generated. */
"rootDir": "./src", /* Specify the root folder within your source files. */
"moduleResolution": "node", /* Specify how TypeScript looks up a file from a given module specifier. */
// "rootDirs": [], /* Allow multiple folders to be treated as one when resolving modules. */
Expand Down

0 comments on commit 6faacae

Please sign in to comment.