Skip to content

Commit

Permalink
Prettier format on src and tests directories
Browse files Browse the repository at this point in the history
  • Loading branch information
kyle1morel committed Oct 25, 2023
1 parent 74d4601 commit 7b5bb13
Show file tree
Hide file tree
Showing 114 changed files with 1,143 additions and 1,316 deletions.
3 changes: 1 addition & 2 deletions app/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,8 @@
"clean": "rimraf coverage dist",
"clean:all": "npm run clean && ts-node ./frontend-utils.ts clean",
"debug": "ts-node-dev --debug --respawn --transpile-only --rs --watch bin,config,dist ./bin/www",
"format": "npx prettier ./src --write",
"format": "prettier ./src --write",
"lint": "eslint . **/www* --no-fix --ext .js,.jsx,.cjs,.mjs,.ts,.tsx,.cts,.mts --ignore-path .gitignore",
"lint:fix": "eslint . **/www* --fix --ext .js,.jsx,.cjs,.mjs,.ts,.tsx,.cts,.mts --ignore-path .gitignore",
"prelint": "npm run typecheck",
"pretest": "npm run lint",
"posttest": "ts-node ./lcov-fix.ts",
Expand Down
14 changes: 8 additions & 6 deletions app/src/components/log.ts
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ const log = createLogger({
format: format.combine(
format.errors({ stack: true }), // Force errors to show stacktrace
format.timestamp(), // Add ISO timestamp to each entry
format.json(), // Force output to be in JSON format
format.json() // Force output to be in JSON format
),
level: config.get('server.logLevel')
});
Expand All @@ -51,10 +51,12 @@ if (process.env.NODE_ENV !== 'test') {
}

if (config.has('server.logFile')) {
log.add(new transports.File({
filename: config.get('server.logFile'),
handleExceptions: true
}));
log.add(
new transports.File({
filename: config.get('server.logFile'),
handleExceptions: true
})
);
}

