- How to Configure an NPM Package?
- How to Implement Asset Picker?
- How to Implement Asset Check-In?
- How to Implement Collection Browse?
- How to Create a Custom Search Tool?
- How to Filter Files in Asset Picker Dialog Based on Content Types?
- How to Browse Files in Collections in Your Custom Plugin?
- How to Hide/Disable Top-Bar Menu Actions from Workspace?
How to Configure an NPM Package?
Prerequisites
Software
- Angular CLI 19.2.14
- Node 22.12.0
NPM Configuration
An npm package gets its config settings from the command line, environment variables, and npmrc files.
A .npmrc file in the root of a project (a sibling of node_modules and package.json) sets config values specific to the project. So, before you install QWC & PWC, create a .npmrc file in the root folder of an app and paste the following code into the file:
@quark:registry=https://qrk.pkgs.visualstudio.com/0fe979d5-4bc4-4a46-9db2-f0a80d796161/_packaging/qppng/npm/registry/
@quark:always-auth=true
Setup Credentials
- To access Quark artifacts, create a .npmrc file in the directory C:\Users<user_name> and copy the code below to the user .npmrc file.
; begin auth token
//qrk.pkgs.visualstudio.com/0fe979d5-4bc4-4a46-9db2-f0a80d796161/_packaging/qppng/npm/registry/:username=qrk
//qrk.pkgs.visualstudio.com/0fe979d5-4bc4-4a46-9db2-f0a80d796161/_packaging/qppng/npm/registry/:_password=[BASE64_ENCODED_PERSONAL_ACCESS_TOKEN]
//qrk.pkgs.visualstudio.com/0fe979d5-4bc4-4a46-9db2-f0a80d796161/_packaging/qppng/npm/registry/:email=npm requires email to be set but doesn't use the value
//qrk.pkgs.visualstudio.com/0fe979d5-4bc4-4a46-9db2-f0a80d796161/_packaging/qppng/npm/:username=qrk
//qrk.pkgs.visualstudio.com/0fe979d5-4bc4-4a46-9db2-f0a80d796161/_packaging/qppng/npm/:_password=[BASE64_ENCODED_PERSONAL_ACCESS_TOKEN]
//qrk.pkgs.visualstudio.com/0fe979d5-4bc4-4a46-9db2-f0a80d796161/_packaging/qppng/npm/:email=npm requires email to be set but doesn't use the value
; end auth token
- Generate Base64 encoded personal access token:
- From command/shell prompt run:
node -e "require('readline') .createInterface({input:process.stdin,output:process.stdout,historySize:0}) .question('PAT> ',p => { b64=Buffer.from(p.trim()).toString('base64');console.log(b64);process.exit(); })" - Paste your personal access token value and press Enter/Return.
- Copy the Base64 encoded value.
- From command/shell prompt run:
- Replace both [BASE64_ENCODED_PERSONAL_ACCESS_TOKEN] values in the .npmrc file with your Base64 encoded value from Step 2.
Prerequisites
Make sure you’re using Yarn version 1.22.19.
To check your version, run the following command:
yarn --version
Install Dependencies
Navigate to your project directory and install all base dependencies:
cd PROJECT-NAME
yarn install
Install QWC and PWC
To install QWC and PWC, run the following commands:
$ cd PROJECT-NAME
$ yarn add @quark/qwc
$ yarn add @quark/platform-components-ng
Add Styles
If you are using Angular CLI, add the following files in the global styles.scss file:
@import ../node_modules/@quark/qwc/styles/qwc;
@import ../node_modules/@quark/qwc/styles/fonts.css;
@import ../node_modules/@quark/platform-components-ng/styles/_ui-components;
@import ../node_modules/@quark/platform-components-ng/styles/icon-assets.css;
If you are not using Angular CLI, add the files to your build tooling or include files via elements in the index.html.
Import QWC and PWC Modules
After you have installed QWC and PWC, import the modules to your application module file (app.module.ts). You should get a code similar to the following:
import { SomeModule } from '...';
import { QwcModule } from "@quark/qwc";
import { UserComponentsModule, CollectionComponentsModule, AccessControlComponentsModule, FormComponentsModule, ContentTypesComponentsModule, WorkflowsModule, QuickSearchComponentsModule, ErrorModule, PublishingModule, QueryService, AuthService, AttributeComponentModule, BackgroundTasksModule } from "@quark/platform-components-ng";
@NgModule({
imports: [..., QwcModule, UserComponentsModule, CollectionComponentsModule, AccessControlComponentsModule, FormComponentsModule, ContentTypesComponentsModule, WorkflowsModule, QuickSearchComponentsModule, ErrorModule, PublishingModule, QueryService, AuthService, AttributeComponentModule, BackgroundTasksModule],
declarations: [AppComponent, ...],
bootstrap: [AppComponent],
})
export class AppModule {}
You do not have to include all the modules from the platform-components-ng library. Import modules based on the uses cased of your application.
Include CUSTOM_ELEMENTS_SCHEMA
To allow an NgModule to contain non-Angular elements with dash case or element properties named with dash case, you need to import CUSTOM_ELEMENTS_SCHEMA. To import CUSTOM_ELEMENTS_SCHEMA, add the following code to the file app.module.ts:
import {CUSTOM_ELEMENTS_SCHEMA } from '@angular/core';
@NgModule({
schemas: [ CUSTOM_ELEMENTS_SCHEMA ]
})
export class AppModule {}
Develop and Debug
Use the following command to run your project:
$ ng serve --open