type
stringclasses 7
values | content
stringlengths 4
9.55k
| repo
stringlengths 7
96
| path
stringlengths 4
178
| language
stringclasses 1
value |
---|---|---|---|---|
ArrowFunction |
() => {
this.store.toggleAuthDialog = jest.fn();
const wrapper = shallow(<PublishButton appState={this.store} />);
wrapper.find('button').simulate('click');
expect(this.store.toggleAuthDialog).toHaveBeenCalled();
} | bradparks/fiddle__electron_fiddle_snippet_try_out | tests/renderer/components/publish-button-spec.tsx | TypeScript |
ArrowFunction |
async () => {
this.store.gitHubToken = 'github-token';
const wrapper = shallow(<PublishButton appState={this.store} />);
const instance: PublishButton = wrapper.instance() as any;
instance.publishFiddle = jest.fn();
await instance.handleClick();
expect(instance.publishFiddle).toHaveBeenCalled();
} | bradparks/fiddle__electron_fiddle_snippet_try_out | tests/renderer/components/publish-button-spec.tsx | TypeScript |
ArrowFunction |
async () => {
const mockOctokit = {
authenticate: jest.fn(),
gists: {
create: jest.fn(async () => ({ data: { id: '123' } }))
}
};
(getOctokit as any).mockReturnValue(mockOctokit);
const wrapper = shallow(<PublishButton appState={this.store} />);
const instance: PublishButton = wrapper.instance() as any;
await instance.publishFiddle();
expect(mockOctokit.authenticate).toHaveBeenCalled();
expect(mockOctokit.gists.create).toHaveBeenCalledWith({
description: 'Electron Fiddle Gist',
files: {
'index.html': { content: 'html-content' },
'renderer.js': { content: 'renderer-content' },
'main.js': { content: 'main-content' },
},
public: true
});
} | bradparks/fiddle__electron_fiddle_snippet_try_out | tests/renderer/components/publish-button-spec.tsx | TypeScript |
ArrowFunction |
async () => ({ data: { id: '123' } }) | bradparks/fiddle__electron_fiddle_snippet_try_out | tests/renderer/components/publish-button-spec.tsx | TypeScript |
ArrowFunction |
async () => {
const mockOctokit = {
authenticate: jest.fn(),
gists: {
create: jest.fn(() => {
throw new Error('bwap bwap');
})
}
};
(getOctokit as any).mockReturnValue(mockOctokit);
const wrapper = shallow(<PublishButton appState={this.store} />);
const instance: PublishButton = wrapper.instance() as any;
await instance.publishFiddle();
expect(mockOctokit.authenticate).toHaveBeenCalled();
expect(wrapper.state('isPublishing')).toBe(false);
} | bradparks/fiddle__electron_fiddle_snippet_try_out | tests/renderer/components/publish-button-spec.tsx | TypeScript |
ArrowFunction |
() => {
throw new Error('bwap bwap');
} | bradparks/fiddle__electron_fiddle_snippet_try_out | tests/renderer/components/publish-button-spec.tsx | TypeScript |
ArrowFunction |
error => this.props.onError(error) | mrkosima/adyen-web | packages/lib/src/components/Dropin/Dropin.tsx | TypeScript |
ArrowFunction |
() => {
const { data, isValid } = this.activePaymentMethod;
if (!isValid) {
this.showValidation();
return false;
}
return this.props.onSubmit({ data, isValid }, this);
} | mrkosima/adyen-web | packages/lib/src/components/Dropin/Dropin.tsx | TypeScript |
ArrowFunction |
state => this.props.onAdditionalDetails(state, this) | mrkosima/adyen-web | packages/lib/src/components/Dropin/Dropin.tsx | TypeScript |
ClassDeclaration |
class DropinElement extends UIElement<DropinElementProps> {
public static type = 'dropin';
protected static defaultProps = defaultProps;
public dropinRef = null;
constructor(props) {
super(props);
this.submit = this.submit.bind(this);
}
get isValid() {
return !!this.dropinRef && !!this.dropinRef.state.activePaymentMethod && !!this.dropinRef.state.activePaymentMethod.isValid;
}
showValidation() {
if (this.dropinRef.state.activePaymentMethod) {
this.dropinRef.state.activePaymentMethod.showValidation();
}
return this;
}
setStatus(status, props = {}) {
this.dropinRef.setStatus({ type: status, props });
return this;
}
get activePaymentMethod() {
if (!this.dropinRef.state && !this.dropinRef.state.activePaymentMethod) {
return null;
}
return this.dropinRef.state.activePaymentMethod;
}
get data() {
if (!this.activePaymentMethod) {
return null;
}
return this.dropinRef.state.activePaymentMethod.data;
}
/**
* Calls the onSubmit event with the state of the activePaymentMethod
*/
submit(): void {
if (!this.activePaymentMethod) {
throw new Error('No active payment method.');
}
this.activePaymentMethod
.startPayment()
.then(this.handleSubmit)
.catch(error => this.props.onError(error));
}
protected handleSubmit = () => {
const { data, isValid } = this.activePaymentMethod;
if (!isValid) {
this.showValidation();
return false;
}
return this.props.onSubmit({ data, isValid }, this);
};
handleAction(action: PaymentAction) {
if (!action || !action.type) throw new Error('Invalid Action');
if (this.activePaymentMethod.updateWithAction) {
return this.activePaymentMethod.updateWithAction(action);
}
// Extract desired props that we need to pass on from the pmConfiguration for this particular PM
const pmConfig = getComponentConfiguration(action.paymentMethodType, this.props.paymentMethodsConfiguration);
const paymentAction: UIElement = this.props.createFromAction(action, {
isDropin: true,
onAdditionalDetails: state => this.props.onAdditionalDetails(state, this),
onError: this.props.onError, // Add ref to onError in case the merchant has defined one in the component options
...(pmConfig?.onError && { onError: pmConfig.onError }) // Overwrite ref to onError in case the merchant has defined one in the pmConfig options
});
if (paymentAction) {
return this.setStatus(paymentAction.props.statusType, { component: paymentAction });
}
return null;
}
render() {
return (
<CoreProvider i18n={this.props.i18n} loadingContext={this.props.loadingContext}>
<DropinComponent
{...this.props}
onChange={this.setState}
onSubmit={this.handleSubmit}
elementRef={this.elementRef}
ref={dropinRef => {
this.dropinRef = dropinRef;
}} | mrkosima/adyen-web | packages/lib/src/components/Dropin/Dropin.tsx | TypeScript |
MethodDeclaration |
showValidation() {
if (this.dropinRef.state.activePaymentMethod) {
this.dropinRef.state.activePaymentMethod.showValidation();
}
return this;
} | mrkosima/adyen-web | packages/lib/src/components/Dropin/Dropin.tsx | TypeScript |
MethodDeclaration |
setStatus(status, props = {}) {
this.dropinRef.setStatus({ type: status, props });
return this;
} | mrkosima/adyen-web | packages/lib/src/components/Dropin/Dropin.tsx | TypeScript |
MethodDeclaration | /**
* Calls the onSubmit event with the state of the activePaymentMethod
*/
submit(): void {
if (!this.activePaymentMethod) {
throw new Error('No active payment method.');
}
this.activePaymentMethod
.startPayment()
.then(this.handleSubmit)
.catch(error => this.props.onError(error));
} | mrkosima/adyen-web | packages/lib/src/components/Dropin/Dropin.tsx | TypeScript |
MethodDeclaration |
handleAction(action: PaymentAction) {
if (!action || !action.type) throw new Error('Invalid Action');
if (this.activePaymentMethod.updateWithAction) {
return this.activePaymentMethod.updateWithAction(action);
}
// Extract desired props that we need to pass on from the pmConfiguration for this particular PM
const pmConfig = getComponentConfiguration(action.paymentMethodType, this.props.paymentMethodsConfiguration);
const paymentAction: UIElement = this.props.createFromAction(action, {
isDropin: true,
onAdditionalDetails: state => this.props.onAdditionalDetails(state, this),
onError: this.props.onError, // Add ref to onError in case the merchant has defined one in the component options
...(pmConfig?.onError && { onError: pmConfig.onError }) // Overwrite ref to onError in case the merchant has defined one in the pmConfig options
});
if (paymentAction) {
return this.setStatus(paymentAction.props.statusType, { component: paymentAction });
}
return null;
} | mrkosima/adyen-web | packages/lib/src/components/Dropin/Dropin.tsx | TypeScript |
MethodDeclaration |
render() {
return (
<CoreProvider i18n={this.props.i18n} loadingContext={this.props.loadingContext}>
<DropinComponent
{...this.props}
onChange={this.setState}
onSubmit={this.handleSubmit}
elementRef={this.elementRef}
ref={dropinRef => {
this.dropinRef = dropinRef;
}} | mrkosima/adyen-web | packages/lib/src/components/Dropin/Dropin.tsx | TypeScript |
ClassDeclaration |
@Module({
providers: [CaslAbilityFactory],
exports: [CaslAbilityFactory],
})
export class CaslModule {} | kamalkech/nestjs-test | src/casl/casl.module.ts | TypeScript |
ArrowFunction |
() => {
const type = select(
'type',
['button', 'submit', 'reset'],
undefined
);
const appearance = select(
'appearance',
['basic', 'primary', 'success', 'alert', 'transparent'],
undefined
);
const size = select(
'size',
['tiny', 'regular', 'large'],
undefined
);
const disabled = boolean(
'disabled',
false
);
const expanded = boolean(
'expanded',
false
);
const loading = boolean(
'loading',
false
);
const icon = text(
'icon',
''
);
const iconAlign = select(
'iconAlign',
['left', 'right'],
undefined
);
const children = text(
'children',
'Button'
);
return (
<Button
onClick={action('button-clicked')}
onMouseEnter={action('mouse-enter')}
onMouseLeave={action('mouse-leave')}
type={type}
appearance={appearance}
size={size}
expanded={expanded}
disabled={disabled}
loading={loading}
icon={icon}
iconAlign={iconAlign}
>
{children}
</Button> | RaghavShubham/design-system | core/components/atoms/button/__stories__/index.story.tsx | TypeScript |
MethodDeclaration |
action('button-clicked') | RaghavShubham/design-system | core/components/atoms/button/__stories__/index.story.tsx | TypeScript |
MethodDeclaration |
action('mouse-enter') | RaghavShubham/design-system | core/components/atoms/button/__stories__/index.story.tsx | TypeScript |
MethodDeclaration |
action('mouse-leave') | RaghavShubham/design-system | core/components/atoms/button/__stories__/index.story.tsx | TypeScript |
FunctionDeclaration | /**
* The Fade transition is used by the [Modal](https://mui.com/components/modal/) component.
* It uses [react-transition-group](https://github.com/reactjs/react-transition-group) internally.
*
* Demos:
*
* - [Transitions](https://mui.com/components/transitions/)
*
* API:
*
* - [Fade API](https://mui.com/api/fade/)
* - inherits [Transition API](http://reactcommunity.org/react-transition-group/transition/#Transition-props)
*/
export default function Fade(props: FadeProps): JSX.Element; | 94YOUNG/material-ui | packages/mui-material/src/Fade/Fade.d.ts | TypeScript |
InterfaceDeclaration |
export interface FadeProps extends Omit<TransitionProps, 'children'> {
/**
* Perform the enter transition when it first mounts if `in` is also `true`.
* Set this to `false` to disable this behavior.
* @default true
*/
appear?: boolean;
/**
* A single child content element.
*/
children: React.ReactElement<any, any>;
/**
* The transition timing function.
* You may specify a single easing or a object containing enter and exit values.
*/
easing?: TransitionProps['easing'];
/**
* If `true`, the component will transition in.
*/
in?: boolean;
ref?: React.Ref<unknown>;
/**
* The duration for the transition, in milliseconds.
* You may specify a single timeout for all transitions, or individually with an object.
* @default {
* enter: duration.enteringScreen,
* exit: duration.leavingScreen,
* }
*/
timeout?: TransitionProps['timeout'];
} | 94YOUNG/material-ui | packages/mui-material/src/Fade/Fade.d.ts | TypeScript |
FunctionDeclaration | /*!
* @license
* Copyright 2016 Alfresco Software, Ltd.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
export declare function getType(type: any): any; | souhirzribi96/application-web-d-indexation-des-documents-GED-en-r-f-rence-la-plateforme-Alfresco | node_modules/@alfresco/adf-core/services/get-type.d.ts | TypeScript |
FunctionDeclaration |
function MyApp({ Component, pageProps }: AppProps) {
return (
<ChakraProvider theme={theme}>
<Component {...pageProps} />
</ChakraProvider>
);
} | Lucbm99/Desafio-Capitulo4-Ignite-WorldTrip | src/pages/_app.tsx | TypeScript |
ArrowFunction |
({ children }) => {
return (
<div className="antares-container">
<AntaresActions></AntaresActions>
<AntaresSidebar></AntaresSidebar>
{children}
</div> | arcanite24/antares-client | src/modules/ui/container/container.component.tsx | TypeScript |
FunctionDeclaration |
function generateSampleMessage<T extends object>(instance: T) {
const filledObject = (instance.constructor as typeof protobuf.Message)
.toObject(instance as protobuf.Message<T>, {defaults: true});
return (instance.constructor as typeof protobuf.Message).fromObject(filledObject) as T;
} | googleapis/googleapis-gen | google/cloud/asset/v1p5beta1/asset-v1p5beta1-nodejs/test/gapic_asset_service_v1p5beta1.ts | TypeScript |
FunctionDeclaration |
function stubSimpleCall<ResponseType>(response?: ResponseType, error?: Error) {
return error ? sinon.stub().rejects(error) : sinon.stub().resolves([response]);
} | googleapis/googleapis-gen | google/cloud/asset/v1p5beta1/asset-v1p5beta1-nodejs/test/gapic_asset_service_v1p5beta1.ts | TypeScript |
FunctionDeclaration |
function stubSimpleCallWithCallback<ResponseType>(response?: ResponseType, error?: Error) {
return error ? sinon.stub().callsArgWith(2, error) : sinon.stub().callsArgWith(2, null, response);
} | googleapis/googleapis-gen | google/cloud/asset/v1p5beta1/asset-v1p5beta1-nodejs/test/gapic_asset_service_v1p5beta1.ts | TypeScript |
FunctionDeclaration |
function stubPageStreamingCall<ResponseType>(responses?: ResponseType[], error?: Error) {
const pagingStub = sinon.stub();
if (responses) {
for (let i = 0; i < responses.length; ++i) {
pagingStub.onCall(i).callsArgWith(2, null, responses[i]);
}
}
const transformStub = error ? sinon.stub().callsArgWith(2, error) : pagingStub;
const mockStream = new PassThrough({
objectMode: true,
transform: transformStub,
});
// trigger as many responses as needed
if (responses) {
for (let i = 0; i < responses.length; ++i) {
setImmediate(() => { mockStream.write({}); });
}
setImmediate(() => { mockStream.end(); });
} else {
setImmediate(() => { mockStream.write({}); });
setImmediate(() => { mockStream.end(); });
}
return sinon.stub().returns(mockStream);
} | googleapis/googleapis-gen | google/cloud/asset/v1p5beta1/asset-v1p5beta1-nodejs/test/gapic_asset_service_v1p5beta1.ts | TypeScript |
FunctionDeclaration |
function stubAsyncIterationCall<ResponseType>(responses?: ResponseType[], error?: Error) {
let counter = 0;
const asyncIterable = {
[Symbol.asyncIterator]() {
return {
async next() {
if (error) {
return Promise.reject(error);
}
if (counter >= responses!.length) {
return Promise.resolve({done: true, value: undefined});
}
return Promise.resolve({done: false, value: responses![counter++]});
}
};
}
};
return sinon.stub().returns(asyncIterable);
} | googleapis/googleapis-gen | google/cloud/asset/v1p5beta1/asset-v1p5beta1-nodejs/test/gapic_asset_service_v1p5beta1.ts | TypeScript |
ArrowFunction |
() => { mockStream.write({}); } | googleapis/googleapis-gen | google/cloud/asset/v1p5beta1/asset-v1p5beta1-nodejs/test/gapic_asset_service_v1p5beta1.ts | TypeScript |
ArrowFunction |
() => { mockStream.end(); } | googleapis/googleapis-gen | google/cloud/asset/v1p5beta1/asset-v1p5beta1-nodejs/test/gapic_asset_service_v1p5beta1.ts | TypeScript |
ArrowFunction |
() => {
const servicePath = assetserviceModule.v1p5beta1.AssetServiceClient.servicePath;
assert(servicePath);
} | googleapis/googleapis-gen | google/cloud/asset/v1p5beta1/asset-v1p5beta1-nodejs/test/gapic_asset_service_v1p5beta1.ts | TypeScript |
ArrowFunction |
() => {
const apiEndpoint = assetserviceModule.v1p5beta1.AssetServiceClient.apiEndpoint;
assert(apiEndpoint);
} | googleapis/googleapis-gen | google/cloud/asset/v1p5beta1/asset-v1p5beta1-nodejs/test/gapic_asset_service_v1p5beta1.ts | TypeScript |
ArrowFunction |
() => {
const port = assetserviceModule.v1p5beta1.AssetServiceClient.port;
assert(port);
assert(typeof port === 'number');
} | googleapis/googleapis-gen | google/cloud/asset/v1p5beta1/asset-v1p5beta1-nodejs/test/gapic_asset_service_v1p5beta1.ts | TypeScript |
ArrowFunction |
() => {
const client = new assetserviceModule.v1p5beta1.AssetServiceClient();
assert(client);
} | googleapis/googleapis-gen | google/cloud/asset/v1p5beta1/asset-v1p5beta1-nodejs/test/gapic_asset_service_v1p5beta1.ts | TypeScript |
ArrowFunction |
() => {
const client = new assetserviceModule.v1p5beta1.AssetServiceClient({
fallback: true,
});
assert(client);
} | googleapis/googleapis-gen | google/cloud/asset/v1p5beta1/asset-v1p5beta1-nodejs/test/gapic_asset_service_v1p5beta1.ts | TypeScript |
ArrowFunction |
async () => {
const client = new assetserviceModule.v1p5beta1.AssetServiceClient({
credentials: {client_email: 'bogus', private_key: 'bogus'},
projectId: 'bogus',
});
assert.strictEqual(client.assetServiceStub, undefined);
await client.initialize();
assert(client.assetServiceStub);
} | googleapis/googleapis-gen | google/cloud/asset/v1p5beta1/asset-v1p5beta1-nodejs/test/gapic_asset_service_v1p5beta1.ts | TypeScript |
ArrowFunction |
() => {
const client = new assetserviceModule.v1p5beta1.AssetServiceClient({
credentials: {client_email: 'bogus', private_key: 'bogus'},
projectId: 'bogus',
});
client.close();
} | googleapis/googleapis-gen | google/cloud/asset/v1p5beta1/asset-v1p5beta1-nodejs/test/gapic_asset_service_v1p5beta1.ts | TypeScript |
ArrowFunction |
async () => {
const fakeProjectId = 'fake-project-id';
const client = new assetserviceModule.v1p5beta1.AssetServiceClient({
credentials: {client_email: 'bogus', private_key: 'bogus'},
projectId: 'bogus',
});
client.auth.getProjectId = sinon.stub().resolves(fakeProjectId);
const result = await client.getProjectId();
assert.strictEqual(result, fakeProjectId);
assert((client.auth.getProjectId as SinonStub).calledWithExactly());
} | googleapis/googleapis-gen | google/cloud/asset/v1p5beta1/asset-v1p5beta1-nodejs/test/gapic_asset_service_v1p5beta1.ts | TypeScript |
ArrowFunction |
async () => {
const fakeProjectId = 'fake-project-id';
const client = new assetserviceModule.v1p5beta1.AssetServiceClient({
credentials: {client_email: 'bogus', private_key: 'bogus'},
projectId: 'bogus',
});
client.auth.getProjectId = sinon.stub().callsArgWith(0, null, fakeProjectId);
const promise = new Promise((resolve, reject) => {
client.getProjectId((err?: Error|null, projectId?: string|null) => {
if (err) {
reject(err);
} else {
resolve(projectId);
}
});
});
const result = await promise;
assert.strictEqual(result, fakeProjectId);
} | googleapis/googleapis-gen | google/cloud/asset/v1p5beta1/asset-v1p5beta1-nodejs/test/gapic_asset_service_v1p5beta1.ts | TypeScript |
ArrowFunction |
(resolve, reject) => {
client.getProjectId((err?: Error|null, projectId?: string|null) => {
if (err) {
reject(err);
} else {
resolve(projectId);
}
});
} | googleapis/googleapis-gen | google/cloud/asset/v1p5beta1/asset-v1p5beta1-nodejs/test/gapic_asset_service_v1p5beta1.ts | TypeScript |
ArrowFunction |
(err?: Error|null, projectId?: string|null) => {
if (err) {
reject(err);
} else {
resolve(projectId);
}
} | googleapis/googleapis-gen | google/cloud/asset/v1p5beta1/asset-v1p5beta1-nodejs/test/gapic_asset_service_v1p5beta1.ts | TypeScript |
ArrowFunction |
async () => {
const client = new assetserviceModule.v1p5beta1.AssetServiceClient({
credentials: {client_email: 'bogus', private_key: 'bogus'},
projectId: 'bogus',
});
client.initialize();
const request = generateSampleMessage(new protos.google.cloud.asset.v1p5beta1.ListAssetsRequest());
request.parent = '';
const expectedHeaderRequestParams = "parent=";
const expectedOptions = {
otherArgs: {
headers: {
'x-goog-request-params': expectedHeaderRequestParams,
},
},
};
const expectedResponse = [
generateSampleMessage(new protos.google.cloud.asset.v1p5beta1.Asset()),
generateSampleMessage(new protos.google.cloud.asset.v1p5beta1.Asset()),
generateSampleMessage(new protos.google.cloud.asset.v1p5beta1.Asset()),
];
client.innerApiCalls.listAssets = stubSimpleCall(expectedResponse);
const [response] = await client.listAssets(request);
assert.deepStrictEqual(response, expectedResponse);
assert((client.innerApiCalls.listAssets as SinonStub)
.getCall(0).calledWith(request, expectedOptions, undefined));
} | googleapis/googleapis-gen | google/cloud/asset/v1p5beta1/asset-v1p5beta1-nodejs/test/gapic_asset_service_v1p5beta1.ts | TypeScript |
ArrowFunction |
async () => {
const client = new assetserviceModule.v1p5beta1.AssetServiceClient({
credentials: {client_email: 'bogus', private_key: 'bogus'},
projectId: 'bogus',
});
client.initialize();
const request = generateSampleMessage(new protos.google.cloud.asset.v1p5beta1.ListAssetsRequest());
request.parent = '';
const expectedHeaderRequestParams = "parent=";
const expectedOptions = {
otherArgs: {
headers: {
'x-goog-request-params': expectedHeaderRequestParams,
},
},
};
const expectedResponse = [
generateSampleMessage(new protos.google.cloud.asset.v1p5beta1.Asset()),
generateSampleMessage(new protos.google.cloud.asset.v1p5beta1.Asset()),
generateSampleMessage(new protos.google.cloud.asset.v1p5beta1.Asset()),
];
client.innerApiCalls.listAssets = stubSimpleCallWithCallback(expectedResponse);
const promise = new Promise((resolve, reject) => {
client.listAssets(
request,
(err?: Error|null, result?: protos.google.cloud.asset.v1p5beta1.IAsset[]|null) => {
if (err) {
reject(err);
} else {
resolve(result);
}
});
});
const response = await promise;
assert.deepStrictEqual(response, expectedResponse);
assert((client.innerApiCalls.listAssets as SinonStub)
.getCall(0).calledWith(request, expectedOptions /*, callback defined above */));
} | googleapis/googleapis-gen | google/cloud/asset/v1p5beta1/asset-v1p5beta1-nodejs/test/gapic_asset_service_v1p5beta1.ts | TypeScript |
ArrowFunction |
(resolve, reject) => {
client.listAssets(
request,
(err?: Error|null, result?: protos.google.cloud.asset.v1p5beta1.IAsset[]|null) => {
if (err) {
reject(err);
} else {
resolve(result);
}
});
} | googleapis/googleapis-gen | google/cloud/asset/v1p5beta1/asset-v1p5beta1-nodejs/test/gapic_asset_service_v1p5beta1.ts | TypeScript |
ArrowFunction |
(err?: Error|null, result?: protos.google.cloud.asset.v1p5beta1.IAsset[]|null) => {
if (err) {
reject(err);
} else {
resolve(result);
}
} | googleapis/googleapis-gen | google/cloud/asset/v1p5beta1/asset-v1p5beta1-nodejs/test/gapic_asset_service_v1p5beta1.ts | TypeScript |
ArrowFunction |
async () => {
const client = new assetserviceModule.v1p5beta1.AssetServiceClient({
credentials: {client_email: 'bogus', private_key: 'bogus'},
projectId: 'bogus',
});
client.initialize();
const request = generateSampleMessage(new protos.google.cloud.asset.v1p5beta1.ListAssetsRequest());
request.parent = '';
const expectedHeaderRequestParams = "parent=";
const expectedOptions = {
otherArgs: {
headers: {
'x-goog-request-params': expectedHeaderRequestParams,
},
},
};
const expectedError = new Error('expected');
client.innerApiCalls.listAssets = stubSimpleCall(undefined, expectedError);
await assert.rejects(client.listAssets(request), expectedError);
assert((client.innerApiCalls.listAssets as SinonStub)
.getCall(0).calledWith(request, expectedOptions, undefined));
} | googleapis/googleapis-gen | google/cloud/asset/v1p5beta1/asset-v1p5beta1-nodejs/test/gapic_asset_service_v1p5beta1.ts | TypeScript |
ArrowFunction |
async () => {
const client = new assetserviceModule.v1p5beta1.AssetServiceClient({
credentials: {client_email: 'bogus', private_key: 'bogus'},
projectId: 'bogus',
});
client.initialize();
const request = generateSampleMessage(new protos.google.cloud.asset.v1p5beta1.ListAssetsRequest());
request.parent = '';
const expectedHeaderRequestParams = "parent=";
const expectedResponse = [
generateSampleMessage(new protos.google.cloud.asset.v1p5beta1.Asset()),
generateSampleMessage(new protos.google.cloud.asset.v1p5beta1.Asset()),
generateSampleMessage(new protos.google.cloud.asset.v1p5beta1.Asset()),
];
client.descriptors.page.listAssets.createStream = stubPageStreamingCall(expectedResponse);
const stream = client.listAssetsStream(request);
const promise = new Promise((resolve, reject) => {
const responses: protos.google.cloud.asset.v1p5beta1.Asset[] = [];
stream.on('data', (response: protos.google.cloud.asset.v1p5beta1.Asset) => {
responses.push(response);
});
stream.on('end', () => {
resolve(responses);
});
stream.on('error', (err: Error) => {
reject(err);
});
});
const responses = await promise;
assert.deepStrictEqual(responses, expectedResponse);
assert((client.descriptors.page.listAssets.createStream as SinonStub)
.getCall(0).calledWith(client.innerApiCalls.listAssets, request));
assert.strictEqual(
(client.descriptors.page.listAssets.createStream as SinonStub)
.getCall(0).args[2].otherArgs.headers['x-goog-request-params'],
expectedHeaderRequestParams
);
} | googleapis/googleapis-gen | google/cloud/asset/v1p5beta1/asset-v1p5beta1-nodejs/test/gapic_asset_service_v1p5beta1.ts | TypeScript |
ArrowFunction |
(resolve, reject) => {
const responses: protos.google.cloud.asset.v1p5beta1.Asset[] = [];
stream.on('data', (response: protos.google.cloud.asset.v1p5beta1.Asset) => {
responses.push(response);
});
stream.on('end', () => {
resolve(responses);
});
stream.on('error', (err: Error) => {
reject(err);
});
} | googleapis/googleapis-gen | google/cloud/asset/v1p5beta1/asset-v1p5beta1-nodejs/test/gapic_asset_service_v1p5beta1.ts | TypeScript |
ArrowFunction |
(response: protos.google.cloud.asset.v1p5beta1.Asset) => {
responses.push(response);
} | googleapis/googleapis-gen | google/cloud/asset/v1p5beta1/asset-v1p5beta1-nodejs/test/gapic_asset_service_v1p5beta1.ts | TypeScript |
ArrowFunction |
() => {
resolve(responses);
} | googleapis/googleapis-gen | google/cloud/asset/v1p5beta1/asset-v1p5beta1-nodejs/test/gapic_asset_service_v1p5beta1.ts | TypeScript |
ArrowFunction |
(err: Error) => {
reject(err);
} | googleapis/googleapis-gen | google/cloud/asset/v1p5beta1/asset-v1p5beta1-nodejs/test/gapic_asset_service_v1p5beta1.ts | TypeScript |
ArrowFunction |
async () => {
const client = new assetserviceModule.v1p5beta1.AssetServiceClient({
credentials: {client_email: 'bogus', private_key: 'bogus'},
projectId: 'bogus',
});
client.initialize();
const request = generateSampleMessage(new protos.google.cloud.asset.v1p5beta1.ListAssetsRequest());
request.parent = '';
const expectedHeaderRequestParams = "parent=";
const expectedError = new Error('expected');
client.descriptors.page.listAssets.createStream = stubPageStreamingCall(undefined, expectedError);
const stream = client.listAssetsStream(request);
const promise = new Promise((resolve, reject) => {
const responses: protos.google.cloud.asset.v1p5beta1.Asset[] = [];
stream.on('data', (response: protos.google.cloud.asset.v1p5beta1.Asset) => {
responses.push(response);
});
stream.on('end', () => {
resolve(responses);
});
stream.on('error', (err: Error) => {
reject(err);
});
});
await assert.rejects(promise, expectedError);
assert((client.descriptors.page.listAssets.createStream as SinonStub)
.getCall(0).calledWith(client.innerApiCalls.listAssets, request));
assert.strictEqual(
(client.descriptors.page.listAssets.createStream as SinonStub)
.getCall(0).args[2].otherArgs.headers['x-goog-request-params'],
expectedHeaderRequestParams
);
} | googleapis/googleapis-gen | google/cloud/asset/v1p5beta1/asset-v1p5beta1-nodejs/test/gapic_asset_service_v1p5beta1.ts | TypeScript |
ArrowFunction |
async () => {
const client = new assetserviceModule.v1p5beta1.AssetServiceClient({
credentials: {client_email: 'bogus', private_key: 'bogus'},
projectId: 'bogus',
});
client.initialize();
const request = generateSampleMessage(new protos.google.cloud.asset.v1p5beta1.ListAssetsRequest());
request.parent = '';
const expectedHeaderRequestParams = "parent=";
const expectedResponse = [
generateSampleMessage(new protos.google.cloud.asset.v1p5beta1.Asset()),
generateSampleMessage(new protos.google.cloud.asset.v1p5beta1.Asset()),
generateSampleMessage(new protos.google.cloud.asset.v1p5beta1.Asset()),
];
client.descriptors.page.listAssets.asyncIterate = stubAsyncIterationCall(expectedResponse);
const responses: protos.google.cloud.asset.v1p5beta1.IAsset[] = [];
const iterable = client.listAssetsAsync(request);
for await (const resource of iterable) {
responses.push(resource!);
}
assert.deepStrictEqual(responses, expectedResponse);
assert.deepStrictEqual(
(client.descriptors.page.listAssets.asyncIterate as SinonStub)
.getCall(0).args[1], request);
assert.strictEqual(
(client.descriptors.page.listAssets.asyncIterate as SinonStub)
.getCall(0).args[2].otherArgs.headers['x-goog-request-params'],
expectedHeaderRequestParams
);
} | googleapis/googleapis-gen | google/cloud/asset/v1p5beta1/asset-v1p5beta1-nodejs/test/gapic_asset_service_v1p5beta1.ts | TypeScript |
ArrowFunction |
async () => {
const client = new assetserviceModule.v1p5beta1.AssetServiceClient({
credentials: {client_email: 'bogus', private_key: 'bogus'},
projectId: 'bogus',
});
client.initialize();
const request = generateSampleMessage(new protos.google.cloud.asset.v1p5beta1.ListAssetsRequest());
request.parent = '';
const expectedHeaderRequestParams = "parent=";const expectedError = new Error('expected');
client.descriptors.page.listAssets.asyncIterate = stubAsyncIterationCall(undefined, expectedError);
const iterable = client.listAssetsAsync(request);
await assert.rejects(async () => {
const responses: protos.google.cloud.asset.v1p5beta1.IAsset[] = [];
for await (const resource of iterable) {
responses.push(resource!);
}
});
assert.deepStrictEqual(
(client.descriptors.page.listAssets.asyncIterate as SinonStub)
.getCall(0).args[1], request);
assert.strictEqual(
(client.descriptors.page.listAssets.asyncIterate as SinonStub)
.getCall(0).args[2].otherArgs.headers['x-goog-request-params'],
expectedHeaderRequestParams
);
} | googleapis/googleapis-gen | google/cloud/asset/v1p5beta1/asset-v1p5beta1-nodejs/test/gapic_asset_service_v1p5beta1.ts | TypeScript |
ArrowFunction |
async () => {
const responses: protos.google.cloud.asset.v1p5beta1.IAsset[] = [];
for await (const resource of iterable) {
responses.push(resource!);
}
} | googleapis/googleapis-gen | google/cloud/asset/v1p5beta1/asset-v1p5beta1-nodejs/test/gapic_asset_service_v1p5beta1.ts | TypeScript |
ArrowFunction |
() => {
describe('accessLevel', () => {
const fakePath = "/rendered/path/accessLevel";
const expectedParameters = {
access_policy: "accessPolicyValue",
access_level: "accessLevelValue",
};
const client = new assetserviceModule.v1p5beta1.AssetServiceClient({
credentials: {client_email: 'bogus', private_key: 'bogus'},
projectId: 'bogus',
});
client.initialize();
client.pathTemplates.accessLevelPathTemplate.render =
sinon.stub().returns(fakePath);
client.pathTemplates.accessLevelPathTemplate.match =
sinon.stub().returns(expectedParameters);
it('accessLevelPath', () => {
const result = client.accessLevelPath("accessPolicyValue", "accessLevelValue");
assert.strictEqual(result, fakePath);
assert((client.pathTemplates.accessLevelPathTemplate.render as SinonStub)
.getCall(-1).calledWith(expectedParameters));
});
it('matchAccessPolicyFromAccessLevelName', () => {
const result = client.matchAccessPolicyFromAccessLevelName(fakePath);
assert.strictEqual(result, "accessPolicyValue");
assert((client.pathTemplates.accessLevelPathTemplate.match as SinonStub)
.getCall(-1).calledWith(fakePath));
});
it('matchAccessLevelFromAccessLevelName', () => {
const result = client.matchAccessLevelFromAccessLevelName(fakePath);
assert.strictEqual(result, "accessLevelValue");
assert((client.pathTemplates.accessLevelPathTemplate.match as SinonStub)
.getCall(-1).calledWith(fakePath));
});
});
describe('accessPolicy', () => {
const fakePath = "/rendered/path/accessPolicy";
const expectedParameters = {
access_policy: "accessPolicyValue",
};
const client = new assetserviceModule.v1p5beta1.AssetServiceClient({
credentials: {client_email: 'bogus', private_key: 'bogus'},
projectId: 'bogus',
});
client.initialize();
client.pathTemplates.accessPolicyPathTemplate.render =
sinon.stub().returns(fakePath);
client.pathTemplates.accessPolicyPathTemplate.match =
sinon.stub().returns(expectedParameters);
it('accessPolicyPath', () => {
const result = client.accessPolicyPath("accessPolicyValue");
assert.strictEqual(result, fakePath);
assert((client.pathTemplates.accessPolicyPathTemplate.render as SinonStub)
.getCall(-1).calledWith(expectedParameters));
});
it('matchAccessPolicyFromAccessPolicyName', () => {
const result = client.matchAccessPolicyFromAccessPolicyName(fakePath);
assert.strictEqual(result, "accessPolicyValue");
assert((client.pathTemplates.accessPolicyPathTemplate.match as SinonStub)
.getCall(-1).calledWith(fakePath));
});
});
describe('servicePerimeter', () => {
const fakePath = "/rendered/path/servicePerimeter";
const expectedParameters = {
access_policy: "accessPolicyValue",
service_perimeter: "servicePerimeterValue",
};
const client = new assetserviceModule.v1p5beta1.AssetServiceClient({
credentials: {client_email: 'bogus', private_key: 'bogus'},
projectId: 'bogus',
});
client.initialize();
client.pathTemplates.servicePerimeterPathTemplate.render =
sinon.stub().returns(fakePath);
client.pathTemplates.servicePerimeterPathTemplate.match =
sinon.stub().returns(expectedParameters);
it('servicePerimeterPath', () => {
const result = client.servicePerimeterPath("accessPolicyValue", "servicePerimeterValue");
assert.strictEqual(result, fakePath);
assert((client.pathTemplates.servicePerimeterPathTemplate.render as SinonStub)
.getCall(-1).calledWith(expectedParameters));
});
it('matchAccessPolicyFromServicePerimeterName', () => {
const result = client.matchAccessPolicyFromServicePerimeterName(fakePath);
assert.strictEqual(result, "accessPolicyValue");
assert((client.pathTemplates.servicePerimeterPathTemplate.match as SinonStub)
.getCall(-1).calledWith(fakePath));
});
it('matchServicePerimeterFromServicePerimeterName', () => {
const result = client.matchServicePerimeterFromServicePerimeterName(fakePath);
assert.strictEqual(result, "servicePerimeterValue");
assert((client.pathTemplates.servicePerimeterPathTemplate.match as SinonStub)
.getCall(-1).calledWith(fakePath));
});
});
} | googleapis/googleapis-gen | google/cloud/asset/v1p5beta1/asset-v1p5beta1-nodejs/test/gapic_asset_service_v1p5beta1.ts | TypeScript |
ArrowFunction |
() => {
const fakePath = "/rendered/path/accessLevel";
const expectedParameters = {
access_policy: "accessPolicyValue",
access_level: "accessLevelValue",
};
const client = new assetserviceModule.v1p5beta1.AssetServiceClient({
credentials: {client_email: 'bogus', private_key: 'bogus'},
projectId: 'bogus',
});
client.initialize();
client.pathTemplates.accessLevelPathTemplate.render =
sinon.stub().returns(fakePath);
client.pathTemplates.accessLevelPathTemplate.match =
sinon.stub().returns(expectedParameters);
it('accessLevelPath', () => {
const result = client.accessLevelPath("accessPolicyValue", "accessLevelValue");
assert.strictEqual(result, fakePath);
assert((client.pathTemplates.accessLevelPathTemplate.render as SinonStub)
.getCall(-1).calledWith(expectedParameters));
});
it('matchAccessPolicyFromAccessLevelName', () => {
const result = client.matchAccessPolicyFromAccessLevelName(fakePath);
assert.strictEqual(result, "accessPolicyValue");
assert((client.pathTemplates.accessLevelPathTemplate.match as SinonStub)
.getCall(-1).calledWith(fakePath));
});
it('matchAccessLevelFromAccessLevelName', () => {
const result = client.matchAccessLevelFromAccessLevelName(fakePath);
assert.strictEqual(result, "accessLevelValue");
assert((client.pathTemplates.accessLevelPathTemplate.match as SinonStub)
.getCall(-1).calledWith(fakePath));
});
} | googleapis/googleapis-gen | google/cloud/asset/v1p5beta1/asset-v1p5beta1-nodejs/test/gapic_asset_service_v1p5beta1.ts | TypeScript |
ArrowFunction |
() => {
const result = client.accessLevelPath("accessPolicyValue", "accessLevelValue");
assert.strictEqual(result, fakePath);
assert((client.pathTemplates.accessLevelPathTemplate.render as SinonStub)
.getCall(-1).calledWith(expectedParameters));
} | googleapis/googleapis-gen | google/cloud/asset/v1p5beta1/asset-v1p5beta1-nodejs/test/gapic_asset_service_v1p5beta1.ts | TypeScript |
ArrowFunction |
() => {
const result = client.matchAccessPolicyFromAccessLevelName(fakePath);
assert.strictEqual(result, "accessPolicyValue");
assert((client.pathTemplates.accessLevelPathTemplate.match as SinonStub)
.getCall(-1).calledWith(fakePath));
} | googleapis/googleapis-gen | google/cloud/asset/v1p5beta1/asset-v1p5beta1-nodejs/test/gapic_asset_service_v1p5beta1.ts | TypeScript |
ArrowFunction |
() => {
const result = client.matchAccessLevelFromAccessLevelName(fakePath);
assert.strictEqual(result, "accessLevelValue");
assert((client.pathTemplates.accessLevelPathTemplate.match as SinonStub)
.getCall(-1).calledWith(fakePath));
} | googleapis/googleapis-gen | google/cloud/asset/v1p5beta1/asset-v1p5beta1-nodejs/test/gapic_asset_service_v1p5beta1.ts | TypeScript |
ArrowFunction |
() => {
const fakePath = "/rendered/path/accessPolicy";
const expectedParameters = {
access_policy: "accessPolicyValue",
};
const client = new assetserviceModule.v1p5beta1.AssetServiceClient({
credentials: {client_email: 'bogus', private_key: 'bogus'},
projectId: 'bogus',
});
client.initialize();
client.pathTemplates.accessPolicyPathTemplate.render =
sinon.stub().returns(fakePath);
client.pathTemplates.accessPolicyPathTemplate.match =
sinon.stub().returns(expectedParameters);
it('accessPolicyPath', () => {
const result = client.accessPolicyPath("accessPolicyValue");
assert.strictEqual(result, fakePath);
assert((client.pathTemplates.accessPolicyPathTemplate.render as SinonStub)
.getCall(-1).calledWith(expectedParameters));
});
it('matchAccessPolicyFromAccessPolicyName', () => {
const result = client.matchAccessPolicyFromAccessPolicyName(fakePath);
assert.strictEqual(result, "accessPolicyValue");
assert((client.pathTemplates.accessPolicyPathTemplate.match as SinonStub)
.getCall(-1).calledWith(fakePath));
});
} | googleapis/googleapis-gen | google/cloud/asset/v1p5beta1/asset-v1p5beta1-nodejs/test/gapic_asset_service_v1p5beta1.ts | TypeScript |
ArrowFunction |
() => {
const result = client.accessPolicyPath("accessPolicyValue");
assert.strictEqual(result, fakePath);
assert((client.pathTemplates.accessPolicyPathTemplate.render as SinonStub)
.getCall(-1).calledWith(expectedParameters));
} | googleapis/googleapis-gen | google/cloud/asset/v1p5beta1/asset-v1p5beta1-nodejs/test/gapic_asset_service_v1p5beta1.ts | TypeScript |
ArrowFunction |
() => {
const result = client.matchAccessPolicyFromAccessPolicyName(fakePath);
assert.strictEqual(result, "accessPolicyValue");
assert((client.pathTemplates.accessPolicyPathTemplate.match as SinonStub)
.getCall(-1).calledWith(fakePath));
} | googleapis/googleapis-gen | google/cloud/asset/v1p5beta1/asset-v1p5beta1-nodejs/test/gapic_asset_service_v1p5beta1.ts | TypeScript |
ArrowFunction |
() => {
const fakePath = "/rendered/path/servicePerimeter";
const expectedParameters = {
access_policy: "accessPolicyValue",
service_perimeter: "servicePerimeterValue",
};
const client = new assetserviceModule.v1p5beta1.AssetServiceClient({
credentials: {client_email: 'bogus', private_key: 'bogus'},
projectId: 'bogus',
});
client.initialize();
client.pathTemplates.servicePerimeterPathTemplate.render =
sinon.stub().returns(fakePath);
client.pathTemplates.servicePerimeterPathTemplate.match =
sinon.stub().returns(expectedParameters);
it('servicePerimeterPath', () => {
const result = client.servicePerimeterPath("accessPolicyValue", "servicePerimeterValue");
assert.strictEqual(result, fakePath);
assert((client.pathTemplates.servicePerimeterPathTemplate.render as SinonStub)
.getCall(-1).calledWith(expectedParameters));
});
it('matchAccessPolicyFromServicePerimeterName', () => {
const result = client.matchAccessPolicyFromServicePerimeterName(fakePath);
assert.strictEqual(result, "accessPolicyValue");
assert((client.pathTemplates.servicePerimeterPathTemplate.match as SinonStub)
.getCall(-1).calledWith(fakePath));
});
it('matchServicePerimeterFromServicePerimeterName', () => {
const result = client.matchServicePerimeterFromServicePerimeterName(fakePath);
assert.strictEqual(result, "servicePerimeterValue");
assert((client.pathTemplates.servicePerimeterPathTemplate.match as SinonStub)
.getCall(-1).calledWith(fakePath));
});
} | googleapis/googleapis-gen | google/cloud/asset/v1p5beta1/asset-v1p5beta1-nodejs/test/gapic_asset_service_v1p5beta1.ts | TypeScript |
ArrowFunction |
() => {
const result = client.servicePerimeterPath("accessPolicyValue", "servicePerimeterValue");
assert.strictEqual(result, fakePath);
assert((client.pathTemplates.servicePerimeterPathTemplate.render as SinonStub)
.getCall(-1).calledWith(expectedParameters));
} | googleapis/googleapis-gen | google/cloud/asset/v1p5beta1/asset-v1p5beta1-nodejs/test/gapic_asset_service_v1p5beta1.ts | TypeScript |
ArrowFunction |
() => {
const result = client.matchAccessPolicyFromServicePerimeterName(fakePath);
assert.strictEqual(result, "accessPolicyValue");
assert((client.pathTemplates.servicePerimeterPathTemplate.match as SinonStub)
.getCall(-1).calledWith(fakePath));
} | googleapis/googleapis-gen | google/cloud/asset/v1p5beta1/asset-v1p5beta1-nodejs/test/gapic_asset_service_v1p5beta1.ts | TypeScript |
ArrowFunction |
() => {
const result = client.matchServicePerimeterFromServicePerimeterName(fakePath);
assert.strictEqual(result, "servicePerimeterValue");
assert((client.pathTemplates.servicePerimeterPathTemplate.match as SinonStub)
.getCall(-1).calledWith(fakePath));
} | googleapis/googleapis-gen | google/cloud/asset/v1p5beta1/asset-v1p5beta1-nodejs/test/gapic_asset_service_v1p5beta1.ts | TypeScript |
MethodDeclaration |
[Symbol.asyncIterator]() {
return {
async next() {
if (error) {
return Promise.reject(error);
}
if (counter >= responses!.length) {
return Promise.resolve({done: true, value: undefined});
}
return Promise.resolve({done: false, value: responses![counter++]});
}
};
} | googleapis/googleapis-gen | google/cloud/asset/v1p5beta1/asset-v1p5beta1-nodejs/test/gapic_asset_service_v1p5beta1.ts | TypeScript |
MethodDeclaration |
async next() {
if (error) {
return Promise.reject(error);
}
if (counter >= responses!.length) {
return Promise.resolve({done: true, value: undefined});
}
return Promise.resolve({done: false, value: responses![counter++]});
} | googleapis/googleapis-gen | google/cloud/asset/v1p5beta1/asset-v1p5beta1-nodejs/test/gapic_asset_service_v1p5beta1.ts | TypeScript |
ArrowFunction |
(nth: number) => {
const s = nth % 100;
if (s > 3 && s < 21) return "th";
switch (s % 10) {
case 1:
return "st";
case 2:
return "nd";
case 3:
return "rd";
default:
return "th";
}
} | Abduvakilov/flatpickr | src/l10n/default.ts | TypeScript |
FunctionDeclaration |
function AllServices() {
return (
<div>
<Layout>
<Headers
pageName={[{ name: 'Services', route: '/services' }]}
tabHeaders={['All services', 'Service Groups (clusters)', 'Settings']}
// 'TODO revamp service global setting'
Components={[<ServicesList />, <ServiceGroups />, <GlobalServieSetting />]}
/>
</Layout>
</div>
);
}
const ServiceView = () => {
return (
<Switch>
<Route exact path="/services" component={AllServices} />
<Route path="/services/groups/group/:ID" component={GroupPage} />
<Route path="/services/service/:ID" component={ServicePage} />
</Switch>
);
} | 0xflotus/trasa | dashboard/src/pages/Services/index.tsx | TypeScript |
ArrowFunction |
() => {
return (
<Switch>
<Route exact path="/services" component={AllServices} />
<Route path="/services/groups/group/:ID" component={GroupPage} />
<Route path="/services/service/:ID" component={ServicePage} />
</Switch> | 0xflotus/trasa | dashboard/src/pages/Services/index.tsx | TypeScript |
ArrowFunction |
(
event: React.MouseEvent<HTMLButtonElement>,
) => {
if (this.props.isActionDisabled) {
return;
}
this.props.disableAction();
event.stopPropagation();
const action = (event.currentTarget.name as any) as ChangeOperation;
this.props.updateTranslationStatus(this.props.translation.pk, action);
} | Stellaris-Mod-Translate/pontoon | frontend/src/modules/history/components/Translation.tsx | TypeScript |
ArrowFunction |
(
event: React.MouseEvent<HTMLButtonElement>,
) => {
if (this.props.isActionDisabled) {
return;
}
this.props.disableAction();
event.stopPropagation();
this.props.deleteTranslation(this.props.translation.pk);
} | Stellaris-Mod-Translate/pontoon | frontend/src/modules/history/components/Translation.tsx | TypeScript |
ArrowFunction |
() => {
if (this.props.isReadOnlyEditor) {
return;
}
// Ignore if selecting text
if (window.getSelection().toString()) {
return;
}
this.props.updateEditorTranslation(
this.props.translation.string,
'history',
);
} | Stellaris-Mod-Translate/pontoon | frontend/src/modules/history/components/Translation.tsx | TypeScript |
ArrowFunction |
(event: React.MouseEvent) => void | Stellaris-Mod-Translate/pontoon | frontend/src/modules/history/components/Translation.tsx | TypeScript |
ArrowFunction |
(
event: React.MouseEvent,
) => {
event.stopPropagation();
this.setState((state) => {
return { areCommentsVisible: !state.areCommentsVisible };
});
} | Stellaris-Mod-Translate/pontoon | frontend/src/modules/history/components/Translation.tsx | TypeScript |
ArrowFunction |
(state) => {
return { areCommentsVisible: !state.areCommentsVisible };
} | Stellaris-Mod-Translate/pontoon | frontend/src/modules/history/components/Translation.tsx | TypeScript |
ArrowFunction |
(
event: React.MouseEvent,
) => {
event.stopPropagation();
this.setState((state) => {
return { isDiffVisible: !state.isDiffVisible };
});
} | Stellaris-Mod-Translate/pontoon | frontend/src/modules/history/components/Translation.tsx | TypeScript |
ArrowFunction |
(state) => {
return { isDiffVisible: !state.isDiffVisible };
} | Stellaris-Mod-Translate/pontoon | frontend/src/modules/history/components/Translation.tsx | TypeScript |
ClassDeclaration | /**
* Render a translation in the History tab.
*
* Shows the translation's status, date, author and reviewer, as well as
* the content of the translation.
*
* The status can be interact with if the user has sufficient permissions to
* change said status.
*/
export class TranslationBase extends React.Component<InternalProps, State> {
constructor(props: InternalProps) {
super(props);
this.state = {
isDiffVisible: false,
areCommentsVisible: false,
};
}
handleStatusChange: (event: React.MouseEvent<HTMLButtonElement>) => void = (
event: React.MouseEvent<HTMLButtonElement>,
) => {
if (this.props.isActionDisabled) {
return;
}
this.props.disableAction();
event.stopPropagation();
const action = (event.currentTarget.name as any) as ChangeOperation;
this.props.updateTranslationStatus(this.props.translation.pk, action);
};
delete: (event: React.MouseEvent<HTMLButtonElement>) => void = (
event: React.MouseEvent<HTMLButtonElement>,
) => {
if (this.props.isActionDisabled) {
return;
}
this.props.disableAction();
event.stopPropagation();
this.props.deleteTranslation(this.props.translation.pk);
};
copyTranslationIntoEditor: () => void = () => {
if (this.props.isReadOnlyEditor) {
return;
}
// Ignore if selecting text
if (window.getSelection().toString()) {
return;
}
this.props.updateEditorTranslation(
this.props.translation.string,
'history',
);
};
getStatus(): string {
const { translation } = this.props;
if (translation.approved) {
return 'approved';
}
if (translation.fuzzy) {
return 'fuzzy';
}
if (translation.rejected) {
return 'rejected';
}
return 'unreviewed';
}
getApprovalTitle(): string {
const { translation } = this.props;
// TODO: To Localize.
if (translation.approved && translation.approvedUser) {
return `Approved by ${translation.approvedUser}`;
}
if (translation.unapprovedUser) {
return `Unapproved by ${translation.unapprovedUser}`;
}
return 'Not reviewed yet';
}
renderUser(): React.ReactElement<'a'> | React.ReactElement<'span'> {
const { translation } = this.props;
if (!translation.uid) {
return <span>{translation.user}</span>;
}
return (
<a
href={`/contributors/${translation.username}`}
title={this.getApprovalTitle()}
target='_blank'
rel='noopener noreferrer'
onClick={(e: React.MouseEvent) => e.stopPropagation()} | Stellaris-Mod-Translate/pontoon | frontend/src/modules/history/components/Translation.tsx | TypeScript |
TypeAliasDeclaration |
type Props = {
entity: Entity;
isReadOnlyEditor: boolean;
isTranslator: boolean;
translation: HistoryTranslation;
activeTranslation: HistoryTranslation;
locale: Locale;
user: UserState;
index: number;
deleteTranslation: (id: number) => void;
addComment: (comment: string, id: number | null | undefined) => void;
updateEditorTranslation: (arg0: string, arg1: string) => void;
updateTranslationStatus: (id: number, operation: ChangeOperation) => void;
}; | Stellaris-Mod-Translate/pontoon | frontend/src/modules/history/components/Translation.tsx | TypeScript |
TypeAliasDeclaration |
type InternalProps = Props & {
isActionDisabled: boolean;
disableAction: () => void;
}; | Stellaris-Mod-Translate/pontoon | frontend/src/modules/history/components/Translation.tsx | TypeScript |
TypeAliasDeclaration |
type State = {
isDiffVisible: boolean;
areCommentsVisible: boolean;
}; | Stellaris-Mod-Translate/pontoon | frontend/src/modules/history/components/Translation.tsx | TypeScript |
MethodDeclaration |
getStatus(): string {
const { translation } = this.props;
if (translation.approved) {
return 'approved';
}
if (translation.fuzzy) {
return 'fuzzy';
}
if (translation.rejected) {
return 'rejected';
}
return 'unreviewed';
} | Stellaris-Mod-Translate/pontoon | frontend/src/modules/history/components/Translation.tsx | TypeScript |
MethodDeclaration |
getApprovalTitle(): string {
const { translation } = this.props;
// TODO: To Localize.
if (translation.approved && translation.approvedUser) {
return `Approved by ${translation.approvedUser}`;
}
if (translation.unapprovedUser) {
return `Unapproved by ${translation.unapprovedUser}`;
}
return 'Not reviewed yet';
} | Stellaris-Mod-Translate/pontoon | frontend/src/modules/history/components/Translation.tsx | TypeScript |
MethodDeclaration |
renderUser(): React.ReactElement<'a'> | React.ReactElement<'span'> {
const { translation } = this.props;
if (!translation.uid) {
return <span>{translation.user}</span>;
}
return (
<a
href={`/contributors/${translation.username}`} | Stellaris-Mod-Translate/pontoon | frontend/src/modules/history/components/Translation.tsx | TypeScript |
MethodDeclaration |
stopPropagation() | Stellaris-Mod-Translate/pontoon | frontend/src/modules/history/components/Translation.tsx | TypeScript |
MethodDeclaration |
if (isReadOnlyEditor) {
// Copying into the editor is not allowed
className += ' cannot-copy';
} | Stellaris-Mod-Translate/pontoon | frontend/src/modules/history/components/Translation.tsx | TypeScript |
MethodDeclaration |
if (isTranslator | Stellaris-Mod-Translate/pontoon | frontend/src/modules/history/components/Translation.tsx | TypeScript |
ArrowFunction |
registration => !isValueProvider(registration.provider) | launchtray/tsyringe | src/dependency-container.ts | TypeScript |
ArrowFunction |
registration => {
registration.instance = undefined;
return registration;
} | launchtray/tsyringe | src/dependency-container.ts | TypeScript |
ArrowFunction |
({options}) => options.lifecycle === Lifecycle.ContainerScoped | launchtray/tsyringe | src/dependency-container.ts | TypeScript |
ArrowFunction |
registration => {
if (registration.options.lifecycle === Lifecycle.ContainerScoped) {
return {
provider: registration.provider,
options: registration.options
};
}
return registration;
} | launchtray/tsyringe | src/dependency-container.ts | TypeScript |
ArrowFunction |
async (param: ParamInfo, idx: number) => {
try {
if (isTokenDescriptor(param)) {
return param.multiple
? await this.resolveAll(param.token)
: await this.resolve(param.token, context);
}
return await this.resolve(param, context);
} catch (e) {
throw new Error(formatErrorCtor(ctor, idx, e));
}
} | launchtray/tsyringe | src/dependency-container.ts | TypeScript |
TypeAliasDeclaration |
export type Registration<T = any> = {
provider: Provider<T>;
options: RegistrationOptions;
instance?: T;
}; | launchtray/tsyringe | src/dependency-container.ts | TypeScript |
TypeAliasDeclaration |
export type ParamInfo = TokenDescriptor | InjectionToken<any>; | launchtray/tsyringe | src/dependency-container.ts | TypeScript |
MethodDeclaration | /**
* Register a dependency provider.
*
* @param provider {Provider} The dependency provider
*/
public register<T>(
token: InjectionToken<T>,
provider: ValueProvider<T>
): InternalDependencyContainer; | launchtray/tsyringe | src/dependency-container.ts | TypeScript |
Subsets and Splits