mirror of
https://github.com/ckaczor/azuredatastudio.git
synced 2026-01-26 17:23:15 -05:00
Update run w/parameters icon and increment parameterized notebook (#15127)
* update icon and increment parameterized notebook
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
<svg width="16" height="16" viewBox="0 0 16 16" fill="none" xmlns="http://www.w3.org/2000/svg">
|
||||
<path fill-rule="evenodd" clip-rule="evenodd" d="M11.8874 6.36205V6.24753L13.5352 5.22324L12.5236 2.78658L10.6341 3.21919C10.5323 3.10892 10.4262 3.00289 10.316 2.90109L10.7486 1.01157L8.31192 0L7.28763 1.64777H7.17311C7.13494 1.64353 7.09677 1.64141 7.05859 1.64141C7.02042 1.64141 6.98225 1.64353 6.94408 1.64777H6.82956L5.80527 0L3.36861 1.01157L3.80123 2.90109C3.69095 3.00289 3.58492 3.10892 3.48312 3.21919L1.5936 2.78658L0.582031 5.22324L2.2298 6.24753C2.2298 6.2857 2.22768 6.32387 2.22344 6.36205V6.47656V6.59108C2.22768 6.62925 2.2298 6.66742 2.2298 6.7056L0.582031 7.72989L1.5936 10.1665L3.48312 9.73393C3.58492 9.8442 3.69095 9.95024 3.80123 10.052L3.36861 11.9416L5.80527 12.9531L6.82956 11.3054C6.86773 11.3054 6.9059 11.3075 6.94408 11.3117H7.05859H7.17311C7.21128 11.3075 7.24945 11.3054 7.28763 11.3054L8.31192 12.9531L8.50497 12.873L8.6309 12.0489L8.59821 12.0624L7.66299 10.561L7.35761 10.5864C7.26006 10.5949 7.16039 10.5992 7.05859 10.5992C6.96104 10.5992 6.86137 10.5949 6.75958 10.5864C6.65778 10.578 6.55811 10.5695 6.46056 10.561L5.51898 12.0624L4.19567 11.5153L4.59648 9.79119C4.43531 9.65546 4.28474 9.51974 4.14478 9.38402C4.00905 9.24829 3.87545 9.09984 3.74397 8.93867L2.01985 9.33948L1.47272 8.01618L2.97416 7.08096C2.96568 6.98341 2.95719 6.88373 2.94871 6.78194C2.94023 6.68015 2.93599 6.58048 2.93599 6.48292C2.93599 6.38113 2.94023 6.28146 2.94871 6.18391L2.97416 5.87853L1.47272 4.93695L2.01985 3.61364L3.74397 4.01445C3.87969 3.85328 4.01541 3.70483 4.15114 3.56911C4.28686 3.42914 4.43531 3.29342 4.59648 3.16194L4.19567 1.43782L5.51898 0.890686L6.4542 2.39213C6.55599 2.38365 6.65566 2.37516 6.75322 2.36668C6.85501 2.3582 6.9568 2.35396 7.05859 2.35396C7.15614 2.35396 7.25582 2.3582 7.35761 2.36668C7.4594 2.37516 7.55907 2.38365 7.65663 2.39213L8.59821 0.890686L9.92151 1.43782L9.5207 3.16194C9.68188 3.29766 9.83032 3.43338 9.96605 3.56911C10.106 3.70483 10.2417 3.85328 10.3732 4.01445L12.0973 3.61364L12.6445 4.93695L11.143 5.87217C11.1515 5.96972 11.16 6.06939 11.1685 6.17118C11.177 6.27298 11.1812 6.37265 11.1812 6.4702C11.1812 6.57199 11.177 6.67379 11.1685 6.77558C11.16 6.87313 11.1515 6.9728 11.143 7.07459L12.6445 8.01618L12.1132 9.30122L12.7351 9.65708L13.5352 7.72989L11.8874 6.7056V6.59108C11.8916 6.55291 11.8937 6.51473 11.8937 6.47656C11.8937 6.43839 11.8916 6.40022 11.8874 6.36205ZM7.98745 4.27529C7.69904 4.14805 7.38942 4.08443 7.05859 4.08443C6.72777 4.08443 6.41603 4.14805 6.12337 4.27529C5.83496 4.39829 5.5826 4.56795 5.36629 4.78426C5.14998 5.00057 4.9782 5.25505 4.85096 5.5477C4.72796 5.83612 4.66646 6.14574 4.66646 6.47656C4.66646 6.80739 4.72796 7.11913 4.85096 7.41178C4.9782 7.7002 5.14998 7.95256 5.36629 8.16887C5.5826 8.38518 5.83496 8.55695 6.12337 8.68419C6.41603 8.80719 6.72777 8.86869 7.05859 8.86869C7.38942 8.86869 7.69904 8.80719 7.98745 8.68419C8.28011 8.55695 8.53459 8.38518 8.7509 8.16887C8.96721 7.95256 9.13686 7.7002 9.25986 7.41178C9.3871 7.11913 9.45072 6.80739 9.45072 6.47656C9.45072 6.14574 9.3871 5.83612 9.25986 5.5477C9.13686 5.25505 8.96721 5.00057 8.7509 4.78426C8.53459 4.56795 8.28011 4.39829 7.98745 4.27529ZM7.71388 8.0289C7.5103 8.11373 7.29187 8.15614 7.05859 8.15614C6.82532 8.15614 6.60689 8.11373 6.4033 8.0289C6.19972 7.93983 6.02158 7.81895 5.86889 7.66626C5.7162 7.51358 5.59532 7.33544 5.50625 7.13185C5.42143 6.92827 5.37901 6.70984 5.37901 6.47656C5.37901 6.24329 5.42143 6.02486 5.50625 5.82127C5.59532 5.61769 5.7162 5.43955 5.86889 5.28686C6.02158 5.13417 6.19972 5.01541 6.4033 4.93058C6.60689 4.84152 6.82532 4.79698 7.05859 4.79698C7.29187 4.79698 7.5103 4.84152 7.71388 4.93058C7.91747 5.01541 8.09561 5.13417 8.2483 5.28686C8.40098 5.43955 8.51974 5.61769 8.60457 5.82127C8.69364 6.02486 8.73817 6.24329 8.73817 6.47656C8.73817 6.70984 8.69364 6.92827 8.60457 7.13185C8.51974 7.33544 8.40098 7.51358 8.2483 7.66626C8.09561 7.81895 7.91747 7.93983 7.71388 8.0289Z" fill="#0078D4"/>
|
||||
<path d="M9.58203 16V9L15.418 12.5L9.58203 16ZM10.582 10.766V14.234L13.473 12.5L10.582 10.766Z" fill="#0078D4"/>
|
||||
<path d="M12 7L2 14V0L12 7ZM3 12.078L10.258 7L3 1.922V12.078Z" fill="#0078D4"/>
|
||||
<path d="M15.9998 11.7L15.0308 12.1C15.0935 12.4146 15.0935 12.7384 15.0308 13.053L15.9998 13.453L15.6168 14.383L14.6478 13.977C14.5606 14.1093 14.4601 14.2322 14.3478 14.344C14.2328 14.4559 14.1072 14.5564 13.9728 14.644L14.3788 15.613L13.4488 15.996L13.0488 15.027C12.7343 15.0897 12.4104 15.0897 12.0958 15.027L11.6998 16L10.7698 15.617L11.1768 14.648C10.9131 14.4681 10.6852 14.2405 10.5048 13.977L9.53583 14.383L9.15283 13.453L10.1218 13.053C10.0592 12.7384 10.0592 12.4146 10.1218 12.1L9.15283 11.7L9.53583 10.77L10.5048 11.177C10.6849 10.913 10.9128 10.6851 11.1768 10.505L10.7698 9.53602L11.6998 9.15302L12.0998 10.122C12.4144 10.0593 12.7383 10.0593 13.0528 10.122L13.4528 9.15302L14.3828 9.53602L13.9768 10.505C14.1093 10.5919 14.2323 10.6925 14.3438 10.805C14.4562 10.9196 14.5567 11.0453 14.6438 11.18L15.6128 10.773L15.9998 11.7ZM12.5778 14.075C12.7765 14.0759 12.9732 14.0361 13.1558 13.958C13.3338 13.8829 13.4958 13.7742 13.6328 13.638C13.7711 13.4979 13.8823 13.3335 13.9608 13.153C14.0427 12.9716 14.0827 12.774 14.0778 12.575C14.0793 12.3737 14.0394 12.1743 13.9608 11.989C13.8093 11.6278 13.522 11.3406 13.1608 11.189C12.9751 11.1118 12.776 11.072 12.5748 11.072C12.3737 11.072 12.1745 11.1118 11.9888 11.189C11.628 11.341 11.3409 11.6281 11.1888 11.989C11.1116 12.1747 11.0718 12.3739 11.0718 12.575C11.0718 12.7762 11.1116 12.9753 11.1888 13.161C11.3404 13.5222 11.6277 13.8094 11.9888 13.961C12.1751 14.04 12.3756 14.0798 12.5778 14.078V14.075Z" fill="#0078D4"/>
|
||||
</svg>
|
||||
|
||||
|
Before Width: | Height: | Size: 4.0 KiB After Width: | Height: | Size: 1.6 KiB |
@@ -364,8 +364,8 @@ export class RunParametersAction extends TooltipFromLabelAction {
|
||||
public async openParameterizedNotebook(uri: URI): Promise<void> {
|
||||
const editor = this._notebookService.findNotebookEditor(uri);
|
||||
let modelContents = JSON.stringify(editor.model.toJSON());
|
||||
let basename = path.basename(uri.fsPath);
|
||||
let untitledUri = uri.with({ authority: '', scheme: 'untitled', path: basename });
|
||||
let untitledUriPath = this._notebookService.getUntitledUriPath(path.basename(uri.fsPath));
|
||||
let untitledUri = uri.with({ authority: '', scheme: 'untitled', path: untitledUriPath });
|
||||
this._notebookService.openNotebook(untitledUri, {
|
||||
initialContent: modelContents,
|
||||
preserveFocus: true
|
||||
|
||||
@@ -561,6 +561,14 @@ suite.skip('NotebookService:', function (): void {
|
||||
mock.verifyAll();
|
||||
|
||||
});
|
||||
|
||||
test('verify getUntitledUriPath gets the proper next title', () => {
|
||||
let getUntitledUriPathSpy = sinon.spy(notebookService, 'getUntitledUriPath');
|
||||
notebookService.getUntitledUriPath('title.ipynb');
|
||||
sinon.assert.calledOnce(getUntitledUriPathSpy);
|
||||
assert.equal(getUntitledUriPathSpy, 'title-0.ipynb');
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
function unRegisterProviders(notebookService: NotebookService) {
|
||||
|
||||
@@ -303,6 +303,9 @@ export class NotebookServiceStub implements INotebookService {
|
||||
notifyCellExecutionStarted(): void {
|
||||
throw new Error('Method not implemented.');
|
||||
}
|
||||
getUntitledUriPath(originalTitle: string): string {
|
||||
throw new Error('Method not implemented.');
|
||||
}
|
||||
}
|
||||
|
||||
export class ClientSessionStub implements IClientSession {
|
||||
|
||||
@@ -143,6 +143,8 @@ export interface INotebookService {
|
||||
notifyCellExecutionStarted(): void;
|
||||
|
||||
openNotebook(resource: UriComponents, options: INotebookShowOptions): Promise<IEditorPane | undefined>;
|
||||
|
||||
getUntitledUriPath(originalTitle: string): string;
|
||||
}
|
||||
|
||||
export interface INotebookProvider {
|
||||
|
||||
@@ -224,6 +224,28 @@ export class NotebookService extends Disposable implements INotebookService {
|
||||
return await this._editorService.openEditor(fileInput, editorOptions, viewColumnToEditorGroup(this._editorGroupService, options.position));
|
||||
}
|
||||
|
||||
/**
|
||||
* Will iterate the title of the parameterized notebook since the original notebook is still open
|
||||
* @param originalTitle is the title of the original notebook that we run parameterized action from
|
||||
* @returns the title of the parameterized notebook
|
||||
*/
|
||||
public getUntitledUriPath(originalTitle: string): string {
|
||||
let title = originalTitle;
|
||||
let nextVal = 0;
|
||||
let ext = path.extname(title);
|
||||
while (this.listNotebookEditors().findIndex(doc => path.basename(doc.notebookParams.notebookUri.fsPath) === title) > -1) {
|
||||
if (ext) {
|
||||
// Need it to be `Readme-0.txt` not `Readme.txt-0`
|
||||
let titleStart = originalTitle.slice(0, originalTitle.length - ext.length);
|
||||
title = `${titleStart}-${nextVal}${ext}`;
|
||||
} else {
|
||||
title = `${originalTitle}-${nextVal}`;
|
||||
}
|
||||
nextVal++;
|
||||
}
|
||||
return title;
|
||||
}
|
||||
|
||||
private updateSQLRegistrationWithConnectionProviders() {
|
||||
// Update the SQL extension
|
||||
let sqlNotebookKernels = this._providerToStandardKernels.get(notebookConstants.SQL);
|
||||
|
||||
Reference in New Issue
Block a user