/**
Expand Down Expand Up @@ -98,7 +100,7 @@ export const httpLogger = logger({
responseWhitelist: [], // Suppress default value output
// Skip logging kube-probe requests
skip: (req) => !!req.get('user-agent')?.includes('kube-probe'),
winstonInstance: log,
winstonInstance: log
});

export default getLogger;
10 changes: 6 additions & 4 deletions app/tests/common/helper.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,11 @@ const helper = {
const app = express();

app.use(express.json());
app.use(express.urlencoded({
extended: false
}));
app.use(
express.urlencoded({
extended: false
})
);
app.use(basePath, router);

// Handle 500
Expand All @@ -32,7 +34,7 @@ const helper = {
err.send(res);
} else {
new Problem(500, {
details: (err.message) ? err.message : err
details: err.message ? err.message : err
}).send(res);
}
});
Expand Down
3 changes: 1 addition & 2 deletions frontend/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,8 @@
"build:dts": "vue-tsc --declaration --emitDeclarationOnly",
"clean": "rimraf coverage dist",
"debug": "vite --mode debug",
"format": "npx prettier ./src --write",
"format": "prettier ./src --write",
"lint": "eslint . --ext .vue,.js,.jsx,.cjs,.mjs,.ts,.tsx,.cts,.mts --no-fix --ignore-path .gitignore",
"lint:fix": "eslint . --ext .vue,.js,.jsx,.cjs,.mjs,.ts,.tsx,.cts,.mts --fix --ignore-path .gitignore",
"preview": "vite preview",
"prebuild": "npm run lint",
"prelint": "npm run typecheck",
Expand Down
2 changes: 1 addition & 1 deletion frontend/src/App.vue
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ onBeforeMount(async () => {
window.addEventListener('beforeunload', preventNav);
});
onBeforeUnmount( () => {
onBeforeUnmount(() => {
window.removeEventListener('beforeunload', preventNav);
});
Expand Down
18 changes: 16 additions & 2 deletions frontend/src/assets/base.css
Original file line number Diff line number Diff line change
Expand Up @@ -62,9 +62,23 @@ body {
min-height: 100vh;
color: var(--color-text);
background: var(--color-background);
transition: color 0.5s, background-color 0.5s;
transition:
color 0.5s,
background-color 0.5s;
line-height: 1.6;
font-family: BCSans, Inter, -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, 'Fira Sans', 'Droid Sans', 'Helvetica Neue',
font-family:
BCSans,
Inter,
-apple-system,
BlinkMacSystemFont,
'Segoe UI',
Roboto,
Oxygen,
Ubuntu,
Cantarell,
'Fira Sans',
'Droid Sans',
'Helvetica Neue',
sans-serif;
text-rendering: optimizeLegibility;
-webkit-font-smoothing: antialiased;
Expand Down
8 changes: 4 additions & 4 deletions frontend/src/assets/main.scss
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
@import "./base.css";
@import "./primevue.scss";
@import "./variables.scss";
@import './base.css';
@import './primevue.scss';
@import './variables.scss';

#app {
margin: 0 auto;
Expand Down Expand Up @@ -175,7 +175,7 @@ td .wrap-block {
}

.versions-table .p-datatable-table tbody tr:not(.selected-row) {
&:hover{
&:hover {
background-color: $bcbox-highlight-background !important;
cursor: pointer;
}
Expand Down
24 changes: 10 additions & 14 deletions frontend/src/assets/primevue.scss
Original file line number Diff line number Diff line change
Expand Up @@ -63,22 +63,14 @@
// Note this could be eventually replaced by a custom themeing (which has JUST been introduced in Primevue)
// once it is more settled implementation-wise
.p-button {
&:not(
.p-button-secondary,
.p-button-success,
.p-button-info,
.p-button-warning,
.p-button-help,
.p-button-danger
) {
&:not(.p-button-secondary, .p-button-success, .p-button-info, .p-button-warning, .p-button-help, .p-button-danger) {
color: $bcbox-primary !important;

&:not(.p-button-outlined, .p-button-text) {
background-color: $bcbox-primary;
border-color: $bcbox-primary;
color: $bcbox-outline-on-primary !important;
}

}
}

Expand Down Expand Up @@ -112,14 +104,18 @@
}
}

.p-tag{
.p-tag {
background-color: $bcbox-primary;
font-size: 1rem;
padding: .25rem .75rem;
padding: 0.25rem 0.75rem;
font-weight: normal;
}

h1, h2, h3, h4, h5 {
font-weight: 600;
line-height: 1.2em;
h1,
h2,
h3,
h4,
h5 {
font-weight: 600;
line-height: 1.2em;
}
16 changes: 9 additions & 7 deletions frontend/src/components/bucket/BucketConfigForm.vue
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,10 @@ const schema = object({
bucket: string().max(255).required().label('Bucket'),
bucketName: string().max(255).required().label('Bucket name'),
endpoint: string().max(255).required().label('Endpoint'),
key: string().matches(/^[^\\]+$/, 'Sub-path must not contain backslashes').max(255).label('Key'),
key: string()
.matches(/^[^\\]+$/, 'Sub-path must not contain backslashes')
.max(255)
.label('Key'),
secretAccessKey: string().max(255).required().label('Secret Access Key')
});
Expand All @@ -66,17 +69,17 @@ const onSubmit = async (values: any) => {
bucket: values.bucket,
bucketName: values.bucketName,
endpoint: values.endpoint,
secretAccessKey: values.secretAccessKey,
secretAccessKey: values.secretAccessKey
} as Bucket;
// Only add key for new configurations
if( !props.bucket && values.key && joinPath(values.key)) {
if (!props.bucket && values.key && joinPath(values.key)) {
formBucket.key = joinPath(values.key);
}
props.bucket ?
await bucketStore.updateBucket(props.bucket?.bucketId, differential(formBucket, initialValues)) :
await bucketStore.createBucket(formBucket);
props.bucket
? await bucketStore.updateBucket(props.bucket?.bucketId, differential(formBucket, initialValues))
: await bucketStore.createBucket(formBucket);
await bucketStore.fetchBuckets({ userId: getUserId.value, objectPerms: true });
emit('submit-bucket-config');
Expand Down Expand Up @@ -157,7 +160,6 @@ const onCancel = () => {
</template>

<style lang="scss" scoped>
:deep(.p-inputtext) {
width: 100% !important;
}
Expand Down
12 changes: 7 additions & 5 deletions frontend/src/components/bucket/BucketList.vue
Original file line number Diff line number Diff line change
Expand Up @@ -90,17 +90,20 @@ onMounted(async () => {
</h3>

<Message severity="info">
Please contact <a
Please contact
<a
href="https://apps.nrs.gov.bc.ca/int/jira/servicedesk/customer/portal/1/create/701"
target="_blank"
>NRIDS Optimization</a>
>
NRIDS Optimization
</a>
(Natural Resource ministries) or your ministry's service desk if you need help with buckets.
</Message>

<Message severity="warn">
If you intend to share files in your bucket with BCeID users, you are required to email
<a href="mailto:[email protected]">[email protected]</a> to share your
BCeID-related intentions and where you intend to advertise this.
<a href="mailto:[email protected]">[email protected]</a>
to share your BCeID-related intentions and where you intend to advertise this.
</Message>

<BucketConfigForm
Expand Down Expand Up @@ -132,7 +135,6 @@ onMounted(async () => {
</template>

<style lang="scss" scoped>
button {
text-indent: 10px;
}
Expand Down
28 changes: 13 additions & 15 deletions frontend/src/components/bucket/BucketPermission.vue
Original file line number Diff line number Diff line change
Expand Up @@ -34,11 +34,10 @@ const cancelSearchUsers = () => {
};
const removeBucketUser = (userId: string) => {
const managers = getMappedBucketToUserPermissions.value.filter( (x: UserPermissions) => x.manage );
if( managers.length === 1 && managers[0].userId === userId ) {
const managers = getMappedBucketToUserPermissions.value.filter((x: UserPermissions) => x.manage);
if (managers.length === 1 && managers[0].userId === userId) {
removeManageAlert.show();
}
else {
} else {
permissionStore.removeBucketUser(props.bucketId, userId);
}
};
Expand All @@ -47,24 +46,24 @@ const updateBucketPermission = (value: boolean, userId: string, permCode: string
if (value) {
permissionStore.addBucketPermission(props.bucketId, userId, permCode);
} else {
const managers = getMappedBucketToUserPermissions.value.filter( (x: UserPermissions) => x.manage );
const managers = getMappedBucketToUserPermissions.value.filter((x: UserPermissions) => x.manage);
// Disallow removable of final MANAGE permission
if( permCode === Permissions.MANAGE && !managers.length ) {
if (permCode === Permissions.MANAGE && !managers.length) {
removeManageAlert.show();
// Set the value back as clicking will automatically change it
const perm: UserPermissions = getMappedBucketToUserPermissions.value
.find( (x: UserPermissions) => x.userId === userId ) as UserPermissions;
const perm: UserPermissions = getMappedBucketToUserPermissions.value.find(
(x: UserPermissions) => x.userId === userId
) as UserPermissions;
perm.manage = true;
}
else {
} else {
permissionStore.deleteBucketPermission(props.bucketId, userId, permCode);
}
}
};
onBeforeMount( async () => {
onBeforeMount(async () => {
await permissionStore.fetchBucketPermissions({ bucketId: props.bucketId });
await permissionStore.mapBucketToUserPermissions(props.bucketId);
});
Expand All @@ -80,13 +79,12 @@ onBeforeMount( async () => {
<font-awesome-icon
icon="fa-solid fa-user-plus"
class="mr-1"
/> Add user
/>
Add user
</Button>
</div>
<div v-else>
<BucketPermissionAddUser
@cancel-search-users="cancelSearchUsers"
/>
<BucketPermissionAddUser @cancel-search-users="cancelSearchUsers" />
</div>

<DataTable
Expand Down
35 changes: 12 additions & 23 deletions frontend/src/components/bucket/BucketSidebar.vue
Original file line number Diff line number Diff line change
Expand Up @@ -35,24 +35,23 @@ const closeSidebarInfo = async () => {
async function load() {
await permissionStore.fetchBucketPermissions({
bucketId: props.sidebarInfo.bucketId,
bucketId: props.sidebarInfo.bucketId
});
const uniqueIds = [
...new Set(
getBucketPermissions.value
.filter(
(x: BucketPermission) =>
x.bucketId === props.sidebarInfo.bucketId &&
x.permCode === Permissions.MANAGE
)
.filter((x: BucketPermission) => x.bucketId === props.sidebarInfo.bucketId && x.permCode === Permissions.MANAGE)
.map((x: BucketPermission) => x.userId)
),
)
];
if (uniqueIds.length) {
await userStore.fetchUsers({ userId: uniqueIds });
managedBy.value = userStore.findUsersById(uniqueIds).map( x => x.fullName ).join(', ');
managedBy.value = userStore
.findUsersById(uniqueIds)
.map((x) => x.fullName)
.join(', ');
}
}
Expand Down Expand Up @@ -87,37 +86,27 @@ watch(props, () => {
<div class="pl-2 sidebar">
<div class="grid details-grid grid-nogutter">
<div class="col-12">
<h2>
Properties
</h2>
<h2>Properties</h2>
</div>
<div class="grid overflow-hidden">
<div class="col-fixed">
Bucket Name:
</div>
<div class="col-fixed">Bucket Name:</div>
<div class="col wrap-block w-6">
{{ props.sidebarInfo?.bucketName }}
</div>
</div>
<div class="grid">
<div class="col-fixed">
Bucket ID:
</div>
<div class="col-fixed">Bucket ID:</div>
<div class="col">
{{ props.sidebarInfo?.bucketId }}
</div>
</div>
</div>
<div class="grid details-grid grid-nogutter">
<div class="col-12">
<h2>
Access
</h2>
<h2>Access</h2>
</div>
<div class="grid">
<div class="col-fixed">
Managed by:
</div>
<div class="col-fixed">Managed by:</div>
<div class="col">
{{ managedBy }}
</div>
Expand Down
Loading

0 comments on commit 7b5bb13

Please sign in to comment.