type
stringclasses
7 values
content
stringlengths
4
9.55k
repo
stringlengths
7
96
path
stringlengths
4
178
language
stringclasses
1 value
ArrowFunction
() => { expect({ value: null }).toEqual( jasmine.objectContaining({ value: jasmine.empty(), }) ); }
Bat-Orshikh/DefinitelyTyped
types/jasmine/ts3.1/jasmine-tests.ts
TypeScript
ArrowFunction
() => { expect({ value: null }).toEqual( jasmine.objectContaining({ value: jasmine.notEmpty(), }) ); }
Bat-Orshikh/DefinitelyTyped
types/jasmine/ts3.1/jasmine-tests.ts
TypeScript
ArrowFunction
() => { expect({ value: null, label: 'abcd' }).toEqual( jasmine.objectContaining({ value: jasmine.anything(), }) ); expect({ value: null }).toEqual( jasmine.objectContaining({ value: 'any value should ok', }) ); }
Bat-Orshikh/DefinitelyTyped
types/jasmine/ts3.1/jasmine-tests.ts
TypeScript
ArrowFunction
() => { describe("https://github.com/DefinitelyTyped/DefinitelyTyped/issues/34080", () => { interface Test { f(): string; f(x: any): number; } it("has a way to opt out of inferred function types", () => { const spyObject: jasmine.NonTypedSpyObj<Test> = jasmine.createSpyObj<Test>("spyObject", ["f"]); spyObject.f.and.returnValue("a string - working"); const spy2 = jasmine.createSpyObj<Test>(['f']); spy2.f.and.returnValue("can return string" as any); }); it("should be possible to opt out for spyOn", () => { const obj: Test = null!; const spy1: jasmine.Spy = spyOn(obj, "f"); spy1.and.returnValue("can return string"); const spy2 = spyOn(obj, "f"); spy2.and.returnValue("can return string" as any); }); }); }
Bat-Orshikh/DefinitelyTyped
types/jasmine/ts3.1/jasmine-tests.ts
TypeScript
ArrowFunction
() => { interface Test { f(): string; f(x: any): number; } it("has a way to opt out of inferred function types", () => { const spyObject: jasmine.NonTypedSpyObj<Test> = jasmine.createSpyObj<Test>("spyObject", ["f"]); spyObject.f.and.returnValue("a string - working"); const spy2 = jasmine.createSpyObj<Test>(['f']); spy2.f.and.returnValue("can return string" as any); }); it("should be possible to opt out for spyOn", () => { const obj: Test = null!; const spy1: jasmine.Spy = spyOn(obj, "f"); spy1.and.returnValue("can return string"); const spy2 = spyOn(obj, "f"); spy2.and.returnValue("can return string" as any); }); }
Bat-Orshikh/DefinitelyTyped
types/jasmine/ts3.1/jasmine-tests.ts
TypeScript
ArrowFunction
() => { const spyObject: jasmine.NonTypedSpyObj<Test> = jasmine.createSpyObj<Test>("spyObject", ["f"]); spyObject.f.and.returnValue("a string - working"); const spy2 = jasmine.createSpyObj<Test>(['f']); spy2.f.and.returnValue("can return string" as any); }
Bat-Orshikh/DefinitelyTyped
types/jasmine/ts3.1/jasmine-tests.ts
TypeScript
ArrowFunction
() => { const obj: Test = null!; const spy1: jasmine.Spy = spyOn(obj, "f"); spy1.and.returnValue("can return string"); const spy2 = spyOn(obj, "f"); spy2.and.returnValue("can return string" as any); }
Bat-Orshikh/DefinitelyTyped
types/jasmine/ts3.1/jasmine-tests.ts
TypeScript
ArrowFunction
() => { // from boot.js const env = jasmine.getEnv(); const htmlReporter = new jasmine.HtmlReporter(); env.addReporter(htmlReporter); const specFilter = new jasmine.HtmlSpecFilter(); env.specFilter = (spec) => { return specFilter.matches(spec.getFullName()); }; const currentWindowOnload = window.onload; window.onload = () => { if (currentWindowOnload) { (currentWindowOnload as any)(null); } htmlReporter.initialize(); env.execute(); }; }
Bat-Orshikh/DefinitelyTyped
types/jasmine/ts3.1/jasmine-tests.ts
TypeScript
ArrowFunction
(spec) => { return specFilter.matches(spec.getFullName()); }
Bat-Orshikh/DefinitelyTyped
types/jasmine/ts3.1/jasmine-tests.ts
TypeScript
ArrowFunction
() => { if (currentWindowOnload) { (currentWindowOnload as any)(null); } htmlReporter.initialize(); env.execute(); }
Bat-Orshikh/DefinitelyTyped
types/jasmine/ts3.1/jasmine-tests.ts
TypeScript
ClassDeclaration
class MyClass { }
Bat-Orshikh/DefinitelyTyped
types/jasmine/ts3.1/jasmine-tests.ts
TypeScript
ClassDeclaration
class Tape { private rewindTo: number; play(): void { } pause(): void { } rewind(pos: number): void { this.rewindTo = pos; } stop(): void { } readonly isPlaying: boolean; // spy obj makes this writable }
Bat-Orshikh/DefinitelyTyped
types/jasmine/ts3.1/jasmine-tests.ts
TypeScript
ClassDeclaration
class Test { }
Bat-Orshikh/DefinitelyTyped
types/jasmine/ts3.1/jasmine-tests.ts
TypeScript
ClassDeclaration
abstract class TestClassBase { }
Bat-Orshikh/DefinitelyTyped
types/jasmine/ts3.1/jasmine-tests.ts
TypeScript
ClassDeclaration
class TestClass extends TestClassBase { }
Bat-Orshikh/DefinitelyTyped
types/jasmine/ts3.1/jasmine-tests.ts
TypeScript
ClassDeclaration
class MyClass { constructor(readonly foo: string) { } }
Bat-Orshikh/DefinitelyTyped
types/jasmine/ts3.1/jasmine-tests.ts
TypeScript
ClassDeclaration
class Base { service() { } }
Bat-Orshikh/DefinitelyTyped
types/jasmine/ts3.1/jasmine-tests.ts
TypeScript
ClassDeclaration
class Super extends Base { service2() { } }
Bat-Orshikh/DefinitelyTyped
types/jasmine/ts3.1/jasmine-tests.ts
TypeScript
InterfaceDeclaration
interface Test { method<T>(): Array<Box<T>>; }
Bat-Orshikh/DefinitelyTyped
types/jasmine/ts3.1/jasmine-tests.ts
TypeScript
InterfaceDeclaration
interface Box<T> { value: T; }
Bat-Orshikh/DefinitelyTyped
types/jasmine/ts3.1/jasmine-tests.ts
TypeScript
InterfaceDeclaration
interface Test { fn1(): void; fn2(param1: number): number; }
Bat-Orshikh/DefinitelyTyped
types/jasmine/ts3.1/jasmine-tests.ts
TypeScript
InterfaceDeclaration
interface fooType { a: number; b: number; bar: string; }
Bat-Orshikh/DefinitelyTyped
types/jasmine/ts3.1/jasmine-tests.ts
TypeScript
InterfaceDeclaration
interface nestedFooType { nested: { a: number; b: number; bar: string; }; }
Bat-Orshikh/DefinitelyTyped
types/jasmine/ts3.1/jasmine-tests.ts
TypeScript
InterfaceDeclaration
interface Matchers<T> { toBeGoofy(expected?: Expected<T>): boolean; toBeWithinRange(expected?: Expected<T>, floor?: number, ceiling?: number): boolean; }
Bat-Orshikh/DefinitelyTyped
types/jasmine/ts3.1/jasmine-tests.ts
TypeScript
InterfaceDeclaration
interface Template { method1(): number; method2(): void; readonly property1: string; property2: number; }
Bat-Orshikh/DefinitelyTyped
types/jasmine/ts3.1/jasmine-tests.ts
TypeScript
InterfaceDeclaration
interface Test { f(): string; f(x: any): number; }
Bat-Orshikh/DefinitelyTyped
types/jasmine/ts3.1/jasmine-tests.ts
TypeScript
MethodDeclaration
play(): void { }
Bat-Orshikh/DefinitelyTyped
types/jasmine/ts3.1/jasmine-tests.ts
TypeScript
MethodDeclaration
pause(): void { }
Bat-Orshikh/DefinitelyTyped
types/jasmine/ts3.1/jasmine-tests.ts
TypeScript
MethodDeclaration
rewind(pos: number): void { this.rewindTo = pos; }
Bat-Orshikh/DefinitelyTyped
types/jasmine/ts3.1/jasmine-tests.ts
TypeScript
MethodDeclaration
stop(): void { }
Bat-Orshikh/DefinitelyTyped
types/jasmine/ts3.1/jasmine-tests.ts
TypeScript
MethodDeclaration
method() { return 'baz'; }
Bat-Orshikh/DefinitelyTyped
types/jasmine/ts3.1/jasmine-tests.ts
TypeScript
MethodDeclaration
service() { }
Bat-Orshikh/DefinitelyTyped
types/jasmine/ts3.1/jasmine-tests.ts
TypeScript
MethodDeclaration
service2() { }
Bat-Orshikh/DefinitelyTyped
types/jasmine/ts3.1/jasmine-tests.ts
TypeScript
FunctionDeclaration
export default function Input(props: Props): JSX.Element { const { id, label, value, onChange, invalid = false, className, validationMessage, type = 'text', ...inputProps } = props; return ( <div className={classnames('input-group', { invalid })}> {label && ( <label className="input-label" htmlFor={id}> {label} </label> )}
jtang376/retroquest
ui/src/react/components/input/Input.tsx
TypeScript
TypeAliasDeclaration
type Props = ComponentPropsWithoutRef<'input'> & { value?: string; label?: string; invalid?: boolean; validationMessage?: string; };
jtang376/retroquest
ui/src/react/components/input/Input.tsx
TypeScript
MethodDeclaration
classnames('input-group', { invalid })
jtang376/retroquest
ui/src/react/components/input/Input.tsx
TypeScript
MethodDeclaration
classnames('input-text', className)
jtang376/retroquest
ui/src/react/components/input/Input.tsx
TypeScript
ClassDeclaration
@Injectable() export class OrderDetailsService { constructor( @InjectRepository(OrderDetails) private repository: Repository<OrderDetails>, ) {} async findOne(where: any): Promise<OrderDetails> { return await this.repository.findOne({ where }); } async find(query: any = null, params: any = null): Promise<any> { const fields: string[] = 'num, course, target, hours, price, cost, timing, rem'.split(', '); const queryParams = QueryParams.prepare(query, fields, params); const [result, total] = await this.repository.findAndCount(queryParams); return { rows: result, rowsNumber: total, }; } async save(orderDetails: OrderDetailsDto): Promise<any> { try { return await this.repository.save(orderDetails); } catch (error) { return { error, orderDetails }; } } async remove(orderDetails: OrderDetailsDto): Promise<any> { const { id } = orderDetails; try { return await this.repository.delete({id}); } catch (error) { return { error, orderDetails }; } } async removeOrder(idOrder: number): Promise<any> { try { return await this.repository.delete({idOrder}); } catch (error) { return { error, idOrder }; } } }
stokaboka/la-backend
src/order-details/order-details.service.ts
TypeScript
MethodDeclaration
async findOne(where: any): Promise<OrderDetails> { return await this.repository.findOne({ where }); }
stokaboka/la-backend
src/order-details/order-details.service.ts
TypeScript
MethodDeclaration
async find(query: any = null, params: any = null): Promise<any> { const fields: string[] = 'num, course, target, hours, price, cost, timing, rem'.split(', '); const queryParams = QueryParams.prepare(query, fields, params); const [result, total] = await this.repository.findAndCount(queryParams); return { rows: result, rowsNumber: total, }; }
stokaboka/la-backend
src/order-details/order-details.service.ts
TypeScript
MethodDeclaration
async save(orderDetails: OrderDetailsDto): Promise<any> { try { return await this.repository.save(orderDetails); } catch (error) { return { error, orderDetails }; } }
stokaboka/la-backend
src/order-details/order-details.service.ts
TypeScript
MethodDeclaration
async remove(orderDetails: OrderDetailsDto): Promise<any> { const { id } = orderDetails; try { return await this.repository.delete({id}); } catch (error) { return { error, orderDetails }; } }
stokaboka/la-backend
src/order-details/order-details.service.ts
TypeScript
MethodDeclaration
async removeOrder(idOrder: number): Promise<any> { try { return await this.repository.delete({idOrder}); } catch (error) { return { error, idOrder }; } }
stokaboka/la-backend
src/order-details/order-details.service.ts
TypeScript
FunctionDeclaration
export function createTopNav( data: DataPublicPluginStart, extraConfig: RegisteredTopNavMenuData[], i18n: I18nStart ) { return (props: TopNavMenuProps) => { const relevantConfig = extraConfig.filter( dataItem => dataItem.appName === undefined || dataItem.appName === props.appName ); const config = (props.config || []).concat(relevantConfig); return ( <i18n.Context> <TopNavMenu {...props} data={data} config={config} /> </i18n.Context> ); }; }
AlexCornigeanu/kibana
src/plugins/navigation/public/top_nav_menu/create_top_nav_menu.tsx
TypeScript
ArrowFunction
(props: TopNavMenuProps) => { const relevantConfig = extraConfig.filter( dataItem => dataItem.appName === undefined || dataItem.appName === props.appName ); const config = (props.config || []).concat(relevantConfig); return ( <i18n.Context> <TopNavMenu {...props} data={data} config={config} /> </i18n.Context> ); }
AlexCornigeanu/kibana
src/plugins/navigation/public/top_nav_menu/create_top_nav_menu.tsx
TypeScript
ArrowFunction
dataItem => dataItem.appName === undefined || dataItem.appName === props.appName
AlexCornigeanu/kibana
src/plugins/navigation/public/top_nav_menu/create_top_nav_menu.tsx
TypeScript
ClassDeclaration
export class TabPage { changeTabAnimation = $('.mat-tab-labels div[class="mat-ripple-element"]'); public disabledContentNodeSelectorTabInfoIcon = TestElement.byCss('[data-automation-id="adf-content-node-selector-disabled-tab-info-icon"]'); async clickTabByLabel(tabLabel): Promise<void> { const user = element(by.cssContainingText('.mat-tab-label-content', tabLabel)); await BrowserActions.click(user); await BrowserVisibility.waitUntilElementIsNotVisible(this.changeTabAnimation); } async checkTabIsDisplayedByLabel(tabLabel): Promise<void> { await BrowserVisibility.waitUntilElementIsVisible(element(by.cssContainingText('.mat-tab-label-content', tabLabel))); } async checkTabIsNotDisplayedByLabel(tabLabel): Promise<void> { await BrowserVisibility.waitUntilElementIsNotVisible(element(by.cssContainingText('.mat-tab-label-content', tabLabel))); } }
silverskyvicto/alfresco-ng2-components
lib/testing/src/lib/protractor/core/pages/form/widgets/tab.page.ts
TypeScript
MethodDeclaration
async clickTabByLabel(tabLabel): Promise<void> { const user = element(by.cssContainingText('.mat-tab-label-content', tabLabel)); await BrowserActions.click(user); await BrowserVisibility.waitUntilElementIsNotVisible(this.changeTabAnimation); }
silverskyvicto/alfresco-ng2-components
lib/testing/src/lib/protractor/core/pages/form/widgets/tab.page.ts
TypeScript
MethodDeclaration
async checkTabIsDisplayedByLabel(tabLabel): Promise<void> { await BrowserVisibility.waitUntilElementIsVisible(element(by.cssContainingText('.mat-tab-label-content', tabLabel))); }
silverskyvicto/alfresco-ng2-components
lib/testing/src/lib/protractor/core/pages/form/widgets/tab.page.ts
TypeScript
MethodDeclaration
async checkTabIsNotDisplayedByLabel(tabLabel): Promise<void> { await BrowserVisibility.waitUntilElementIsNotVisible(element(by.cssContainingText('.mat-tab-label-content', tabLabel))); }
silverskyvicto/alfresco-ng2-components
lib/testing/src/lib/protractor/core/pages/form/widgets/tab.page.ts
TypeScript
ArrowFunction
() => { return ( <PatternLayout pattern={Pattern.StackedCards}> <Head> <meta name="description" content="Create stacked cards with CSS" /> <meta name="og:description" content="Create stacked cards with CSS" /> <meta name="twitter:description" content="Create stacked cards with CSS" /> <meta name="keywords" content="css card, css stacked cards, css transform rotate" /> </Head> <BrowserFrame html={` <div class="container"> <!-- Repeat if you want to have more cards --> <div class="container__card"></div> <!-- Main card's content --> ... </div> `}
1milligram/csslayout
pages/stacked-cards/index.tsx
TypeScript
ArrowFunction
(_, index) => { return ( <div key={index} style={{ backgroundColor: '#fff', border: '1px solid rgba(0, 0, 0, 0.3)', borderRadius: '4px', height: '100%', left: 0, position: 'absolute', top: 0, transform: `rotate(${5 * (index + 1)}deg)`, width: '100%', zIndex: -1, }}
1milligram/csslayout
pages/stacked-cards/index.tsx
TypeScript
MethodDeclaration
Array(5)
1milligram/csslayout
pages/stacked-cards/index.tsx
TypeScript
ClassDeclaration
@Entity() export class User { @PrimaryColumn('uuid') id: string; @Column({ unique: true }) username: string; @Column() password: string; }
Fasara/nestjs-task-management
src/auth/user.entity.ts
TypeScript
FunctionDeclaration
export default function Band({ id, onChange, band }: Props) { const sliders = useTypedSelector(Selectors.getSliders); const value = sliders[band]; const backgroundPosition = useMemo(() => { const { x, y } = spriteOffsets(spriteNumber(value)); const xOffset = x * 15; // Each sprite is 15px wide const yOffset = y * 65; // Each sprite is 15px tall return `-${xOffset}px -${yOffset}px`; }, [value]); const focusBand = useActionCreator(Actions.focusBand); const usetFocus = useActionCreator(Actions.unsetFocus); // Note: The band background is actually one pixel taller (63) than the slider // it contains (62). return ( <div id={id} className="band" style={{ backgroundPosition, height: 63 }}
0x5066/webamp
packages/webamp/js/components/EqualizerWindow/Band.tsx
TypeScript
ArrowFunction
(value: number): number => { const percent = value / MAX_VALUE; return Math.round(percent * 27); }
0x5066/webamp
packages/webamp/js/components/EqualizerWindow/Band.tsx
TypeScript
ArrowFunction
(number: number): { x: number; y: number } => { const x = number % 14; const y = Math.floor(number / 14); return { x, y }; }
0x5066/webamp
packages/webamp/js/components/EqualizerWindow/Band.tsx
TypeScript
ArrowFunction
() => { const style = { width: 11, height: 11, marginLeft: 1 }; return <div style={style} className="slider-handle" />; }
0x5066/webamp
packages/webamp/js/components/EqualizerWindow/Band.tsx
TypeScript
ArrowFunction
() => { const { x, y } = spriteOffsets(spriteNumber(value)); const xOffset = x * 15; // Each sprite is 15px wide const yOffset = y * 65; // Each sprite is 15px tall return `-${xOffset}px -${yOffset}px`; }
0x5066/webamp
packages/webamp/js/components/EqualizerWindow/Band.tsx
TypeScript
InterfaceDeclaration
interface Props { id: string; band: SliderType; onChange(value: number): void; }
0x5066/webamp
packages/webamp/js/components/EqualizerWindow/Band.tsx
TypeScript
ArrowFunction
( props: AntdIconProps, ref: React.MutableRefObject<HTMLSpanElement>, ) => <AntdIcon {...props}
infra-fe/infra-design-icons
packages/icons-react/src/icons/IEmail.tsx
TypeScript
ArrowFunction
(eventInfoVersion) => { assert.equal(expected, getDroppedObjectsText(eventInfoVersion)); }
123youyouer/cockroach
pkg/ui/src/util/events.spec.ts
TypeScript
ArrowFunction
(type, key1) => ( type.map((data, key2) => ( data.version !== "" && data.type === "draft" && ( <GridItem span={6}> <Card className="pf-m-light pf-site-background-medium pf-c-card-draft"> <CardHeader> <CardHeaderMain><strong>Draft</strong></CardHeaderMain> <CardActions>{ }</CardActions> {data.metadata !== undefined && !this.state.showMetadataAlertIcon && <CardActions> <Button variant="link" isInline={true} onClick={this.handleModalToggle} id="draft">Add metadata</Button> </CardActions>} {data.metadata !== undefined && this.state.showMetadataAlertIcon && <CardActions><ExclamationTriangleIcon color="#f0ab00" /> <Button variant="link" isInline={true} onClick={this.handleModalToggle} id="draft">Add metadata</Button> </CardActions>} <CardActions><Button variant="link" isInline={true} onClick={() => this.previewDoc(data.secondButtonText)
laubai/pantheon
pantheon-bundle/frontend/src/app/versions.tsx
TypeScript
ArrowFunction
(data, key2) => ( data.version !== "" && data.type === "draft" && ( <GridItem span={6}> <Card className
laubai/pantheon
pantheon-bundle/frontend/src/app/versions.tsx
TypeScript
ArrowFunction
item => ( <TextList component={TextListVariants.ul}> <TextListItem component
laubai/pantheon
pantheon-bundle/frontend/src/app/versions.tsx
TypeScript
ArrowFunction
(item) => ( <TextList component={TextListVariants.ul}> <TextListItem component
laubai/pantheon
pantheon-bundle/frontend/src/app/versions.tsx
TypeScript
ArrowFunction
(type, key1) => ( type.map((data, key2) => ( data.version !== "" && data.type === "release" && ( <GridItem span={6}> <div className="pf-c-card pf-m-selectable pf-m-selected"> <Card className="pf-m-selected"> <CardHeader> <CardHeaderMain><strong><span id="span-source-type-version-published">Published</span></strong></CardHeaderMain> <CardActions>{ }</CardActions> <CardActions> <Button variant="link" isInline={true} onClick={this.handleModalToggle} id="released">Add metadata</Button> </CardActions> <CardActions> <Button variant="link" isInline={true} onClick={() => this.previewDoc(data.secondButtonText)
laubai/pantheon
pantheon-bundle/frontend/src/app/versions.tsx
TypeScript
ArrowFunction
(data, key2) => ( data.version !== "" && data.type === "release" && ( <GridItem span={6}> <div className
laubai/pantheon
pantheon-bundle/frontend/src/app/versions.tsx
TypeScript
ArrowFunction
item => ( <TextList component={TextListVariants.ul}> <TextListItem component
laubai/pantheon
pantheon-bundle/frontend/src/app/versions.tsx
TypeScript
ArrowFunction
(item) => ( <TextList component={TextListVariants.ul}> <TextListItem component
laubai/pantheon
pantheon-bundle/frontend/src/app/versions.tsx
TypeScript
ArrowFunction
(option, key) => ( <FormSelectOption key={key}
laubai/pantheon
pantheon-bundle/frontend/src/app/versions.tsx
TypeScript
ArrowFunction
(option, key) => ( <FormSelectOption key={"usecase_" + key}
laubai/pantheon
pantheon-bundle/frontend/src/app/versions.tsx
TypeScript
ArrowFunction
() => { // TODO: need a better fix for the 404 error. if (this.props.modulePath !== "") { this.getValidations("draft") this.getValidations("released") // fetchpath needs to start from modulePath instead of modulePath/en_US. // We need extact the module uuid for customer portal url to the module. const fetchpath = "/content" + this.props.modulePath + ".harray.5.json" fetch(fetchpath) .then(response => response.json()) .then(responseJSON => { const en_US = this.getHarrayChildNamed(responseJSON, "en_US") const source = this.getHarrayChildNamed(en_US, "source") const variants = this.getHarrayChildNamed(en_US, "variants") const firstVariant = this.getHarrayChildNamed(variants, this.props.variant) // process draftUpdateDate from source/draft let draftUpload = "" let releaseUpload = "" if (source !== "undefined" && source.__name__ === "source") { for (const childNode of source.__children__) { if (childNode.__name__ === "draft") { draftUpload = childNode["jcr:created"] } else if (childNode.__name__ === "released") { releaseUpload = childNode["jcr:created"] } } } // process variantUUID let variantUuid = "" if (firstVariant["jcr:primaryType"] !== "undefined" && (firstVariant["jcr:primaryType"] === "pant:moduleVariant" || firstVariant["jcr:primaryType"] === "pant:assemblyVariant")) { variantUuid = firstVariant["jcr:uuid"] } const versionCount = firstVariant.__children__.length for (let i = 0; i < versionCount; i++) { const moduleVersion = firstVariant.__children__[i] let variantReleased = false if (moduleVersion.__name__ === "draft") { this.draft[0].version = "Version " + moduleVersion.__name__ this.draft[0].metadata = this.getHarrayChildNamed(moduleVersion, "metadata") // get created date from source/draft this.draft[0].updatedDate = draftUpload // this.props.modulePath starts with a slash this.draft[0].path = "/content" + this.props.modulePath + "/en_US/variants/" + firstVariant.__name__ + "/" + moduleVersion.__name__ this.draft[0].validations = this.state.draftValidations } if (moduleVersion.__name__ === "released") { this.release[0].version = "Version " + moduleVersion.__name__ this.release[0].metadata = this.getHarrayChildNamed(moduleVersion, "metadata") this.release[0].updatedDate = releaseUpload // get created date from source/draft this.release[0].draftUploadDate = draftUpload // this.props.modulePath starts with a slash this.release[0].path = "/content" + this.props.modulePath + "/en_US/variants/" + firstVariant.__name__ + "/" + moduleVersion.__name__ this.release[0].validations = this.state.releasedValidations variantReleased = true } if (!variantReleased) { this.release[0].updatedDate = "-" } this.props.updateDate(this.release[0].version, variantUuid) } this.setState({ results: [this.draft, this.release], variantPath: "/content" + this.props.modulePath + "/en_US/variants/" + this.props.variant }) // Check metadata for draft. Show warning icon if metadata missing for draft if (this.draft && this.draft[0].path.length > 0) { if (this.draft[0].metadata !== undefined && this.draft[0].metadata.productVersion === undefined) { this.setState({ showMetadataAlertIcon: true }) } else { this.setState({ showMetadataAlertIcon: false }) } } // Get documents included in assembly if (this.props.contentType === "assembly") { this.getDocumentsIncluded(variantUuid) } }) } }
laubai/pantheon
pantheon-bundle/frontend/src/app/versions.tsx
TypeScript
ArrowFunction
responseJSON => { const en_US = this.getHarrayChildNamed(responseJSON, "en_US") const source = this.getHarrayChildNamed(en_US, "source") const variants = this.getHarrayChildNamed(en_US, "variants") const firstVariant = this.getHarrayChildNamed(variants, this.props.variant) // process draftUpdateDate from source/draft let draftUpload = "" let releaseUpload = "" if (source !== "undefined" && source.__name__ === "source") { for (const childNode of source.__children__) { if (childNode.__name__ === "draft") { draftUpload = childNode["jcr:created"] } else if (childNode.__name__ === "released") { releaseUpload = childNode["jcr:created"] } } } // process variantUUID let variantUuid = "" if (firstVariant["jcr:primaryType"] !== "undefined" && (firstVariant["jcr:primaryType"] === "pant:moduleVariant" || firstVariant["jcr:primaryType"] === "pant:assemblyVariant")) { variantUuid = firstVariant["jcr:uuid"] } const versionCount = firstVariant.__children__.length for (let i = 0; i < versionCount; i++) { const moduleVersion = firstVariant.__children__[i] let variantReleased = false if (moduleVersion.__name__ === "draft") { this.draft[0].version = "Version " + moduleVersion.__name__ this.draft[0].metadata = this.getHarrayChildNamed(moduleVersion, "metadata") // get created date from source/draft this.draft[0].updatedDate = draftUpload // this.props.modulePath starts with a slash this.draft[0].path = "/content" + this.props.modulePath + "/en_US/variants/" + firstVariant.__name__ + "/" + moduleVersion.__name__ this.draft[0].validations = this.state.draftValidations } if (moduleVersion.__name__ === "released") { this.release[0].version = "Version " + moduleVersion.__name__ this.release[0].metadata = this.getHarrayChildNamed(moduleVersion, "metadata") this.release[0].updatedDate = releaseUpload // get created date from source/draft this.release[0].draftUploadDate = draftUpload // this.props.modulePath starts with a slash this.release[0].path = "/content" + this.props.modulePath + "/en_US/variants/" + firstVariant.__name__ + "/" + moduleVersion.__name__ this.release[0].validations = this.state.releasedValidations variantReleased = true } if (!variantReleased) { this.release[0].updatedDate = "-" } this.props.updateDate(this.release[0].version, variantUuid) } this.setState({ results: [this.draft, this.release], variantPath: "/content" + this.props.modulePath + "/en_US/variants/" + this.props.variant }) // Check metadata for draft. Show warning icon if metadata missing for draft if (this.draft && this.draft[0].path.length > 0) { if (this.draft[0].metadata !== undefined && this.draft[0].metadata.productVersion === undefined) { this.setState({ showMetadataAlertIcon: true }) } else { this.setState({ showMetadataAlertIcon: false }) } } // Get documents included in assembly if (this.props.contentType === "assembly") { this.getDocumentsIncluded(variantUuid) } }
laubai/pantheon
pantheon-bundle/frontend/src/app/versions.tsx
TypeScript
ArrowFunction
(object, name) => { for (const childName in object.__children__) { if (object.__children__.hasOwnProperty(childName)) { // Not sure what this does, but makes tslin happy const child = object.__children__[childName] if (child.__name__ === name) { return child } } } return "" }
laubai/pantheon
pantheon-bundle/frontend/src/app/versions.tsx
TypeScript
ArrowFunction
(buttonText) => { // Validate productValue before Publish if (this.props.productInfo !== undefined && this.props.productInfo.trim() === "" && buttonText === "Publish") { this.setState({ canChangePublishState: false, publishAlertVisible: true }) } else { if (this.state.canChangePublishState === true) { const formData = new FormData(); if (buttonText === "Publish") { formData.append(":operation", "pant:publish"); // console.log("Published file path:", this.props.modulePath) this.draft[0].version = ""; this.setState({ unpublishAlertForModuleVisible: false }) } else { formData.append(":operation", "pant:unpublish"); // console.log("Unpublished file path:", this.props.modulePath); this.release[0].version = ""; this.setState({ unpublishAlertForModuleVisible: true }) } const hdrs = { "Accept": "application/json", "cache-control": "no-cache", "Access-Control-Allow-Origin": "*" } formData.append("locale", "en_US") formData.append("variant", this.props.variant) fetch("/content" + this.props.modulePath, { body: formData, method: "post", headers: hdrs }).then(response => { if (response.status === 201 || response.status === 200) { console.log(buttonText + " works: " + response.status) this.setState({ canChangePublishState: true, publishAlertVisible: false, showMetadataAlertIcon: false }) } else { console.log(buttonText + " failed " + response.status) this.setState({ publishAlertVisible: true }) this.setAlertTitle() } this.fetchVersions() return response.json() }).then(response => this.props.onGetUrl(response.path)); } } }
laubai/pantheon
pantheon-bundle/frontend/src/app/versions.tsx
TypeScript
ArrowFunction
response => { if (response.status === 201 || response.status === 200) { console.log(buttonText + " works: " + response.status) this.setState({ canChangePublishState: true, publishAlertVisible: false, showMetadataAlertIcon: false }) } else { console.log(buttonText + " failed " + response.status) this.setState({ publishAlertVisible: true }) this.setAlertTitle() } this.fetchVersions() return response.json() }
laubai/pantheon
pantheon-bundle/frontend/src/app/versions.tsx
TypeScript
ArrowFunction
response => this.props.onGetUrl(response.path)
laubai/pantheon
pantheon-bundle/frontend/src/app/versions.tsx
TypeScript
ArrowFunction
(buttonText) => { let docPath = "" docPath = "/pantheon/preview/" + (buttonText === "Preview" ? "latest" : "released") + "/" + this.props.variantUUID return window.open(docPath) }
laubai/pantheon
pantheon-bundle/frontend/src/app/versions.tsx
TypeScript
ArrowFunction
(event) => { this.setState({ isModalOpen: !this.state.isModalOpen }) // process path const target = event.nativeEvent.target if (target.id !== undefined && target.id.trim().length > 0) { this.getMetadata(event) } }
laubai/pantheon
pantheon-bundle/frontend/src/app/versions.tsx
TypeScript
ArrowFunction
() => { this.setState({ isModalOpen: false }) }
laubai/pantheon
pantheon-bundle/frontend/src/app/versions.tsx
TypeScript
ArrowFunction
(event) => { // save form data if (this.state.product.value === undefined || this.state.product.value === "Select a Product" || this.state.product.value === "" || this.state.productVersion.uuid === undefined || this.state.productVersion.label === "Select a Version" || this.state.productVersion.uuid === "" || this.state.usecaseValue === undefined || this.state.usecaseValue === "Select Use Case" || this.state.usecaseValue === "") { this.setState({ isMissingFields: true }) } else { const hdrs = { "Accept": "application/json", "cache-control": "no-cache" } const formData = new FormData(event.target.form) let eventID = "" formData.append("productVersion", this.state.productVersion.uuid) formData.append("documentUsecase", this.state.usecaseValue) formData.append("urlFragment", this.state.urlFragment.trim().length > 0 ? "/" + this.state.urlFragment.trim() : "") formData.append("searchKeywords", this.state.keywords === undefined ? "" : this.state.keywords) const target = event.nativeEvent.target if (target !== null && target.id !== undefined && target.id === "draft") { eventID = event.target.id } fetch(this.state.metadataPath + "/metadata", { body: formData, headers: hdrs, method: "post" }).then(response => { if (response.status === 201 || response.status === 200) { // console.log("successful edit ", response.status) this.handleModalClose() this.setState({ canChangePublishState: true, publishAlertVisible: false, successAlertVisible: true, }) if (this.state.metadataPath.endsWith("/draft")) { this.setState({ showMetadataAlertIcon: false }) this.fetchVersions() } this.props.onGetProduct(this.state.product.label) this.props.onGetVersion(this.state.productVersion.label) } else if (response.status === 500) { // console.log(" Needs login " + response.status) this.setState({ login: true }) } }) } }
laubai/pantheon
pantheon-bundle/frontend/src/app/versions.tsx
TypeScript
ArrowFunction
response => { if (response.status === 201 || response.status === 200) { // console.log("successful edit ", response.status) this.handleModalClose() this.setState({ canChangePublishState: true, publishAlertVisible: false, successAlertVisible: true, }) if (this.state.metadataPath.endsWith("/draft")) { this.setState({ showMetadataAlertIcon: false }) this.fetchVersions() } this.props.onGetProduct(this.state.product.label) this.props.onGetVersion(this.state.productVersion.label) } else if (response.status === 500) { // console.log(" Needs login " + response.status) this.setState({ login: true }) } }
laubai/pantheon
pantheon-bundle/frontend/src/app/versions.tsx
TypeScript
ArrowFunction
(productValue: string, event: React.FormEvent<HTMLSelectElement>) => { let productLabel = "" const target = event.nativeEvent.target if (target !== null) { // Necessary because target.selectedOptions produces a compiler error but is valid // tslint:disable-next-line: no-string-literal productLabel = target["selectedOptions"][0].label } this.setState({ product: { label: productLabel, value: productValue }, productVersion: { label: "", uuid: "" } }) this.populateProductVersions(productValue) }
laubai/pantheon
pantheon-bundle/frontend/src/app/versions.tsx
TypeScript
ArrowFunction
json => { this.setState({ allProductVersions: json.__children__ }) }
laubai/pantheon
pantheon-bundle/frontend/src/app/versions.tsx
TypeScript
ArrowFunction
(value: string, event: React.FormEvent<HTMLSelectElement>) => { if (event.target !== null) { // Necessary because target.selectedOptions produces a compiler error but is valid // tslint:disable-next-line: no-string-literal const selectedOption = event.target["selectedOptions"][0] if (this.state.productVersion.uuid !== selectedOption.value) { this.setState({ productVersion: { label: selectedOption.label, uuid: selectedOption.value } }) } } }
laubai/pantheon
pantheon-bundle/frontend/src/app/versions.tsx
TypeScript
ArrowFunction
(usecaseValue, event) => { this.setState({ usecaseValue }) }
laubai/pantheon
pantheon-bundle/frontend/src/app/versions.tsx
TypeScript
ArrowFunction
urlFragment => { this.setState({ urlFragment }) }
laubai/pantheon
pantheon-bundle/frontend/src/app/versions.tsx
TypeScript
ArrowFunction
keywords => { this.setState({ keywords }) }
laubai/pantheon
pantheon-bundle/frontend/src/app/versions.tsx
TypeScript
ArrowFunction
() => { const path = "/content/products.harray.1.json" const products = new Array() fetch(path) .then((response) => { if (response.ok) { return response.json() } else { throw new Error(response.statusText) } }) .then(responseJSON => { for (const product of responseJSON.__children__) { if (product.name !== undefined) { products.push({ label: product.name, value: product.__name__ }) } } this.setState({ allProducts: products }) }) .catch((error) => { console.log(error) }) return products }
laubai/pantheon
pantheon-bundle/frontend/src/app/versions.tsx
TypeScript
ArrowFunction
(response) => { if (response.ok) { return response.json() } else { throw new Error(response.statusText) } }
laubai/pantheon
pantheon-bundle/frontend/src/app/versions.tsx
TypeScript
ArrowFunction
responseJSON => { for (const product of responseJSON.__children__) { if (product.name !== undefined) { products.push({ label: product.name, value: product.__name__ }) } } this.setState({ allProducts: products }) }
laubai/pantheon
pantheon-bundle/frontend/src/app/versions.tsx
TypeScript
ArrowFunction
(error) => { console.log(error) }
laubai/pantheon
pantheon-bundle/frontend/src/app/versions.tsx
TypeScript
ArrowFunction
() => { this.setState({ isMissingFields: false }) }
laubai/pantheon
pantheon-bundle/frontend/src/app/versions.tsx
TypeScript
ArrowFunction
() => { this.setState({ successAlertVisible: false }) }
laubai/pantheon
pantheon-bundle/frontend/src/app/versions.tsx
TypeScript
ArrowFunction
() => { this.setState({ publishAlertVisible: false }) }
laubai/pantheon
pantheon-bundle/frontend/src/app/versions.tsx
TypeScript
ArrowFunction
() => { this.setState({ unpublishAlertForModuleVisible: false }) }
laubai/pantheon
pantheon-bundle/frontend/src/app/versions.tsx
TypeScript
ArrowFunction
(event) => { let versionValue = "" let metadataPath = "" if (event !== undefined && event.target.id !== undefined) { versionValue = event.target.id } else { versionValue = "draft" } metadataPath = this.state.variantPath + "/" + versionValue fetch(`${this.state.variantPath}/${versionValue}/metadata.json`) .then(response => response.json()) .then(metadataResults => { if (JSON.stringify(metadataResults) !== "[]") { this.setState({ metadataPath }) // Process results // Remove leading slash. if (metadataResults.urlFragment) { let urlFragment = metadataResults.urlFragment if (urlFragment.indexOf("/") === 0) { urlFragment = urlFragment.replace("/", "") } this.setState({ urlFragment }) } if (metadataResults.searchKeywords) { this.setState({ keywords: metadataResults.searchKeywords }) } if (metadataResults.productVersion) { this.setState({ productVersion: { label: "", uuid: metadataResults.productVersion } }) } if (metadataResults.documentUsecase) { this.setState({ usecaseValue: metadataResults.documentUsecase }) } if (metadataResults.productVersion !== undefined) { this.getProductFromVersionUuid(metadataResults.productVersion) if (versionValue === "draft") { this.setState({ showMetadataAlertIcon: false }) } } } }) }
laubai/pantheon
pantheon-bundle/frontend/src/app/versions.tsx
TypeScript
ArrowFunction
metadataResults => { if (JSON.stringify(metadataResults) !== "[]") { this.setState({ metadataPath }) // Process results // Remove leading slash. if (metadataResults.urlFragment) { let urlFragment = metadataResults.urlFragment if (urlFragment.indexOf("/") === 0) { urlFragment = urlFragment.replace("/", "") } this.setState({ urlFragment }) } if (metadataResults.searchKeywords) { this.setState({ keywords: metadataResults.searchKeywords }) } if (metadataResults.productVersion) { this.setState({ productVersion: { label: "", uuid: metadataResults.productVersion } }) } if (metadataResults.documentUsecase) { this.setState({ usecaseValue: metadataResults.documentUsecase }) } if (metadataResults.productVersion !== undefined) { this.getProductFromVersionUuid(metadataResults.productVersion) if (versionValue === "draft") { this.setState({ showMetadataAlertIcon: false }) } } } }
laubai/pantheon
pantheon-bundle/frontend/src/app/versions.tsx
TypeScript
ArrowFunction
responseJSON => { this.setState({ product: { label: responseJSON.ancestors[1].name, value: responseJSON.ancestors[1].__name__ }, productVersion: { label: responseJSON.name, uuid: responseJSON["jcr:uuid"] } }) this.populateProductVersions(this.state.product.value) this.props.onGetProduct(this.state.product.label) this.props.onGetVersion(this.state.productVersion.label) }
laubai/pantheon
pantheon-bundle/frontend/src/app/versions.tsx
TypeScript