How to use workspaceRelativePath method in Playwright Internal

Best JavaScript code snippet using playwright-internal

CellModel.js

Source:CellModel.js Github

copy

Full Screen

1/*2 * Copyright 2007-2017 Charles du Jeu - Abstrium SAS <team (at) pyd.io>3 * This file is part of Pydio.4 *5 * Pydio is free software: you can redistribute it and/or modify6 * it under the terms of the GNU Affero General Public License as published by7 * the Free Software Foundation, either version 3 of the License, or8 * (at your option) any later version.9 *10 * Pydio is distributed in the hope that it will be useful,11 * but WITHOUT ANY WARRANTY; without even the implied warranty of12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the13 * GNU Affero General Public License for more details.14 *15 * You should have received a copy of the GNU Affero General Public License16 * along with Pydio. If not, see <http://www.gnu.org/licenses/>.17 *18 * The latest code can be found at <https://pydio.com>.19 */20'use strict';21exports.__esModule = true;22function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj }; }23function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError('Cannot call a class as a function'); } }24function _inherits(subClass, superClass) { if (typeof superClass !== 'function' && superClass !== null) { throw new TypeError('Super expression must either be null or a function, not ' + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; }25var _pydio = require('pydio');26var _pydio2 = _interopRequireDefault(_pydio);27var _httpPydioApi = require('../http/PydioApi');28var _httpPydioApi2 = _interopRequireDefault(_httpPydioApi);29var _langObservable = require('../lang/Observable');30var _langObservable2 = _interopRequireDefault(_langObservable);31var _utilPathUtils = require('../util/PathUtils');32var _utilPathUtils2 = _interopRequireDefault(_utilPathUtils);33var _IdmObjectHelper = require('./IdmObjectHelper');34var _IdmObjectHelper2 = _interopRequireDefault(_IdmObjectHelper);35var _httpGenIndex = require('../http/gen/index');36var CellModel = (function (_Observable) {37 _inherits(CellModel, _Observable);38 function CellModel() {39 var editMode = arguments.length <= 0 || arguments[0] === undefined ? false : arguments[0];40 _classCallCheck(this, CellModel);41 _Observable.call(this);42 // Create an empty room43 this.cell = new _httpGenIndex.RestCell();44 this.cell.Label = '';45 this.cell.Description = '';46 this.cell.ACLs = {};47 this.cell.RootNodes = [];48 this.cell.Policies = [];49 this.cell.PoliciesContextEditable = true;50 this._edit = editMode;51 }52 CellModel.prototype.isDirty = function isDirty() {53 return this.dirty;54 };55 CellModel.prototype.isEditable = function isEditable() {56 return this.cell.PoliciesContextEditable;57 };58 CellModel.prototype.getRootNodes = function getRootNodes() {59 return this.cell.RootNodes;60 };61 CellModel.prototype.notifyDirty = function notifyDirty() {62 this.dirty = true;63 this.notify('update');64 };65 CellModel.prototype.revertChanges = function revertChanges() {66 if (this.originalCell) {67 this.cell = this.clone(this.originalCell);68 this.dirty = false;69 this.notify('update');70 }71 };72 /**73 *74 * @param node {TreeNode}75 * @return string76 */77 CellModel.prototype.getNodeLabelInContext = function getNodeLabelInContext(node) {78 var _this = this;79 var path = node.Path;80 var label = _utilPathUtils2['default'].getBasename(path);81 if (node.MetaStore && node.MetaStore.selection) {82 return label;83 }84 if (node.MetaStore && node.MetaStore.CellNode) {85 return '[Cell Folder]';86 }87 if (node.AppearsIn && node.AppearsIn.length) {88 node.AppearsIn.map(function (workspaceRelativePath) {89 if (workspaceRelativePath.WsUuid !== _this.cell.Uuid) {90 label = '[' + workspaceRelativePath.WsLabel + '] ' + _utilPathUtils2['default'].getBasename(workspaceRelativePath.Path);91 }92 });93 }94 return label;95 };96 /**97 *98 * @return {string}99 */100 CellModel.prototype.getAclsSubjects = function getAclsSubjects() {101 var _this2 = this;102 return Object.keys(this.cell.ACLs).map(function (roleId) {103 var acl = _this2.cell.ACLs[roleId];104 return _IdmObjectHelper2['default'].extractLabel(_pydio2['default'].getInstance(), acl);105 }).join(', ');106 };107 /**108 * @return {Object.<String, module:model/RestCellAcl>}109 */110 CellModel.prototype.getAcls = function getAcls() {111 return this.cell.ACLs;112 };113 /**114 *115 * @param idmObject IdmUser|IdmRole116 */117 CellModel.prototype.addUser = function addUser(idmObject) {118 var acl = new _httpGenIndex.RestCellAcl();119 acl.RoleId = idmObject.Uuid;120 if (idmObject.Login !== undefined) {121 acl.IsUserRole = true;122 acl.User = idmObject;123 } else if (idmObject.IsGroup) {124 acl.Group = idmObject;125 } else {126 acl.Role = idmObject;127 }128 acl.Actions = [];129 var action = new _httpGenIndex.IdmACLAction();130 action.Name = 'read';131 action.Value = '1';132 acl.Actions.push(action);133 this.cell.ACLs[acl.RoleId] = acl;134 this.notifyDirty();135 };136 /**137 *138 * @param roleId string139 */140 CellModel.prototype.removeUser = function removeUser(roleId) {141 if (this.cell.ACLs[roleId]) {142 delete this.cell.ACLs[roleId];143 }144 this.notifyDirty();145 };146 /**147 *148 * @param roleId string149 * @param right string150 * @param value bool151 */152 CellModel.prototype.updateUserRight = function updateUserRight(roleId, right, value) {153 if (value) {154 var acl = this.cell.ACLs[roleId];155 var action = new _httpGenIndex.IdmACLAction();156 action.Name = right;157 action.Value = '1';158 acl.Actions.push(action);159 this.cell.ACLs[roleId] = acl;160 } else {161 if (this.cell.ACLs[roleId]) {162 var actions = this.cell.ACLs[roleId].Actions;163 this.cell.ACLs[roleId].Actions = actions.filter(function (action) {164 return action.Name !== right;165 });166 if (!this.cell.ACLs[roleId].Actions.length) {167 this.removeUser(roleId);168 return;169 }170 }171 }172 this.notifyDirty();173 };174 /**175 *176 * @param node Node177 * @param repositoryId String178 */179 CellModel.prototype.addRootNode = function addRootNode(node) {180 var repositoryId = arguments.length <= 1 || arguments[1] === undefined ? null : arguments[1];181 var pydio = _pydio2['default'].getInstance();182 var treeNode = new _httpGenIndex.TreeNode();183 treeNode.Uuid = node.getMetadata().get('uuid');184 var slug = undefined;185 if (repositoryId) {186 slug = pydio.user.getRepositoriesList().get(repositoryId).getSlug();187 } else {188 slug = pydio.user.getActiveRepositoryObject().getSlug();189 }190 treeNode.Path = slug + node.getPath();191 treeNode.MetaStore = { selection: true };192 this.cell.RootNodes.push(treeNode);193 this.notifyDirty();194 };195 /**196 *197 * @param uuid string198 */199 CellModel.prototype.removeRootNode = function removeRootNode(uuid) {200 var newNodes = [];201 this.cell.RootNodes.map(function (n) {202 if (n.Uuid !== uuid) {203 newNodes.push(n);204 }205 });206 this.cell.RootNodes = newNodes;207 this.notifyDirty();208 };209 /**210 *211 * @param nodeId212 * @return bool213 */214 CellModel.prototype.hasRootNode = function hasRootNode(nodeId) {215 return this.cell.RootNodes.filter(function (root) {216 return root.Uuid === nodeId;217 }).length;218 };219 /**220 * Check if there are differences between current root nodes and original ones221 * @return {boolean}222 */223 CellModel.prototype.hasDirtyRootNodes = function hasDirtyRootNodes() {224 var _this3 = this;225 if (!this.originalCell) {226 return false;227 }228 var newNodes = [],229 deletedNodes = [];230 this.cell.RootNodes.map(function (n) {231 if (_this3.originalCell.RootNodes.filter(function (root) {232 return root.Uuid === n.Uuid;233 }).length === 0) {234 newNodes.push(n.Uuid);235 }236 });237 this.originalCell.RootNodes.map(function (n) {238 if (_this3.cell.RootNodes.filter(function (root) {239 return root.Uuid === n.Uuid;240 }).length === 0) {241 deletedNodes.push(n.Uuid);242 }243 });244 return newNodes.length > 0 || deletedNodes.length > 0;245 };246 /**247 *248 * @param roomLabel249 */250 CellModel.prototype.setLabel = function setLabel(roomLabel) {251 this.cell.Label = roomLabel;252 this.notifyDirty();253 };254 /**255 *256 * @return {String}257 */258 CellModel.prototype.getLabel = function getLabel() {259 return this.cell.Label;260 };261 /**262 *263 * @return {String}264 */265 CellModel.prototype.getDescription = function getDescription() {266 return this.cell.Description;267 };268 /**269 *270 * @return {String}271 */272 CellModel.prototype.getUuid = function getUuid() {273 return this.cell.Uuid;274 };275 /**276 *277 * @param description278 */279 CellModel.prototype.setDescription = function setDescription(description) {280 this.cell.Description = description;281 this.notifyDirty();282 };283 CellModel.prototype.clone = function clone(room) {284 return _httpGenIndex.RestCell.constructFromObject(JSON.parse(JSON.stringify(room)));285 };286 /**287 * @return {Promise}288 */289 CellModel.prototype.save = function save() {290 var _this4 = this;291 if (!this.cell.RootNodes.length && this.cell.Uuid) {292 // cell was emptied, remove it293 return this.deleteCell('This cell has no more items in it, it will be deleted, are you sure?');294 }295 var api = new _httpGenIndex.ShareServiceApi(_httpPydioApi2['default'].getRestClient());296 var request = new _httpGenIndex.RestPutCellRequest();297 if (!this._edit && !this.cell.RootNodes.length) {298 request.CreateEmptyRoot = true;299 }300 this.cell.RootNodes.map(function (node) {301 if (node.MetaStore && node.MetaStore.selection) {302 delete node.MetaStore.selection;303 }304 });305 request.Room = this.cell;306 return api.putCell(request).then(function (response) {307 if (!response || !response.Uuid) {308 throw new Error('Error while saving cell');309 }310 if (_this4._edit) {311 _this4.cell = response;312 _this4.dirty = false;313 _this4.originalCell = _this4.clone(_this4.cell);314 _this4.notify('update');315 } else {316 _pydio2['default'].getInstance().observeOnce('repository_list_refreshed', function () {317 _pydio2['default'].getInstance().triggerRepositoryChange(response.Uuid);318 });319 }320 });321 };322 CellModel.prototype.load = function load(cellId) {323 var _this5 = this;324 var api = new _httpGenIndex.ShareServiceApi(_httpPydioApi2['default'].getRestClient());325 return api.getCell(cellId).then(function (room) {326 _this5.cell = room;327 if (!_this5.cell.RootNodes) {328 _this5.cell.RootNodes = [];329 }330 if (!_this5.cell.ACLs) {331 _this5.cell.ACLs = {};332 }333 if (!_this5.cell.Policies) {334 _this5.cell.Policies = [];335 }336 if (!_this5.cell.Description) {337 _this5.cell.Description = '';338 }339 _this5._edit = true;340 _this5.originalCell = _this5.clone(_this5.cell);341 _this5.notify('update');342 });343 };344 /**345 * @param confirmMessage String346 * @return {Promise}347 */348 CellModel.prototype.deleteCell = function deleteCell() {349 var _this6 = this;350 var confirmMessage = arguments.length <= 0 || arguments[0] === undefined ? '' : arguments[0];351 if (!confirmMessage) {352 confirmMessage = 'Are you sure you want to delete this cell? This cannot be undone.';353 }354 if (confirm(confirmMessage)) {355 var _ret = (function () {356 var api = new _httpGenIndex.ShareServiceApi(_httpPydioApi2['default'].getRestClient());357 var pydio = _pydio2['default'].getInstance();358 if (pydio.user.activeRepository === _this6.cell.Uuid) {359 (function () {360 var switchToOther = undefined;361 pydio.user.getRepositoriesList().forEach(function (v, k) {362 if (k !== _this6.cell.Uuid && (!switchToOther || v.getAccessType() === 'gateway')) {363 switchToOther = k;364 }365 });366 if (switchToOther) {367 pydio.triggerRepositoryChange(switchToOther, function () {368 api.deleteCell(_this6.cell.Uuid).then(function (res) {});369 });370 }371 })();372 } else {373 return {374 v: api.deleteCell(_this6.cell.Uuid).then(function (res) {})375 };376 }377 })();378 if (typeof _ret === 'object') return _ret.v;379 }380 return Promise.resolve({});381 };382 return CellModel;383})(_langObservable2['default']);384exports['default'] = CellModel;...

Full Screen

Full Screen

CellModel.es6

Source:CellModel.es6 Github

copy

Full Screen

1/*2 * Copyright 2007-2017 Charles du Jeu - Abstrium SAS <team (at) pyd.io>3 * This file is part of Pydio.4 *5 * Pydio is free software: you can redistribute it and/or modify6 * it under the terms of the GNU Affero General Public License as published by7 * the Free Software Foundation, either version 3 of the License, or8 * (at your option) any later version.9 *10 * Pydio is distributed in the hope that it will be useful,11 * but WITHOUT ANY WARRANTY; without even the implied warranty of12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the13 * GNU Affero General Public License for more details.14 *15 * You should have received a copy of the GNU Affero General Public License16 * along with Pydio. If not, see <http://www.gnu.org/licenses/>.17 *18 * The latest code can be found at <https://pydio.com>.19 */20import PydioApi from '../http/PydioApi'21import Observable from '../lang/Observable'22import PathUtils from '../util/PathUtils'23import IdmObjectHelper from './IdmObjectHelper'24import {ShareServiceApi, RestPutCellRequest, RestCell, RestCellAcl, IdmACLAction, TreeNode} from '../http/gen/index'25class CellModel extends Observable{26 dirty;27 constructor(editMode = false){28 super();29 // Create an empty room30 this.cell = new RestCell();31 this.cell.Label = '';32 this.cell.Description = '';33 this.cell.ACLs = {};34 this.cell.RootNodes = [];35 this.cell.Policies = [];36 this.cell.PoliciesContextEditable = true;37 this._edit = editMode;38 }39 isDirty(){40 return this.dirty;41 }42 isEditable(){43 return this.cell.PoliciesContextEditable;44 }45 getRootNodes(){46 return this.cell.RootNodes;47 }48 49 notifyDirty(){50 this.dirty = true;51 this.notify('update');52 }53 revertChanges(){54 if(this.originalCell){55 this.cell = this.clone(this.originalCell);56 this.dirty = false;57 this.notify('update');58 }59 }60 /**61 *62 * @param node {TreeNode}63 * @return string64 */65 getNodeLabelInContext(node){66 const path = node.Path;67 let label = PathUtils.getBasename(path);68 if(node.MetaStore && node.MetaStore.selection){69 return label;70 }71 if(node.MetaStore && node.MetaStore.CellNode) {72 return '[Cell Folder]';73 }74 if(node.AppearsIn && node.AppearsIn.length){75 node.AppearsIn.map(workspaceRelativePath => {76 if (workspaceRelativePath.WsUuid !== this.cell.Uuid){77 label = '[' + workspaceRelativePath.WsLabel + '] ' + PathUtils.getBasename(workspaceRelativePath.Path);78 }79 })80 }81 return label;82 }83 /**84 *85 * @return {string}86 */87 getAclsSubjects(){88 return Object.keys(this.cell.ACLs).map(roleId => {89 const acl = this.cell.ACLs[roleId];90 return IdmObjectHelper.extractLabel(pydio, acl);91 }).join(', ');92 }93 /**94 * @return {Object.<String, module:model/RestCellAcl>}95 */96 getAcls(){97 return this.cell.ACLs;98 }99 /**100 *101 * @param idmObject IdmUser|IdmRole102 */103 addUser(idmObject){104 let acl = new RestCellAcl();105 acl.RoleId = idmObject.Uuid;106 if(idmObject.Login !== undefined){107 acl.IsUserRole = true;108 acl.User = idmObject;109 } else if(idmObject.IsGroup){110 acl.Group = idmObject;111 } else {112 acl.Role = idmObject;113 }114 acl.Actions = [];115 let action = new IdmACLAction();116 action.Name = 'read';117 action.Value = '1';118 acl.Actions.push(action);119 this.cell.ACLs[acl.RoleId] = acl;120 this.notifyDirty();121 }122 /**123 *124 * @param roleId string125 */126 removeUser(roleId){127 if(this.cell.ACLs[roleId]){128 delete this.cell.ACLs[roleId];129 }130 this.notifyDirty();131 }132 /**133 *134 * @param roleId string135 * @param right string136 * @param value bool137 */138 updateUserRight(roleId, right, value){139 if (value) {140 const acl = this.cell.ACLs[roleId];141 let action = new IdmACLAction();142 action.Name = right;143 action.Value = '1';144 acl.Actions.push(action);145 this.cell.ACLs[roleId] = acl;146 } else {147 if (this.cell.ACLs[roleId]) {148 const actions = this.cell.ACLs[roleId].Actions;149 this.cell.ACLs[roleId].Actions = actions.filter((action) => {150 return action.Name !== right;151 });152 if(!this.cell.ACLs[roleId].Actions.length) {153 this.removeUser(roleId);154 return;155 }156 }157 }158 this.notifyDirty();159 }160 /**161 *162 * @param node Node163 */164 addRootNode(node){165 let treeNode = new TreeNode();166 treeNode.Uuid = node.getMetadata().get('uuid');167 treeNode.Path = node.getPath();168 treeNode.MetaStore = {selection:true};169 this.cell.RootNodes.push(treeNode);170 this.notifyDirty();171 }172 /**173 *174 * @param uuid string175 */176 removeRootNode(uuid){177 let newNodes = [];178 this.cell.RootNodes.map(n => {179 if (n.Uuid !== uuid) {180 newNodes.push(n);181 }182 });183 this.cell.RootNodes = newNodes;184 this.notifyDirty();185 }186 /**187 *188 * @param nodeId189 * @return bool190 */191 hasRootNode(nodeId){192 return this.cell.RootNodes.filter(root => {193 return root.Uuid === nodeId;194 }).length;195 }196 /**197 * Check if there are differences between current root nodes and original ones198 * @return {boolean}199 */200 hasDirtyRootNodes(){201 if(!this.originalCell) {202 return false;203 }204 let newNodes = [], deletedNodes = [];205 this.cell.RootNodes.map(n => {206 if (this.originalCell.RootNodes.filter(root => {207 return root.Uuid === n.Uuid;208 }).length === 0) {209 newNodes.push(n.Uuid);210 }211 });212 this.originalCell.RootNodes.map(n => {213 if (this.cell.RootNodes.filter(root => {214 return root.Uuid === n.Uuid;215 }).length === 0) {216 deletedNodes.push(n.Uuid);217 }218 });219 return newNodes.length > 0 || deletedNodes.length > 0;220 }221 /**222 *223 * @param roomLabel224 */225 setLabel(roomLabel){226 this.cell.Label = roomLabel;227 this.notifyDirty();228 }229 /**230 *231 * @return {String}232 */233 getLabel(){234 return this.cell.Label;235 }236 /**237 *238 * @return {String}239 */240 getDescription(){241 return this.cell.Description;242 }243 /**244 *245 * @return {String}246 */247 getUuid(){248 return this.cell.Uuid;249 }250 /**251 *252 * @param description253 */254 setDescription(description){255 this.cell.Description = description;256 this.notifyDirty();257 }258 clone(room){259 return RestCell.constructFromObject(JSON.parse(JSON.stringify(room)));260 }261 /**262 * @return {Promise}263 */264 save(){265 if(!this.cell.RootNodes.length && this.cell.Uuid) {266 // cell was emptied, remove it267 return this.deleteCell('This cell has no more items in it, it will be deleted, are you sure?');268 }269 const api = new ShareServiceApi(PydioApi.getRestClient());270 let request = new RestPutCellRequest();271 if(!this._edit && !this.cell.RootNodes.length){272 request.CreateEmptyRoot = true;273 }274 this.cell.RootNodes.map(node => {275 if(node.MetaStore && node.MetaStore.selection){276 delete node.MetaStore.selection;277 }278 });279 request.Room = this.cell;280 return api.putCell(request).then(response=>{281 if(!response || !response.Uuid){282 throw new Error('Error while saving cell');283 }284 if(this._edit) {285 this.cell = response;286 this.dirty = false;287 this.originalCell = this.clone(this.cell);288 this.notify('update');289 } else {290 pydio.observeOnce('repository_list_refreshed', ()=>{291 pydio.triggerRepositoryChange(response.Uuid);292 });293 }294 });295 }296 load(cellId){297 const api = new ShareServiceApi(PydioApi.getRestClient());298 return api.getCell(cellId).then(room => {299 this.cell = room;300 if(!this.cell.RootNodes){301 this.cell.RootNodes = [];302 }303 if(!this.cell.ACLs){304 this.cell.ACLs = {};305 }306 if(!this.cell.Policies){307 this.cell.Policies = [];308 }309 if(!this.cell.Description){310 this.cell.Description = '';311 }312 this._edit = true;313 this.originalCell = this.clone(this.cell);314 this.notify('update');315 })316 }317 /**318 *319 * @return {Promise}320 */321 deleteCell(confirmMessage = ''){322 if(!confirmMessage){323 confirmMessage = 'Are you sure you want to delete this cell? This cannot be undone.';324 }325 if (confirm(confirmMessage)){326 const api = new ShareServiceApi(PydioApi.getRestClient());327 if(pydio.user.activeRepository === this.cell.Uuid){328 let switchToOther;329 pydio.user.getRepositoriesList().forEach((v, k) => {330 if(k !== this.cell.Uuid && (!switchToOther || v.getAccessType() === 'gateway')){331 switchToOther = k;332 }333 });334 if(switchToOther){335 pydio.triggerRepositoryChange(switchToOther, () => {336 api.deleteCell(this.cell.Uuid).then(res => {});337 });338 }339 } else {340 return api.deleteCell(this.cell.Uuid).then(res => {});341 }342 }343 return Promise.resolve({});344 }345}...

Full Screen

Full Screen

stat.js

Source:stat.js Github

copy

Full Screen

1/*---------------------------------------------------------2 * Copyright (C) Microsoft Corporation. All rights reserved.3 *--------------------------------------------------------*/4/// <reference path="../../declare/node.d.ts" />5'use strict';6define(["require", "exports", 'fs', 'path', '../../lib/extfs', '../../lib/extpath', '../../lib/mime', '../../lib/types', '../../lib/flow', '../../lib/uri'], function (require, exports, fs, npath, extfs, extpath, mime, types, flow, URI) {7 var parallel = flow.parallel;8 var sequence = flow.sequence;9 // In case we get an EPERM/ENOENT/EBUSY error this indicates that a call to fs.stat() failed with insufficient permissions10 // or that the file does not exist anymore at the time where the call was made.11 // This can mean monaco is unable to read the node in the file system and we will simply ignore it. This enables12 // monaco to run over partially readable filesystems without failing big time.13 var errorsToIgnore = ['EPERM', 'ENOENT', 'EBUSY'];14 var Stat = (function () {15 function Stat(resource, basePath, workspaceRelativePath, isDirectory, mtime, size) {16 this.resource = resource;17 this.basePath = basePath;18 if (!workspaceRelativePath) {19 var root = URI.file(this.basePath).path;20 if (this.resource.path.indexOf(root + '/') === 0) {21 this.workspaceRelativePath = extpath.normalize(this.resource.path.substr(root.length));22 }23 }24 else {25 this.workspaceRelativePath = extpath.normalize(workspaceRelativePath);26 }27 this.isDirectory = isDirectory;28 this.mtime = mtime;29 this.name = extpath.getName(resource.path);30 this.mime = !this.isDirectory ? mime.guessMimeTypes(resource.path).join(', ') : null;31 this.etag = extfs.etag(size, mtime);32 }33 Stat.prototype.serialize = function (options, callback) {34 var _this = this;35 // General Data36 var serialized = {37 resource: this.resource,38 isDirectory: this.isDirectory,39 path: this.workspaceRelativePath,40 name: this.name,41 etag: this.etag,42 hasChildren: undefined,43 size: undefined,44 mtime: this.mtime,45 mime: this.mime46 };47 // Set default options if needed48 if (!options) {49 options = {};50 }51 // File Specific Data52 if (!this.isDirectory) {53 callback(null, serialized);54 return;55 }56 else {57 // Convert the paths from options.resolveTo to absolute paths58 var absoluteTargetPaths = null;59 if (options.resolveTo) {60 absoluteTargetPaths = [];61 options.resolveTo.forEach(function (path) {62 absoluteTargetPaths.push(extpath.join(_this.basePath, path));63 });64 }65 // Load children66 var errorBucket = [];67 this.serializeChildren(this.basePath, this.workspaceRelativePath, absoluteTargetPaths, options.resolveSingleChildDescendants, errorBucket, function (error, children) {68 // Remove null entries69 error = types.coalesce(error);70 errorBucket = types.coalesce(errorBucket);71 children = types.coalesce(children);72 // Send any errors back to client73 if (error && error.length > 0) {74 if (_this.workspaceRelativePath === '\\' || _this.workspaceRelativePath === '/') {75 var errorMsg = 'Error reading workspace. If this error persists, please restart this website (' + error[0].toString() + ').';76 callback(new Error(errorMsg), null, errorBucket);77 }78 else {79 callback(error[0], null, errorBucket);80 }81 return;82 }83 serialized.hasChildren = children && children.length > 0;84 serialized.children = children || [];85 callback(null, serialized, errorBucket);86 });87 }88 };89 Stat.prototype.serializeChildren = function (basePath, relativePath, absoluteTargetPaths, resolveSingleChildDescendants, errorBucket, callback) {90 var _this = this;91 var absolutePath = extpath.join(basePath, relativePath);92 fs.readdir(absolutePath, function (error, files) {93 if (error) {94 if (errorsToIgnore.some(function (ignore) { return error.code === ignore; })) {95 return callback(null, null);96 }97 errorBucket.push(error);98 return callback([error], null);99 }100 parallel(files, function (file, clb) {101 var filePath = npath.resolve(absolutePath, file);102 var relativeFilePath = npath.join(relativePath, file);103 var fileStat;104 var $this = _this;105 sequence(function onError(error) {106 clb(errorsToIgnore.some(function (ignore) { return error.code === ignore; }) ? null : error, null);107 }, function stat() {108 fs.stat(filePath, this);109 }, function countChildren(fsstat) {110 fileStat = fsstat;111 if (fileStat.isDirectory()) {112 extfs.countChildren(filePath, this);113 }114 else {115 this(null, 0);116 }117 }, function serialize(childCount) {118 var childStat = {119 resource: URI.file(filePath),120 isDirectory: fileStat.isDirectory(),121 hasChildren: childCount > 0,122 name: file,123 mtime: fileStat.mtime.getTime(),124 path: relativeFilePath,125 etag: extfs.etag(fileStat),126 mime: !fileStat.isDirectory() ? mime.guessMimeTypes(filePath).join(', ') : undefined127 };128 // Return early for files129 if (!fileStat.isDirectory()) {130 return clb(null, childStat);131 }132 // Handle Folder133 var resolveFolderChildren = false;134 if (files.length === 1 && resolveSingleChildDescendants) {135 resolveFolderChildren = true;136 }137 else if (childCount > 0 && absoluteTargetPaths && absoluteTargetPaths.some(function (targetPath) { return targetPath.indexOf(filePath) === 0; })) {138 resolveFolderChildren = true;139 }140 // Continue resolving children based on condition141 if (resolveFolderChildren) {142 $this.serializeChildren(basePath, relativeFilePath, absoluteTargetPaths, resolveSingleChildDescendants, errorBucket, function (error, children) {143 // Remove null entries144 error = types.coalesce(error);145 children = types.coalesce(children);146 if (error && error.length > 0) {147 clb(error[0], null);148 return;149 }150 childStat.hasChildren = children && children.length > 0;151 childStat.children = children || [];152 clb(null, childStat);153 });154 }155 else {156 clb(null, childStat);157 }158 });159 }, function (errors, result) {160 if (errors && errors.length > 0) {161 errorBucket.push.apply(errorBucket, errors);162 }163 callback(errors, result);164 });165 });166 };167 Stat.prototype.matches = function (etag) {168 return this.etag === etag;169 };170 return Stat;171 })();172 exports.Stat = Stat; ...

Full Screen

Full Screen

views.js

Source:views.js Github

copy

Full Screen

...7 * */8const vscode = require('vscode');9const path = require('path');10const fs = require('fs');11function workspaceRelativePath(uri){12 let workspacePath = vscode.workspace.getWorkspaceFolder(uri).uri.fsPath;13 return path.relative(workspacePath, uri.fsPath);14}15 /** views */16class BaseView {17 async refresh(value) {18 this.treeView.message = undefined; // clear the treeview message19 return this.dataProvider.refresh(value);20 }21 async onDidSelectionChange(event) { }22}23class BaseDataProvider {24 async dataGetRoot() {25 return [];26 }27 dataGetChildren(element) {28 return null;29 }30 /** tree methods */31 getChildren(element) {32 return element ? this.dataGetChildren(element) : this.dataGetRoot();33 }34 getParent(element) {35 return element.parent;36 }37 getTreeItem(element) {38 return {39 resourceUri: element.resource,40 label: element.label,41 iconPath: element.iconPath,42 collapsibleState: element.collapsibleState,43 children: element.children,44 command: element.command || {45 command: 'vscode-tarantula.jumpToRange',46 arguments: [element.resource],47 title: 'JumpTo'48 }49 };50 }51 /** other methods */52 refresh() {53 return new Promise((resolve, reject) => {54 this._onDidChangeTreeData.fire();55 resolve();56 });57 }58}59class HighScoreViewDataProvider extends BaseDataProvider {60 constructor(treeView) {61 super();62 this.treeView = treeView;63 this._onDidChangeTreeData = new vscode.EventEmitter();64 this.onDidChangeTreeData = this._onDidChangeTreeData.event;65 this.data = null;66 this.documentUri = null;67 }68 async dataGetRoot() {69 if (this.data === null && this.documentUri === null) {70 return [];71 }72 return this.data.map(entry => {73 let element = {74 "rank": entry[0],75 "path": entry[1],76 "resource": vscode.Uri.file(entry[1]),77 "lineStart": entry[2] -1,78 "lineEnd": entry[3] -179 };80 let label = `(${element.rank}) ${workspaceRelativePath(element.resource)} (${element.lineStart}-${element.lineEnd})`;81 let range = new vscode.Range(element.lineStart, 0, element.lineEnd, 100000);82 let item = {83 resource: element.resource,84 contextValue: element.resource.fsPath,85 range: range,86 label: label,87 tooltip: label,88 name: label,89 iconPath: vscode.ThemeIcon.File,90 collapsibleState: 0,// vscode.TreeItemCollapsibleState.Collapsed,91 parent: null,92 children: null,93 command: {94 command: 'vscode-tarantula.jumpToRange',...

Full Screen

Full Screen

utils.js

Source:utils.js Github

copy

Full Screen

1import path from "node:path";2import { pnpmWorskpaceProjectConfig, pnpmWorskpaceConfig } from "../pnpm/config.js";3import { readJson, readFile, copyFile } from "../common/utils.js";4import { workspacePath } from "../common/paths.js";5export async function projectRelativePath(projectName) {6 return pnpmWorskpaceProjectConfig(projectName);7}8export async function projectPath(projectName) {9 const projectPathBasedOnPnpmConfig = await projectRelativePath(projectName);10 return workspacePath(projectPathBasedOnPnpmConfig);11}12export async function projectFilePath(projectName, ...rest) {13 const projectRootPath = await projectPath(projectName);14 return path.resolve.apply(path, [projectRootPath, ...rest]);15}16export async function readProjectJson(projectName, fileName) {17 const projectJson = await projectFilePath(projectName, fileName);18 return readJson(projectJson);19}20export async function readProjectFile(projectName, fileName) {21 const projectFile = await projectFilePath(projectName, fileName);22 return readFile(projectFile);23}24export async function allProjectNames() {25 const workspaceConfig = await pnpmWorskpaceConfig();26 return Object.keys(workspaceConfig.projects);27}28export async function copyWorkspaceFileToProject(29 projectName,30 workspaceRelativePath,31 relativePathInProject32) {33 const dest = await projectFilePath(projectName, relativePathInProject || workspaceRelativePath);34 return copyFile(workspacePath(workspaceRelativePath), dest);...

Full Screen

Full Screen

visibilityOfCrossModuleTypeUsage.js

Source:visibilityOfCrossModuleTypeUsage.js Github

copy

Full Screen

1//// [tests/cases/compiler/visibilityOfCrossModuleTypeUsage.ts] ////23//// [visibilityOfCrossModuleTypeUsage_commands.ts]4//visibilityOfCrossModuleTypeUsage5import fs = require('./visibilityOfCrossModuleTypeUsage_fs');6import server = require('./visibilityOfCrossModuleTypeUsage_server');7export interface IConfiguration {8 workspace: server.IWorkspace;9 server?: server.IServer;10}1112//// [visibilityOfCrossModuleTypeUsage_server.ts]13export interface IServer {14}15export interface IWorkspace {16 toAbsolutePath(server: IServer, workspaceRelativePath?: string): string;17}1819//// [visibilityOfCrossModuleTypeUsage_fs.ts]20import commands = require('./visibilityOfCrossModuleTypeUsage_commands');21function run(configuration: commands.IConfiguration) {22 var absoluteWorkspacePath = configuration.workspace.toAbsolutePath(configuration.server);23}2425//// [visibilityOfCrossModuleTypeUsage_server.js]26//// [visibilityOfCrossModuleTypeUsage_commands.js]27//visibilityOfCrossModuleTypeUsage28//// [visibilityOfCrossModuleTypeUsage_fs.js]29function run(configuration) {30 var absoluteWorkspacePath = configuration.workspace.toAbsolutePath(configuration.server); ...

Full Screen

Full Screen

paths.js

Source:paths.js Github

copy

Full Screen

1/* eslint-disable import/no-dynamic-require */2/* eslint-disable global-require */3/* eslint-disable no-multi-assign */4const path = require('path');5const ROOT = require('find-yarn-workspace-root')(__dirname);6const rootPackage = require(path.join(ROOT, 'package.json'));7const WORKSPACES = rootPackage.workspaces.reduce(8 (obj, workspaceRelativePath) => {9 const workspacePath = path.join(workspaceRelativePath);10 const { name: workspaceName } = require(path.join(11 ROOT,12 workspacePath,13 'package.json',14 ));15 return { ...obj, [workspaceName]: workspacePath };16 },17 {},18);19const NODE_MODULES = path.join(ROOT, 'node_modules');20const WORKSPACE = process.cwd(); // TODO: Test this with Lerna21module.exports = {22 ROOT,23 WORKSPACES,24 WORKSPACE,25 NODE_MODULES,...

Full Screen

Full Screen

config.service.js

Source:config.service.js Github

copy

Full Screen

1const path = require('path');2module.exports = new class ConfigService { 3 async init(workspaceRelativePath) { 4 this.workspaceRelativePath = workspaceRelativePath;5 const ref = await import(this.path('config.js'));6 this.config = ref.default;7 }8 path(param) { 9 return path.join(process.cwd(), this.workspaceRelativePath, param);10 }...

Full Screen

Full Screen

Using AI Code Generation

copy

Full Screen

1const path = require('path');2const playwright = require('playwright');3(async () => {4 const browser = await playwright.chromium.launch({ headless: false });5 const context = await browser.newContext();6 const page = await context.newPage();7 await page.screenshot({ path: path.join(await context.workspaceRelativePath(), 'screenshot.png') });8 await browser.close();9})();

Full Screen

Using AI Code Generation

copy

Full Screen

1const playwright = require('playwright');2const path = require('path');3(async () => {4 const browser = await playwright.chromium.launch();5 const context = await browser.newContext();6 const page = await context.newPage();7 const filePath = path.join(process.cwd(), 'test.pdf');8 await page.pdf({ path: filePath });9 console.log(filePath);10 await browser.close();11})();

Full Screen

Using AI Code Generation

copy

Full Screen

1const playwright = require('playwright');2const path = require('path');3const fs = require('fs');4(async () => {5 const browser = await playwright.chromium.launch();6 const context = await browser.newContext();7 const page = await context.newPage();8 const fileToUpload = await page.evaluateHandle(() => {9 const input = document.createElement('input');10 input.type = 'file';11 return input;12 });13 await fileToUpload.asElement().uploadFile('test.txt');14 const filePath = await page.evaluate((fileToUpload) => {15 return fileToUpload.files[0].path;16 }, fileToUpload);17 console.log(filePath);18 await browser.close();19})();

Full Screen

Using AI Code Generation

copy

Full Screen

1const { workspaceRelativePath } = require('@playwright/test');2const path = require('path');3module.exports = {4 {5 use: {6 launchOptions: {7 userDataDir: workspaceRelativePath(8 path.join('..', '..', 'data', 'chrome')9 },10 },11 },12 {13 use: {14 launchOptions: {15 userDataDir: workspaceRelativePath(16 path.join('..', '..', 'data', 'firefox')17 },18 },19 },20};21const { workspaceRelativePath } = require('@playwright/test');22const path = require('path');23module.exports = {24 {25 use: {26 launchOptions: {27 userDataDir: workspaceRelativePath(28 path.join('..', '..', 'data', 'chrome')29 },30 },31 },32 {33 use: {34 launchOptions: {35 userDataDir: workspaceRelativePath(36 path.join('..', '..', 'data', 'firefox')37 },38 },39 },40};41const { workspaceRelativePath } = require('@playwright/test');42const path = require('path');43module.exports = {44 {45 use: {46 launchOptions: {47 userDataDir: workspaceRelativePath(48 path.join('..', '..', 'data', 'chrome')49 },50 },51 },52 {53 use: {

Full Screen

Using AI Code Generation

copy

Full Screen

1const path = require('path');2const { chromium } = require('playwright');3const { workspaceRelativePath } = require('playwright/lib/utils/workspacePath');4(async () => {5 const browser = await chromium.launch();6 const context = await browser.newContext();7 const page = await context.newPage();8 const title = await page.title();9 console.log(title);10 await page.screenshot({ path: workspaceRelativePath(path.join('test', 'screenshot.png')) });11 await browser.close();12})();13const path = require('path');14const { chromium } = require('playwright');15const { workspacePath } = require('playwright/lib/utils/workspacePath');16(async () => {17 const browser = await chromium.launch();18 const context = await browser.newContext();19 const page = await context.newPage();20 const title = await page.title();21 console.log(title);22 await page.screenshot({ path: workspacePath(path.join('test', 'screenshot.png')) });23 await browser.close();24})();25We welcome any contributions to Playwright. Please read our [contribution guide](

Full Screen

Using AI Code Generation

copy

Full Screen

1const path = require('path');2const playwright = require('playwright');3const { workspaceRelativePath } = require('playwright/lib/utils/utils');4const browser = await playwright.chromium.launch();5const context = await browser.newContext();6const page = await context.newPage();

Full Screen

Using AI Code Generation

copy

Full Screen

1const { workspaceRelativePath } = require('@playwright/test');2console.log(workspaceRelativePath('test.js'));3const { workspaceRelativePath } = require('@playwright/test');4console.log(workspaceRelativePath('test.spec.js'));5const { workspaceRelativePath } = require('@playwright/test');6console.log(workspaceRelativePath('test.spec.ts'));7const { workspaceRelativePath } = require('@playwright/test');8console.log(workspaceRelativePath('test.spec.ts'));9const { workspaceRelativePath } = require('@playwright/test');10console.log(workspaceRelativePath('test.spec.ts'));11const { workspaceRelativePath } = require('@playwright/test');12console.log(workspaceRelativePath('test.spec.ts'));13const { workspaceRelativePath } = require('@playwright/test');14console.log(workspaceRelativePath('test.spec.ts'));15const { workspaceRelativePath } = require('@playwright/test');16console.log(workspaceRelativePath('test.spec.ts'));17const { workspaceRelativePath } = require('@playwright/test');18console.log(workspaceRelativePath('test.spec.ts'));19const { workspaceRelativePath } = require('@playwright/test');20console.log(workspaceRelativePath('test.spec.ts'));21const { workspaceRelativePath } = require('@playwright/test');22console.log(workspaceRelativePath('test.spec.ts'));23const { workspaceRelativePath } = require('@playwright/test');

Full Screen

Using AI Code Generation

copy

Full Screen

1const path = require('path');2const { test, expect } = require('@playwright/test');3const { workspaceRelativePath } = require('@playwright/test/lib/utils/workspaceRelativePath');4test('My test', async () => {5 const testPath = workspaceRelativePath(__filename);6 const expectedPath = path.join('test', 'test.js');7 expect(testPath).toBe(expectedPath);8});9module.exports = {10}11module.exports = {12}13module.exports = {14}15module.exports = {16}

Full Screen

Using AI Code Generation

copy

Full Screen

1const { workspaceRelativePath } = require('@playwright/test');2const path = require('path');3const fs = require('fs');4const filePath = workspaceRelativePath('test.txt');5fs.writeFileSync(filePath, 'Hello World!');6console.log('File created at: ', filePath);7const { workspaceRelativePath } = require('@playwright/test');8const path = require('path');9const fs = require('fs');10const filePath = workspaceRelativePath('test.txt');11fs.writeFileSync(filePath, 'Hello World!');12console.log('File created at: ', filePath);

Full Screen

Playwright tutorial

LambdaTest’s Playwright tutorial will give you a broader idea about the Playwright automation framework, its unique features, and use cases with examples to exceed your understanding of Playwright testing. This tutorial will give A to Z guidance, from installing the Playwright framework to some best practices and advanced concepts.

Chapters:

  1. What is Playwright : Playwright is comparatively new but has gained good popularity. Get to know some history of the Playwright with some interesting facts connected with it.
  2. How To Install Playwright : Learn in detail about what basic configuration and dependencies are required for installing Playwright and run a test. Get a step-by-step direction for installing the Playwright automation framework.
  3. Playwright Futuristic Features: Launched in 2020, Playwright gained huge popularity quickly because of some obliging features such as Playwright Test Generator and Inspector, Playwright Reporter, Playwright auto-waiting mechanism and etc. Read up on those features to master Playwright testing.
  4. What is Component Testing: Component testing in Playwright is a unique feature that allows a tester to test a single component of a web application without integrating them with other elements. Learn how to perform Component testing on the Playwright automation framework.
  5. Inputs And Buttons In Playwright: Every website has Input boxes and buttons; learn about testing inputs and buttons with different scenarios and examples.
  6. Functions and Selectors in Playwright: Learn how to launch the Chromium browser with Playwright. Also, gain a better understanding of some important functions like “BrowserContext,” which allows you to run multiple browser sessions, and “newPage” which interacts with a page.
  7. Handling Alerts and Dropdowns in Playwright : Playwright interact with different types of alerts and pop-ups, such as simple, confirmation, and prompt, and different types of dropdowns, such as single selector and multi-selector get your hands-on with handling alerts and dropdown in Playright testing.
  8. Playwright vs Puppeteer: Get to know about the difference between two testing frameworks and how they are different than one another, which browsers they support, and what features they provide.
  9. Run Playwright Tests on LambdaTest: Playwright testing with LambdaTest leverages test performance to the utmost. You can run multiple Playwright tests in Parallel with the LammbdaTest test cloud. Get a step-by-step guide to run your Playwright test on the LambdaTest platform.
  10. Playwright Python Tutorial: Playwright automation framework support all major languages such as Python, JavaScript, TypeScript, .NET and etc. However, there are various advantages to Python end-to-end testing with Playwright because of its versatile utility. Get the hang of Playwright python testing with this chapter.
  11. Playwright End To End Testing Tutorial: Get your hands on with Playwright end-to-end testing and learn to use some exciting features such as TraceViewer, Debugging, Networking, Component testing, Visual testing, and many more.
  12. Playwright Video Tutorial: Watch the video tutorials on Playwright testing from experts and get a consecutive in-depth explanation of Playwright automation testing.

Run Playwright Internal automation tests on LambdaTest cloud grid

Perform automation testing on 3000+ real desktop and mobile devices online.

Try LambdaTest Now !!

Get 100 minutes of automation test minutes FREE!!

Next-Gen App & Browser Testing Cloud

Was this article helpful?

Helpful

NotHelpful