<commit_before>'use babel';

import {Notification} from 'atom';
const {View, TextEditorView} = require('atom-space-pen-views');
const {LibraryListCommandSite, LibraryListCommand} = require('../cli');
import {LibrariesListView} from './libraries_list';
import {runCommand, fetchApiClient} from '../library';

let target = {};

export function listingLibrariesErrorNotification() {
	return new Notification('error', 'There was an error while listing libraries. Please try again later.', {
		dismissable: true
	});
}

class DevLibraryListCommandSite extends LibraryListCommandSite {
	constructor(filter) {
		super();
		this._filter = filter;
	}

	sections() {
		return ['popular'];
	}

	settings() {
		return {
			filter: this._filter
		};
	}

	target() {
		return target;
	}

	apiClient() {
		return fetchApiClient();
	}
}

export class LibrariesPanelView extends View {
	initialize() {
		this.searchEditor.getModel().onDidStopChanging(() => {
			this.fetchLibraries(this.searchEditor.getModel().getText());
		});

		this.fetchLibraries('');
	}

	static content() {
		const content = this.div({id: 'libraries-panel'}, (...args) => {
			this.h1('Particle Libraries');
			this.div({'class': 'editor-container'}, () => {
				this.subview('searchEditor', new TextEditorView({mini: true, placeholderText: 'Search libraries'}));
			});
			this.h2('Community Libraries');
			this.subview('community', new LibrariesListView());
		});
		return content;
	}

	getTitle() {
		return 'Particle Libraries';
	}

	getPath() {
		return 'libraries';
	}

	getUri() {
		return `particle-dev://editor/${this.getPath()}`;
	}

	fetchLibraries(query) {
		this.community.setLoading();
		const list = new LibraryListCommand();
		return runCommand(new DevLibraryListCommandSite(query).run(list, {})).then(() => {
			this.community.setItems(target[0]);
		}).catch(err => {
			atom.notifications.addNotification(listingLibrariesErrorNotification());
			console.error(err);
		});
	}
}<commit_msg>List my libraries<commit_after>'use babel';

import {Notification} from 'atom';
const {View, TextEditorView} = require('atom-space-pen-views');
const {LibraryListCommandSite, LibraryListCommand} = require('../cli');
import {LibrariesListView} from './libraries_list';
import {runCommand, fetchApiClient} from '../library';

let target = {};

export function listingLibrariesErrorNotification() {
	return new Notification('error', 'There was an error while listing libraries. Please try again later.', {
		dismissable: true
	});
}

class DevLibraryListCommandSite extends LibraryListCommandSite {
	constructor(filter) {
		super();
		this._filter = filter;
	}

	sections() {
		return {
			'mine' : {},
			'popular': {}
		};
	}

	settings() {
		return {
			filter: this._filter
		};
	}

	target() {
		return target;
	}

	apiClient() {
		return fetchApiClient();
	}
}

export class LibrariesPanelView extends View {
	initialize() {
		this.searchEditor.getModel().onDidStopChanging(() => {
			this.fetchLibraries(this.searchEditor.getModel().getText());
		});

		this.fetchLibraries('');
	}

	static content() {
		const content = this.div({id: 'libraries-panel'}, (...args) => {
			this.h1('Particle Libraries');
			this.div({'class': 'editor-container'}, () => {
				this.subview('searchEditor', new TextEditorView({mini: true, placeholderText: 'Search libraries'}));
			});
			this.h2('My Libraries');
			this.subview('mine', new LibrariesListView());
			this.h2('Popular Libraries');
			this.subview('popular', new LibrariesListView());
		});
		return content;
	}

	getTitle() {
		return 'Particle Libraries';
	}

	getPath() {
		return 'libraries';
	}

	getUri() {
		return `particle-dev://editor/${this.getPath()}`;
	}

	fetchLibraries(query) {
		this.mine.setLoading();
		this.popular.setLoading();
		const list = new LibraryListCommand();
		return runCommand(new DevLibraryListCommandSite(query).run(list, {})).then(() => {
			this.mine.setItems(target.mine);
			this.popular.setItems(target.popular);
		}).catch(err => {
			atom.notifications.addNotification(listingLibrariesErrorNotification());
			console.error(err);
		});
	}
}
{'fraction_non_alphanumeric': 0.16650390625, 'fraction_numerical': 0.00146484375, 'mean_word_length': 4.635488308115543, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 13, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4123958', 'n_tokens_mistral': 1410, 'n_tokens_neox': 1269, 'n_words': 256}